babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388
  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. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): 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. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result 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. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" 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. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * 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".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal 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 Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2534. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2535. */
  2536. toQuaternion(): Quaternion;
  2537. /**
  2538. * Adds the given vector to the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Adds the given coordinates to the current Vector3
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2553. * @param otherVector defines the second operand
  2554. * @returns the resulting Vector3
  2555. */
  2556. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2559. * @param otherVector defines the second operand
  2560. * @param result defines the Vector3 object where to store the result
  2561. * @returns the current Vector3
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2564. /**
  2565. * Subtract the given vector from the current Vector3
  2566. * @param otherVector defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the resulting Vector3
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2578. * @param otherVector defines the second operand
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2583. /**
  2584. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the resulting Vector3
  2589. */
  2590. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2593. * @param x defines the x coordinate of the operand
  2594. * @param y defines the y coordinate of the operand
  2595. * @param z defines the z coordinate of the operand
  2596. * @param result defines the Vector3 object where to store the result
  2597. * @returns the current Vector3
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2600. /**
  2601. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2602. * @returns a new Vector3
  2603. */
  2604. negate(): Vector3;
  2605. /**
  2606. * Negate this vector in place
  2607. * @returns this
  2608. */
  2609. negateInPlace(): Vector3;
  2610. /**
  2611. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. negateToRef(result: Vector3): Vector3;
  2616. /**
  2617. * Multiplies the Vector3 coordinates by the float "scale"
  2618. * @param scale defines the multiplier factor
  2619. * @returns the current updated Vector3
  2620. */
  2621. scaleInPlace(scale: number): Vector3;
  2622. /**
  2623. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2624. * @param scale defines the multiplier factor
  2625. * @returns a new Vector3
  2626. */
  2627. scale(scale: number): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2630. * @param scale defines the multiplier factor
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. scaleToRef(scale: number, result: Vector3): Vector3;
  2635. /**
  2636. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2637. * @param scale defines the scale factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the unmodified current Vector3
  2640. */
  2641. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2644. * @param origin defines the origin of the projection ray
  2645. * @param plane defines the plane to project to
  2646. * @returns the projected vector3
  2647. */
  2648. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @param result defines the Vector3 where to store the result
  2654. */
  2655. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2656. /**
  2657. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2658. * @param otherVector defines the second operand
  2659. * @returns true if both vectors are equals
  2660. */
  2661. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2662. /**
  2663. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2664. * @param otherVector defines the second operand
  2665. * @param epsilon defines the minimal distance to define values as equals
  2666. * @returns true if both vectors are distant less than epsilon
  2667. */
  2668. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 coordinates equals the given floats
  2671. * @param x defines the x coordinate of the operand
  2672. * @param y defines the y coordinate of the operand
  2673. * @param z defines the z coordinate of the operand
  2674. * @returns true if both vectors are equals
  2675. */
  2676. equalsToFloats(x: number, y: number, z: number): boolean;
  2677. /**
  2678. * Multiplies the current Vector3 coordinates by the given ones
  2679. * @param otherVector defines the second operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2683. /**
  2684. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2685. * @param otherVector defines the second operand
  2686. * @returns the new Vector3
  2687. */
  2688. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2689. /**
  2690. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2691. * @param otherVector defines the second operand
  2692. * @param result defines the Vector3 object where to store the result
  2693. * @returns the current Vector3
  2694. */
  2695. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2696. /**
  2697. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2698. * @param x defines the x coordinate of the operand
  2699. * @param y defines the y coordinate of the operand
  2700. * @param z defines the z coordinate of the operand
  2701. * @returns the new Vector3
  2702. */
  2703. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2706. * @param otherVector defines the second operand
  2707. * @returns the new Vector3
  2708. */
  2709. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2712. * @param otherVector defines the second operand
  2713. * @param result defines the Vector3 object where to store the result
  2714. * @returns the current Vector3
  2715. */
  2716. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones.
  2719. * @param otherVector defines the second operand
  2720. * @returns the current updated Vector3
  2721. */
  2722. divideInPlace(otherVector: Vector3): Vector3;
  2723. /**
  2724. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2729. /**
  2730. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2731. * @param other defines the second operand
  2732. * @returns the current updated Vector3
  2733. */
  2734. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2735. /**
  2736. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2737. * @param x defines the x coordinate of the operand
  2738. * @param y defines the y coordinate of the operand
  2739. * @param z defines the z coordinate of the operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the current updated Vector3
  2749. */
  2750. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2753. * Check if is non uniform within a certain amount of decimal places to account for this
  2754. * @param epsilon the amount the values can differ
  2755. * @returns if the the vector is non uniform to a certain number of decimal places
  2756. */
  2757. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2758. /**
  2759. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2760. */
  2761. get isNonUniform(): boolean;
  2762. /**
  2763. * Gets a new Vector3 from current Vector3 floored values
  2764. * @returns a new Vector3
  2765. */
  2766. floor(): Vector3;
  2767. /**
  2768. * Gets a new Vector3 from current Vector3 floored values
  2769. * @returns a new Vector3
  2770. */
  2771. fract(): Vector3;
  2772. /**
  2773. * Gets the length of the Vector3
  2774. * @returns the length of the Vector3
  2775. */
  2776. length(): number;
  2777. /**
  2778. * Gets the squared length of the Vector3
  2779. * @returns squared length of the Vector3
  2780. */
  2781. lengthSquared(): number;
  2782. /**
  2783. * Normalize the current Vector3.
  2784. * Please note that this is an in place operation.
  2785. * @returns the current updated Vector3
  2786. */
  2787. normalize(): Vector3;
  2788. /**
  2789. * Reorders the x y z properties of the vector in place
  2790. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2791. * @returns the current updated vector
  2792. */
  2793. reorderInPlace(order: string): this;
  2794. /**
  2795. * Rotates the vector around 0,0,0 by a quaternion
  2796. * @param quaternion the rotation quaternion
  2797. * @param result vector to store the result
  2798. * @returns the resulting vector
  2799. */
  2800. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2801. /**
  2802. * Rotates a vector around a given point
  2803. * @param quaternion the rotation quaternion
  2804. * @param point the point to rotate around
  2805. * @param result vector to store the result
  2806. * @returns the resulting vector
  2807. */
  2808. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2809. /**
  2810. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2811. * The cross product is then orthogonal to both current and "other"
  2812. * @param other defines the right operand
  2813. * @returns the cross product
  2814. */
  2815. cross(other: Vector3): Vector3;
  2816. /**
  2817. * Normalize the current Vector3 with the given input length.
  2818. * Please note that this is an in place operation.
  2819. * @param len the length of the vector
  2820. * @returns the current updated Vector3
  2821. */
  2822. normalizeFromLength(len: number): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 to a new vector
  2825. * @returns the new Vector3
  2826. */
  2827. normalizeToNew(): Vector3;
  2828. /**
  2829. * Normalize the current Vector3 to the reference
  2830. * @param reference define the Vector3 to update
  2831. * @returns the updated Vector3
  2832. */
  2833. normalizeToRef(reference: Vector3): Vector3;
  2834. /**
  2835. * Creates a new Vector3 copied from the current Vector3
  2836. * @returns the new Vector3
  2837. */
  2838. clone(): Vector3;
  2839. /**
  2840. * Copies the given vector coordinates to the current Vector3 ones
  2841. * @param source defines the source Vector3
  2842. * @returns the current updated Vector3
  2843. */
  2844. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2845. /**
  2846. * Copies the given floats to the current Vector3 coordinates
  2847. * @param x defines the x coordinate of the operand
  2848. * @param y defines the y coordinate of the operand
  2849. * @param z defines the z coordinate of the operand
  2850. * @returns the current updated Vector3
  2851. */
  2852. copyFromFloats(x: number, y: number, z: number): Vector3;
  2853. /**
  2854. * Copies the given floats to the current Vector3 coordinates
  2855. * @param x defines the x coordinate of the operand
  2856. * @param y defines the y coordinate of the operand
  2857. * @param z defines the z coordinate of the operand
  2858. * @returns the current updated Vector3
  2859. */
  2860. set(x: number, y: number, z: number): Vector3;
  2861. /**
  2862. * Copies the given float to the current Vector3 coordinates
  2863. * @param v defines the x, y and z coordinates of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. setAll(v: number): Vector3;
  2867. /**
  2868. * Get the clip factor between two vectors
  2869. * @param vector0 defines the first operand
  2870. * @param vector1 defines the second operand
  2871. * @param axis defines the axis to use
  2872. * @param size defines the size along the axis
  2873. * @returns the clip factor
  2874. */
  2875. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2876. /**
  2877. * Get angle between two vectors
  2878. * @param vector0 angle between vector0 and vector1
  2879. * @param vector1 angle between vector0 and vector1
  2880. * @param normal direction of the normal
  2881. * @return the angle between vector0 and vector1
  2882. */
  2883. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2884. /**
  2885. * Returns a new Vector3 set from the index "offset" of the given array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @returns the new Vector3
  2889. */
  2890. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. * @deprecated Please use FromArray instead.
  2897. */
  2898. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2901. * @param array defines the source array
  2902. * @param offset defines the offset in the source array
  2903. * @param result defines the Vector3 where to store the result
  2904. */
  2905. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. * @deprecated Please use FromArrayToRef instead.
  2912. */
  2913. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2914. /**
  2915. * Sets the given vector "result" with the given floats.
  2916. * @param x defines the x coordinate of the source
  2917. * @param y defines the y coordinate of the source
  2918. * @param z defines the z coordinate of the source
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2922. /**
  2923. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2924. * @returns a new empty Vector3
  2925. */
  2926. static Zero(): Vector3;
  2927. /**
  2928. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2929. * @returns a new unit Vector3
  2930. */
  2931. static One(): Vector3;
  2932. /**
  2933. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2934. * @returns a new up Vector3
  2935. */
  2936. static Up(): Vector3;
  2937. /**
  2938. * Gets a up Vector3 that must not be updated
  2939. */
  2940. static get UpReadOnly(): DeepImmutable<Vector3>;
  2941. /**
  2942. * Gets a zero Vector3 that must not be updated
  2943. */
  2944. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2945. /**
  2946. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2947. * @returns a new down Vector3
  2948. */
  2949. static Down(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2952. * @param rightHandedSystem is the scene right-handed (negative z)
  2953. * @returns a new forward Vector3
  2954. */
  2955. static Forward(rightHandedSystem?: boolean): Vector3;
  2956. /**
  2957. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2958. * @param rightHandedSystem is the scene right-handed (negative-z)
  2959. * @returns a new forward Vector3
  2960. */
  2961. static Backward(rightHandedSystem?: boolean): Vector3;
  2962. /**
  2963. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2964. * @returns a new right Vector3
  2965. */
  2966. static Right(): Vector3;
  2967. /**
  2968. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2969. * @returns a new left Vector3
  2970. */
  2971. static Left(): Vector3;
  2972. /**
  2973. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2974. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2975. * @param vector defines the Vector3 to transform
  2976. * @param transformation defines the transformation matrix
  2977. * @returns the transformed Vector3
  2978. */
  2979. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2980. /**
  2981. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2982. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2983. * @param vector defines the Vector3 to transform
  2984. * @param transformation defines the transformation matrix
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2990. * This method computes tranformed coordinates only, not transformed direction vectors
  2991. * @param x define the x coordinate of the source vector
  2992. * @param y define the y coordinate of the source vector
  2993. * @param z define the z coordinate of the source vector
  2994. * @param transformation defines the transformation matrix
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3000. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3001. * @param vector defines the Vector3 to transform
  3002. * @param transformation defines the transformation matrix
  3003. * @returns the new Vector3
  3004. */
  3005. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3006. /**
  3007. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3008. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3009. * @param vector defines the Vector3 to transform
  3010. * @param transformation defines the transformation matrix
  3011. * @param result defines the Vector3 where to store the result
  3012. */
  3013. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3014. /**
  3015. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3016. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3017. * @param x define the x coordinate of the source vector
  3018. * @param y define the y coordinate of the source vector
  3019. * @param z define the z coordinate of the source vector
  3020. * @param transformation defines the transformation matrix
  3021. * @param result defines the Vector3 where to store the result
  3022. */
  3023. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3024. /**
  3025. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3026. * @param value1 defines the first control point
  3027. * @param value2 defines the second control point
  3028. * @param value3 defines the third control point
  3029. * @param value4 defines the fourth control point
  3030. * @param amount defines the amount on the spline to use
  3031. * @returns the new Vector3
  3032. */
  3033. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3034. /**
  3035. * 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"
  3036. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3037. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3038. * @param value defines the current value
  3039. * @param min defines the lower range value
  3040. * @param max defines the upper range value
  3041. * @returns the new Vector3
  3042. */
  3043. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * 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"
  3046. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3047. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3048. * @param value defines the current value
  3049. * @param min defines the lower range value
  3050. * @param max defines the upper range value
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Checks if a given vector is inside a specific range
  3056. * @param v defines the vector to test
  3057. * @param min defines the minimum range
  3058. * @param max defines the maximum range
  3059. */
  3060. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3063. * @param value1 defines the first control point
  3064. * @param tangent1 defines the first tangent vector
  3065. * @param value2 defines the second control point
  3066. * @param tangent2 defines the second tangent vector
  3067. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3068. * @returns the new Vector3
  3069. */
  3070. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3073. * @param start defines the start value
  3074. * @param end defines the end value
  3075. * @param amount max defines amount between both (between 0 and 1)
  3076. * @returns the new Vector3
  3077. */
  3078. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3079. /**
  3080. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3081. * @param start defines the start value
  3082. * @param end defines the end value
  3083. * @param amount max defines amount between both (between 0 and 1)
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3087. /**
  3088. * Returns the dot product (float) between the vectors "left" and "right"
  3089. * @param left defines the left operand
  3090. * @param right defines the right operand
  3091. * @returns the dot product
  3092. */
  3093. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3094. /**
  3095. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3096. * The cross product is then orthogonal to both "left" and "right"
  3097. * @param left defines the left operand
  3098. * @param right defines the right operand
  3099. * @returns the cross product
  3100. */
  3101. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3102. /**
  3103. * Sets the given vector "result" with the cross product of "left" and "right"
  3104. * The cross product is then orthogonal to both "left" and "right"
  3105. * @param left defines the left operand
  3106. * @param right defines the right operand
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3110. /**
  3111. * Returns a new Vector3 as the normalization of the given vector
  3112. * @param vector defines the Vector3 to normalize
  3113. * @returns the new Vector3
  3114. */
  3115. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the normalization of the given first vector
  3118. * @param vector defines the Vector3 to normalize
  3119. * @param result defines the Vector3 where to store the result
  3120. */
  3121. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3122. /**
  3123. * Project a Vector3 onto screen space
  3124. * @param vector defines the Vector3 to project
  3125. * @param world defines the world matrix to use
  3126. * @param transform defines the transform (view x projection) matrix to use
  3127. * @param viewport defines the screen viewport to use
  3128. * @returns the new Vector3
  3129. */
  3130. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3131. /** @hidden */
  3132. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3133. /**
  3134. * Unproject from screen space to object space
  3135. * @param source defines the screen space Vector3 to use
  3136. * @param viewportWidth defines the current width of the viewport
  3137. * @param viewportHeight defines the current height of the viewport
  3138. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3139. * @param transform defines the transform (view x projection) matrix to use
  3140. * @returns the new Vector3
  3141. */
  3142. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param source defines the screen space Vector3 to use
  3146. * @param viewportWidth defines the current width of the viewport
  3147. * @param viewportHeight defines the current height of the viewport
  3148. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3149. * @param view defines the view matrix to use
  3150. * @param projection defines the projection matrix to use
  3151. * @returns the new Vector3
  3152. */
  3153. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3154. /**
  3155. * Unproject from screen space to object space
  3156. * @param source defines the screen space Vector3 to use
  3157. * @param viewportWidth defines the current width of the viewport
  3158. * @param viewportHeight defines the current height of the viewport
  3159. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3160. * @param view defines the view matrix to use
  3161. * @param projection defines the projection matrix to use
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3165. /**
  3166. * Unproject from screen space to object space
  3167. * @param sourceX defines the screen space x coordinate to use
  3168. * @param sourceY defines the screen space y coordinate to use
  3169. * @param sourceZ defines the screen space z coordinate to use
  3170. * @param viewportWidth defines the current width of the viewport
  3171. * @param viewportHeight defines the current height of the viewport
  3172. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3173. * @param view defines the view matrix to use
  3174. * @param projection defines the projection matrix to use
  3175. * @param result defines the Vector3 where to store the result
  3176. */
  3177. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3178. /**
  3179. * Gets the minimal coordinate values between two Vector3
  3180. * @param left defines the first operand
  3181. * @param right defines the second operand
  3182. * @returns the new Vector3
  3183. */
  3184. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3185. /**
  3186. * Gets the maximal coordinate values between two Vector3
  3187. * @param left defines the first operand
  3188. * @param right defines the second operand
  3189. * @returns the new Vector3
  3190. */
  3191. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * Returns the distance between the vectors "value1" and "value2"
  3194. * @param value1 defines the first operand
  3195. * @param value2 defines the second operand
  3196. * @returns the distance
  3197. */
  3198. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3199. /**
  3200. * Returns the squared distance between the vectors "value1" and "value2"
  3201. * @param value1 defines the first operand
  3202. * @param value2 defines the second operand
  3203. * @returns the squared distance
  3204. */
  3205. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3206. /**
  3207. * Returns a new Vector3 located at the center between "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the new Vector3
  3211. */
  3212. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3213. /**
  3214. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3215. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3216. * to something in order to rotate it from its local system to the given target system
  3217. * Note: axis1, axis2 and axis3 are normalized during this operation
  3218. * @param axis1 defines the first axis
  3219. * @param axis2 defines the second axis
  3220. * @param axis3 defines the third axis
  3221. * @returns a new Vector3
  3222. */
  3223. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3224. /**
  3225. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3226. * @param axis1 defines the first axis
  3227. * @param axis2 defines the second axis
  3228. * @param axis3 defines the third axis
  3229. * @param ref defines the Vector3 where to store the result
  3230. */
  3231. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3232. }
  3233. /**
  3234. * Vector4 class created for EulerAngle class conversion to Quaternion
  3235. */
  3236. export class Vector4 {
  3237. /** x value of the vector */
  3238. x: number;
  3239. /** y value of the vector */
  3240. y: number;
  3241. /** z value of the vector */
  3242. z: number;
  3243. /** w value of the vector */
  3244. w: number;
  3245. /**
  3246. * Creates a Vector4 object from the given floats.
  3247. * @param x x value of the vector
  3248. * @param y y value of the vector
  3249. * @param z z value of the vector
  3250. * @param w w value of the vector
  3251. */
  3252. constructor(
  3253. /** x value of the vector */
  3254. x: number,
  3255. /** y value of the vector */
  3256. y: number,
  3257. /** z value of the vector */
  3258. z: number,
  3259. /** w value of the vector */
  3260. w: number);
  3261. /**
  3262. * Returns the string with the Vector4 coordinates.
  3263. * @returns a string containing all the vector values
  3264. */
  3265. toString(): string;
  3266. /**
  3267. * Returns the string "Vector4".
  3268. * @returns "Vector4"
  3269. */
  3270. getClassName(): string;
  3271. /**
  3272. * Returns the Vector4 hash code.
  3273. * @returns a unique hash code
  3274. */
  3275. getHashCode(): number;
  3276. /**
  3277. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3278. * @returns the resulting array
  3279. */
  3280. asArray(): number[];
  3281. /**
  3282. * Populates the given array from the given index with the Vector4 coordinates.
  3283. * @param array array to populate
  3284. * @param index index of the array to start at (default: 0)
  3285. * @returns the Vector4.
  3286. */
  3287. toArray(array: FloatArray, index?: number): Vector4;
  3288. /**
  3289. * Adds the given vector to the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the updated Vector4.
  3292. */
  3293. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3296. * @param otherVector the vector to add
  3297. * @returns the resulting vector
  3298. */
  3299. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3302. * @param otherVector the vector to add
  3303. * @param result the vector to store the result
  3304. * @returns the current Vector4.
  3305. */
  3306. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3307. /**
  3308. * Subtract in place the given vector from the current Vector4.
  3309. * @param otherVector the vector to subtract
  3310. * @returns the updated Vector4.
  3311. */
  3312. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3315. * @param otherVector the vector to add
  3316. * @returns the new vector with the result
  3317. */
  3318. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3321. * @param otherVector the vector to subtract
  3322. * @param result the vector to store the result
  3323. * @returns the current Vector4.
  3324. */
  3325. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3326. /**
  3327. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3328. */
  3329. /**
  3330. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3331. * @param x value to subtract
  3332. * @param y value to subtract
  3333. * @param z value to subtract
  3334. * @param w value to subtract
  3335. * @returns new vector containing the result
  3336. */
  3337. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3338. /**
  3339. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3340. * @param x value to subtract
  3341. * @param y value to subtract
  3342. * @param z value to subtract
  3343. * @param w value to subtract
  3344. * @param result the vector to store the result in
  3345. * @returns the current Vector4.
  3346. */
  3347. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3348. /**
  3349. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3350. * @returns a new vector with the negated values
  3351. */
  3352. negate(): Vector4;
  3353. /**
  3354. * Negate this vector in place
  3355. * @returns this
  3356. */
  3357. negateInPlace(): Vector4;
  3358. /**
  3359. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3360. * @param result defines the Vector3 object where to store the result
  3361. * @returns the current Vector4
  3362. */
  3363. negateToRef(result: Vector4): Vector4;
  3364. /**
  3365. * Multiplies the current Vector4 coordinates by scale (float).
  3366. * @param scale the number to scale with
  3367. * @returns the updated Vector4.
  3368. */
  3369. scaleInPlace(scale: number): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3372. * @param scale the number to scale with
  3373. * @returns a new vector with the result
  3374. */
  3375. scale(scale: number): Vector4;
  3376. /**
  3377. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3378. * @param scale the number to scale with
  3379. * @param result a vector to store the result in
  3380. * @returns the current Vector4.
  3381. */
  3382. scaleToRef(scale: number, result: Vector4): Vector4;
  3383. /**
  3384. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3385. * @param scale defines the scale factor
  3386. * @param result defines the Vector4 object where to store the result
  3387. * @returns the unmodified current Vector4
  3388. */
  3389. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3390. /**
  3391. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3392. * @param otherVector the vector to compare against
  3393. * @returns true if they are equal
  3394. */
  3395. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3396. /**
  3397. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3398. * @param otherVector vector to compare against
  3399. * @param epsilon (Default: very small number)
  3400. * @returns true if they are equal
  3401. */
  3402. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3403. /**
  3404. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3405. * @param x x value to compare against
  3406. * @param y y value to compare against
  3407. * @param z z value to compare against
  3408. * @param w w value to compare against
  3409. * @returns true if equal
  3410. */
  3411. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3412. /**
  3413. * Multiplies in place the current Vector4 by the given one.
  3414. * @param otherVector vector to multiple with
  3415. * @returns the updated Vector4.
  3416. */
  3417. multiplyInPlace(otherVector: Vector4): Vector4;
  3418. /**
  3419. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3420. * @param otherVector vector to multiple with
  3421. * @returns resulting new vector
  3422. */
  3423. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3426. * @param otherVector vector to multiple with
  3427. * @param result vector to store the result
  3428. * @returns the current Vector4.
  3429. */
  3430. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3431. /**
  3432. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3433. * @param x x value multiply with
  3434. * @param y y value multiply with
  3435. * @param z z value multiply with
  3436. * @param w w value multiply with
  3437. * @returns resulting new vector
  3438. */
  3439. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3440. /**
  3441. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3442. * @param otherVector vector to devide with
  3443. * @returns resulting new vector
  3444. */
  3445. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3448. * @param otherVector vector to devide with
  3449. * @param result vector to store the result
  3450. * @returns the current Vector4.
  3451. */
  3452. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3453. /**
  3454. * Divides the current Vector3 coordinates by the given ones.
  3455. * @param otherVector vector to devide with
  3456. * @returns the updated Vector3.
  3457. */
  3458. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3459. /**
  3460. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3461. * @param other defines the second operand
  3462. * @returns the current updated Vector4
  3463. */
  3464. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3465. /**
  3466. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3467. * @param other defines the second operand
  3468. * @returns the current updated Vector4
  3469. */
  3470. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3471. /**
  3472. * Gets a new Vector4 from current Vector4 floored values
  3473. * @returns a new Vector4
  3474. */
  3475. floor(): Vector4;
  3476. /**
  3477. * Gets a new Vector4 from current Vector3 floored values
  3478. * @returns a new Vector4
  3479. */
  3480. fract(): Vector4;
  3481. /**
  3482. * Returns the Vector4 length (float).
  3483. * @returns the length
  3484. */
  3485. length(): number;
  3486. /**
  3487. * Returns the Vector4 squared length (float).
  3488. * @returns the length squared
  3489. */
  3490. lengthSquared(): number;
  3491. /**
  3492. * Normalizes in place the Vector4.
  3493. * @returns the updated Vector4.
  3494. */
  3495. normalize(): Vector4;
  3496. /**
  3497. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3498. * @returns this converted to a new vector3
  3499. */
  3500. toVector3(): Vector3;
  3501. /**
  3502. * Returns a new Vector4 copied from the current one.
  3503. * @returns the new cloned vector
  3504. */
  3505. clone(): Vector4;
  3506. /**
  3507. * Updates the current Vector4 with the given one coordinates.
  3508. * @param source the source vector to copy from
  3509. * @returns the updated Vector4.
  3510. */
  3511. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3512. /**
  3513. * Updates the current Vector4 coordinates with the given floats.
  3514. * @param x float to copy from
  3515. * @param y float to copy from
  3516. * @param z float to copy from
  3517. * @param w float to copy from
  3518. * @returns the updated Vector4.
  3519. */
  3520. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3521. /**
  3522. * Updates the current Vector4 coordinates with the given floats.
  3523. * @param x float to set from
  3524. * @param y float to set from
  3525. * @param z float to set from
  3526. * @param w float to set from
  3527. * @returns the updated Vector4.
  3528. */
  3529. set(x: number, y: number, z: number, w: number): Vector4;
  3530. /**
  3531. * Copies the given float to the current Vector3 coordinates
  3532. * @param v defines the x, y, z and w coordinates of the operand
  3533. * @returns the current updated Vector3
  3534. */
  3535. setAll(v: number): Vector4;
  3536. /**
  3537. * Returns a new Vector4 set from the starting index of the given array.
  3538. * @param array the array to pull values from
  3539. * @param offset the offset into the array to start at
  3540. * @returns the new vector
  3541. */
  3542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3543. /**
  3544. * Updates the given vector "result" from the starting index of the given array.
  3545. * @param array the array to pull values from
  3546. * @param offset the offset into the array to start at
  3547. * @param result the vector to store the result in
  3548. */
  3549. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3550. /**
  3551. * Updates the given vector "result" from the starting index of the given Float32Array.
  3552. * @param array the array to pull values from
  3553. * @param offset the offset into the array to start at
  3554. * @param result the vector to store the result in
  3555. */
  3556. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3557. /**
  3558. * Updates the given vector "result" coordinates from the given floats.
  3559. * @param x float to set from
  3560. * @param y float to set from
  3561. * @param z float to set from
  3562. * @param w float to set from
  3563. * @param result the vector to the floats in
  3564. */
  3565. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3566. /**
  3567. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3568. * @returns the new vector
  3569. */
  3570. static Zero(): Vector4;
  3571. /**
  3572. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3573. * @returns the new vector
  3574. */
  3575. static One(): Vector4;
  3576. /**
  3577. * Returns a new normalized Vector4 from the given one.
  3578. * @param vector the vector to normalize
  3579. * @returns the vector
  3580. */
  3581. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3582. /**
  3583. * Updates the given vector "result" from the normalization of the given one.
  3584. * @param vector the vector to normalize
  3585. * @param result the vector to store the result in
  3586. */
  3587. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3588. /**
  3589. * Returns a vector with the minimum values from the left and right vectors
  3590. * @param left left vector to minimize
  3591. * @param right right vector to minimize
  3592. * @returns a new vector with the minimum of the left and right vector values
  3593. */
  3594. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3595. /**
  3596. * Returns a vector with the maximum values from the left and right vectors
  3597. * @param left left vector to maximize
  3598. * @param right right vector to maximize
  3599. * @returns a new vector with the maximum of the left and right vector values
  3600. */
  3601. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3602. /**
  3603. * Returns the distance (float) between the vectors "value1" and "value2".
  3604. * @param value1 value to calulate the distance between
  3605. * @param value2 value to calulate the distance between
  3606. * @return the distance between the two vectors
  3607. */
  3608. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3609. /**
  3610. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3611. * @param value1 value to calulate the distance between
  3612. * @param value2 value to calulate the distance between
  3613. * @return the distance between the two vectors squared
  3614. */
  3615. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3616. /**
  3617. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3618. * @param value1 value to calulate the center between
  3619. * @param value2 value to calulate the center between
  3620. * @return the center between the two vectors
  3621. */
  3622. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3625. * This methods computes transformed normalized direction vectors only.
  3626. * @param vector the vector to transform
  3627. * @param transformation the transformation matrix to apply
  3628. * @returns the new vector
  3629. */
  3630. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3631. /**
  3632. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3633. * This methods computes transformed normalized direction vectors only.
  3634. * @param vector the vector to transform
  3635. * @param transformation the transformation matrix to apply
  3636. * @param result the vector to store the result in
  3637. */
  3638. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3639. /**
  3640. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3641. * This methods computes transformed normalized direction vectors only.
  3642. * @param x value to transform
  3643. * @param y value to transform
  3644. * @param z value to transform
  3645. * @param w value to transform
  3646. * @param transformation the transformation matrix to apply
  3647. * @param result the vector to store the results in
  3648. */
  3649. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3650. /**
  3651. * Creates a new Vector4 from a Vector3
  3652. * @param source defines the source data
  3653. * @param w defines the 4th component (default is 0)
  3654. * @returns a new Vector4
  3655. */
  3656. static FromVector3(source: Vector3, w?: number): Vector4;
  3657. }
  3658. /**
  3659. * Class used to store quaternion data
  3660. * @see https://en.wikipedia.org/wiki/Quaternion
  3661. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3662. */
  3663. export class Quaternion {
  3664. /** @hidden */
  3665. _x: number;
  3666. /** @hidden */
  3667. _y: number;
  3668. /** @hidden */
  3669. _z: number;
  3670. /** @hidden */
  3671. _w: number;
  3672. /** @hidden */
  3673. _isDirty: boolean;
  3674. /** Gets or sets the x coordinate */
  3675. get x(): number;
  3676. set x(value: number);
  3677. /** Gets or sets the y coordinate */
  3678. get y(): number;
  3679. set y(value: number);
  3680. /** Gets or sets the z coordinate */
  3681. get z(): number;
  3682. set z(value: number);
  3683. /** Gets or sets the w coordinate */
  3684. get w(): number;
  3685. set w(value: number);
  3686. /**
  3687. * Creates a new Quaternion from the given floats
  3688. * @param x defines the first component (0 by default)
  3689. * @param y defines the second component (0 by default)
  3690. * @param z defines the third component (0 by default)
  3691. * @param w defines the fourth component (1.0 by default)
  3692. */
  3693. constructor(x?: number, y?: number, z?: number, w?: number);
  3694. /**
  3695. * Gets a string representation for the current quaternion
  3696. * @returns a string with the Quaternion coordinates
  3697. */
  3698. toString(): string;
  3699. /**
  3700. * Gets the class name of the quaternion
  3701. * @returns the string "Quaternion"
  3702. */
  3703. getClassName(): string;
  3704. /**
  3705. * Gets a hash code for this quaternion
  3706. * @returns the quaternion hash code
  3707. */
  3708. getHashCode(): number;
  3709. /**
  3710. * Copy the quaternion to an array
  3711. * @returns a new array populated with 4 elements from the quaternion coordinates
  3712. */
  3713. asArray(): number[];
  3714. /**
  3715. * Check if two quaternions are equals
  3716. * @param otherQuaternion defines the second operand
  3717. * @return true if the current quaternion and the given one coordinates are strictly equals
  3718. */
  3719. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3720. /**
  3721. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3722. * @param otherQuaternion defines the other quaternion
  3723. * @param epsilon defines the minimal distance to consider equality
  3724. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3725. */
  3726. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3727. /**
  3728. * Clone the current quaternion
  3729. * @returns a new quaternion copied from the current one
  3730. */
  3731. clone(): Quaternion;
  3732. /**
  3733. * Copy a quaternion to the current one
  3734. * @param other defines the other quaternion
  3735. * @returns the updated current quaternion
  3736. */
  3737. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the given float coordinates
  3740. * @param x defines the x coordinate
  3741. * @param y defines the y coordinate
  3742. * @param z defines the z coordinate
  3743. * @param w defines the w coordinate
  3744. * @returns the updated current quaternion
  3745. */
  3746. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3747. /**
  3748. * Updates the current quaternion from the given float coordinates
  3749. * @param x defines the x coordinate
  3750. * @param y defines the y coordinate
  3751. * @param z defines the z coordinate
  3752. * @param w defines the w coordinate
  3753. * @returns the updated current quaternion
  3754. */
  3755. set(x: number, y: number, z: number, w: number): Quaternion;
  3756. /**
  3757. * Adds two quaternions
  3758. * @param other defines the second operand
  3759. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3760. */
  3761. add(other: DeepImmutable<Quaternion>): Quaternion;
  3762. /**
  3763. * Add a quaternion to the current one
  3764. * @param other defines the quaternion to add
  3765. * @returns the current quaternion
  3766. */
  3767. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3768. /**
  3769. * Subtract two quaternions
  3770. * @param other defines the second operand
  3771. * @returns a new quaternion as the subtraction result of the given one from the current one
  3772. */
  3773. subtract(other: Quaternion): Quaternion;
  3774. /**
  3775. * Multiplies the current quaternion by a scale factor
  3776. * @param value defines the scale factor
  3777. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3778. */
  3779. scale(value: number): Quaternion;
  3780. /**
  3781. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3782. * @param scale defines the scale factor
  3783. * @param result defines the Quaternion object where to store the result
  3784. * @returns the unmodified current quaternion
  3785. */
  3786. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3787. /**
  3788. * Multiplies in place the current quaternion by a scale factor
  3789. * @param value defines the scale factor
  3790. * @returns the current modified quaternion
  3791. */
  3792. scaleInPlace(value: number): Quaternion;
  3793. /**
  3794. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3795. * @param scale defines the scale factor
  3796. * @param result defines the Quaternion object where to store the result
  3797. * @returns the unmodified current quaternion
  3798. */
  3799. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies two quaternions
  3802. * @param q1 defines the second operand
  3803. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3804. */
  3805. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3808. * @param q1 defines the second operand
  3809. * @param result defines the target quaternion
  3810. * @returns the current quaternion
  3811. */
  3812. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3813. /**
  3814. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3815. * @param q1 defines the second operand
  3816. * @returns the currentupdated quaternion
  3817. */
  3818. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3819. /**
  3820. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3821. * @param ref defines the target quaternion
  3822. * @returns the current quaternion
  3823. */
  3824. conjugateToRef(ref: Quaternion): Quaternion;
  3825. /**
  3826. * Conjugates in place (1-q) the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. conjugateInPlace(): Quaternion;
  3830. /**
  3831. * Conjugates in place (1-q) the current quaternion
  3832. * @returns a new quaternion
  3833. */
  3834. conjugate(): Quaternion;
  3835. /**
  3836. * Gets length of current quaternion
  3837. * @returns the quaternion length (float)
  3838. */
  3839. length(): number;
  3840. /**
  3841. * Normalize in place the current quaternion
  3842. * @returns the current updated quaternion
  3843. */
  3844. normalize(): Quaternion;
  3845. /**
  3846. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3847. * @param order is a reserved parameter and is ignore for now
  3848. * @returns a new Vector3 containing the Euler angles
  3849. */
  3850. toEulerAngles(order?: string): Vector3;
  3851. /**
  3852. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3853. * @param result defines the vector which will be filled with the Euler angles
  3854. * @param order is a reserved parameter and is ignore for now
  3855. * @returns the current unchanged quaternion
  3856. */
  3857. toEulerAnglesToRef(result: Vector3): Quaternion;
  3858. /**
  3859. * Updates the given rotation matrix with the current quaternion values
  3860. * @param result defines the target matrix
  3861. * @returns the current unchanged quaternion
  3862. */
  3863. toRotationMatrix(result: Matrix): Quaternion;
  3864. /**
  3865. * Updates the current quaternion from the given rotation matrix values
  3866. * @param matrix defines the source matrix
  3867. * @returns the current updated quaternion
  3868. */
  3869. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3870. /**
  3871. * Creates a new quaternion from a rotation matrix
  3872. * @param matrix defines the source matrix
  3873. * @returns a new quaternion created from the given rotation matrix values
  3874. */
  3875. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3876. /**
  3877. * Updates the given quaternion with the given rotation matrix values
  3878. * @param matrix defines the source matrix
  3879. * @param result defines the target quaternion
  3880. */
  3881. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3882. /**
  3883. * Returns the dot product (float) between the quaternions "left" and "right"
  3884. * @param left defines the left operand
  3885. * @param right defines the right operand
  3886. * @returns the dot product
  3887. */
  3888. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3889. /**
  3890. * Checks if the two quaternions are close to each other
  3891. * @param quat0 defines the first quaternion to check
  3892. * @param quat1 defines the second quaternion to check
  3893. * @returns true if the two quaternions are close to each other
  3894. */
  3895. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3896. /**
  3897. * Creates an empty quaternion
  3898. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3899. */
  3900. static Zero(): Quaternion;
  3901. /**
  3902. * Inverse a given quaternion
  3903. * @param q defines the source quaternion
  3904. * @returns a new quaternion as the inverted current quaternion
  3905. */
  3906. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3907. /**
  3908. * Inverse a given quaternion
  3909. * @param q defines the source quaternion
  3910. * @param result the quaternion the result will be stored in
  3911. * @returns the result quaternion
  3912. */
  3913. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3914. /**
  3915. * Creates an identity quaternion
  3916. * @returns the identity quaternion
  3917. */
  3918. static Identity(): Quaternion;
  3919. /**
  3920. * Gets a boolean indicating if the given quaternion is identity
  3921. * @param quaternion defines the quaternion to check
  3922. * @returns true if the quaternion is identity
  3923. */
  3924. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3925. /**
  3926. * Creates a quaternion from a rotation around an axis
  3927. * @param axis defines the axis to use
  3928. * @param angle defines the angle to use
  3929. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3930. */
  3931. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3932. /**
  3933. * Creates a rotation around an axis and stores it into the given quaternion
  3934. * @param axis defines the axis to use
  3935. * @param angle defines the angle to use
  3936. * @param result defines the target quaternion
  3937. * @returns the target quaternion
  3938. */
  3939. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from data stored into an array
  3942. * @param array defines the data source
  3943. * @param offset defines the offset in the source array where the data starts
  3944. * @returns a new quaternion
  3945. */
  3946. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3947. /**
  3948. * Updates the given quaternion "result" from the starting index of the given array.
  3949. * @param array the array to pull values from
  3950. * @param offset the offset into the array to start at
  3951. * @param result the quaternion to store the result in
  3952. */
  3953. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3954. /**
  3955. * Create a quaternion from Euler rotation angles
  3956. * @param x Pitch
  3957. * @param y Yaw
  3958. * @param z Roll
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation angles
  3964. * @param x Pitch
  3965. * @param y Yaw
  3966. * @param z Roll
  3967. * @param result the quaternion to store the result
  3968. * @returns the updated quaternion
  3969. */
  3970. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3971. /**
  3972. * Create a quaternion from Euler rotation vector
  3973. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3974. * @returns the new Quaternion
  3975. */
  3976. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3977. /**
  3978. * Updates a quaternion from Euler rotation vector
  3979. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3980. * @param result the quaternion to store the result
  3981. * @returns the updated quaternion
  3982. */
  3983. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3984. /**
  3985. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3986. * @param yaw defines the rotation around Y axis
  3987. * @param pitch defines the rotation around X axis
  3988. * @param roll defines the rotation around Z axis
  3989. * @returns the new quaternion
  3990. */
  3991. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3992. /**
  3993. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3994. * @param yaw defines the rotation around Y axis
  3995. * @param pitch defines the rotation around X axis
  3996. * @param roll defines the rotation around Z axis
  3997. * @param result defines the target quaternion
  3998. */
  3999. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4000. /**
  4001. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4002. * @param alpha defines the rotation around first axis
  4003. * @param beta defines the rotation around second axis
  4004. * @param gamma defines the rotation around third axis
  4005. * @returns the new quaternion
  4006. */
  4007. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4008. /**
  4009. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4010. * @param alpha defines the rotation around first axis
  4011. * @param beta defines the rotation around second axis
  4012. * @param gamma defines the rotation around third axis
  4013. * @param result defines the target quaternion
  4014. */
  4015. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4016. /**
  4017. * 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)
  4018. * @param axis1 defines the first axis
  4019. * @param axis2 defines the second axis
  4020. * @param axis3 defines the third axis
  4021. * @returns the new quaternion
  4022. */
  4023. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4024. /**
  4025. * 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
  4026. * @param axis1 defines the first axis
  4027. * @param axis2 defines the second axis
  4028. * @param axis3 defines the third axis
  4029. * @param ref defines the target quaternion
  4030. */
  4031. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4032. /**
  4033. * Interpolates between two quaternions
  4034. * @param left defines first quaternion
  4035. * @param right defines second quaternion
  4036. * @param amount defines the gradient to use
  4037. * @returns the new interpolated quaternion
  4038. */
  4039. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4040. /**
  4041. * Interpolates between two quaternions and stores it into a target quaternion
  4042. * @param left defines first quaternion
  4043. * @param right defines second quaternion
  4044. * @param amount defines the gradient to use
  4045. * @param result defines the target quaternion
  4046. */
  4047. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4048. /**
  4049. * Interpolate between two quaternions using Hermite interpolation
  4050. * @param value1 defines first quaternion
  4051. * @param tangent1 defines the incoming tangent
  4052. * @param value2 defines second quaternion
  4053. * @param tangent2 defines the outgoing tangent
  4054. * @param amount defines the target quaternion
  4055. * @returns the new interpolated quaternion
  4056. */
  4057. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4058. }
  4059. /**
  4060. * Class used to store matrix data (4x4)
  4061. */
  4062. export class Matrix {
  4063. /**
  4064. * Gets the precision of matrix computations
  4065. */
  4066. static get Use64Bits(): boolean;
  4067. private static _updateFlagSeed;
  4068. private static _identityReadOnly;
  4069. private _isIdentity;
  4070. private _isIdentityDirty;
  4071. private _isIdentity3x2;
  4072. private _isIdentity3x2Dirty;
  4073. /**
  4074. * Gets the update flag of the matrix which is an unique number for the matrix.
  4075. * It will be incremented every time the matrix data change.
  4076. * You can use it to speed the comparison between two versions of the same matrix.
  4077. */
  4078. updateFlag: number;
  4079. private readonly _m;
  4080. /**
  4081. * Gets the internal data of the matrix
  4082. */
  4083. get m(): DeepImmutable<Float32Array | Array<number>>;
  4084. /** @hidden */
  4085. _markAsUpdated(): void;
  4086. /** @hidden */
  4087. private _updateIdentityStatus;
  4088. /**
  4089. * Creates an empty matrix (filled with zeros)
  4090. */
  4091. constructor();
  4092. /**
  4093. * Check if the current matrix is identity
  4094. * @returns true is the matrix is the identity matrix
  4095. */
  4096. isIdentity(): boolean;
  4097. /**
  4098. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4099. * @returns true is the matrix is the identity matrix
  4100. */
  4101. isIdentityAs3x2(): boolean;
  4102. /**
  4103. * Gets the determinant of the matrix
  4104. * @returns the matrix determinant
  4105. */
  4106. determinant(): number;
  4107. /**
  4108. * Returns the matrix as a Float32Array or Array<number>
  4109. * @returns the matrix underlying array
  4110. */
  4111. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4112. /**
  4113. * Returns the matrix as a Float32Array or Array<number>
  4114. * @returns the matrix underlying array.
  4115. */
  4116. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4117. /**
  4118. * Inverts the current matrix in place
  4119. * @returns the current inverted matrix
  4120. */
  4121. invert(): Matrix;
  4122. /**
  4123. * Sets all the matrix elements to zero
  4124. * @returns the current matrix
  4125. */
  4126. reset(): Matrix;
  4127. /**
  4128. * Adds the current matrix with a second one
  4129. * @param other defines the matrix to add
  4130. * @returns a new matrix as the addition of the current matrix and the given one
  4131. */
  4132. add(other: DeepImmutable<Matrix>): Matrix;
  4133. /**
  4134. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4135. * @param other defines the matrix to add
  4136. * @param result defines the target matrix
  4137. * @returns the current matrix
  4138. */
  4139. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4140. /**
  4141. * Adds in place the given matrix to the current matrix
  4142. * @param other defines the second operand
  4143. * @returns the current updated matrix
  4144. */
  4145. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4146. /**
  4147. * Sets the given matrix to the current inverted Matrix
  4148. * @param other defines the target matrix
  4149. * @returns the unmodified current matrix
  4150. */
  4151. invertToRef(other: Matrix): Matrix;
  4152. /**
  4153. * add a value at the specified position in the current Matrix
  4154. * @param index the index of the value within the matrix. between 0 and 15.
  4155. * @param value the value to be added
  4156. * @returns the current updated matrix
  4157. */
  4158. addAtIndex(index: number, value: number): Matrix;
  4159. /**
  4160. * mutiply the specified position in the current Matrix by a value
  4161. * @param index the index of the value within the matrix. between 0 and 15.
  4162. * @param value the value to be added
  4163. * @returns the current updated matrix
  4164. */
  4165. multiplyAtIndex(index: number, value: number): Matrix;
  4166. /**
  4167. * Inserts the translation vector (using 3 floats) in the current matrix
  4168. * @param x defines the 1st component of the translation
  4169. * @param y defines the 2nd component of the translation
  4170. * @param z defines the 3rd component of the translation
  4171. * @returns the current updated matrix
  4172. */
  4173. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4174. /**
  4175. * Adds the translation vector (using 3 floats) in the current matrix
  4176. * @param x defines the 1st component of the translation
  4177. * @param y defines the 2nd component of the translation
  4178. * @param z defines the 3rd component of the translation
  4179. * @returns the current updated matrix
  4180. */
  4181. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4182. /**
  4183. * Inserts the translation vector in the current matrix
  4184. * @param vector3 defines the translation to insert
  4185. * @returns the current updated matrix
  4186. */
  4187. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4188. /**
  4189. * Gets the translation value of the current matrix
  4190. * @returns a new Vector3 as the extracted translation from the matrix
  4191. */
  4192. getTranslation(): Vector3;
  4193. /**
  4194. * Fill a Vector3 with the extracted translation from the matrix
  4195. * @param result defines the Vector3 where to store the translation
  4196. * @returns the current matrix
  4197. */
  4198. getTranslationToRef(result: Vector3): Matrix;
  4199. /**
  4200. * Remove rotation and scaling part from the matrix
  4201. * @returns the updated matrix
  4202. */
  4203. removeRotationAndScaling(): Matrix;
  4204. /**
  4205. * Multiply two matrices
  4206. * @param other defines the second operand
  4207. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4208. */
  4209. multiply(other: DeepImmutable<Matrix>): Matrix;
  4210. /**
  4211. * Copy the current matrix from the given one
  4212. * @param other defines the source matrix
  4213. * @returns the current updated matrix
  4214. */
  4215. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4216. /**
  4217. * Populates the given array from the starting index with the current matrix values
  4218. * @param array defines the target array
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4223. /**
  4224. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4225. * @param other defines the second operand
  4226. * @param result defines the matrix where to store the multiplication
  4227. * @returns the current matrix
  4228. */
  4229. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4230. /**
  4231. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4232. * @param other defines the second operand
  4233. * @param result defines the array where to store the multiplication
  4234. * @param offset defines the offset in the target array where to start storing values
  4235. * @returns the current matrix
  4236. */
  4237. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4238. /**
  4239. * Check equality between this matrix and a second one
  4240. * @param value defines the second matrix to compare
  4241. * @returns true is the current matrix and the given one values are strictly equal
  4242. */
  4243. equals(value: DeepImmutable<Matrix>): boolean;
  4244. /**
  4245. * Clone the current matrix
  4246. * @returns a new matrix from the current matrix
  4247. */
  4248. clone(): Matrix;
  4249. /**
  4250. * Returns the name of the current matrix class
  4251. * @returns the string "Matrix"
  4252. */
  4253. getClassName(): string;
  4254. /**
  4255. * Gets the hash code of the current matrix
  4256. * @returns the hash code
  4257. */
  4258. getHashCode(): number;
  4259. /**
  4260. * Decomposes the current Matrix into a translation, rotation and scaling components
  4261. * @param scale defines the scale vector3 given as a reference to update
  4262. * @param rotation defines the rotation quaternion given as a reference to update
  4263. * @param translation defines the translation vector3 given as a reference to update
  4264. * @returns true if operation was successful
  4265. */
  4266. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4267. /**
  4268. * Gets specific row of the matrix
  4269. * @param index defines the number of the row to get
  4270. * @returns the index-th row of the current matrix as a new Vector4
  4271. */
  4272. getRow(index: number): Nullable<Vector4>;
  4273. /**
  4274. * Sets the index-th row of the current matrix to the vector4 values
  4275. * @param index defines the number of the row to set
  4276. * @param row defines the target vector4
  4277. * @returns the updated current matrix
  4278. */
  4279. setRow(index: number, row: Vector4): Matrix;
  4280. /**
  4281. * Compute the transpose of the matrix
  4282. * @returns the new transposed matrix
  4283. */
  4284. transpose(): Matrix;
  4285. /**
  4286. * Compute the transpose of the matrix and store it in a given matrix
  4287. * @param result defines the target matrix
  4288. * @returns the current matrix
  4289. */
  4290. transposeToRef(result: Matrix): Matrix;
  4291. /**
  4292. * Sets the index-th row of the current matrix with the given 4 x float values
  4293. * @param index defines the row index
  4294. * @param x defines the x component to set
  4295. * @param y defines the y component to set
  4296. * @param z defines the z component to set
  4297. * @param w defines the w component to set
  4298. * @returns the updated current matrix
  4299. */
  4300. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4301. /**
  4302. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4303. * @param scale defines the scale factor
  4304. * @returns a new matrix
  4305. */
  4306. scale(scale: number): Matrix;
  4307. /**
  4308. * Scale the current matrix values by a factor to a given result matrix
  4309. * @param scale defines the scale factor
  4310. * @param result defines the matrix to store the result
  4311. * @returns the current matrix
  4312. */
  4313. scaleToRef(scale: number, result: Matrix): Matrix;
  4314. /**
  4315. * Scale the current matrix values by a factor and add the result to a given matrix
  4316. * @param scale defines the scale factor
  4317. * @param result defines the Matrix to store the result
  4318. * @returns the current matrix
  4319. */
  4320. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4321. /**
  4322. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4323. * @param ref matrix to store the result
  4324. */
  4325. toNormalMatrix(ref: Matrix): void;
  4326. /**
  4327. * Gets only rotation part of the current matrix
  4328. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4329. */
  4330. getRotationMatrix(): Matrix;
  4331. /**
  4332. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4333. * @param result defines the target matrix to store data to
  4334. * @returns the current matrix
  4335. */
  4336. getRotationMatrixToRef(result: Matrix): Matrix;
  4337. /**
  4338. * Toggles model matrix from being right handed to left handed in place and vice versa
  4339. */
  4340. toggleModelMatrixHandInPlace(): void;
  4341. /**
  4342. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4343. */
  4344. toggleProjectionMatrixHandInPlace(): void;
  4345. /**
  4346. * Creates a matrix from an array
  4347. * @param array defines the source array
  4348. * @param offset defines an offset in the source array
  4349. * @returns a new Matrix set from the starting index of the given array
  4350. */
  4351. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4352. /**
  4353. * Copy the content of an array into a given matrix
  4354. * @param array defines the source array
  4355. * @param offset defines an offset in the source array
  4356. * @param result defines the target matrix
  4357. */
  4358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4359. /**
  4360. * Stores an array into a matrix after having multiplied each component by a given factor
  4361. * @param array defines the source array
  4362. * @param offset defines the offset in the source array
  4363. * @param scale defines the scaling factor
  4364. * @param result defines the target matrix
  4365. */
  4366. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4367. /**
  4368. * Gets an identity matrix that must not be updated
  4369. */
  4370. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4371. /**
  4372. * Stores a list of values (16) inside a given matrix
  4373. * @param initialM11 defines 1st value of 1st row
  4374. * @param initialM12 defines 2nd value of 1st row
  4375. * @param initialM13 defines 3rd value of 1st row
  4376. * @param initialM14 defines 4th value of 1st row
  4377. * @param initialM21 defines 1st value of 2nd row
  4378. * @param initialM22 defines 2nd value of 2nd row
  4379. * @param initialM23 defines 3rd value of 2nd row
  4380. * @param initialM24 defines 4th value of 2nd row
  4381. * @param initialM31 defines 1st value of 3rd row
  4382. * @param initialM32 defines 2nd value of 3rd row
  4383. * @param initialM33 defines 3rd value of 3rd row
  4384. * @param initialM34 defines 4th value of 3rd row
  4385. * @param initialM41 defines 1st value of 4th row
  4386. * @param initialM42 defines 2nd value of 4th row
  4387. * @param initialM43 defines 3rd value of 4th row
  4388. * @param initialM44 defines 4th value of 4th row
  4389. * @param result defines the target matrix
  4390. */
  4391. 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;
  4392. /**
  4393. * Creates new matrix from a list of values (16)
  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. * @returns the new matrix
  4411. */
  4412. 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;
  4413. /**
  4414. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4415. * @param scale defines the scale vector3
  4416. * @param rotation defines the rotation quaternion
  4417. * @param translation defines the translation vector3
  4418. * @returns a new matrix
  4419. */
  4420. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4421. /**
  4422. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4423. * @param scale defines the scale vector3
  4424. * @param rotation defines the rotation quaternion
  4425. * @param translation defines the translation vector3
  4426. * @param result defines the target matrix
  4427. */
  4428. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a new identity matrix
  4431. * @returns a new identity matrix
  4432. */
  4433. static Identity(): Matrix;
  4434. /**
  4435. * Creates a new identity matrix and stores the result in a given matrix
  4436. * @param result defines the target matrix
  4437. */
  4438. static IdentityToRef(result: Matrix): void;
  4439. /**
  4440. * Creates a new zero matrix
  4441. * @returns a new zero matrix
  4442. */
  4443. static Zero(): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the X axis
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationX(angle: number): Matrix;
  4450. /**
  4451. * Creates a new matrix as the invert of a given matrix
  4452. * @param source defines the source matrix
  4453. * @returns the new matrix
  4454. */
  4455. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4456. /**
  4457. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4458. * @param angle defines the angle (in radians) to use
  4459. * @param result defines the target matrix
  4460. */
  4461. static RotationXToRef(angle: number, result: Matrix): void;
  4462. /**
  4463. * Creates a new rotation matrix for "angle" radians around the Y axis
  4464. * @param angle defines the angle (in radians) to use
  4465. * @return the new matrix
  4466. */
  4467. static RotationY(angle: number): Matrix;
  4468. /**
  4469. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4470. * @param angle defines the angle (in radians) to use
  4471. * @param result defines the target matrix
  4472. */
  4473. static RotationYToRef(angle: number, result: Matrix): void;
  4474. /**
  4475. * Creates a new rotation matrix for "angle" radians around the Z axis
  4476. * @param angle defines the angle (in radians) to use
  4477. * @return the new matrix
  4478. */
  4479. static RotationZ(angle: number): Matrix;
  4480. /**
  4481. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4482. * @param angle defines the angle (in radians) to use
  4483. * @param result defines the target matrix
  4484. */
  4485. static RotationZToRef(angle: number, result: Matrix): void;
  4486. /**
  4487. * Creates a new rotation matrix for "angle" radians around the given axis
  4488. * @param axis defines the axis to use
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4495. * @param axis defines the axis to use
  4496. * @param angle defines the angle (in radians) to use
  4497. * @param result defines the target matrix
  4498. */
  4499. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4500. /**
  4501. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4502. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4503. * @param from defines the vector to align
  4504. * @param to defines the vector to align to
  4505. * @param result defines the target matrix
  4506. */
  4507. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4508. /**
  4509. * Creates a rotation matrix
  4510. * @param yaw defines the yaw angle in radians (Y axis)
  4511. * @param pitch defines the pitch angle in radians (X axis)
  4512. * @param roll defines the roll angle in radians (X axis)
  4513. * @returns the new rotation matrix
  4514. */
  4515. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4516. /**
  4517. * Creates a rotation matrix and stores it in a given matrix
  4518. * @param yaw defines the yaw angle in radians (Y axis)
  4519. * @param pitch defines the pitch angle in radians (X axis)
  4520. * @param roll defines the roll angle in radians (X axis)
  4521. * @param result defines the target matrix
  4522. */
  4523. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4524. /**
  4525. * Creates a scaling matrix
  4526. * @param x defines the scale factor on X axis
  4527. * @param y defines the scale factor on Y axis
  4528. * @param z defines the scale factor on Z axis
  4529. * @returns the new matrix
  4530. */
  4531. static Scaling(x: number, y: number, z: number): Matrix;
  4532. /**
  4533. * Creates a scaling matrix and stores it in a given matrix
  4534. * @param x defines the scale factor on X axis
  4535. * @param y defines the scale factor on Y axis
  4536. * @param z defines the scale factor on Z axis
  4537. * @param result defines the target matrix
  4538. */
  4539. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4540. /**
  4541. * Creates a translation matrix
  4542. * @param x defines the translation on X axis
  4543. * @param y defines the translation on Y axis
  4544. * @param z defines the translationon Z axis
  4545. * @returns the new matrix
  4546. */
  4547. static Translation(x: number, y: number, z: number): Matrix;
  4548. /**
  4549. * Creates a translation matrix and stores it in a given matrix
  4550. * @param x defines the translation on X axis
  4551. * @param y defines the translation on Y axis
  4552. * @param z defines the translationon Z axis
  4553. * @param result defines the target matrix
  4554. */
  4555. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4556. /**
  4557. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4558. * @param startValue defines the start value
  4559. * @param endValue defines the end value
  4560. * @param gradient defines the gradient factor
  4561. * @returns the new matrix
  4562. */
  4563. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4564. /**
  4565. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4566. * @param startValue defines the start value
  4567. * @param endValue defines the end value
  4568. * @param gradient defines the gradient factor
  4569. * @param result defines the Matrix object where to store data
  4570. */
  4571. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4572. /**
  4573. * Builds a new matrix whose values are computed by:
  4574. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4575. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4576. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4577. * @param startValue defines the first matrix
  4578. * @param endValue defines the second matrix
  4579. * @param gradient defines the gradient between the two matrices
  4580. * @returns the new matrix
  4581. */
  4582. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4583. /**
  4584. * Update a matrix to values which are computed by:
  4585. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4586. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4587. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4588. * @param startValue defines the first matrix
  4589. * @param endValue defines the second matrix
  4590. * @param gradient defines the gradient between the two matrices
  4591. * @param result defines the target matrix
  4592. */
  4593. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4594. /**
  4595. * 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"
  4596. * This function works in left handed mode
  4597. * @param eye defines the final position of the entity
  4598. * @param target defines where the entity should look at
  4599. * @param up defines the up vector for the entity
  4600. * @returns the new matrix
  4601. */
  4602. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4603. /**
  4604. * 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".
  4605. * This function works in left handed mode
  4606. * @param eye defines the final position of the entity
  4607. * @param target defines where the entity should look at
  4608. * @param up defines the up vector for the entity
  4609. * @param result defines the target matrix
  4610. */
  4611. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4612. /**
  4613. * 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"
  4614. * This function works in right handed mode
  4615. * @param eye defines the final position of the entity
  4616. * @param target defines where the entity should look at
  4617. * @param up defines the up vector for the entity
  4618. * @returns the new matrix
  4619. */
  4620. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4621. /**
  4622. * 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".
  4623. * This function works in right handed mode
  4624. * @param eye defines the final position of the entity
  4625. * @param target defines where the entity should look at
  4626. * @param up defines the up vector for the entity
  4627. * @param result defines the target matrix
  4628. */
  4629. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4630. /**
  4631. * Create a left-handed orthographic projection matrix
  4632. * @param width defines the viewport width
  4633. * @param height defines the viewport height
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed orthographic projection matrix
  4637. */
  4638. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Store a left-handed orthographic projection to a given matrix
  4641. * @param width defines the viewport width
  4642. * @param height defines the viewport height
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. */
  4647. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4648. /**
  4649. * Create a left-handed orthographic projection matrix
  4650. * @param left defines the viewport left coordinate
  4651. * @param right defines the viewport right coordinate
  4652. * @param bottom defines the viewport bottom coordinate
  4653. * @param top defines the viewport top coordinate
  4654. * @param znear defines the near clip plane
  4655. * @param zfar defines the far clip plane
  4656. * @returns a new matrix as a left-handed orthographic projection matrix
  4657. */
  4658. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4659. /**
  4660. * Stores a left-handed orthographic projection into a given matrix
  4661. * @param left defines the viewport left coordinate
  4662. * @param right defines the viewport right coordinate
  4663. * @param bottom defines the viewport bottom coordinate
  4664. * @param top defines the viewport top coordinate
  4665. * @param znear defines the near clip plane
  4666. * @param zfar defines the far clip plane
  4667. * @param result defines the target matrix
  4668. */
  4669. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4670. /**
  4671. * Creates a right-handed orthographic projection matrix
  4672. * @param left defines the viewport left coordinate
  4673. * @param right defines the viewport right coordinate
  4674. * @param bottom defines the viewport bottom coordinate
  4675. * @param top defines the viewport top coordinate
  4676. * @param znear defines the near clip plane
  4677. * @param zfar defines the far clip plane
  4678. * @returns a new matrix as a right-handed orthographic projection matrix
  4679. */
  4680. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4681. /**
  4682. * Stores a right-handed orthographic projection into a given matrix
  4683. * @param left defines the viewport left coordinate
  4684. * @param right defines the viewport right coordinate
  4685. * @param bottom defines the viewport bottom coordinate
  4686. * @param top defines the viewport top coordinate
  4687. * @param znear defines the near clip plane
  4688. * @param zfar defines the far clip plane
  4689. * @param result defines the target matrix
  4690. */
  4691. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4692. /**
  4693. * Creates a left-handed perspective projection matrix
  4694. * @param width defines the viewport width
  4695. * @param height defines the viewport height
  4696. * @param znear defines the near clip plane
  4697. * @param zfar defines the far clip plane
  4698. * @returns a new matrix as a left-handed perspective projection matrix
  4699. */
  4700. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4701. /**
  4702. * Creates a left-handed perspective projection matrix
  4703. * @param fov defines the horizontal field of view
  4704. * @param aspect defines the aspect ratio
  4705. * @param znear defines the near clip plane
  4706. * @param zfar defines the far clip plane
  4707. * @returns a new matrix as a left-handed perspective projection matrix
  4708. */
  4709. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4710. /**
  4711. * Stores a left-handed perspective projection into a given matrix
  4712. * @param fov defines the horizontal field of view
  4713. * @param aspect defines the aspect ratio
  4714. * @param znear defines the near clip plane
  4715. * @param zfar defines the far clip plane
  4716. * @param result defines the target matrix
  4717. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4718. */
  4719. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4720. /**
  4721. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4722. * @param fov defines the horizontal field of view
  4723. * @param aspect defines the aspect ratio
  4724. * @param znear defines the near clip plane
  4725. * @param zfar not used as infinity is used as far clip
  4726. * @param result defines the target matrix
  4727. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4728. */
  4729. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4730. /**
  4731. * Creates a right-handed perspective projection matrix
  4732. * @param fov defines the horizontal field of view
  4733. * @param aspect defines the aspect ratio
  4734. * @param znear defines the near clip plane
  4735. * @param zfar defines the far clip plane
  4736. * @returns a new matrix as a right-handed perspective projection matrix
  4737. */
  4738. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4739. /**
  4740. * Stores a right-handed perspective projection into a given matrix
  4741. * @param fov defines the horizontal field of view
  4742. * @param aspect defines the aspect ratio
  4743. * @param znear defines the near clip plane
  4744. * @param zfar defines the far clip plane
  4745. * @param result defines the target matrix
  4746. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4747. */
  4748. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4749. /**
  4750. * Stores a right-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar not used as infinity is used as far clip
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a perspective projection for WebVR info a given matrix
  4761. * @param fov defines the field of view
  4762. * @param znear defines the near clip plane
  4763. * @param zfar defines the far clip plane
  4764. * @param result defines the target matrix
  4765. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4766. */
  4767. static PerspectiveFovWebVRToRef(fov: {
  4768. upDegrees: number;
  4769. downDegrees: number;
  4770. leftDegrees: number;
  4771. rightDegrees: number;
  4772. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4773. /**
  4774. * Computes a complete transformation matrix
  4775. * @param viewport defines the viewport to use
  4776. * @param world defines the world matrix
  4777. * @param view defines the view matrix
  4778. * @param projection defines the projection matrix
  4779. * @param zmin defines the near clip plane
  4780. * @param zmax defines the far clip plane
  4781. * @returns the transformation matrix
  4782. */
  4783. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4784. /**
  4785. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4786. * @param matrix defines the matrix to use
  4787. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4788. */
  4789. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4790. /**
  4791. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4792. * @param matrix defines the matrix to use
  4793. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4794. */
  4795. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4796. /**
  4797. * Compute the transpose of a given matrix
  4798. * @param matrix defines the matrix to transpose
  4799. * @returns the new matrix
  4800. */
  4801. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4802. /**
  4803. * Compute the transpose of a matrix and store it in a target matrix
  4804. * @param matrix defines the matrix to transpose
  4805. * @param result defines the target matrix
  4806. */
  4807. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4808. /**
  4809. * Computes a reflection matrix from a plane
  4810. * @param plane defines the reflection plane
  4811. * @returns a new matrix
  4812. */
  4813. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4814. /**
  4815. * Computes a reflection matrix from a plane
  4816. * @param plane defines the reflection plane
  4817. * @param result defines the target matrix
  4818. */
  4819. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4820. /**
  4821. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4822. * @param xaxis defines the value of the 1st axis
  4823. * @param yaxis defines the value of the 2nd axis
  4824. * @param zaxis defines the value of the 3rd axis
  4825. * @param result defines the target matrix
  4826. */
  4827. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4828. /**
  4829. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4830. * @param quat defines the quaternion to use
  4831. * @param result defines the target matrix
  4832. */
  4833. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4834. }
  4835. /**
  4836. * @hidden
  4837. */
  4838. export class TmpVectors {
  4839. static Vector2: Vector2[];
  4840. static Vector3: Vector3[];
  4841. static Vector4: Vector4[];
  4842. static Quaternion: Quaternion[];
  4843. static Matrix: Matrix[];
  4844. }
  4845. }
  4846. declare module "babylonjs/Maths/math.path" {
  4847. import { DeepImmutable, Nullable } from "babylonjs/types";
  4848. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4849. /**
  4850. * Defines potential orientation for back face culling
  4851. */
  4852. export enum Orientation {
  4853. /**
  4854. * Clockwise
  4855. */
  4856. CW = 0,
  4857. /** Counter clockwise */
  4858. CCW = 1
  4859. }
  4860. /** Class used to represent a Bezier curve */
  4861. export class BezierCurve {
  4862. /**
  4863. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4864. * @param t defines the time
  4865. * @param x1 defines the left coordinate on X axis
  4866. * @param y1 defines the left coordinate on Y axis
  4867. * @param x2 defines the right coordinate on X axis
  4868. * @param y2 defines the right coordinate on Y axis
  4869. * @returns the interpolated value
  4870. */
  4871. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4872. }
  4873. /**
  4874. * Defines angle representation
  4875. */
  4876. export class Angle {
  4877. private _radians;
  4878. /**
  4879. * Creates an Angle object of "radians" radians (float).
  4880. * @param radians the angle in radians
  4881. */
  4882. constructor(radians: number);
  4883. /**
  4884. * Get value in degrees
  4885. * @returns the Angle value in degrees (float)
  4886. */
  4887. degrees(): number;
  4888. /**
  4889. * Get value in radians
  4890. * @returns the Angle value in radians (float)
  4891. */
  4892. radians(): number;
  4893. /**
  4894. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4895. * @param a defines first point as the origin
  4896. * @param b defines point
  4897. * @returns a new Angle
  4898. */
  4899. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4900. /**
  4901. * Gets a new Angle object from the given float in radians
  4902. * @param radians defines the angle value in radians
  4903. * @returns a new Angle
  4904. */
  4905. static FromRadians(radians: number): Angle;
  4906. /**
  4907. * Gets a new Angle object from the given float in degrees
  4908. * @param degrees defines the angle value in degrees
  4909. * @returns a new Angle
  4910. */
  4911. static FromDegrees(degrees: number): Angle;
  4912. }
  4913. /**
  4914. * This represents an arc in a 2d space.
  4915. */
  4916. export class Arc2 {
  4917. /** Defines the start point of the arc */
  4918. startPoint: Vector2;
  4919. /** Defines the mid point of the arc */
  4920. midPoint: Vector2;
  4921. /** Defines the end point of the arc */
  4922. endPoint: Vector2;
  4923. /**
  4924. * Defines the center point of the arc.
  4925. */
  4926. centerPoint: Vector2;
  4927. /**
  4928. * Defines the radius of the arc.
  4929. */
  4930. radius: number;
  4931. /**
  4932. * Defines the angle of the arc (from mid point to end point).
  4933. */
  4934. angle: Angle;
  4935. /**
  4936. * Defines the start angle of the arc (from start point to middle point).
  4937. */
  4938. startAngle: Angle;
  4939. /**
  4940. * Defines the orientation of the arc (clock wise/counter clock wise).
  4941. */
  4942. orientation: Orientation;
  4943. /**
  4944. * Creates an Arc object from the three given points : start, middle and end.
  4945. * @param startPoint Defines the start point of the arc
  4946. * @param midPoint Defines the midlle point of the arc
  4947. * @param endPoint Defines the end point of the arc
  4948. */
  4949. constructor(
  4950. /** Defines the start point of the arc */
  4951. startPoint: Vector2,
  4952. /** Defines the mid point of the arc */
  4953. midPoint: Vector2,
  4954. /** Defines the end point of the arc */
  4955. endPoint: Vector2);
  4956. }
  4957. /**
  4958. * Represents a 2D path made up of multiple 2D points
  4959. */
  4960. export class Path2 {
  4961. private _points;
  4962. private _length;
  4963. /**
  4964. * If the path start and end point are the same
  4965. */
  4966. closed: boolean;
  4967. /**
  4968. * Creates a Path2 object from the starting 2D coordinates x and y.
  4969. * @param x the starting points x value
  4970. * @param y the starting points y value
  4971. */
  4972. constructor(x: number, y: number);
  4973. /**
  4974. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4975. * @param x the added points x value
  4976. * @param y the added points y value
  4977. * @returns the updated Path2.
  4978. */
  4979. addLineTo(x: number, y: number): Path2;
  4980. /**
  4981. * 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.
  4982. * @param midX middle point x value
  4983. * @param midY middle point y value
  4984. * @param endX end point x value
  4985. * @param endY end point y value
  4986. * @param numberOfSegments (default: 36)
  4987. * @returns the updated Path2.
  4988. */
  4989. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4990. /**
  4991. * Closes the Path2.
  4992. * @returns the Path2.
  4993. */
  4994. close(): Path2;
  4995. /**
  4996. * Gets the sum of the distance between each sequential point in the path
  4997. * @returns the Path2 total length (float).
  4998. */
  4999. length(): number;
  5000. /**
  5001. * Gets the points which construct the path
  5002. * @returns the Path2 internal array of points.
  5003. */
  5004. getPoints(): Vector2[];
  5005. /**
  5006. * Retreives the point at the distance aways from the starting point
  5007. * @param normalizedLengthPosition the length along the path to retreive the point from
  5008. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5009. */
  5010. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5011. /**
  5012. * Creates a new path starting from an x and y position
  5013. * @param x starting x value
  5014. * @param y starting y value
  5015. * @returns a new Path2 starting at the coordinates (x, y).
  5016. */
  5017. static StartingAt(x: number, y: number): Path2;
  5018. }
  5019. /**
  5020. * Represents a 3D path made up of multiple 3D points
  5021. */
  5022. export class Path3D {
  5023. /**
  5024. * an array of Vector3, the curve axis of the Path3D
  5025. */
  5026. path: Vector3[];
  5027. private _curve;
  5028. private _distances;
  5029. private _tangents;
  5030. private _normals;
  5031. private _binormals;
  5032. private _raw;
  5033. private _alignTangentsWithPath;
  5034. private readonly _pointAtData;
  5035. /**
  5036. * new Path3D(path, normal, raw)
  5037. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5038. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5039. * @param path an array of Vector3, the curve axis of the Path3D
  5040. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5041. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5042. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5043. */
  5044. constructor(
  5045. /**
  5046. * an array of Vector3, the curve axis of the Path3D
  5047. */
  5048. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5049. /**
  5050. * Returns the Path3D array of successive Vector3 designing its curve.
  5051. * @returns the Path3D array of successive Vector3 designing its curve.
  5052. */
  5053. getCurve(): Vector3[];
  5054. /**
  5055. * Returns the Path3D array of successive Vector3 designing its curve.
  5056. * @returns the Path3D array of successive Vector3 designing its curve.
  5057. */
  5058. getPoints(): Vector3[];
  5059. /**
  5060. * @returns the computed length (float) of the path.
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Returns an array populated with tangent vectors on each Path3D curve point.
  5065. * @returns an array populated with tangent vectors on each Path3D curve point.
  5066. */
  5067. getTangents(): Vector3[];
  5068. /**
  5069. * Returns an array populated with normal vectors on each Path3D curve point.
  5070. * @returns an array populated with normal vectors on each Path3D curve point.
  5071. */
  5072. getNormals(): Vector3[];
  5073. /**
  5074. * Returns an array populated with binormal vectors on each Path3D curve point.
  5075. * @returns an array populated with binormal vectors on each Path3D curve point.
  5076. */
  5077. getBinormals(): Vector3[];
  5078. /**
  5079. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5080. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5081. */
  5082. getDistances(): number[];
  5083. /**
  5084. * Returns an interpolated point along this path
  5085. * @param position the position of the point along this path, from 0.0 to 1.0
  5086. * @returns a new Vector3 as the point
  5087. */
  5088. getPointAt(position: number): Vector3;
  5089. /**
  5090. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5091. * @param position the position of the point along this path, from 0.0 to 1.0
  5092. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5093. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5094. */
  5095. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5096. /**
  5097. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5098. * @param position the position of the point along this path, from 0.0 to 1.0
  5099. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5100. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5101. */
  5102. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5103. /**
  5104. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5105. * @param position the position of the point along this path, from 0.0 to 1.0
  5106. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5107. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5108. */
  5109. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5110. /**
  5111. * Returns the distance (float) 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. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5114. */
  5115. getDistanceAt(position: number): number;
  5116. /**
  5117. * Returns the array index of the previous point of an interpolated point along this path
  5118. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5119. * @returns the array index
  5120. */
  5121. getPreviousPointIndexAt(position: number): number;
  5122. /**
  5123. * 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)
  5124. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5125. * @returns the sub position
  5126. */
  5127. getSubPositionAt(position: number): number;
  5128. /**
  5129. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5130. * @param target the vector of which to get the closest position to
  5131. * @returns the position of the closest virtual point on this path to the target vector
  5132. */
  5133. getClosestPositionTo(target: Vector3): number;
  5134. /**
  5135. * Returns a sub path (slice) of this path
  5136. * @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
  5137. * @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
  5138. * @returns a sub path (slice) of this path
  5139. */
  5140. slice(start?: number, end?: number): Path3D;
  5141. /**
  5142. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5143. * @param path path which all values are copied into the curves points
  5144. * @param firstNormal which should be projected onto the curve
  5145. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5146. * @returns the same object updated.
  5147. */
  5148. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5149. private _compute;
  5150. private _getFirstNonNullVector;
  5151. private _getLastNonNullVector;
  5152. private _normalVector;
  5153. /**
  5154. * Updates the point at data for an interpolated point along this curve
  5155. * @param position the position of the point along this curve, from 0.0 to 1.0
  5156. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5157. * @returns the (updated) point at data
  5158. */
  5159. private _updatePointAtData;
  5160. /**
  5161. * Updates the point at data from the specified parameters
  5162. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5163. * @param point the interpolated point
  5164. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5165. */
  5166. private _setPointAtData;
  5167. /**
  5168. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5169. */
  5170. private _updateInterpolationMatrix;
  5171. }
  5172. /**
  5173. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5174. * A Curve3 is designed from a series of successive Vector3.
  5175. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5176. */
  5177. export class Curve3 {
  5178. private _points;
  5179. private _length;
  5180. /**
  5181. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5182. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5183. * @param v1 (Vector3) the control point
  5184. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5185. * @param nbPoints (integer) the wanted number of points in the curve
  5186. * @returns the created Curve3
  5187. */
  5188. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5189. /**
  5190. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5191. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5192. * @param v1 (Vector3) the first control point
  5193. * @param v2 (Vector3) the second control point
  5194. * @param v3 (Vector3) the end point of the Cubic Bezier
  5195. * @param nbPoints (integer) the wanted number of points in the curve
  5196. * @returns the created Curve3
  5197. */
  5198. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5199. /**
  5200. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5201. * @param p1 (Vector3) the origin point of the Hermite Spline
  5202. * @param t1 (Vector3) the tangent vector at the origin point
  5203. * @param p2 (Vector3) the end point of the Hermite Spline
  5204. * @param t2 (Vector3) the tangent vector at the end point
  5205. * @param nbPoints (integer) the wanted number of points in the curve
  5206. * @returns the created Curve3
  5207. */
  5208. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5209. /**
  5210. * Returns a Curve3 object along a CatmullRom Spline curve :
  5211. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5212. * @param nbPoints (integer) the wanted number of points between each curve control points
  5213. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5214. * @returns the created Curve3
  5215. */
  5216. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5217. /**
  5218. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5219. * A Curve3 is designed from a series of successive Vector3.
  5220. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5221. * @param points points which make up the curve
  5222. */
  5223. constructor(points: Vector3[]);
  5224. /**
  5225. * @returns the Curve3 stored array of successive Vector3
  5226. */
  5227. getPoints(): Vector3[];
  5228. /**
  5229. * @returns the computed length (float) of the curve.
  5230. */
  5231. length(): number;
  5232. /**
  5233. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5234. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5235. * curveA and curveB keep unchanged.
  5236. * @param curve the curve to continue from this curve
  5237. * @returns the newly constructed curve
  5238. */
  5239. continue(curve: DeepImmutable<Curve3>): Curve3;
  5240. private _computeLength;
  5241. }
  5242. }
  5243. declare module "babylonjs/Animations/easing" {
  5244. /**
  5245. * This represents the main contract an easing function should follow.
  5246. * Easing functions are used throughout the animation system.
  5247. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export interface IEasingFunction {
  5250. /**
  5251. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5252. * of the easing function.
  5253. * The link below provides some of the most common examples of easing functions.
  5254. * @see https://easings.net/
  5255. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5256. * @returns the corresponding value on the curve defined by the easing function
  5257. */
  5258. ease(gradient: number): number;
  5259. }
  5260. /**
  5261. * Base class used for every default easing function.
  5262. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5263. */
  5264. export class EasingFunction implements IEasingFunction {
  5265. /**
  5266. * Interpolation follows the mathematical formula associated with the easing function.
  5267. */
  5268. static readonly EASINGMODE_EASEIN: number;
  5269. /**
  5270. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5271. */
  5272. static readonly EASINGMODE_EASEOUT: number;
  5273. /**
  5274. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5275. */
  5276. static readonly EASINGMODE_EASEINOUT: number;
  5277. private _easingMode;
  5278. /**
  5279. * Sets the easing mode of the current function.
  5280. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5281. */
  5282. setEasingMode(easingMode: number): void;
  5283. /**
  5284. * Gets the current easing mode.
  5285. * @returns the easing mode
  5286. */
  5287. getEasingMode(): number;
  5288. /**
  5289. * @hidden
  5290. */
  5291. easeInCore(gradient: number): number;
  5292. /**
  5293. * Given an input gradient between 0 and 1, this returns the corresponding value
  5294. * of the easing function.
  5295. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5296. * @returns the corresponding value on the curve defined by the easing function
  5297. */
  5298. ease(gradient: number): number;
  5299. }
  5300. /**
  5301. * Easing function with a circle shape (see link below).
  5302. * @see https://easings.net/#easeInCirc
  5303. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5304. */
  5305. export class CircleEase extends EasingFunction implements IEasingFunction {
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a ease back shape (see link below).
  5311. * @see https://easings.net/#easeInBack
  5312. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class BackEase extends EasingFunction implements IEasingFunction {
  5315. /** Defines the amplitude of the function */
  5316. amplitude: number;
  5317. /**
  5318. * Instantiates a back ease easing
  5319. * @see https://easings.net/#easeInBack
  5320. * @param amplitude Defines the amplitude of the function
  5321. */
  5322. constructor(
  5323. /** Defines the amplitude of the function */
  5324. amplitude?: number);
  5325. /** @hidden */
  5326. easeInCore(gradient: number): number;
  5327. }
  5328. /**
  5329. * Easing function with a bouncing shape (see link below).
  5330. * @see https://easings.net/#easeInBounce
  5331. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5332. */
  5333. export class BounceEase extends EasingFunction implements IEasingFunction {
  5334. /** Defines the number of bounces */
  5335. bounces: number;
  5336. /** Defines the amplitude of the bounce */
  5337. bounciness: number;
  5338. /**
  5339. * Instantiates a bounce easing
  5340. * @see https://easings.net/#easeInBounce
  5341. * @param bounces Defines the number of bounces
  5342. * @param bounciness Defines the amplitude of the bounce
  5343. */
  5344. constructor(
  5345. /** Defines the number of bounces */
  5346. bounces?: number,
  5347. /** Defines the amplitude of the bounce */
  5348. bounciness?: number);
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a power of 3 shape (see link below).
  5354. * @see https://easings.net/#easeInCubic
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class CubicEase extends EasingFunction implements IEasingFunction {
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with an elastic shape (see link below).
  5363. * @see https://easings.net/#easeInElastic
  5364. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the number of oscillations*/
  5368. oscillations: number;
  5369. /** Defines the amplitude of the oscillations*/
  5370. springiness: number;
  5371. /**
  5372. * Instantiates an elastic easing function
  5373. * @see https://easings.net/#easeInElastic
  5374. * @param oscillations Defines the number of oscillations
  5375. * @param springiness Defines the amplitude of the oscillations
  5376. */
  5377. constructor(
  5378. /** Defines the number of oscillations*/
  5379. oscillations?: number,
  5380. /** Defines the amplitude of the oscillations*/
  5381. springiness?: number);
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with an exponential shape (see link below).
  5387. * @see https://easings.net/#easeInExpo
  5388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the exponent of the function */
  5392. exponent: number;
  5393. /**
  5394. * Instantiates an exponential easing function
  5395. * @see https://easings.net/#easeInExpo
  5396. * @param exponent Defines the exponent of the function
  5397. */
  5398. constructor(
  5399. /** Defines the exponent of the function */
  5400. exponent?: number);
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with a power shape (see link below).
  5406. * @see https://easings.net/#easeInQuad
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class PowerEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the power of the function */
  5411. power: number;
  5412. /**
  5413. * Instantiates an power base easing function
  5414. * @see https://easings.net/#easeInQuad
  5415. * @param power Defines the power of the function
  5416. */
  5417. constructor(
  5418. /** Defines the power of the function */
  5419. power?: number);
  5420. /** @hidden */
  5421. easeInCore(gradient: number): number;
  5422. }
  5423. /**
  5424. * Easing function with a power of 2 shape (see link below).
  5425. * @see https://easings.net/#easeInQuad
  5426. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5427. */
  5428. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5429. /** @hidden */
  5430. easeInCore(gradient: number): number;
  5431. }
  5432. /**
  5433. * Easing function with a power of 4 shape (see link below).
  5434. * @see https://easings.net/#easeInQuart
  5435. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5436. */
  5437. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5438. /** @hidden */
  5439. easeInCore(gradient: number): number;
  5440. }
  5441. /**
  5442. * Easing function with a power of 5 shape (see link below).
  5443. * @see https://easings.net/#easeInQuint
  5444. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5445. */
  5446. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. /**
  5451. * Easing function with a sin shape (see link below).
  5452. * @see https://easings.net/#easeInSine
  5453. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5454. */
  5455. export class SineEase extends EasingFunction implements IEasingFunction {
  5456. /** @hidden */
  5457. easeInCore(gradient: number): number;
  5458. }
  5459. /**
  5460. * Easing function with a bezier shape (see link below).
  5461. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5462. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5463. */
  5464. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1: number;
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1: number;
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2: number;
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2: number;
  5473. /**
  5474. * Instantiates a bezier function
  5475. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5476. * @param x1 Defines the x component of the start tangent in the bezier curve
  5477. * @param y1 Defines the y component of the start tangent in the bezier curve
  5478. * @param x2 Defines the x component of the end tangent in the bezier curve
  5479. * @param y2 Defines the y component of the end tangent in the bezier curve
  5480. */
  5481. constructor(
  5482. /** Defines the x component of the start tangent in the bezier curve */
  5483. x1?: number,
  5484. /** Defines the y component of the start tangent in the bezier curve */
  5485. y1?: number,
  5486. /** Defines the x component of the end tangent in the bezier curve */
  5487. x2?: number,
  5488. /** Defines the y component of the end tangent in the bezier curve */
  5489. y2?: number);
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. }
  5494. declare module "babylonjs/Maths/math.color" {
  5495. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5496. /**
  5497. * Class used to hold a RBG color
  5498. */
  5499. export class Color3 {
  5500. /**
  5501. * Defines the red component (between 0 and 1, default is 0)
  5502. */
  5503. r: number;
  5504. /**
  5505. * Defines the green component (between 0 and 1, default is 0)
  5506. */
  5507. g: number;
  5508. /**
  5509. * Defines the blue component (between 0 and 1, default is 0)
  5510. */
  5511. b: number;
  5512. /**
  5513. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5514. * @param r defines the red component (between 0 and 1, default is 0)
  5515. * @param g defines the green component (between 0 and 1, default is 0)
  5516. * @param b defines the blue component (between 0 and 1, default is 0)
  5517. */
  5518. constructor(
  5519. /**
  5520. * Defines the red component (between 0 and 1, default is 0)
  5521. */
  5522. r?: number,
  5523. /**
  5524. * Defines the green component (between 0 and 1, default is 0)
  5525. */
  5526. g?: number,
  5527. /**
  5528. * Defines the blue component (between 0 and 1, default is 0)
  5529. */
  5530. b?: number);
  5531. /**
  5532. * Creates a string with the Color3 current values
  5533. * @returns the string representation of the Color3 object
  5534. */
  5535. toString(): string;
  5536. /**
  5537. * Returns the string "Color3"
  5538. * @returns "Color3"
  5539. */
  5540. getClassName(): string;
  5541. /**
  5542. * Compute the Color3 hash code
  5543. * @returns an unique number that can be used to hash Color3 objects
  5544. */
  5545. getHashCode(): number;
  5546. /**
  5547. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5548. * @param array defines the array where to store the r,g,b components
  5549. * @param index defines an optional index in the target array to define where to start storing values
  5550. * @returns the current Color3 object
  5551. */
  5552. toArray(array: FloatArray, index?: number): Color3;
  5553. /**
  5554. * Returns a new Color4 object from the current Color3 and the given alpha
  5555. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5556. * @returns a new Color4 object
  5557. */
  5558. toColor4(alpha?: number): Color4;
  5559. /**
  5560. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5561. * @returns the new array
  5562. */
  5563. asArray(): number[];
  5564. /**
  5565. * Returns the luminance value
  5566. * @returns a float value
  5567. */
  5568. toLuminance(): number;
  5569. /**
  5570. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5571. * @param otherColor defines the second operand
  5572. * @returns the new Color3 object
  5573. */
  5574. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5575. /**
  5576. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5577. * @param otherColor defines the second operand
  5578. * @param result defines the Color3 object where to store the result
  5579. * @returns the current Color3
  5580. */
  5581. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5582. /**
  5583. * Determines equality between Color3 objects
  5584. * @param otherColor defines the second operand
  5585. * @returns true if the rgb values are equal to the given ones
  5586. */
  5587. equals(otherColor: DeepImmutable<Color3>): boolean;
  5588. /**
  5589. * Determines equality between the current Color3 object and a set of r,b,g values
  5590. * @param r defines the red component to check
  5591. * @param g defines the green component to check
  5592. * @param b defines the blue component to check
  5593. * @returns true if the rgb values are equal to the given ones
  5594. */
  5595. equalsFloats(r: number, g: number, b: number): boolean;
  5596. /**
  5597. * Multiplies in place each rgb value by scale
  5598. * @param scale defines the scaling factor
  5599. * @returns the updated Color3
  5600. */
  5601. scale(scale: number): Color3;
  5602. /**
  5603. * Multiplies the rgb values by scale and stores the result into "result"
  5604. * @param scale defines the scaling factor
  5605. * @param result defines the Color3 object where to store the result
  5606. * @returns the unmodified current Color3
  5607. */
  5608. scaleToRef(scale: number, result: Color3): Color3;
  5609. /**
  5610. * Scale the current Color3 values by a factor and add the result to a given Color3
  5611. * @param scale defines the scale factor
  5612. * @param result defines color to store the result into
  5613. * @returns the unmodified current Color3
  5614. */
  5615. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5616. /**
  5617. * Clamps the rgb values by the min and max values and stores the result into "result"
  5618. * @param min defines minimum clamping value (default is 0)
  5619. * @param max defines maximum clamping value (default is 1)
  5620. * @param result defines color to store the result into
  5621. * @returns the original Color3
  5622. */
  5623. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5624. /**
  5625. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5626. * @param otherColor defines the second operand
  5627. * @returns the new Color3
  5628. */
  5629. add(otherColor: DeepImmutable<Color3>): Color3;
  5630. /**
  5631. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5632. * @param otherColor defines the second operand
  5633. * @param result defines Color3 object to store the result into
  5634. * @returns the unmodified current Color3
  5635. */
  5636. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5637. /**
  5638. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5639. * @param otherColor defines the second operand
  5640. * @returns the new Color3
  5641. */
  5642. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5643. /**
  5644. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5645. * @param otherColor defines the second operand
  5646. * @param result defines Color3 object to store the result into
  5647. * @returns the unmodified current Color3
  5648. */
  5649. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5650. /**
  5651. * Copy the current object
  5652. * @returns a new Color3 copied the current one
  5653. */
  5654. clone(): Color3;
  5655. /**
  5656. * Copies the rgb values from the source in the current Color3
  5657. * @param source defines the source Color3 object
  5658. * @returns the updated Color3 object
  5659. */
  5660. copyFrom(source: DeepImmutable<Color3>): Color3;
  5661. /**
  5662. * Updates the Color3 rgb values from the given floats
  5663. * @param r defines the red component to read from
  5664. * @param g defines the green component to read from
  5665. * @param b defines the blue component to read from
  5666. * @returns the current Color3 object
  5667. */
  5668. copyFromFloats(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Updates the Color3 rgb values from the given floats
  5671. * @param r defines the red component to read from
  5672. * @param g defines the green component to read from
  5673. * @param b defines the blue component to read from
  5674. * @returns the current Color3 object
  5675. */
  5676. set(r: number, g: number, b: number): Color3;
  5677. /**
  5678. * Compute the Color3 hexadecimal code as a string
  5679. * @returns a string containing the hexadecimal representation of the Color3 object
  5680. */
  5681. toHexString(): string;
  5682. /**
  5683. * Computes a new Color3 converted from the current one to linear space
  5684. * @returns a new Color3 object
  5685. */
  5686. toLinearSpace(): Color3;
  5687. /**
  5688. * Converts current color in rgb space to HSV values
  5689. * @returns a new color3 representing the HSV values
  5690. */
  5691. toHSV(): Color3;
  5692. /**
  5693. * Converts current color in rgb space to HSV values
  5694. * @param result defines the Color3 where to store the HSV values
  5695. */
  5696. toHSVToRef(result: Color3): void;
  5697. /**
  5698. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the linear space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5703. /**
  5704. * Computes a new Color3 converted from the current one to gamma space
  5705. * @returns a new Color3 object
  5706. */
  5707. toGammaSpace(): Color3;
  5708. /**
  5709. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5710. * @param convertedColor defines the Color3 object where to store the gamma space version
  5711. * @returns the unmodified Color3
  5712. */
  5713. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5714. private static _BlackReadOnly;
  5715. /**
  5716. * Convert Hue, saturation and value to a Color3 (RGB)
  5717. * @param hue defines the hue
  5718. * @param saturation defines the saturation
  5719. * @param value defines the value
  5720. * @param result defines the Color3 where to store the RGB values
  5721. */
  5722. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5723. /**
  5724. * Creates a new Color3 from the string containing valid hexadecimal values
  5725. * @param hex defines a string containing valid hexadecimal values
  5726. * @returns a new Color3 object
  5727. */
  5728. static FromHexString(hex: string): Color3;
  5729. /**
  5730. * Creates a new Color3 from the starting index of the given array
  5731. * @param array defines the source array
  5732. * @param offset defines an offset in the source array
  5733. * @returns a new Color3 object
  5734. */
  5735. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5736. /**
  5737. * Creates a new Color3 from integer values (< 256)
  5738. * @param r defines the red component to read from (value between 0 and 255)
  5739. * @param g defines the green component to read from (value between 0 and 255)
  5740. * @param b defines the blue component to read from (value between 0 and 255)
  5741. * @returns a new Color3 object
  5742. */
  5743. static FromInts(r: number, g: number, b: number): Color3;
  5744. /**
  5745. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5746. * @param start defines the start Color3 value
  5747. * @param end defines the end Color3 value
  5748. * @param amount defines the gradient value between start and end
  5749. * @returns a new Color3 object
  5750. */
  5751. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5752. /**
  5753. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5754. * @param left defines the start value
  5755. * @param right defines the end value
  5756. * @param amount defines the gradient factor
  5757. * @param result defines the Color3 object where to store the result
  5758. */
  5759. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5760. /**
  5761. * Returns a Color3 value containing a red color
  5762. * @returns a new Color3 object
  5763. */
  5764. static Red(): Color3;
  5765. /**
  5766. * Returns a Color3 value containing a green color
  5767. * @returns a new Color3 object
  5768. */
  5769. static Green(): Color3;
  5770. /**
  5771. * Returns a Color3 value containing a blue color
  5772. * @returns a new Color3 object
  5773. */
  5774. static Blue(): Color3;
  5775. /**
  5776. * Returns a Color3 value containing a black color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Black(): Color3;
  5780. /**
  5781. * Gets a Color3 value containing a black color that must not be updated
  5782. */
  5783. static get BlackReadOnly(): DeepImmutable<Color3>;
  5784. /**
  5785. * Returns a Color3 value containing a white color
  5786. * @returns a new Color3 object
  5787. */
  5788. static White(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a purple color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Purple(): Color3;
  5794. /**
  5795. * Returns a Color3 value containing a magenta color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Magenta(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a yellow color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Yellow(): Color3;
  5804. /**
  5805. * Returns a Color3 value containing a gray color
  5806. * @returns a new Color3 object
  5807. */
  5808. static Gray(): Color3;
  5809. /**
  5810. * Returns a Color3 value containing a teal color
  5811. * @returns a new Color3 object
  5812. */
  5813. static Teal(): Color3;
  5814. /**
  5815. * Returns a Color3 value containing a random color
  5816. * @returns a new Color3 object
  5817. */
  5818. static Random(): Color3;
  5819. }
  5820. /**
  5821. * Class used to hold a RBGA color
  5822. */
  5823. export class Color4 {
  5824. /**
  5825. * Defines the red component (between 0 and 1, default is 0)
  5826. */
  5827. r: number;
  5828. /**
  5829. * Defines the green component (between 0 and 1, default is 0)
  5830. */
  5831. g: number;
  5832. /**
  5833. * Defines the blue component (between 0 and 1, default is 0)
  5834. */
  5835. b: number;
  5836. /**
  5837. * Defines the alpha component (between 0 and 1, default is 1)
  5838. */
  5839. a: number;
  5840. /**
  5841. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5842. * @param r defines the red component (between 0 and 1, default is 0)
  5843. * @param g defines the green component (between 0 and 1, default is 0)
  5844. * @param b defines the blue component (between 0 and 1, default is 0)
  5845. * @param a defines the alpha component (between 0 and 1, default is 1)
  5846. */
  5847. constructor(
  5848. /**
  5849. * Defines the red component (between 0 and 1, default is 0)
  5850. */
  5851. r?: number,
  5852. /**
  5853. * Defines the green component (between 0 and 1, default is 0)
  5854. */
  5855. g?: number,
  5856. /**
  5857. * Defines the blue component (between 0 and 1, default is 0)
  5858. */
  5859. b?: number,
  5860. /**
  5861. * Defines the alpha component (between 0 and 1, default is 1)
  5862. */
  5863. a?: number);
  5864. /**
  5865. * Adds in place the given Color4 values to the current Color4 object
  5866. * @param right defines the second operand
  5867. * @returns the current updated Color4 object
  5868. */
  5869. addInPlace(right: DeepImmutable<Color4>): Color4;
  5870. /**
  5871. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5872. * @returns the new array
  5873. */
  5874. asArray(): number[];
  5875. /**
  5876. * Stores from the starting index in the given array the Color4 successive values
  5877. * @param array defines the array where to store the r,g,b components
  5878. * @param index defines an optional index in the target array to define where to start storing values
  5879. * @returns the current Color4 object
  5880. */
  5881. toArray(array: number[], index?: number): Color4;
  5882. /**
  5883. * Determines equality between Color4 objects
  5884. * @param otherColor defines the second operand
  5885. * @returns true if the rgba values are equal to the given ones
  5886. */
  5887. equals(otherColor: DeepImmutable<Color4>): boolean;
  5888. /**
  5889. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5890. * @param right defines the second operand
  5891. * @returns a new Color4 object
  5892. */
  5893. add(right: DeepImmutable<Color4>): Color4;
  5894. /**
  5895. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5896. * @param right defines the second operand
  5897. * @returns a new Color4 object
  5898. */
  5899. subtract(right: DeepImmutable<Color4>): Color4;
  5900. /**
  5901. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5902. * @param right defines the second operand
  5903. * @param result defines the Color4 object where to store the result
  5904. * @returns the current Color4 object
  5905. */
  5906. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5907. /**
  5908. * Creates a new Color4 with the current Color4 values multiplied by scale
  5909. * @param scale defines the scaling factor to apply
  5910. * @returns a new Color4 object
  5911. */
  5912. scale(scale: number): Color4;
  5913. /**
  5914. * Multiplies the current Color4 values by scale and stores the result in "result"
  5915. * @param scale defines the scaling factor to apply
  5916. * @param result defines the Color4 object where to store the result
  5917. * @returns the current unmodified Color4
  5918. */
  5919. scaleToRef(scale: number, result: Color4): Color4;
  5920. /**
  5921. * Scale the current Color4 values by a factor and add the result to a given Color4
  5922. * @param scale defines the scale factor
  5923. * @param result defines the Color4 object where to store the result
  5924. * @returns the unmodified current Color4
  5925. */
  5926. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5927. /**
  5928. * Clamps the rgb values by the min and max values and stores the result into "result"
  5929. * @param min defines minimum clamping value (default is 0)
  5930. * @param max defines maximum clamping value (default is 1)
  5931. * @param result defines color to store the result into.
  5932. * @returns the cuurent Color4
  5933. */
  5934. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5935. /**
  5936. * Multipy an Color4 value by another and return a new Color4 object
  5937. * @param color defines the Color4 value to multiply by
  5938. * @returns a new Color4 object
  5939. */
  5940. multiply(color: Color4): Color4;
  5941. /**
  5942. * Multipy a Color4 value by another and push the result in a reference value
  5943. * @param color defines the Color4 value to multiply by
  5944. * @param result defines the Color4 to fill the result in
  5945. * @returns the result Color4
  5946. */
  5947. multiplyToRef(color: Color4, result: Color4): Color4;
  5948. /**
  5949. * Creates a string with the Color4 current values
  5950. * @returns the string representation of the Color4 object
  5951. */
  5952. toString(): string;
  5953. /**
  5954. * Returns the string "Color4"
  5955. * @returns "Color4"
  5956. */
  5957. getClassName(): string;
  5958. /**
  5959. * Compute the Color4 hash code
  5960. * @returns an unique number that can be used to hash Color4 objects
  5961. */
  5962. getHashCode(): number;
  5963. /**
  5964. * Creates a new Color4 copied from the current one
  5965. * @returns a new Color4 object
  5966. */
  5967. clone(): Color4;
  5968. /**
  5969. * Copies the given Color4 values into the current one
  5970. * @param source defines the source Color4 object
  5971. * @returns the current updated Color4 object
  5972. */
  5973. copyFrom(source: Color4): Color4;
  5974. /**
  5975. * Copies the given float values into the current one
  5976. * @param r defines the red component to read from
  5977. * @param g defines the green component to read from
  5978. * @param b defines the blue component to read from
  5979. * @param a defines the alpha component to read from
  5980. * @returns the current updated Color4 object
  5981. */
  5982. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Copies the given float values into the current one
  5985. * @param r defines the red component to read from
  5986. * @param g defines the green component to read from
  5987. * @param b defines the blue component to read from
  5988. * @param a defines the alpha component to read from
  5989. * @returns the current updated Color4 object
  5990. */
  5991. set(r: number, g: number, b: number, a: number): Color4;
  5992. /**
  5993. * Compute the Color4 hexadecimal code as a string
  5994. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5995. * @returns a string containing the hexadecimal representation of the Color4 object
  5996. */
  5997. toHexString(returnAsColor3?: boolean): string;
  5998. /**
  5999. * Computes a new Color4 converted from the current one to linear space
  6000. * @returns a new Color4 object
  6001. */
  6002. toLinearSpace(): Color4;
  6003. /**
  6004. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6005. * @param convertedColor defines the Color4 object where to store the linear space version
  6006. * @returns the unmodified Color4
  6007. */
  6008. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6009. /**
  6010. * Computes a new Color4 converted from the current one to gamma space
  6011. * @returns a new Color4 object
  6012. */
  6013. toGammaSpace(): Color4;
  6014. /**
  6015. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6016. * @param convertedColor defines the Color4 object where to store the gamma space version
  6017. * @returns the unmodified Color4
  6018. */
  6019. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6020. /**
  6021. * Creates a new Color4 from the string containing valid hexadecimal values
  6022. * @param hex defines a string containing valid hexadecimal values
  6023. * @returns a new Color4 object
  6024. */
  6025. static FromHexString(hex: string): Color4;
  6026. /**
  6027. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6028. * @param left defines the start value
  6029. * @param right defines the end value
  6030. * @param amount defines the gradient factor
  6031. * @returns a new Color4 object
  6032. */
  6033. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6034. /**
  6035. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6036. * @param left defines the start value
  6037. * @param right defines the end value
  6038. * @param amount defines the gradient factor
  6039. * @param result defines the Color4 object where to store data
  6040. */
  6041. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6042. /**
  6043. * Creates a new Color4 from a Color3 and an alpha value
  6044. * @param color3 defines the source Color3 to read from
  6045. * @param alpha defines the alpha component (1.0 by default)
  6046. * @returns a new Color4 object
  6047. */
  6048. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6049. /**
  6050. * Creates a new Color4 from the starting index element of the given array
  6051. * @param array defines the source array to read from
  6052. * @param offset defines the offset in the source array
  6053. * @returns a new Color4 object
  6054. */
  6055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6056. /**
  6057. * Creates a new Color3 from integer values (< 256)
  6058. * @param r defines the red component to read from (value between 0 and 255)
  6059. * @param g defines the green component to read from (value between 0 and 255)
  6060. * @param b defines the blue component to read from (value between 0 and 255)
  6061. * @param a defines the alpha component to read from (value between 0 and 255)
  6062. * @returns a new Color3 object
  6063. */
  6064. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6065. /**
  6066. * Check the content of a given array and convert it to an array containing RGBA data
  6067. * If the original array was already containing count * 4 values then it is returned directly
  6068. * @param colors defines the array to check
  6069. * @param count defines the number of RGBA data to expect
  6070. * @returns an array containing count * 4 values (RGBA)
  6071. */
  6072. static CheckColors4(colors: number[], count: number): number[];
  6073. }
  6074. /**
  6075. * @hidden
  6076. */
  6077. export class TmpColors {
  6078. static Color3: Color3[];
  6079. static Color4: Color4[];
  6080. }
  6081. }
  6082. declare module "babylonjs/Animations/animationKey" {
  6083. /**
  6084. * Defines an interface which represents an animation key frame
  6085. */
  6086. export interface IAnimationKey {
  6087. /**
  6088. * Frame of the key frame
  6089. */
  6090. frame: number;
  6091. /**
  6092. * Value at the specifies key frame
  6093. */
  6094. value: any;
  6095. /**
  6096. * The input tangent for the cubic hermite spline
  6097. */
  6098. inTangent?: any;
  6099. /**
  6100. * The output tangent for the cubic hermite spline
  6101. */
  6102. outTangent?: any;
  6103. /**
  6104. * The animation interpolation type
  6105. */
  6106. interpolation?: AnimationKeyInterpolation;
  6107. }
  6108. /**
  6109. * Enum for the animation key frame interpolation type
  6110. */
  6111. export enum AnimationKeyInterpolation {
  6112. /**
  6113. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6114. */
  6115. STEP = 1
  6116. }
  6117. }
  6118. declare module "babylonjs/Animations/animationRange" {
  6119. /**
  6120. * Represents the range of an animation
  6121. */
  6122. export class AnimationRange {
  6123. /**The name of the animation range**/
  6124. name: string;
  6125. /**The starting frame of the animation */
  6126. from: number;
  6127. /**The ending frame of the animation*/
  6128. to: number;
  6129. /**
  6130. * Initializes the range of an animation
  6131. * @param name The name of the animation range
  6132. * @param from The starting frame of the animation
  6133. * @param to The ending frame of the animation
  6134. */
  6135. constructor(
  6136. /**The name of the animation range**/
  6137. name: string,
  6138. /**The starting frame of the animation */
  6139. from: number,
  6140. /**The ending frame of the animation*/
  6141. to: number);
  6142. /**
  6143. * Makes a copy of the animation range
  6144. * @returns A copy of the animation range
  6145. */
  6146. clone(): AnimationRange;
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationEvent" {
  6150. /**
  6151. * Composed of a frame, and an action function
  6152. */
  6153. export class AnimationEvent {
  6154. /** The frame for which the event is triggered **/
  6155. frame: number;
  6156. /** The event to perform when triggered **/
  6157. action: (currentFrame: number) => void;
  6158. /** Specifies if the event should be triggered only once**/
  6159. onlyOnce?: boolean | undefined;
  6160. /**
  6161. * Specifies if the animation event is done
  6162. */
  6163. isDone: boolean;
  6164. /**
  6165. * Initializes the animation event
  6166. * @param frame The frame for which the event is triggered
  6167. * @param action The event to perform when triggered
  6168. * @param onlyOnce Specifies if the event should be triggered only once
  6169. */
  6170. constructor(
  6171. /** The frame for which the event is triggered **/
  6172. frame: number,
  6173. /** The event to perform when triggered **/
  6174. action: (currentFrame: number) => void,
  6175. /** Specifies if the event should be triggered only once**/
  6176. onlyOnce?: boolean | undefined);
  6177. /** @hidden */
  6178. _clone(): AnimationEvent;
  6179. }
  6180. }
  6181. declare module "babylonjs/Behaviors/behavior" {
  6182. import { Nullable } from "babylonjs/types";
  6183. /**
  6184. * Interface used to define a behavior
  6185. */
  6186. export interface Behavior<T> {
  6187. /** gets or sets behavior's name */
  6188. name: string;
  6189. /**
  6190. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6191. */
  6192. init(): void;
  6193. /**
  6194. * Called when the behavior is attached to a target
  6195. * @param target defines the target where the behavior is attached to
  6196. */
  6197. attach(target: T): void;
  6198. /**
  6199. * Called when the behavior is detached from its target
  6200. */
  6201. detach(): void;
  6202. }
  6203. /**
  6204. * Interface implemented by classes supporting behaviors
  6205. */
  6206. export interface IBehaviorAware<T> {
  6207. /**
  6208. * Attach a behavior
  6209. * @param behavior defines the behavior to attach
  6210. * @returns the current host
  6211. */
  6212. addBehavior(behavior: Behavior<T>): T;
  6213. /**
  6214. * Remove a behavior from the current object
  6215. * @param behavior defines the behavior to detach
  6216. * @returns the current host
  6217. */
  6218. removeBehavior(behavior: Behavior<T>): T;
  6219. /**
  6220. * Gets a behavior using its name to search
  6221. * @param name defines the name to search
  6222. * @returns the behavior or null if not found
  6223. */
  6224. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6225. }
  6226. }
  6227. declare module "babylonjs/Misc/smartArray" {
  6228. /**
  6229. * Defines an array and its length.
  6230. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6231. */
  6232. export interface ISmartArrayLike<T> {
  6233. /**
  6234. * The data of the array.
  6235. */
  6236. data: Array<T>;
  6237. /**
  6238. * The active length of the array.
  6239. */
  6240. length: number;
  6241. }
  6242. /**
  6243. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6244. */
  6245. export class SmartArray<T> implements ISmartArrayLike<T> {
  6246. /**
  6247. * The full set of data from the array.
  6248. */
  6249. data: Array<T>;
  6250. /**
  6251. * The active length of the array.
  6252. */
  6253. length: number;
  6254. protected _id: number;
  6255. /**
  6256. * Instantiates a Smart Array.
  6257. * @param capacity defines the default capacity of the array.
  6258. */
  6259. constructor(capacity: number);
  6260. /**
  6261. * Pushes a value at the end of the active data.
  6262. * @param value defines the object to push in the array.
  6263. */
  6264. push(value: T): void;
  6265. /**
  6266. * Iterates over the active data and apply the lambda to them.
  6267. * @param func defines the action to apply on each value.
  6268. */
  6269. forEach(func: (content: T) => void): void;
  6270. /**
  6271. * Sorts the full sets of data.
  6272. * @param compareFn defines the comparison function to apply.
  6273. */
  6274. sort(compareFn: (a: T, b: T) => number): void;
  6275. /**
  6276. * Resets the active data to an empty array.
  6277. */
  6278. reset(): void;
  6279. /**
  6280. * Releases all the data from the array as well as the array.
  6281. */
  6282. dispose(): void;
  6283. /**
  6284. * Concats the active data with a given array.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concat(array: any): void;
  6288. /**
  6289. * Returns the position of a value in the active data.
  6290. * @param value defines the value to find the index for
  6291. * @returns the index if found in the active data otherwise -1
  6292. */
  6293. indexOf(value: T): number;
  6294. /**
  6295. * Returns whether an element is part of the active data.
  6296. * @param value defines the value to look for
  6297. * @returns true if found in the active data otherwise false
  6298. */
  6299. contains(value: T): boolean;
  6300. private static _GlobalId;
  6301. }
  6302. /**
  6303. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6304. * The data in this array can only be present once
  6305. */
  6306. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6307. private _duplicateId;
  6308. /**
  6309. * Pushes a value at the end of the active data.
  6310. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Pushes a value at the end of the active data.
  6316. * If the data is already present, it won t be added again
  6317. * @param value defines the object to push in the array.
  6318. * @returns true if added false if it was already present
  6319. */
  6320. pushNoDuplicate(value: T): boolean;
  6321. /**
  6322. * Resets the active data to an empty array.
  6323. */
  6324. reset(): void;
  6325. /**
  6326. * Concats the active data with a given array.
  6327. * This ensures no dupplicate will be present in the result.
  6328. * @param array defines the data to concatenate with.
  6329. */
  6330. concatWithNoDuplicate(array: any): void;
  6331. }
  6332. }
  6333. declare module "babylonjs/Cameras/cameraInputsManager" {
  6334. import { Nullable } from "babylonjs/types";
  6335. import { Camera } from "babylonjs/Cameras/camera";
  6336. /**
  6337. * @ignore
  6338. * This is a list of all the different input types that are available in the application.
  6339. * Fo instance: ArcRotateCameraGamepadInput...
  6340. */
  6341. export var CameraInputTypes: {};
  6342. /**
  6343. * This is the contract to implement in order to create a new input class.
  6344. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6345. */
  6346. export interface ICameraInput<TCamera extends Camera> {
  6347. /**
  6348. * Defines the camera the input is attached to.
  6349. */
  6350. camera: Nullable<TCamera>;
  6351. /**
  6352. * Gets the class name of the current intput.
  6353. * @returns the class name
  6354. */
  6355. getClassName(): string;
  6356. /**
  6357. * Get the friendly name associated with the input class.
  6358. * @returns the input friendly name
  6359. */
  6360. getSimpleName(): string;
  6361. /**
  6362. * Attach the input controls to a specific dom element to get the input from.
  6363. * @param element Defines the element the controls should be listened from
  6364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6367. /**
  6368. * Detach the current controls from the specified dom element.
  6369. * @param element Defines the element to stop listening the inputs from
  6370. */
  6371. detachControl(element: Nullable<HTMLElement>): void;
  6372. /**
  6373. * Update the current camera state depending on the inputs that have been used this frame.
  6374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6375. */
  6376. checkInputs?: () => void;
  6377. }
  6378. /**
  6379. * Represents a map of input types to input instance or input index to input instance.
  6380. */
  6381. export interface CameraInputsMap<TCamera extends Camera> {
  6382. /**
  6383. * Accessor to the input by input type.
  6384. */
  6385. [name: string]: ICameraInput<TCamera>;
  6386. /**
  6387. * Accessor to the input by input index.
  6388. */
  6389. [idx: number]: ICameraInput<TCamera>;
  6390. }
  6391. /**
  6392. * This represents the input manager used within a camera.
  6393. * It helps dealing with all the different kind of input attached to a camera.
  6394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6395. */
  6396. export class CameraInputsManager<TCamera extends Camera> {
  6397. /**
  6398. * Defines the list of inputs attahed to the camera.
  6399. */
  6400. attached: CameraInputsMap<TCamera>;
  6401. /**
  6402. * Defines the dom element the camera is collecting inputs from.
  6403. * This is null if the controls have not been attached.
  6404. */
  6405. attachedElement: Nullable<HTMLElement>;
  6406. /**
  6407. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6408. */
  6409. noPreventDefault: boolean;
  6410. /**
  6411. * Defined the camera the input manager belongs to.
  6412. */
  6413. camera: TCamera;
  6414. /**
  6415. * Update the current camera state depending on the inputs that have been used this frame.
  6416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6417. */
  6418. checkInputs: () => void;
  6419. /**
  6420. * Instantiate a new Camera Input Manager.
  6421. * @param camera Defines the camera the input manager blongs to
  6422. */
  6423. constructor(camera: TCamera);
  6424. /**
  6425. * Add an input method to a camera
  6426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6427. * @param input camera input method
  6428. */
  6429. add(input: ICameraInput<TCamera>): void;
  6430. /**
  6431. * Remove a specific input method from a camera
  6432. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6433. * @param inputToRemove camera input method
  6434. */
  6435. remove(inputToRemove: ICameraInput<TCamera>): void;
  6436. /**
  6437. * Remove a specific input type from a camera
  6438. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6439. * @param inputType the type of the input to remove
  6440. */
  6441. removeByType(inputType: string): void;
  6442. private _addCheckInputs;
  6443. /**
  6444. * Attach the input controls to the currently attached dom element to listen the events from.
  6445. * @param input Defines the input to attach
  6446. */
  6447. attachInput(input: ICameraInput<TCamera>): void;
  6448. /**
  6449. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6450. * @param element Defines the dom element to collect the events from
  6451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6452. */
  6453. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6454. /**
  6455. * Detach the current manager inputs controls from a specific dom element.
  6456. * @param element Defines the dom element to collect the events from
  6457. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6458. */
  6459. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6460. /**
  6461. * Rebuild the dynamic inputCheck function from the current list of
  6462. * defined inputs in the manager.
  6463. */
  6464. rebuildInputCheck(): void;
  6465. /**
  6466. * Remove all attached input methods from a camera
  6467. */
  6468. clear(): void;
  6469. /**
  6470. * Serialize the current input manager attached to a camera.
  6471. * This ensures than once parsed,
  6472. * the input associated to the camera will be identical to the current ones
  6473. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6474. */
  6475. serialize(serializedCamera: any): void;
  6476. /**
  6477. * Parses an input manager serialized JSON to restore the previous list of inputs
  6478. * and states associated to a camera.
  6479. * @param parsedCamera Defines the JSON to parse
  6480. */
  6481. parse(parsedCamera: any): void;
  6482. }
  6483. }
  6484. declare module "babylonjs/Meshes/buffer" {
  6485. import { Nullable, DataArray } from "babylonjs/types";
  6486. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6487. /**
  6488. * Class used to store data that will be store in GPU memory
  6489. */
  6490. export class Buffer {
  6491. private _engine;
  6492. private _buffer;
  6493. /** @hidden */
  6494. _data: Nullable<DataArray>;
  6495. private _updatable;
  6496. private _instanced;
  6497. private _divisor;
  6498. /**
  6499. * Gets the byte stride.
  6500. */
  6501. readonly byteStride: number;
  6502. /**
  6503. * Constructor
  6504. * @param engine the engine
  6505. * @param data the data to use for this buffer
  6506. * @param updatable whether the data is updatable
  6507. * @param stride the stride (optional)
  6508. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6509. * @param instanced whether the buffer is instanced (optional)
  6510. * @param useBytes set to true if the stride in in bytes (optional)
  6511. * @param divisor sets an optional divisor for instances (1 by default)
  6512. */
  6513. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6514. /**
  6515. * Create a new VertexBuffer based on the current buffer
  6516. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6517. * @param offset defines offset in the buffer (0 by default)
  6518. * @param size defines the size in floats of attributes (position is 3 for instance)
  6519. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6520. * @param instanced defines if the vertex buffer contains indexed data
  6521. * @param useBytes defines if the offset and stride are in bytes *
  6522. * @param divisor sets an optional divisor for instances (1 by default)
  6523. * @returns the new vertex buffer
  6524. */
  6525. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6526. /**
  6527. * Gets a boolean indicating if the Buffer is updatable?
  6528. * @returns true if the buffer is updatable
  6529. */
  6530. isUpdatable(): boolean;
  6531. /**
  6532. * Gets current buffer's data
  6533. * @returns a DataArray or null
  6534. */
  6535. getData(): Nullable<DataArray>;
  6536. /**
  6537. * Gets underlying native buffer
  6538. * @returns underlying native buffer
  6539. */
  6540. getBuffer(): Nullable<DataBuffer>;
  6541. /**
  6542. * Gets the stride in float32 units (i.e. byte stride / 4).
  6543. * May not be an integer if the byte stride is not divisible by 4.
  6544. * @returns the stride in float32 units
  6545. * @deprecated Please use byteStride instead.
  6546. */
  6547. getStrideSize(): number;
  6548. /**
  6549. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6550. * @param data defines the data to store
  6551. */
  6552. create(data?: Nullable<DataArray>): void;
  6553. /** @hidden */
  6554. _rebuild(): void;
  6555. /**
  6556. * Update current buffer data
  6557. * @param data defines the data to store
  6558. */
  6559. update(data: DataArray): void;
  6560. /**
  6561. * Updates the data directly.
  6562. * @param data the new data
  6563. * @param offset the new offset
  6564. * @param vertexCount the vertex count (optional)
  6565. * @param useBytes set to true if the offset is in bytes
  6566. */
  6567. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6568. /**
  6569. * Release all resources
  6570. */
  6571. dispose(): void;
  6572. }
  6573. /**
  6574. * Specialized buffer used to store vertex data
  6575. */
  6576. export class VertexBuffer {
  6577. /** @hidden */
  6578. _buffer: Buffer;
  6579. private _kind;
  6580. private _size;
  6581. private _ownsBuffer;
  6582. private _instanced;
  6583. private _instanceDivisor;
  6584. /**
  6585. * The byte type.
  6586. */
  6587. static readonly BYTE: number;
  6588. /**
  6589. * The unsigned byte type.
  6590. */
  6591. static readonly UNSIGNED_BYTE: number;
  6592. /**
  6593. * The short type.
  6594. */
  6595. static readonly SHORT: number;
  6596. /**
  6597. * The unsigned short type.
  6598. */
  6599. static readonly UNSIGNED_SHORT: number;
  6600. /**
  6601. * The integer type.
  6602. */
  6603. static readonly INT: number;
  6604. /**
  6605. * The unsigned integer type.
  6606. */
  6607. static readonly UNSIGNED_INT: number;
  6608. /**
  6609. * The float type.
  6610. */
  6611. static readonly FLOAT: number;
  6612. /**
  6613. * Gets or sets the instance divisor when in instanced mode
  6614. */
  6615. get instanceDivisor(): number;
  6616. set instanceDivisor(value: number);
  6617. /**
  6618. * Gets the byte stride.
  6619. */
  6620. readonly byteStride: number;
  6621. /**
  6622. * Gets the byte offset.
  6623. */
  6624. readonly byteOffset: number;
  6625. /**
  6626. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6627. */
  6628. readonly normalized: boolean;
  6629. /**
  6630. * Gets the data type of each component in the array.
  6631. */
  6632. readonly type: number;
  6633. /**
  6634. * Constructor
  6635. * @param engine the engine
  6636. * @param data the data to use for this vertex buffer
  6637. * @param kind the vertex buffer kind
  6638. * @param updatable whether the data is updatable
  6639. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6640. * @param stride the stride (optional)
  6641. * @param instanced whether the buffer is instanced (optional)
  6642. * @param offset the offset of the data (optional)
  6643. * @param size the number of components (optional)
  6644. * @param type the type of the component (optional)
  6645. * @param normalized whether the data contains normalized data (optional)
  6646. * @param useBytes set to true if stride and offset are in bytes (optional)
  6647. * @param divisor defines the instance divisor to use (1 by default)
  6648. */
  6649. 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);
  6650. /** @hidden */
  6651. _rebuild(): void;
  6652. /**
  6653. * Returns the kind of the VertexBuffer (string)
  6654. * @returns a string
  6655. */
  6656. getKind(): string;
  6657. /**
  6658. * Gets a boolean indicating if the VertexBuffer is updatable?
  6659. * @returns true if the buffer is updatable
  6660. */
  6661. isUpdatable(): boolean;
  6662. /**
  6663. * Gets current buffer's data
  6664. * @returns a DataArray or null
  6665. */
  6666. getData(): Nullable<DataArray>;
  6667. /**
  6668. * Gets underlying native buffer
  6669. * @returns underlying native buffer
  6670. */
  6671. getBuffer(): Nullable<DataBuffer>;
  6672. /**
  6673. * Gets the stride in float32 units (i.e. byte stride / 4).
  6674. * May not be an integer if the byte stride is not divisible by 4.
  6675. * @returns the stride in float32 units
  6676. * @deprecated Please use byteStride instead.
  6677. */
  6678. getStrideSize(): number;
  6679. /**
  6680. * Returns the offset as a multiple of the type byte length.
  6681. * @returns the offset in bytes
  6682. * @deprecated Please use byteOffset instead.
  6683. */
  6684. getOffset(): number;
  6685. /**
  6686. * Returns the number of components per vertex attribute (integer)
  6687. * @returns the size in float
  6688. */
  6689. getSize(): number;
  6690. /**
  6691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6692. * @returns true if this buffer is instanced
  6693. */
  6694. getIsInstanced(): boolean;
  6695. /**
  6696. * Returns the instancing divisor, zero for non-instanced (integer).
  6697. * @returns a number
  6698. */
  6699. getInstanceDivisor(): number;
  6700. /**
  6701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6702. * @param data defines the data to store
  6703. */
  6704. create(data?: DataArray): void;
  6705. /**
  6706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6707. * This function will create a new buffer if the current one is not updatable
  6708. * @param data defines the data to store
  6709. */
  6710. update(data: DataArray): void;
  6711. /**
  6712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6713. * Returns the directly updated WebGLBuffer.
  6714. * @param data the new data
  6715. * @param offset the new offset
  6716. * @param useBytes set to true if the offset is in bytes
  6717. */
  6718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6719. /**
  6720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6721. */
  6722. dispose(): void;
  6723. /**
  6724. * Enumerates each value of this vertex buffer as numbers.
  6725. * @param count the number of values to enumerate
  6726. * @param callback the callback function called for each value
  6727. */
  6728. forEach(count: number, callback: (value: number, index: number) => void): void;
  6729. /**
  6730. * Positions
  6731. */
  6732. static readonly PositionKind: string;
  6733. /**
  6734. * Normals
  6735. */
  6736. static readonly NormalKind: string;
  6737. /**
  6738. * Tangents
  6739. */
  6740. static readonly TangentKind: string;
  6741. /**
  6742. * Texture coordinates
  6743. */
  6744. static readonly UVKind: string;
  6745. /**
  6746. * Texture coordinates 2
  6747. */
  6748. static readonly UV2Kind: string;
  6749. /**
  6750. * Texture coordinates 3
  6751. */
  6752. static readonly UV3Kind: string;
  6753. /**
  6754. * Texture coordinates 4
  6755. */
  6756. static readonly UV4Kind: string;
  6757. /**
  6758. * Texture coordinates 5
  6759. */
  6760. static readonly UV5Kind: string;
  6761. /**
  6762. * Texture coordinates 6
  6763. */
  6764. static readonly UV6Kind: string;
  6765. /**
  6766. * Colors
  6767. */
  6768. static readonly ColorKind: string;
  6769. /**
  6770. * Matrix indices (for bones)
  6771. */
  6772. static readonly MatricesIndicesKind: string;
  6773. /**
  6774. * Matrix weights (for bones)
  6775. */
  6776. static readonly MatricesWeightsKind: string;
  6777. /**
  6778. * Additional matrix indices (for bones)
  6779. */
  6780. static readonly MatricesIndicesExtraKind: string;
  6781. /**
  6782. * Additional matrix weights (for bones)
  6783. */
  6784. static readonly MatricesWeightsExtraKind: string;
  6785. /**
  6786. * Deduces the stride given a kind.
  6787. * @param kind The kind string to deduce
  6788. * @returns The deduced stride
  6789. */
  6790. static DeduceStride(kind: string): number;
  6791. /**
  6792. * Gets the byte length of the given type.
  6793. * @param type the type
  6794. * @returns the number of bytes
  6795. */
  6796. static GetTypeByteLength(type: number): number;
  6797. /**
  6798. * Enumerates each value of the given parameters as numbers.
  6799. * @param data the data to enumerate
  6800. * @param byteOffset the byte offset of the data
  6801. * @param byteStride the byte stride of the data
  6802. * @param componentCount the number of components per element
  6803. * @param componentType the type of the component
  6804. * @param count the number of values to enumerate
  6805. * @param normalized whether the data is normalized
  6806. * @param callback the callback function called for each value
  6807. */
  6808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6809. private static _GetFloatValue;
  6810. }
  6811. }
  6812. declare module "babylonjs/Collisions/intersectionInfo" {
  6813. import { Nullable } from "babylonjs/types";
  6814. /**
  6815. * @hidden
  6816. */
  6817. export class IntersectionInfo {
  6818. bu: Nullable<number>;
  6819. bv: Nullable<number>;
  6820. distance: number;
  6821. faceId: number;
  6822. subMeshId: number;
  6823. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6824. }
  6825. }
  6826. declare module "babylonjs/Culling/boundingSphere" {
  6827. import { DeepImmutable } from "babylonjs/types";
  6828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6829. import { Plane } from "babylonjs/Maths/math.plane";
  6830. /**
  6831. * Class used to store bounding sphere information
  6832. */
  6833. export class BoundingSphere {
  6834. /**
  6835. * Gets the center of the bounding sphere in local space
  6836. */
  6837. readonly center: Vector3;
  6838. /**
  6839. * Radius of the bounding sphere in local space
  6840. */
  6841. radius: number;
  6842. /**
  6843. * Gets the center of the bounding sphere in world space
  6844. */
  6845. readonly centerWorld: Vector3;
  6846. /**
  6847. * Radius of the bounding sphere in world space
  6848. */
  6849. radiusWorld: number;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * Creates a new bounding sphere
  6862. * @param min defines the minimum vector (in local space)
  6863. * @param max defines the maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6867. /**
  6868. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6869. * @param min defines the new minimum vector (in local space)
  6870. * @param max defines the new maximum vector (in local space)
  6871. * @param worldMatrix defines the new world matrix
  6872. */
  6873. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Scale the current bounding sphere by applying a scale factor
  6876. * @param factor defines the scale factor to apply
  6877. * @returns the current bounding box
  6878. */
  6879. scale(factor: number): BoundingSphere;
  6880. /**
  6881. * Gets the world matrix of the bounding box
  6882. * @returns a matrix
  6883. */
  6884. getWorldMatrix(): DeepImmutable<Matrix>;
  6885. /** @hidden */
  6886. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6887. /**
  6888. * Tests if the bounding sphere is intersecting the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an intersection
  6891. */
  6892. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if the bounding sphere center is in between the frustum planes.
  6895. * Used for optimistic fast inclusion.
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if the sphere center is in between the frustum planes
  6898. */
  6899. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding sphere
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding sphere
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Checks if two sphere intersct
  6908. * @param sphere0 sphere 0
  6909. * @param sphere1 sphere 1
  6910. * @returns true if the speres intersect
  6911. */
  6912. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6913. }
  6914. }
  6915. declare module "babylonjs/Culling/boundingBox" {
  6916. import { DeepImmutable } from "babylonjs/types";
  6917. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6918. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6919. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6920. import { Plane } from "babylonjs/Maths/math.plane";
  6921. /**
  6922. * Class used to store bounding box information
  6923. */
  6924. export class BoundingBox implements ICullable {
  6925. /**
  6926. * Gets the 8 vectors representing the bounding box in local space
  6927. */
  6928. readonly vectors: Vector3[];
  6929. /**
  6930. * Gets the center of the bounding box in local space
  6931. */
  6932. readonly center: Vector3;
  6933. /**
  6934. * Gets the center of the bounding box in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Gets the extend size in local space
  6939. */
  6940. readonly extendSize: Vector3;
  6941. /**
  6942. * Gets the extend size in world space
  6943. */
  6944. readonly extendSizeWorld: Vector3;
  6945. /**
  6946. * Gets the OBB (object bounding box) directions
  6947. */
  6948. readonly directions: Vector3[];
  6949. /**
  6950. * Gets the 8 vectors representing the bounding box in world space
  6951. */
  6952. readonly vectorsWorld: Vector3[];
  6953. /**
  6954. * Gets the minimum vector in world space
  6955. */
  6956. readonly minimumWorld: Vector3;
  6957. /**
  6958. * Gets the maximum vector in world space
  6959. */
  6960. readonly maximumWorld: Vector3;
  6961. /**
  6962. * Gets the minimum vector in local space
  6963. */
  6964. readonly minimum: Vector3;
  6965. /**
  6966. * Gets the maximum vector in local space
  6967. */
  6968. readonly maximum: Vector3;
  6969. private _worldMatrix;
  6970. private static readonly TmpVector3;
  6971. /**
  6972. * @hidden
  6973. */
  6974. _tag: number;
  6975. /**
  6976. * Creates a new bounding box
  6977. * @param min defines the minimum vector (in local space)
  6978. * @param max defines the maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6982. /**
  6983. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6984. * @param min defines the new minimum vector (in local space)
  6985. * @param max defines the new maximum vector (in local space)
  6986. * @param worldMatrix defines the new world matrix
  6987. */
  6988. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6989. /**
  6990. * Scale the current bounding box by applying a scale factor
  6991. * @param factor defines the scale factor to apply
  6992. * @returns the current bounding box
  6993. */
  6994. scale(factor: number): BoundingBox;
  6995. /**
  6996. * Gets the world matrix of the bounding box
  6997. * @returns a matrix
  6998. */
  6999. getWorldMatrix(): DeepImmutable<Matrix>;
  7000. /** @hidden */
  7001. _update(world: DeepImmutable<Matrix>): void;
  7002. /**
  7003. * Tests if the bounding box is intersecting the frustum planes
  7004. * @param frustumPlanes defines the frustum planes to test
  7005. * @returns true if there is an intersection
  7006. */
  7007. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7008. /**
  7009. * Tests if the bounding box is entirely inside the frustum planes
  7010. * @param frustumPlanes defines the frustum planes to test
  7011. * @returns true if there is an inclusion
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7014. /**
  7015. * Tests if a point is inside the bounding box
  7016. * @param point defines the point to test
  7017. * @returns true if the point is inside the bounding box
  7018. */
  7019. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7020. /**
  7021. * Tests if the bounding box intersects with a bounding sphere
  7022. * @param sphere defines the sphere to test
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7026. /**
  7027. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7028. * @param min defines the min vector to use
  7029. * @param max defines the max vector to use
  7030. * @returns true if there is an intersection
  7031. */
  7032. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7033. /**
  7034. * Tests if two bounding boxes are intersections
  7035. * @param box0 defines the first box to test
  7036. * @param box1 defines the second box to test
  7037. * @returns true if there is an intersection
  7038. */
  7039. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7040. /**
  7041. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7042. * @param minPoint defines the minimum vector of the bounding box
  7043. * @param maxPoint defines the maximum vector of the bounding box
  7044. * @param sphereCenter defines the sphere center
  7045. * @param sphereRadius defines the sphere radius
  7046. * @returns true if there is an intersection
  7047. */
  7048. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an inclusion
  7054. */
  7055. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. /**
  7057. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7058. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @return true if there is an intersection
  7061. */
  7062. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. }
  7064. }
  7065. declare module "babylonjs/Collisions/collider" {
  7066. import { Nullable, IndicesArray } from "babylonjs/types";
  7067. import { Vector3 } from "babylonjs/Maths/math.vector";
  7068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7069. import { Plane } from "babylonjs/Maths/math.plane";
  7070. /** @hidden */
  7071. export class Collider {
  7072. /** Define if a collision was found */
  7073. collisionFound: boolean;
  7074. /**
  7075. * Define last intersection point in local space
  7076. */
  7077. intersectionPoint: Vector3;
  7078. /**
  7079. * Define last collided mesh
  7080. */
  7081. collidedMesh: Nullable<AbstractMesh>;
  7082. private _collisionPoint;
  7083. private _planeIntersectionPoint;
  7084. private _tempVector;
  7085. private _tempVector2;
  7086. private _tempVector3;
  7087. private _tempVector4;
  7088. private _edge;
  7089. private _baseToVertex;
  7090. private _destinationPoint;
  7091. private _slidePlaneNormal;
  7092. private _displacementVector;
  7093. /** @hidden */
  7094. _radius: Vector3;
  7095. /** @hidden */
  7096. _retry: number;
  7097. private _velocity;
  7098. private _basePoint;
  7099. private _epsilon;
  7100. /** @hidden */
  7101. _velocityWorldLength: number;
  7102. /** @hidden */
  7103. _basePointWorld: Vector3;
  7104. private _velocityWorld;
  7105. private _normalizedVelocity;
  7106. /** @hidden */
  7107. _initialVelocity: Vector3;
  7108. /** @hidden */
  7109. _initialPosition: Vector3;
  7110. private _nearestDistance;
  7111. private _collisionMask;
  7112. get collisionMask(): number;
  7113. set collisionMask(mask: number);
  7114. /**
  7115. * Gets the plane normal used to compute the sliding response (in local space)
  7116. */
  7117. get slidePlaneNormal(): Vector3;
  7118. /** @hidden */
  7119. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7120. /** @hidden */
  7121. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7122. /** @hidden */
  7123. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7124. /** @hidden */
  7125. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7126. /** @hidden */
  7127. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7128. /** @hidden */
  7129. _getResponse(pos: Vector3, vel: Vector3): void;
  7130. }
  7131. }
  7132. declare module "babylonjs/Culling/boundingInfo" {
  7133. import { DeepImmutable } from "babylonjs/types";
  7134. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7135. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7137. import { Plane } from "babylonjs/Maths/math.plane";
  7138. import { Collider } from "babylonjs/Collisions/collider";
  7139. /**
  7140. * Interface for cullable objects
  7141. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7142. */
  7143. export interface ICullable {
  7144. /**
  7145. * Checks if the object or part of the object is in the frustum
  7146. * @param frustumPlanes Camera near/planes
  7147. * @returns true if the object is in frustum otherwise false
  7148. */
  7149. isInFrustum(frustumPlanes: Plane[]): boolean;
  7150. /**
  7151. * Checks if a cullable object (mesh...) is in the camera frustum
  7152. * Unlike isInFrustum this cheks the full bounding box
  7153. * @param frustumPlanes Camera near/planes
  7154. * @returns true if the object is in frustum otherwise false
  7155. */
  7156. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7157. }
  7158. /**
  7159. * Info for a bounding data of a mesh
  7160. */
  7161. export class BoundingInfo implements ICullable {
  7162. /**
  7163. * Bounding box for the mesh
  7164. */
  7165. readonly boundingBox: BoundingBox;
  7166. /**
  7167. * Bounding sphere for the mesh
  7168. */
  7169. readonly boundingSphere: BoundingSphere;
  7170. private _isLocked;
  7171. private static readonly TmpVector3;
  7172. /**
  7173. * Constructs bounding info
  7174. * @param minimum min vector of the bounding box/sphere
  7175. * @param maximum max vector of the bounding box/sphere
  7176. * @param worldMatrix defines the new world matrix
  7177. */
  7178. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7179. /**
  7180. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7181. * @param min defines the new minimum vector (in local space)
  7182. * @param max defines the new maximum vector (in local space)
  7183. * @param worldMatrix defines the new world matrix
  7184. */
  7185. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * min vector of the bounding box/sphere
  7188. */
  7189. get minimum(): Vector3;
  7190. /**
  7191. * max vector of the bounding box/sphere
  7192. */
  7193. get maximum(): Vector3;
  7194. /**
  7195. * If the info is locked and won't be updated to avoid perf overhead
  7196. */
  7197. get isLocked(): boolean;
  7198. set isLocked(value: boolean);
  7199. /**
  7200. * Updates the bounding sphere and box
  7201. * @param world world matrix to be used to update
  7202. */
  7203. update(world: DeepImmutable<Matrix>): void;
  7204. /**
  7205. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7206. * @param center New center of the bounding info
  7207. * @param extend New extend of the bounding info
  7208. * @returns the current bounding info
  7209. */
  7210. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7211. /**
  7212. * Scale the current bounding info by applying a scale factor
  7213. * @param factor defines the scale factor to apply
  7214. * @returns the current bounding info
  7215. */
  7216. scale(factor: number): BoundingInfo;
  7217. /**
  7218. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7219. * @param frustumPlanes defines the frustum to test
  7220. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7221. * @returns true if the bounding info is in the frustum planes
  7222. */
  7223. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7224. /**
  7225. * Gets the world distance between the min and max points of the bounding box
  7226. */
  7227. get diagonalLength(): number;
  7228. /**
  7229. * Checks if a cullable object (mesh...) is in the camera frustum
  7230. * Unlike isInFrustum this cheks the full bounding box
  7231. * @param frustumPlanes Camera near/planes
  7232. * @returns true if the object is in frustum otherwise false
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /** @hidden */
  7236. _checkCollision(collider: Collider): boolean;
  7237. /**
  7238. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7239. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7240. * @param point the point to check intersection with
  7241. * @returns if the point intersects
  7242. */
  7243. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7244. /**
  7245. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7246. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7247. * @param boundingInfo the bounding info to check intersection with
  7248. * @param precise if the intersection should be done using OBB
  7249. * @returns if the bounding info intersects
  7250. */
  7251. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7252. }
  7253. }
  7254. declare module "babylonjs/Maths/math.functions" {
  7255. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7256. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7257. /**
  7258. * Extracts minimum and maximum values from a list of indexed positions
  7259. * @param positions defines the positions to use
  7260. * @param indices defines the indices to the positions
  7261. * @param indexStart defines the start index
  7262. * @param indexCount defines the end index
  7263. * @param bias defines bias value to add to the result
  7264. * @return minimum and maximum values
  7265. */
  7266. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7267. minimum: Vector3;
  7268. maximum: Vector3;
  7269. };
  7270. /**
  7271. * Extracts minimum and maximum values from a list of positions
  7272. * @param positions defines the positions to use
  7273. * @param start defines the start index in the positions array
  7274. * @param count defines the number of positions to handle
  7275. * @param bias defines bias value to add to the result
  7276. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7277. * @return minimum and maximum values
  7278. */
  7279. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7280. minimum: Vector3;
  7281. maximum: Vector3;
  7282. };
  7283. }
  7284. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. /** @hidden */
  7287. export class WebGLDataBuffer extends DataBuffer {
  7288. private _buffer;
  7289. constructor(resource: WebGLBuffer);
  7290. get underlyingResource(): any;
  7291. }
  7292. }
  7293. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7294. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7295. import { Nullable } from "babylonjs/types";
  7296. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7297. /** @hidden */
  7298. export class WebGLPipelineContext implements IPipelineContext {
  7299. engine: ThinEngine;
  7300. program: Nullable<WebGLProgram>;
  7301. context?: WebGLRenderingContext;
  7302. vertexShader?: WebGLShader;
  7303. fragmentShader?: WebGLShader;
  7304. isParallelCompiled: boolean;
  7305. onCompiled?: () => void;
  7306. transformFeedback?: WebGLTransformFeedback | null;
  7307. vertexCompilationError: Nullable<string>;
  7308. fragmentCompilationError: Nullable<string>;
  7309. programLinkError: Nullable<string>;
  7310. programValidationError: Nullable<string>;
  7311. get isAsync(): boolean;
  7312. get isReady(): boolean;
  7313. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7314. _getVertexShaderCode(): string | null;
  7315. _getFragmentShaderCode(): string | null;
  7316. }
  7317. }
  7318. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7319. import { FloatArray, Nullable } from "babylonjs/types";
  7320. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7321. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7322. module "babylonjs/Engines/thinEngine" {
  7323. interface ThinEngine {
  7324. /**
  7325. * Create an uniform buffer
  7326. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7327. * @param elements defines the content of the uniform buffer
  7328. * @returns the webGL uniform buffer
  7329. */
  7330. createUniformBuffer(elements: FloatArray): DataBuffer;
  7331. /**
  7332. * Create a dynamic uniform buffer
  7333. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7334. * @param elements defines the content of the uniform buffer
  7335. * @returns the webGL uniform buffer
  7336. */
  7337. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7338. /**
  7339. * Update an existing uniform buffer
  7340. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7341. * @param uniformBuffer defines the target uniform buffer
  7342. * @param elements defines the content to update
  7343. * @param offset defines the offset in the uniform buffer where update should start
  7344. * @param count defines the size of the data to update
  7345. */
  7346. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7347. /**
  7348. * Bind an uniform buffer to the current webGL context
  7349. * @param buffer defines the buffer to bind
  7350. */
  7351. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7352. /**
  7353. * Bind a buffer to the current webGL context at a given location
  7354. * @param buffer defines the buffer to bind
  7355. * @param location defines the index where to bind the buffer
  7356. */
  7357. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7358. /**
  7359. * Bind a specific block at a given index in a specific shader program
  7360. * @param pipelineContext defines the pipeline context to use
  7361. * @param blockName defines the block name
  7362. * @param index defines the index where to bind the block
  7363. */
  7364. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7365. }
  7366. }
  7367. }
  7368. declare module "babylonjs/Materials/uniformBuffer" {
  7369. import { Nullable, FloatArray } from "babylonjs/types";
  7370. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7371. import { Engine } from "babylonjs/Engines/engine";
  7372. import { Effect } from "babylonjs/Materials/effect";
  7373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7374. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7375. import { Color3 } from "babylonjs/Maths/math.color";
  7376. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7377. /**
  7378. * Uniform buffer objects.
  7379. *
  7380. * Handles blocks of uniform on the GPU.
  7381. *
  7382. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7383. *
  7384. * For more information, please refer to :
  7385. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7386. */
  7387. export class UniformBuffer {
  7388. private _engine;
  7389. private _buffer;
  7390. private _data;
  7391. private _bufferData;
  7392. private _dynamic?;
  7393. private _uniformLocations;
  7394. private _uniformSizes;
  7395. private _uniformLocationPointer;
  7396. private _needSync;
  7397. private _noUBO;
  7398. private _currentEffect;
  7399. /** @hidden */
  7400. _alreadyBound: boolean;
  7401. private static _MAX_UNIFORM_SIZE;
  7402. private static _tempBuffer;
  7403. /**
  7404. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7409. /**
  7410. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7411. * This is dynamic to allow compat with webgl 1 and 2.
  7412. * You will need to pass the name of the uniform as well as the value.
  7413. */
  7414. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7415. /**
  7416. * Lambda to Update a single float in a uniform buffer.
  7417. * This is dynamic to allow compat with webgl 1 and 2.
  7418. * You will need to pass the name of the uniform as well as the value.
  7419. */
  7420. updateFloat: (name: string, x: number) => void;
  7421. /**
  7422. * Lambda to Update a vec2 of float in a uniform buffer.
  7423. * This is dynamic to allow compat with webgl 1 and 2.
  7424. * You will need to pass the name of the uniform as well as the value.
  7425. */
  7426. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7427. /**
  7428. * Lambda to Update a vec3 of float in a uniform buffer.
  7429. * This is dynamic to allow compat with webgl 1 and 2.
  7430. * You will need to pass the name of the uniform as well as the value.
  7431. */
  7432. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7433. /**
  7434. * Lambda to Update a vec4 of float in a uniform buffer.
  7435. * This is dynamic to allow compat with webgl 1 and 2.
  7436. * You will need to pass the name of the uniform as well as the value.
  7437. */
  7438. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7439. /**
  7440. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7441. * This is dynamic to allow compat with webgl 1 and 2.
  7442. * You will need to pass the name of the uniform as well as the value.
  7443. */
  7444. updateMatrix: (name: string, mat: Matrix) => void;
  7445. /**
  7446. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7447. * This is dynamic to allow compat with webgl 1 and 2.
  7448. * You will need to pass the name of the uniform as well as the value.
  7449. */
  7450. updateVector3: (name: string, vector: Vector3) => void;
  7451. /**
  7452. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7453. * This is dynamic to allow compat with webgl 1 and 2.
  7454. * You will need to pass the name of the uniform as well as the value.
  7455. */
  7456. updateVector4: (name: string, vector: Vector4) => void;
  7457. /**
  7458. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7459. * This is dynamic to allow compat with webgl 1 and 2.
  7460. * You will need to pass the name of the uniform as well as the value.
  7461. */
  7462. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7463. /**
  7464. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7465. * This is dynamic to allow compat with webgl 1 and 2.
  7466. * You will need to pass the name of the uniform as well as the value.
  7467. */
  7468. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7469. /**
  7470. * Instantiates a new Uniform buffer objects.
  7471. *
  7472. * Handles blocks of uniform on the GPU.
  7473. *
  7474. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7475. *
  7476. * For more information, please refer to :
  7477. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7478. * @param engine Define the engine the buffer is associated with
  7479. * @param data Define the data contained in the buffer
  7480. * @param dynamic Define if the buffer is updatable
  7481. */
  7482. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7483. /**
  7484. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7485. * or just falling back on setUniformXXX calls.
  7486. */
  7487. get useUbo(): boolean;
  7488. /**
  7489. * Indicates if the WebGL underlying uniform buffer is in sync
  7490. * with the javascript cache data.
  7491. */
  7492. get isSync(): boolean;
  7493. /**
  7494. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7495. * Also, a dynamic UniformBuffer will disable cache verification and always
  7496. * update the underlying WebGL uniform buffer to the GPU.
  7497. * @returns if Dynamic, otherwise false
  7498. */
  7499. isDynamic(): boolean;
  7500. /**
  7501. * The data cache on JS side.
  7502. * @returns the underlying data as a float array
  7503. */
  7504. getData(): Float32Array;
  7505. /**
  7506. * The underlying WebGL Uniform buffer.
  7507. * @returns the webgl buffer
  7508. */
  7509. getBuffer(): Nullable<DataBuffer>;
  7510. /**
  7511. * std140 layout specifies how to align data within an UBO structure.
  7512. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7513. * for specs.
  7514. */
  7515. private _fillAlignment;
  7516. /**
  7517. * Adds an uniform in the buffer.
  7518. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7519. * for the layout to be correct !
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param size Data size, or data directly.
  7522. */
  7523. addUniform(name: string, size: number | number[]): void;
  7524. /**
  7525. * Adds a Matrix 4x4 to the uniform buffer.
  7526. * @param name Name of the uniform, as used in the uniform block in the shader.
  7527. * @param mat A 4x4 matrix.
  7528. */
  7529. addMatrix(name: string, mat: Matrix): void;
  7530. /**
  7531. * Adds a vec2 to the uniform buffer.
  7532. * @param name Name of the uniform, as used in the uniform block in the shader.
  7533. * @param x Define the x component value of the vec2
  7534. * @param y Define the y component value of the vec2
  7535. */
  7536. addFloat2(name: string, x: number, y: number): void;
  7537. /**
  7538. * Adds a vec3 to the uniform buffer.
  7539. * @param name Name of the uniform, as used in the uniform block in the shader.
  7540. * @param x Define the x component value of the vec3
  7541. * @param y Define the y component value of the vec3
  7542. * @param z Define the z component value of the vec3
  7543. */
  7544. addFloat3(name: string, x: number, y: number, z: number): void;
  7545. /**
  7546. * Adds a vec3 to the uniform buffer.
  7547. * @param name Name of the uniform, as used in the uniform block in the shader.
  7548. * @param color Define the vec3 from a Color
  7549. */
  7550. addColor3(name: string, color: Color3): void;
  7551. /**
  7552. * Adds a vec4 to the uniform buffer.
  7553. * @param name Name of the uniform, as used in the uniform block in the shader.
  7554. * @param color Define the rgb components from a Color
  7555. * @param alpha Define the a component of the vec4
  7556. */
  7557. addColor4(name: string, color: Color3, alpha: number): void;
  7558. /**
  7559. * Adds a vec3 to the uniform buffer.
  7560. * @param name Name of the uniform, as used in the uniform block in the shader.
  7561. * @param vector Define the vec3 components from a Vector
  7562. */
  7563. addVector3(name: string, vector: Vector3): void;
  7564. /**
  7565. * Adds a Matrix 3x3 to the uniform buffer.
  7566. * @param name Name of the uniform, as used in the uniform block in the shader.
  7567. */
  7568. addMatrix3x3(name: string): void;
  7569. /**
  7570. * Adds a Matrix 2x2 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. */
  7573. addMatrix2x2(name: string): void;
  7574. /**
  7575. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7576. */
  7577. create(): void;
  7578. /** @hidden */
  7579. _rebuild(): void;
  7580. /**
  7581. * Updates the WebGL Uniform Buffer on the GPU.
  7582. * If the `dynamic` flag is set to true, no cache comparison is done.
  7583. * Otherwise, the buffer will be updated only if the cache differs.
  7584. */
  7585. update(): void;
  7586. /**
  7587. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7588. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7589. * @param data Define the flattened data
  7590. * @param size Define the size of the data.
  7591. */
  7592. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7593. private _valueCache;
  7594. private _cacheMatrix;
  7595. private _updateMatrix3x3ForUniform;
  7596. private _updateMatrix3x3ForEffect;
  7597. private _updateMatrix2x2ForEffect;
  7598. private _updateMatrix2x2ForUniform;
  7599. private _updateFloatForEffect;
  7600. private _updateFloatForUniform;
  7601. private _updateFloat2ForEffect;
  7602. private _updateFloat2ForUniform;
  7603. private _updateFloat3ForEffect;
  7604. private _updateFloat3ForUniform;
  7605. private _updateFloat4ForEffect;
  7606. private _updateFloat4ForUniform;
  7607. private _updateMatrixForEffect;
  7608. private _updateMatrixForUniform;
  7609. private _updateVector3ForEffect;
  7610. private _updateVector3ForUniform;
  7611. private _updateVector4ForEffect;
  7612. private _updateVector4ForUniform;
  7613. private _updateColor3ForEffect;
  7614. private _updateColor3ForUniform;
  7615. private _updateColor4ForEffect;
  7616. private _updateColor4ForUniform;
  7617. /**
  7618. * Sets a sampler uniform on the effect.
  7619. * @param name Define the name of the sampler.
  7620. * @param texture Define the texture to set in the sampler
  7621. */
  7622. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7623. /**
  7624. * Directly updates the value of the uniform in the cache AND on the GPU.
  7625. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7626. * @param data Define the flattened data
  7627. */
  7628. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7629. /**
  7630. * Binds this uniform buffer to an effect.
  7631. * @param effect Define the effect to bind the buffer to
  7632. * @param name Name of the uniform block in the shader.
  7633. */
  7634. bindToEffect(effect: Effect, name: string): void;
  7635. /**
  7636. * Disposes the uniform buffer.
  7637. */
  7638. dispose(): void;
  7639. }
  7640. }
  7641. declare module "babylonjs/Misc/iInspectable" {
  7642. /**
  7643. * Enum that determines the text-wrapping mode to use.
  7644. */
  7645. export enum InspectableType {
  7646. /**
  7647. * Checkbox for booleans
  7648. */
  7649. Checkbox = 0,
  7650. /**
  7651. * Sliders for numbers
  7652. */
  7653. Slider = 1,
  7654. /**
  7655. * Vector3
  7656. */
  7657. Vector3 = 2,
  7658. /**
  7659. * Quaternions
  7660. */
  7661. Quaternion = 3,
  7662. /**
  7663. * Color3
  7664. */
  7665. Color3 = 4,
  7666. /**
  7667. * String
  7668. */
  7669. String = 5
  7670. }
  7671. /**
  7672. * Interface used to define custom inspectable properties.
  7673. * This interface is used by the inspector to display custom property grids
  7674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7675. */
  7676. export interface IInspectable {
  7677. /**
  7678. * Gets the label to display
  7679. */
  7680. label: string;
  7681. /**
  7682. * Gets the name of the property to edit
  7683. */
  7684. propertyName: string;
  7685. /**
  7686. * Gets the type of the editor to use
  7687. */
  7688. type: InspectableType;
  7689. /**
  7690. * Gets the minimum value of the property when using in "slider" mode
  7691. */
  7692. min?: number;
  7693. /**
  7694. * Gets the maximum value of the property when using in "slider" mode
  7695. */
  7696. max?: number;
  7697. /**
  7698. * Gets the setp to use when using in "slider" mode
  7699. */
  7700. step?: number;
  7701. }
  7702. }
  7703. declare module "babylonjs/Misc/timingTools" {
  7704. /**
  7705. * Class used to provide helper for timing
  7706. */
  7707. export class TimingTools {
  7708. /**
  7709. * Polyfill for setImmediate
  7710. * @param action defines the action to execute after the current execution block
  7711. */
  7712. static SetImmediate(action: () => void): void;
  7713. }
  7714. }
  7715. declare module "babylonjs/Misc/instantiationTools" {
  7716. /**
  7717. * Class used to enable instatition of objects by class name
  7718. */
  7719. export class InstantiationTools {
  7720. /**
  7721. * Use this object to register external classes like custom textures or material
  7722. * to allow the laoders to instantiate them
  7723. */
  7724. static RegisteredExternalClasses: {
  7725. [key: string]: Object;
  7726. };
  7727. /**
  7728. * Tries to instantiate a new object from a given class name
  7729. * @param className defines the class name to instantiate
  7730. * @returns the new object or null if the system was not able to do the instantiation
  7731. */
  7732. static Instantiate(className: string): any;
  7733. }
  7734. }
  7735. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7736. /**
  7737. * Define options used to create a depth texture
  7738. */
  7739. export class DepthTextureCreationOptions {
  7740. /** Specifies whether or not a stencil should be allocated in the texture */
  7741. generateStencil?: boolean;
  7742. /** Specifies whether or not bilinear filtering is enable on the texture */
  7743. bilinearFiltering?: boolean;
  7744. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7745. comparisonFunction?: number;
  7746. /** Specifies if the created texture is a cube texture */
  7747. isCube?: boolean;
  7748. }
  7749. }
  7750. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7752. import { Nullable } from "babylonjs/types";
  7753. import { Scene } from "babylonjs/scene";
  7754. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7755. module "babylonjs/Engines/thinEngine" {
  7756. interface ThinEngine {
  7757. /**
  7758. * Creates a depth stencil cube texture.
  7759. * This is only available in WebGL 2.
  7760. * @param size The size of face edge in the cube texture.
  7761. * @param options The options defining the cube texture.
  7762. * @returns The cube texture
  7763. */
  7764. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7765. /**
  7766. * Creates a cube texture
  7767. * @param rootUrl defines the url where the files to load is located
  7768. * @param scene defines the current scene
  7769. * @param files defines the list of files to load (1 per face)
  7770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7771. * @param onLoad defines an optional callback raised when the texture is loaded
  7772. * @param onError defines an optional callback raised if there is an issue to load the texture
  7773. * @param format defines the format of the data
  7774. * @param forcedExtension defines the extension to use to pick the right loader
  7775. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7776. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7777. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7778. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7779. * @returns the cube texture as an InternalTexture
  7780. */
  7781. 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;
  7782. /**
  7783. * Creates a cube texture
  7784. * @param rootUrl defines the url where the files to load is located
  7785. * @param scene defines the current scene
  7786. * @param files defines the list of files to load (1 per face)
  7787. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7788. * @param onLoad defines an optional callback raised when the texture is loaded
  7789. * @param onError defines an optional callback raised if there is an issue to load the texture
  7790. * @param format defines the format of the data
  7791. * @param forcedExtension defines the extension to use to pick the right loader
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. 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;
  7795. /**
  7796. * Creates a cube texture
  7797. * @param rootUrl defines the url where the files to load is located
  7798. * @param scene defines the current scene
  7799. * @param files defines the list of files to load (1 per face)
  7800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7801. * @param onLoad defines an optional callback raised when the texture is loaded
  7802. * @param onError defines an optional callback raised if there is an issue to load the texture
  7803. * @param format defines the format of the data
  7804. * @param forcedExtension defines the extension to use to pick the right loader
  7805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7808. * @returns the cube texture as an InternalTexture
  7809. */
  7810. 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;
  7811. /** @hidden */
  7812. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7813. /** @hidden */
  7814. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7815. /** @hidden */
  7816. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7817. /** @hidden */
  7818. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7819. /**
  7820. * @hidden
  7821. */
  7822. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7823. }
  7824. }
  7825. }
  7826. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7827. import { Nullable } from "babylonjs/types";
  7828. import { Scene } from "babylonjs/scene";
  7829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7831. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7832. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7833. import { Observable } from "babylonjs/Misc/observable";
  7834. /**
  7835. * Class for creating a cube texture
  7836. */
  7837. export class CubeTexture extends BaseTexture {
  7838. private _delayedOnLoad;
  7839. /**
  7840. * Observable triggered once the texture has been loaded.
  7841. */
  7842. onLoadObservable: Observable<CubeTexture>;
  7843. /**
  7844. * The url of the texture
  7845. */
  7846. url: string;
  7847. /**
  7848. * Gets or sets the center of the bounding box associated with the cube texture.
  7849. * It must define where the camera used to render the texture was set
  7850. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7851. */
  7852. boundingBoxPosition: Vector3;
  7853. private _boundingBoxSize;
  7854. /**
  7855. * Gets or sets the size of the bounding box associated with the cube texture
  7856. * When defined, the cubemap will switch to local mode
  7857. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7858. * @example https://www.babylonjs-playground.com/#RNASML
  7859. */
  7860. set boundingBoxSize(value: Vector3);
  7861. /**
  7862. * Returns the bounding box size
  7863. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7864. */
  7865. get boundingBoxSize(): Vector3;
  7866. protected _rotationY: number;
  7867. /**
  7868. * Sets texture matrix rotation angle around Y axis in radians.
  7869. */
  7870. set rotationY(value: number);
  7871. /**
  7872. * Gets texture matrix rotation angle around Y axis radians.
  7873. */
  7874. get rotationY(): number;
  7875. /**
  7876. * Are mip maps generated for this texture or not.
  7877. */
  7878. get noMipmap(): boolean;
  7879. private _noMipmap;
  7880. private _files;
  7881. protected _forcedExtension: Nullable<string>;
  7882. private _extensions;
  7883. private _textureMatrix;
  7884. private _format;
  7885. private _createPolynomials;
  7886. /**
  7887. * Creates a cube texture from an array of image urls
  7888. * @param files defines an array of image urls
  7889. * @param scene defines the hosting scene
  7890. * @param noMipmap specifies if mip maps are not used
  7891. * @returns a cube texture
  7892. */
  7893. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7894. /**
  7895. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7896. * @param url defines the url of the prefiltered texture
  7897. * @param scene defines the scene the texture is attached to
  7898. * @param forcedExtension defines the extension of the file if different from the url
  7899. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7900. * @return the prefiltered texture
  7901. */
  7902. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7903. /**
  7904. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7905. * as prefiltered data.
  7906. * @param rootUrl defines the url of the texture or the root name of the six images
  7907. * @param null defines the scene or engine the texture is attached to
  7908. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7909. * @param noMipmap defines if mipmaps should be created or not
  7910. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7911. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7912. * @param onError defines a callback triggered in case of error during load
  7913. * @param format defines the internal format to use for the texture once loaded
  7914. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7915. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7916. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7919. * @return the cube texture
  7920. */
  7921. 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);
  7922. /**
  7923. * Get the current class name of the texture useful for serialization or dynamic coding.
  7924. * @returns "CubeTexture"
  7925. */
  7926. getClassName(): string;
  7927. /**
  7928. * Update the url (and optional buffer) of this texture if url was null during construction.
  7929. * @param url the url of the texture
  7930. * @param forcedExtension defines the extension to use
  7931. * @param onLoad callback called when the texture is loaded (defaults to null)
  7932. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7933. */
  7934. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7935. /**
  7936. * Delays loading of the cube texture
  7937. * @param forcedExtension defines the extension to use
  7938. */
  7939. delayLoad(forcedExtension?: string): void;
  7940. /**
  7941. * Returns the reflection texture matrix
  7942. * @returns the reflection texture matrix
  7943. */
  7944. getReflectionTextureMatrix(): Matrix;
  7945. /**
  7946. * Sets the reflection texture matrix
  7947. * @param value Reflection texture matrix
  7948. */
  7949. setReflectionTextureMatrix(value: Matrix): void;
  7950. /**
  7951. * Parses text to create a cube texture
  7952. * @param parsedTexture define the serialized text to read from
  7953. * @param scene defines the hosting scene
  7954. * @param rootUrl defines the root url of the cube texture
  7955. * @returns a cube texture
  7956. */
  7957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7958. /**
  7959. * Makes a clone, or deep copy, of the cube texture
  7960. * @returns a new cube texture
  7961. */
  7962. clone(): CubeTexture;
  7963. }
  7964. }
  7965. declare module "babylonjs/Materials/materialDefines" {
  7966. /**
  7967. * Manages the defines for the Material
  7968. */
  7969. export class MaterialDefines {
  7970. /** @hidden */
  7971. protected _keys: string[];
  7972. private _isDirty;
  7973. /** @hidden */
  7974. _renderId: number;
  7975. /** @hidden */
  7976. _areLightsDirty: boolean;
  7977. /** @hidden */
  7978. _areLightsDisposed: boolean;
  7979. /** @hidden */
  7980. _areAttributesDirty: boolean;
  7981. /** @hidden */
  7982. _areTexturesDirty: boolean;
  7983. /** @hidden */
  7984. _areFresnelDirty: boolean;
  7985. /** @hidden */
  7986. _areMiscDirty: boolean;
  7987. /** @hidden */
  7988. _areImageProcessingDirty: boolean;
  7989. /** @hidden */
  7990. _normals: boolean;
  7991. /** @hidden */
  7992. _uvs: boolean;
  7993. /** @hidden */
  7994. _needNormals: boolean;
  7995. /** @hidden */
  7996. _needUVs: boolean;
  7997. [id: string]: any;
  7998. /**
  7999. * Specifies if the material needs to be re-calculated
  8000. */
  8001. get isDirty(): boolean;
  8002. /**
  8003. * Marks the material to indicate that it has been re-calculated
  8004. */
  8005. markAsProcessed(): void;
  8006. /**
  8007. * Marks the material to indicate that it needs to be re-calculated
  8008. */
  8009. markAsUnprocessed(): void;
  8010. /**
  8011. * Marks the material to indicate all of its defines need to be re-calculated
  8012. */
  8013. markAllAsDirty(): void;
  8014. /**
  8015. * Marks the material to indicate that image processing needs to be re-calculated
  8016. */
  8017. markAsImageProcessingDirty(): void;
  8018. /**
  8019. * Marks the material to indicate the lights need to be re-calculated
  8020. * @param disposed Defines whether the light is dirty due to dispose or not
  8021. */
  8022. markAsLightDirty(disposed?: boolean): void;
  8023. /**
  8024. * Marks the attribute state as changed
  8025. */
  8026. markAsAttributesDirty(): void;
  8027. /**
  8028. * Marks the texture state as changed
  8029. */
  8030. markAsTexturesDirty(): void;
  8031. /**
  8032. * Marks the fresnel state as changed
  8033. */
  8034. markAsFresnelDirty(): void;
  8035. /**
  8036. * Marks the misc state as changed
  8037. */
  8038. markAsMiscDirty(): void;
  8039. /**
  8040. * Rebuilds the material defines
  8041. */
  8042. rebuild(): void;
  8043. /**
  8044. * Specifies if two material defines are equal
  8045. * @param other - A material define instance to compare to
  8046. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8047. */
  8048. isEqual(other: MaterialDefines): boolean;
  8049. /**
  8050. * Clones this instance's defines to another instance
  8051. * @param other - material defines to clone values to
  8052. */
  8053. cloneTo(other: MaterialDefines): void;
  8054. /**
  8055. * Resets the material define values
  8056. */
  8057. reset(): void;
  8058. /**
  8059. * Converts the material define values to a string
  8060. * @returns - String of material define information
  8061. */
  8062. toString(): string;
  8063. }
  8064. }
  8065. declare module "babylonjs/Materials/colorCurves" {
  8066. import { Effect } from "babylonjs/Materials/effect";
  8067. /**
  8068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8070. * 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;
  8071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8072. */
  8073. export class ColorCurves {
  8074. private _dirty;
  8075. private _tempColor;
  8076. private _globalCurve;
  8077. private _highlightsCurve;
  8078. private _midtonesCurve;
  8079. private _shadowsCurve;
  8080. private _positiveCurve;
  8081. private _negativeCurve;
  8082. private _globalHue;
  8083. private _globalDensity;
  8084. private _globalSaturation;
  8085. private _globalExposure;
  8086. /**
  8087. * Gets the global Hue value.
  8088. * 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).
  8089. */
  8090. get globalHue(): number;
  8091. /**
  8092. * Sets the global Hue value.
  8093. * 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).
  8094. */
  8095. set globalHue(value: number);
  8096. /**
  8097. * Gets the global Density value.
  8098. * 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.
  8099. * Values less than zero provide a filter of opposite hue.
  8100. */
  8101. get globalDensity(): number;
  8102. /**
  8103. * Sets the global Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. set globalDensity(value: number);
  8108. /**
  8109. * Gets the global Saturation value.
  8110. * 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.
  8111. */
  8112. get globalSaturation(): number;
  8113. /**
  8114. * Sets the global Saturation value.
  8115. * 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.
  8116. */
  8117. set globalSaturation(value: number);
  8118. /**
  8119. * Gets the global Exposure value.
  8120. * 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.
  8121. */
  8122. get globalExposure(): number;
  8123. /**
  8124. * Sets the global Exposure value.
  8125. * 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.
  8126. */
  8127. set globalExposure(value: number);
  8128. private _highlightsHue;
  8129. private _highlightsDensity;
  8130. private _highlightsSaturation;
  8131. private _highlightsExposure;
  8132. /**
  8133. * Gets the highlights Hue value.
  8134. * 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).
  8135. */
  8136. get highlightsHue(): number;
  8137. /**
  8138. * Sets the highlights Hue value.
  8139. * 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).
  8140. */
  8141. set highlightsHue(value: number);
  8142. /**
  8143. * Gets the highlights Density value.
  8144. * 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.
  8145. * Values less than zero provide a filter of opposite hue.
  8146. */
  8147. get highlightsDensity(): number;
  8148. /**
  8149. * Sets the highlights Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. set highlightsDensity(value: number);
  8154. /**
  8155. * Gets the highlights Saturation value.
  8156. * 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.
  8157. */
  8158. get highlightsSaturation(): number;
  8159. /**
  8160. * Sets the highlights Saturation value.
  8161. * 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.
  8162. */
  8163. set highlightsSaturation(value: number);
  8164. /**
  8165. * Gets the highlights Exposure value.
  8166. * 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.
  8167. */
  8168. get highlightsExposure(): number;
  8169. /**
  8170. * Sets the highlights Exposure value.
  8171. * 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.
  8172. */
  8173. set highlightsExposure(value: number);
  8174. private _midtonesHue;
  8175. private _midtonesDensity;
  8176. private _midtonesSaturation;
  8177. private _midtonesExposure;
  8178. /**
  8179. * Gets the midtones Hue value.
  8180. * 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).
  8181. */
  8182. get midtonesHue(): number;
  8183. /**
  8184. * Sets the midtones Hue value.
  8185. * 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).
  8186. */
  8187. set midtonesHue(value: number);
  8188. /**
  8189. * Gets the midtones Density value.
  8190. * 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.
  8191. * Values less than zero provide a filter of opposite hue.
  8192. */
  8193. get midtonesDensity(): number;
  8194. /**
  8195. * Sets the midtones Density value.
  8196. * 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.
  8197. * Values less than zero provide a filter of opposite hue.
  8198. */
  8199. set midtonesDensity(value: number);
  8200. /**
  8201. * Gets the midtones Saturation value.
  8202. * 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.
  8203. */
  8204. get midtonesSaturation(): number;
  8205. /**
  8206. * Sets the midtones Saturation value.
  8207. * 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.
  8208. */
  8209. set midtonesSaturation(value: number);
  8210. /**
  8211. * Gets the midtones Exposure value.
  8212. * 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.
  8213. */
  8214. get midtonesExposure(): number;
  8215. /**
  8216. * Sets the midtones Exposure value.
  8217. * 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.
  8218. */
  8219. set midtonesExposure(value: number);
  8220. private _shadowsHue;
  8221. private _shadowsDensity;
  8222. private _shadowsSaturation;
  8223. private _shadowsExposure;
  8224. /**
  8225. * Gets the shadows Hue value.
  8226. * 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).
  8227. */
  8228. get shadowsHue(): number;
  8229. /**
  8230. * Sets the shadows Hue value.
  8231. * 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).
  8232. */
  8233. set shadowsHue(value: number);
  8234. /**
  8235. * Gets the shadows Density value.
  8236. * 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.
  8237. * Values less than zero provide a filter of opposite hue.
  8238. */
  8239. get shadowsDensity(): number;
  8240. /**
  8241. * Sets the shadows Density value.
  8242. * 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.
  8243. * Values less than zero provide a filter of opposite hue.
  8244. */
  8245. set shadowsDensity(value: number);
  8246. /**
  8247. * Gets the shadows Saturation value.
  8248. * 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.
  8249. */
  8250. get shadowsSaturation(): number;
  8251. /**
  8252. * Sets the shadows Saturation value.
  8253. * 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.
  8254. */
  8255. set shadowsSaturation(value: number);
  8256. /**
  8257. * Gets the shadows Exposure value.
  8258. * 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.
  8259. */
  8260. get shadowsExposure(): number;
  8261. /**
  8262. * Sets the shadows Exposure value.
  8263. * 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.
  8264. */
  8265. set shadowsExposure(value: number);
  8266. /**
  8267. * Returns the class name
  8268. * @returns The class name
  8269. */
  8270. getClassName(): string;
  8271. /**
  8272. * Binds the color curves to the shader.
  8273. * @param colorCurves The color curve to bind
  8274. * @param effect The effect to bind to
  8275. * @param positiveUniform The positive uniform shader parameter
  8276. * @param neutralUniform The neutral uniform shader parameter
  8277. * @param negativeUniform The negative uniform shader parameter
  8278. */
  8279. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8280. /**
  8281. * Prepare the list of uniforms associated with the ColorCurves effects.
  8282. * @param uniformsList The list of uniforms used in the effect
  8283. */
  8284. static PrepareUniforms(uniformsList: string[]): void;
  8285. /**
  8286. * Returns color grading data based on a hue, density, saturation and exposure value.
  8287. * @param filterHue The hue of the color filter.
  8288. * @param filterDensity The density of the color filter.
  8289. * @param saturation The saturation.
  8290. * @param exposure The exposure.
  8291. * @param result The result data container.
  8292. */
  8293. private getColorGradingDataToRef;
  8294. /**
  8295. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8296. * @param value The input slider value in range [-100,100].
  8297. * @returns Adjusted value.
  8298. */
  8299. private static applyColorGradingSliderNonlinear;
  8300. /**
  8301. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8302. * @param hue The hue (H) input.
  8303. * @param saturation The saturation (S) input.
  8304. * @param brightness The brightness (B) input.
  8305. * @result An RGBA color represented as Vector4.
  8306. */
  8307. private static fromHSBToRef;
  8308. /**
  8309. * Returns a value clamped between min and max
  8310. * @param value The value to clamp
  8311. * @param min The minimum of value
  8312. * @param max The maximum of value
  8313. * @returns The clamped value.
  8314. */
  8315. private static clamp;
  8316. /**
  8317. * Clones the current color curve instance.
  8318. * @return The cloned curves
  8319. */
  8320. clone(): ColorCurves;
  8321. /**
  8322. * Serializes the current color curve instance to a json representation.
  8323. * @return a JSON representation
  8324. */
  8325. serialize(): any;
  8326. /**
  8327. * Parses the color curve from a json representation.
  8328. * @param source the JSON source to parse
  8329. * @return The parsed curves
  8330. */
  8331. static Parse(source: any): ColorCurves;
  8332. }
  8333. }
  8334. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8335. import { Observable } from "babylonjs/Misc/observable";
  8336. import { Nullable } from "babylonjs/types";
  8337. import { Color4 } from "babylonjs/Maths/math.color";
  8338. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8339. import { Effect } from "babylonjs/Materials/effect";
  8340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8341. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8342. /**
  8343. * Interface to follow in your material defines to integrate easily the
  8344. * Image proccessing functions.
  8345. * @hidden
  8346. */
  8347. export interface IImageProcessingConfigurationDefines {
  8348. IMAGEPROCESSING: boolean;
  8349. VIGNETTE: boolean;
  8350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8351. VIGNETTEBLENDMODEOPAQUE: boolean;
  8352. TONEMAPPING: boolean;
  8353. TONEMAPPING_ACES: boolean;
  8354. CONTRAST: boolean;
  8355. EXPOSURE: boolean;
  8356. COLORCURVES: boolean;
  8357. COLORGRADING: boolean;
  8358. COLORGRADING3D: boolean;
  8359. SAMPLER3DGREENDEPTH: boolean;
  8360. SAMPLER3DBGRMAP: boolean;
  8361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8362. }
  8363. /**
  8364. * @hidden
  8365. */
  8366. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8367. IMAGEPROCESSING: boolean;
  8368. VIGNETTE: boolean;
  8369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8370. VIGNETTEBLENDMODEOPAQUE: boolean;
  8371. TONEMAPPING: boolean;
  8372. TONEMAPPING_ACES: boolean;
  8373. CONTRAST: boolean;
  8374. COLORCURVES: boolean;
  8375. COLORGRADING: boolean;
  8376. COLORGRADING3D: boolean;
  8377. SAMPLER3DGREENDEPTH: boolean;
  8378. SAMPLER3DBGRMAP: boolean;
  8379. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8380. EXPOSURE: boolean;
  8381. constructor();
  8382. }
  8383. /**
  8384. * This groups together the common properties used for image processing either in direct forward pass
  8385. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8386. * or not.
  8387. */
  8388. export class ImageProcessingConfiguration {
  8389. /**
  8390. * Default tone mapping applied in BabylonJS.
  8391. */
  8392. static readonly TONEMAPPING_STANDARD: number;
  8393. /**
  8394. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8395. * to other engines rendering to increase portability.
  8396. */
  8397. static readonly TONEMAPPING_ACES: number;
  8398. /**
  8399. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8400. */
  8401. colorCurves: Nullable<ColorCurves>;
  8402. private _colorCurvesEnabled;
  8403. /**
  8404. * Gets wether the color curves effect is enabled.
  8405. */
  8406. get colorCurvesEnabled(): boolean;
  8407. /**
  8408. * Sets wether the color curves effect is enabled.
  8409. */
  8410. set colorCurvesEnabled(value: boolean);
  8411. private _colorGradingTexture;
  8412. /**
  8413. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8414. */
  8415. get colorGradingTexture(): Nullable<BaseTexture>;
  8416. /**
  8417. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8418. */
  8419. set colorGradingTexture(value: Nullable<BaseTexture>);
  8420. private _colorGradingEnabled;
  8421. /**
  8422. * Gets wether the color grading effect is enabled.
  8423. */
  8424. get colorGradingEnabled(): boolean;
  8425. /**
  8426. * Sets wether the color grading effect is enabled.
  8427. */
  8428. set colorGradingEnabled(value: boolean);
  8429. private _colorGradingWithGreenDepth;
  8430. /**
  8431. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8432. */
  8433. get colorGradingWithGreenDepth(): boolean;
  8434. /**
  8435. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8436. */
  8437. set colorGradingWithGreenDepth(value: boolean);
  8438. private _colorGradingBGR;
  8439. /**
  8440. * Gets wether the color grading texture contains BGR values.
  8441. */
  8442. get colorGradingBGR(): boolean;
  8443. /**
  8444. * Sets wether the color grading texture contains BGR values.
  8445. */
  8446. set colorGradingBGR(value: boolean);
  8447. /** @hidden */
  8448. _exposure: number;
  8449. /**
  8450. * Gets the Exposure used in the effect.
  8451. */
  8452. get exposure(): number;
  8453. /**
  8454. * Sets the Exposure used in the effect.
  8455. */
  8456. set exposure(value: number);
  8457. private _toneMappingEnabled;
  8458. /**
  8459. * Gets wether the tone mapping effect is enabled.
  8460. */
  8461. get toneMappingEnabled(): boolean;
  8462. /**
  8463. * Sets wether the tone mapping effect is enabled.
  8464. */
  8465. set toneMappingEnabled(value: boolean);
  8466. private _toneMappingType;
  8467. /**
  8468. * Gets the type of tone mapping effect.
  8469. */
  8470. get toneMappingType(): number;
  8471. /**
  8472. * Sets the type of tone mapping effect used in BabylonJS.
  8473. */
  8474. set toneMappingType(value: number);
  8475. protected _contrast: number;
  8476. /**
  8477. * Gets the contrast used in the effect.
  8478. */
  8479. get contrast(): number;
  8480. /**
  8481. * Sets the contrast used in the effect.
  8482. */
  8483. set contrast(value: number);
  8484. /**
  8485. * Vignette stretch size.
  8486. */
  8487. vignetteStretch: number;
  8488. /**
  8489. * Vignette centre X Offset.
  8490. */
  8491. vignetteCentreX: number;
  8492. /**
  8493. * Vignette centre Y Offset.
  8494. */
  8495. vignetteCentreY: number;
  8496. /**
  8497. * Vignette weight or intensity of the vignette effect.
  8498. */
  8499. vignetteWeight: number;
  8500. /**
  8501. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8502. * if vignetteEnabled is set to true.
  8503. */
  8504. vignetteColor: Color4;
  8505. /**
  8506. * Camera field of view used by the Vignette effect.
  8507. */
  8508. vignetteCameraFov: number;
  8509. private _vignetteBlendMode;
  8510. /**
  8511. * Gets the vignette blend mode allowing different kind of effect.
  8512. */
  8513. get vignetteBlendMode(): number;
  8514. /**
  8515. * Sets the vignette blend mode allowing different kind of effect.
  8516. */
  8517. set vignetteBlendMode(value: number);
  8518. private _vignetteEnabled;
  8519. /**
  8520. * Gets wether the vignette effect is enabled.
  8521. */
  8522. get vignetteEnabled(): boolean;
  8523. /**
  8524. * Sets wether the vignette effect is enabled.
  8525. */
  8526. set vignetteEnabled(value: boolean);
  8527. private _applyByPostProcess;
  8528. /**
  8529. * Gets wether the image processing is applied through a post process or not.
  8530. */
  8531. get applyByPostProcess(): boolean;
  8532. /**
  8533. * Sets wether the image processing is applied through a post process or not.
  8534. */
  8535. set applyByPostProcess(value: boolean);
  8536. private _isEnabled;
  8537. /**
  8538. * Gets wether the image processing is enabled or not.
  8539. */
  8540. get isEnabled(): boolean;
  8541. /**
  8542. * Sets wether the image processing is enabled or not.
  8543. */
  8544. set isEnabled(value: boolean);
  8545. /**
  8546. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8547. */
  8548. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8549. /**
  8550. * Method called each time the image processing information changes requires to recompile the effect.
  8551. */
  8552. protected _updateParameters(): void;
  8553. /**
  8554. * Gets the current class name.
  8555. * @return "ImageProcessingConfiguration"
  8556. */
  8557. getClassName(): string;
  8558. /**
  8559. * Prepare the list of uniforms associated with the Image Processing effects.
  8560. * @param uniforms The list of uniforms used in the effect
  8561. * @param defines the list of defines currently in use
  8562. */
  8563. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8564. /**
  8565. * Prepare the list of samplers associated with the Image Processing effects.
  8566. * @param samplersList The list of uniforms used in the effect
  8567. * @param defines the list of defines currently in use
  8568. */
  8569. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8570. /**
  8571. * Prepare the list of defines associated to the shader.
  8572. * @param defines the list of defines to complete
  8573. * @param forPostProcess Define if we are currently in post process mode or not
  8574. */
  8575. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8576. /**
  8577. * Returns true if all the image processing information are ready.
  8578. * @returns True if ready, otherwise, false
  8579. */
  8580. isReady(): boolean;
  8581. /**
  8582. * Binds the image processing to the shader.
  8583. * @param effect The effect to bind to
  8584. * @param overrideAspectRatio Override the aspect ratio of the effect
  8585. */
  8586. bind(effect: Effect, overrideAspectRatio?: number): void;
  8587. /**
  8588. * Clones the current image processing instance.
  8589. * @return The cloned image processing
  8590. */
  8591. clone(): ImageProcessingConfiguration;
  8592. /**
  8593. * Serializes the current image processing instance to a json representation.
  8594. * @return a JSON representation
  8595. */
  8596. serialize(): any;
  8597. /**
  8598. * Parses the image processing from a json representation.
  8599. * @param source the JSON source to parse
  8600. * @return The parsed image processing
  8601. */
  8602. static Parse(source: any): ImageProcessingConfiguration;
  8603. private static _VIGNETTEMODE_MULTIPLY;
  8604. private static _VIGNETTEMODE_OPAQUE;
  8605. /**
  8606. * Used to apply the vignette as a mix with the pixel color.
  8607. */
  8608. static get VIGNETTEMODE_MULTIPLY(): number;
  8609. /**
  8610. * Used to apply the vignette as a replacement of the pixel color.
  8611. */
  8612. static get VIGNETTEMODE_OPAQUE(): number;
  8613. }
  8614. }
  8615. declare module "babylonjs/Shaders/postprocess.vertex" {
  8616. /** @hidden */
  8617. export var postprocessVertexShader: {
  8618. name: string;
  8619. shader: string;
  8620. };
  8621. }
  8622. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8624. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8626. module "babylonjs/Engines/thinEngine" {
  8627. interface ThinEngine {
  8628. /**
  8629. * Creates a new render target texture
  8630. * @param size defines the size of the texture
  8631. * @param options defines the options used to create the texture
  8632. * @returns a new render target texture stored in an InternalTexture
  8633. */
  8634. createRenderTargetTexture(size: number | {
  8635. width: number;
  8636. height: number;
  8637. layers?: number;
  8638. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8639. /**
  8640. * Creates a depth stencil texture.
  8641. * This is only available in WebGL 2 or with the depth texture extension available.
  8642. * @param size The size of face edge in the texture.
  8643. * @param options The options defining the texture.
  8644. * @returns The texture
  8645. */
  8646. createDepthStencilTexture(size: number | {
  8647. width: number;
  8648. height: number;
  8649. layers?: number;
  8650. }, options: DepthTextureCreationOptions): InternalTexture;
  8651. /** @hidden */
  8652. _createDepthStencilTexture(size: number | {
  8653. width: number;
  8654. height: number;
  8655. layers?: number;
  8656. }, options: DepthTextureCreationOptions): InternalTexture;
  8657. }
  8658. }
  8659. }
  8660. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8661. /**
  8662. * Defines the kind of connection point for node based material
  8663. */
  8664. export enum NodeMaterialBlockConnectionPointTypes {
  8665. /** Float */
  8666. Float = 1,
  8667. /** Int */
  8668. Int = 2,
  8669. /** Vector2 */
  8670. Vector2 = 4,
  8671. /** Vector3 */
  8672. Vector3 = 8,
  8673. /** Vector4 */
  8674. Vector4 = 16,
  8675. /** Color3 */
  8676. Color3 = 32,
  8677. /** Color4 */
  8678. Color4 = 64,
  8679. /** Matrix */
  8680. Matrix = 128,
  8681. /** Custom object */
  8682. Object = 256,
  8683. /** Detect type based on connection */
  8684. AutoDetect = 1024,
  8685. /** Output type that will be defined by input type */
  8686. BasedOnInput = 2048
  8687. }
  8688. }
  8689. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8690. /**
  8691. * Enum used to define the target of a block
  8692. */
  8693. export enum NodeMaterialBlockTargets {
  8694. /** Vertex shader */
  8695. Vertex = 1,
  8696. /** Fragment shader */
  8697. Fragment = 2,
  8698. /** Neutral */
  8699. Neutral = 4,
  8700. /** Vertex and Fragment */
  8701. VertexAndFragment = 3
  8702. }
  8703. }
  8704. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8705. /**
  8706. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8707. */
  8708. export enum NodeMaterialBlockConnectionPointMode {
  8709. /** Value is an uniform */
  8710. Uniform = 0,
  8711. /** Value is a mesh attribute */
  8712. Attribute = 1,
  8713. /** Value is a varying between vertex and fragment shaders */
  8714. Varying = 2,
  8715. /** Mode is undefined */
  8716. Undefined = 3
  8717. }
  8718. }
  8719. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8720. /**
  8721. * Enum used to define system values e.g. values automatically provided by the system
  8722. */
  8723. export enum NodeMaterialSystemValues {
  8724. /** World */
  8725. World = 1,
  8726. /** View */
  8727. View = 2,
  8728. /** Projection */
  8729. Projection = 3,
  8730. /** ViewProjection */
  8731. ViewProjection = 4,
  8732. /** WorldView */
  8733. WorldView = 5,
  8734. /** WorldViewProjection */
  8735. WorldViewProjection = 6,
  8736. /** CameraPosition */
  8737. CameraPosition = 7,
  8738. /** Fog Color */
  8739. FogColor = 8,
  8740. /** Delta time */
  8741. DeltaTime = 9
  8742. }
  8743. }
  8744. declare module "babylonjs/Maths/math.axis" {
  8745. import { Vector3 } from "babylonjs/Maths/math.vector";
  8746. /** Defines supported spaces */
  8747. export enum Space {
  8748. /** Local (object) space */
  8749. LOCAL = 0,
  8750. /** World space */
  8751. WORLD = 1,
  8752. /** Bone space */
  8753. BONE = 2
  8754. }
  8755. /** Defines the 3 main axes */
  8756. export class Axis {
  8757. /** X axis */
  8758. static X: Vector3;
  8759. /** Y axis */
  8760. static Y: Vector3;
  8761. /** Z axis */
  8762. static Z: Vector3;
  8763. }
  8764. }
  8765. declare module "babylonjs/Maths/math.frustum" {
  8766. import { Matrix } from "babylonjs/Maths/math.vector";
  8767. import { DeepImmutable } from "babylonjs/types";
  8768. import { Plane } from "babylonjs/Maths/math.plane";
  8769. /**
  8770. * Represents a camera frustum
  8771. */
  8772. export class Frustum {
  8773. /**
  8774. * Gets the planes representing the frustum
  8775. * @param transform matrix to be applied to the returned planes
  8776. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8777. */
  8778. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8779. /**
  8780. * Gets the near frustum plane transformed by the transform matrix
  8781. * @param transform transformation matrix to be applied to the resulting frustum plane
  8782. * @param frustumPlane the resuling frustum plane
  8783. */
  8784. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8785. /**
  8786. * Gets the far frustum plane transformed by the transform matrix
  8787. * @param transform transformation matrix to be applied to the resulting frustum plane
  8788. * @param frustumPlane the resuling frustum plane
  8789. */
  8790. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8791. /**
  8792. * Gets the left frustum plane transformed by the transform matrix
  8793. * @param transform transformation matrix to be applied to the resulting frustum plane
  8794. * @param frustumPlane the resuling frustum plane
  8795. */
  8796. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8797. /**
  8798. * Gets the right frustum plane transformed by the transform matrix
  8799. * @param transform transformation matrix to be applied to the resulting frustum plane
  8800. * @param frustumPlane the resuling frustum plane
  8801. */
  8802. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8803. /**
  8804. * Gets the top frustum plane transformed by the transform matrix
  8805. * @param transform transformation matrix to be applied to the resulting frustum plane
  8806. * @param frustumPlane the resuling frustum plane
  8807. */
  8808. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8809. /**
  8810. * Gets the bottom frustum plane transformed by the transform matrix
  8811. * @param transform transformation matrix to be applied to the resulting frustum plane
  8812. * @param frustumPlane the resuling frustum plane
  8813. */
  8814. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8815. /**
  8816. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8817. * @param transform transformation matrix to be applied to the resulting frustum planes
  8818. * @param frustumPlanes the resuling frustum planes
  8819. */
  8820. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8821. }
  8822. }
  8823. declare module "babylonjs/Maths/math.size" {
  8824. /**
  8825. * Interface for the size containing width and height
  8826. */
  8827. export interface ISize {
  8828. /**
  8829. * Width
  8830. */
  8831. width: number;
  8832. /**
  8833. * Heighht
  8834. */
  8835. height: number;
  8836. }
  8837. /**
  8838. * Size containing widht and height
  8839. */
  8840. export class Size implements ISize {
  8841. /**
  8842. * Width
  8843. */
  8844. width: number;
  8845. /**
  8846. * Height
  8847. */
  8848. height: number;
  8849. /**
  8850. * Creates a Size object from the given width and height (floats).
  8851. * @param width width of the new size
  8852. * @param height height of the new size
  8853. */
  8854. constructor(width: number, height: number);
  8855. /**
  8856. * Returns a string with the Size width and height
  8857. * @returns a string with the Size width and height
  8858. */
  8859. toString(): string;
  8860. /**
  8861. * "Size"
  8862. * @returns the string "Size"
  8863. */
  8864. getClassName(): string;
  8865. /**
  8866. * Returns the Size hash code.
  8867. * @returns a hash code for a unique width and height
  8868. */
  8869. getHashCode(): number;
  8870. /**
  8871. * Updates the current size from the given one.
  8872. * @param src the given size
  8873. */
  8874. copyFrom(src: Size): void;
  8875. /**
  8876. * Updates in place the current Size from the given floats.
  8877. * @param width width of the new size
  8878. * @param height height of the new size
  8879. * @returns the updated Size.
  8880. */
  8881. copyFromFloats(width: number, height: number): Size;
  8882. /**
  8883. * Updates in place the current Size from the given floats.
  8884. * @param width width to set
  8885. * @param height height to set
  8886. * @returns the updated Size.
  8887. */
  8888. set(width: number, height: number): Size;
  8889. /**
  8890. * Multiplies the width and height by numbers
  8891. * @param w factor to multiple the width by
  8892. * @param h factor to multiple the height by
  8893. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8894. */
  8895. multiplyByFloats(w: number, h: number): Size;
  8896. /**
  8897. * Clones the size
  8898. * @returns a new Size copied from the given one.
  8899. */
  8900. clone(): Size;
  8901. /**
  8902. * True if the current Size and the given one width and height are strictly equal.
  8903. * @param other the other size to compare against
  8904. * @returns True if the current Size and the given one width and height are strictly equal.
  8905. */
  8906. equals(other: Size): boolean;
  8907. /**
  8908. * The surface of the Size : width * height (float).
  8909. */
  8910. get surface(): number;
  8911. /**
  8912. * Create a new size of zero
  8913. * @returns a new Size set to (0.0, 0.0)
  8914. */
  8915. static Zero(): Size;
  8916. /**
  8917. * Sums the width and height of two sizes
  8918. * @param otherSize size to add to this size
  8919. * @returns a new Size set as the addition result of the current Size and the given one.
  8920. */
  8921. add(otherSize: Size): Size;
  8922. /**
  8923. * Subtracts the width and height of two
  8924. * @param otherSize size to subtract to this size
  8925. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8926. */
  8927. subtract(otherSize: Size): Size;
  8928. /**
  8929. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8930. * @param start starting size to lerp between
  8931. * @param end end size to lerp between
  8932. * @param amount amount to lerp between the start and end values
  8933. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8934. */
  8935. static Lerp(start: Size, end: Size, amount: number): Size;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.vertexFormat" {
  8939. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8940. /**
  8941. * Contains position and normal vectors for a vertex
  8942. */
  8943. export class PositionNormalVertex {
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position: Vector3;
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal: Vector3;
  8948. /**
  8949. * Creates a PositionNormalVertex
  8950. * @param position the position of the vertex (defaut: 0,0,0)
  8951. * @param normal the normal of the vertex (defaut: 0,1,0)
  8952. */
  8953. constructor(
  8954. /** the position of the vertex (defaut: 0,0,0) */
  8955. position?: Vector3,
  8956. /** the normal of the vertex (defaut: 0,1,0) */
  8957. normal?: Vector3);
  8958. /**
  8959. * Clones the PositionNormalVertex
  8960. * @returns the cloned PositionNormalVertex
  8961. */
  8962. clone(): PositionNormalVertex;
  8963. }
  8964. /**
  8965. * Contains position, normal and uv vectors for a vertex
  8966. */
  8967. export class PositionNormalTextureVertex {
  8968. /** the position of the vertex (defaut: 0,0,0) */
  8969. position: Vector3;
  8970. /** the normal of the vertex (defaut: 0,1,0) */
  8971. normal: Vector3;
  8972. /** the uv of the vertex (default: 0,0) */
  8973. uv: Vector2;
  8974. /**
  8975. * Creates a PositionNormalTextureVertex
  8976. * @param position the position of the vertex (defaut: 0,0,0)
  8977. * @param normal the normal of the vertex (defaut: 0,1,0)
  8978. * @param uv the uv of the vertex (default: 0,0)
  8979. */
  8980. constructor(
  8981. /** the position of the vertex (defaut: 0,0,0) */
  8982. position?: Vector3,
  8983. /** the normal of the vertex (defaut: 0,1,0) */
  8984. normal?: Vector3,
  8985. /** the uv of the vertex (default: 0,0) */
  8986. uv?: Vector2);
  8987. /**
  8988. * Clones the PositionNormalTextureVertex
  8989. * @returns the cloned PositionNormalTextureVertex
  8990. */
  8991. clone(): PositionNormalTextureVertex;
  8992. }
  8993. }
  8994. declare module "babylonjs/Maths/math" {
  8995. export * from "babylonjs/Maths/math.axis";
  8996. export * from "babylonjs/Maths/math.color";
  8997. export * from "babylonjs/Maths/math.constants";
  8998. export * from "babylonjs/Maths/math.frustum";
  8999. export * from "babylonjs/Maths/math.path";
  9000. export * from "babylonjs/Maths/math.plane";
  9001. export * from "babylonjs/Maths/math.size";
  9002. export * from "babylonjs/Maths/math.vector";
  9003. export * from "babylonjs/Maths/math.vertexFormat";
  9004. export * from "babylonjs/Maths/math.viewport";
  9005. }
  9006. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9007. /**
  9008. * Enum defining the type of animations supported by InputBlock
  9009. */
  9010. export enum AnimatedInputBlockTypes {
  9011. /** No animation */
  9012. None = 0,
  9013. /** Time based animation. Will only work for floats */
  9014. Time = 1
  9015. }
  9016. }
  9017. declare module "babylonjs/Lights/shadowLight" {
  9018. import { Camera } from "babylonjs/Cameras/camera";
  9019. import { Scene } from "babylonjs/scene";
  9020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9022. import { Light } from "babylonjs/Lights/light";
  9023. /**
  9024. * Interface describing all the common properties and methods a shadow light needs to implement.
  9025. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9026. * as well as binding the different shadow properties to the effects.
  9027. */
  9028. export interface IShadowLight extends Light {
  9029. /**
  9030. * The light id in the scene (used in scene.findLighById for instance)
  9031. */
  9032. id: string;
  9033. /**
  9034. * The position the shdow will be casted from.
  9035. */
  9036. position: Vector3;
  9037. /**
  9038. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9039. */
  9040. direction: Vector3;
  9041. /**
  9042. * The transformed position. Position of the light in world space taking parenting in account.
  9043. */
  9044. transformedPosition: Vector3;
  9045. /**
  9046. * The transformed direction. Direction of the light in world space taking parenting in account.
  9047. */
  9048. transformedDirection: Vector3;
  9049. /**
  9050. * The friendly name of the light in the scene.
  9051. */
  9052. name: string;
  9053. /**
  9054. * Defines the shadow projection clipping minimum z value.
  9055. */
  9056. shadowMinZ: number;
  9057. /**
  9058. * Defines the shadow projection clipping maximum z value.
  9059. */
  9060. shadowMaxZ: number;
  9061. /**
  9062. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9063. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9064. */
  9065. computeTransformedInformation(): boolean;
  9066. /**
  9067. * Gets the scene the light belongs to.
  9068. * @returns The scene
  9069. */
  9070. getScene(): Scene;
  9071. /**
  9072. * Callback defining a custom Projection Matrix Builder.
  9073. * This can be used to override the default projection matrix computation.
  9074. */
  9075. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9076. /**
  9077. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9078. * @param matrix The materix to updated with the projection information
  9079. * @param viewMatrix The transform matrix of the light
  9080. * @param renderList The list of mesh to render in the map
  9081. * @returns The current light
  9082. */
  9083. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9084. /**
  9085. * Gets the current depth scale used in ESM.
  9086. * @returns The scale
  9087. */
  9088. getDepthScale(): number;
  9089. /**
  9090. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9091. * @returns true if a cube texture needs to be use
  9092. */
  9093. needCube(): boolean;
  9094. /**
  9095. * Detects if the projection matrix requires to be recomputed this frame.
  9096. * @returns true if it requires to be recomputed otherwise, false.
  9097. */
  9098. needProjectionMatrixCompute(): boolean;
  9099. /**
  9100. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9101. */
  9102. forceProjectionMatrixCompute(): void;
  9103. /**
  9104. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9105. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9106. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9107. */
  9108. getShadowDirection(faceIndex?: number): Vector3;
  9109. /**
  9110. * Gets the minZ used for shadow according to both the scene and the light.
  9111. * @param activeCamera The camera we are returning the min for
  9112. * @returns the depth min z
  9113. */
  9114. getDepthMinZ(activeCamera: Camera): number;
  9115. /**
  9116. * Gets the maxZ used for shadow according to both the scene and the light.
  9117. * @param activeCamera The camera we are returning the max for
  9118. * @returns the depth max z
  9119. */
  9120. getDepthMaxZ(activeCamera: Camera): number;
  9121. }
  9122. /**
  9123. * Base implementation IShadowLight
  9124. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9125. */
  9126. export abstract class ShadowLight extends Light implements IShadowLight {
  9127. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9128. protected _position: Vector3;
  9129. protected _setPosition(value: Vector3): void;
  9130. /**
  9131. * Sets the position the shadow will be casted from. Also use as the light position for both
  9132. * point and spot lights.
  9133. */
  9134. get position(): Vector3;
  9135. /**
  9136. * Sets the position the shadow will be casted from. Also use as the light position for both
  9137. * point and spot lights.
  9138. */
  9139. set position(value: Vector3);
  9140. protected _direction: Vector3;
  9141. protected _setDirection(value: Vector3): void;
  9142. /**
  9143. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9144. * Also use as the light direction on spot and directional lights.
  9145. */
  9146. get direction(): Vector3;
  9147. /**
  9148. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9149. * Also use as the light direction on spot and directional lights.
  9150. */
  9151. set direction(value: Vector3);
  9152. protected _shadowMinZ: number;
  9153. /**
  9154. * Gets the shadow projection clipping minimum z value.
  9155. */
  9156. get shadowMinZ(): number;
  9157. /**
  9158. * Sets the shadow projection clipping minimum z value.
  9159. */
  9160. set shadowMinZ(value: number);
  9161. protected _shadowMaxZ: number;
  9162. /**
  9163. * Sets the shadow projection clipping maximum z value.
  9164. */
  9165. get shadowMaxZ(): number;
  9166. /**
  9167. * Gets the shadow projection clipping maximum z value.
  9168. */
  9169. set shadowMaxZ(value: number);
  9170. /**
  9171. * Callback defining a custom Projection Matrix Builder.
  9172. * This can be used to override the default projection matrix computation.
  9173. */
  9174. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9175. /**
  9176. * The transformed position. Position of the light in world space taking parenting in account.
  9177. */
  9178. transformedPosition: Vector3;
  9179. /**
  9180. * The transformed direction. Direction of the light in world space taking parenting in account.
  9181. */
  9182. transformedDirection: Vector3;
  9183. private _needProjectionMatrixCompute;
  9184. /**
  9185. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9186. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9187. */
  9188. computeTransformedInformation(): boolean;
  9189. /**
  9190. * Return the depth scale used for the shadow map.
  9191. * @returns the depth scale.
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9196. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9197. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9198. */
  9199. getShadowDirection(faceIndex?: number): Vector3;
  9200. /**
  9201. * Returns the ShadowLight absolute position in the World.
  9202. * @returns the position vector in world space
  9203. */
  9204. getAbsolutePosition(): Vector3;
  9205. /**
  9206. * Sets the ShadowLight direction toward the passed target.
  9207. * @param target The point to target in local space
  9208. * @returns the updated ShadowLight direction
  9209. */
  9210. setDirectionToTarget(target: Vector3): Vector3;
  9211. /**
  9212. * Returns the light rotation in euler definition.
  9213. * @returns the x y z rotation in local space.
  9214. */
  9215. getRotation(): Vector3;
  9216. /**
  9217. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9218. * @returns true if a cube texture needs to be use
  9219. */
  9220. needCube(): boolean;
  9221. /**
  9222. * Detects if the projection matrix requires to be recomputed this frame.
  9223. * @returns true if it requires to be recomputed otherwise, false.
  9224. */
  9225. needProjectionMatrixCompute(): boolean;
  9226. /**
  9227. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9228. */
  9229. forceProjectionMatrixCompute(): void;
  9230. /** @hidden */
  9231. _initCache(): void;
  9232. /** @hidden */
  9233. _isSynchronized(): boolean;
  9234. /**
  9235. * Computes the world matrix of the node
  9236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9237. * @returns the world matrix
  9238. */
  9239. computeWorldMatrix(force?: boolean): Matrix;
  9240. /**
  9241. * Gets the minZ used for shadow according to both the scene and the light.
  9242. * @param activeCamera The camera we are returning the min for
  9243. * @returns the depth min z
  9244. */
  9245. getDepthMinZ(activeCamera: Camera): number;
  9246. /**
  9247. * Gets the maxZ used for shadow according to both the scene and the light.
  9248. * @param activeCamera The camera we are returning the max for
  9249. * @returns the depth max z
  9250. */
  9251. getDepthMaxZ(activeCamera: Camera): number;
  9252. /**
  9253. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9254. * @param matrix The materix to updated with the projection information
  9255. * @param viewMatrix The transform matrix of the light
  9256. * @param renderList The list of mesh to render in the map
  9257. * @returns The current light
  9258. */
  9259. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9260. }
  9261. }
  9262. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9263. /** @hidden */
  9264. export var packingFunctions: {
  9265. name: string;
  9266. shader: string;
  9267. };
  9268. }
  9269. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9270. /** @hidden */
  9271. export var bayerDitherFunctions: {
  9272. name: string;
  9273. shader: string;
  9274. };
  9275. }
  9276. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9277. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9278. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9279. /** @hidden */
  9280. export var shadowMapFragmentDeclaration: {
  9281. name: string;
  9282. shader: string;
  9283. };
  9284. }
  9285. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9286. /** @hidden */
  9287. export var clipPlaneFragmentDeclaration: {
  9288. name: string;
  9289. shader: string;
  9290. };
  9291. }
  9292. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9293. /** @hidden */
  9294. export var clipPlaneFragment: {
  9295. name: string;
  9296. shader: string;
  9297. };
  9298. }
  9299. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9300. /** @hidden */
  9301. export var shadowMapFragment: {
  9302. name: string;
  9303. shader: string;
  9304. };
  9305. }
  9306. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9307. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9310. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9311. /** @hidden */
  9312. export var shadowMapPixelShader: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9318. /** @hidden */
  9319. export var bonesDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9325. /** @hidden */
  9326. export var morphTargetsVertexGlobalDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9332. /** @hidden */
  9333. export var morphTargetsVertexDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9339. /** @hidden */
  9340. export var instancesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9346. /** @hidden */
  9347. export var helperFunctions: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9353. /** @hidden */
  9354. export var shadowMapVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9360. /** @hidden */
  9361. export var clipPlaneVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9367. /** @hidden */
  9368. export var morphTargetsVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9374. /** @hidden */
  9375. export var instancesVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9381. /** @hidden */
  9382. export var bonesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9388. /** @hidden */
  9389. export var shadowMapVertexNormalBias: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9395. /** @hidden */
  9396. export var shadowMapVertexMetric: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9409. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9412. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9414. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9415. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9417. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9418. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9419. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9420. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9422. /** @hidden */
  9423. export var shadowMapVertexShader: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9429. /** @hidden */
  9430. export var depthBoxBlurPixelShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9436. /** @hidden */
  9437. export var shadowMapFragmentSoftTransparentShadow: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Materials/effectFallbacks" {
  9443. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9444. import { Effect } from "babylonjs/Materials/effect";
  9445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9446. /**
  9447. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9448. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9449. */
  9450. export class EffectFallbacks implements IEffectFallbacks {
  9451. private _defines;
  9452. private _currentRank;
  9453. private _maxRank;
  9454. private _mesh;
  9455. /**
  9456. * Removes the fallback from the bound mesh.
  9457. */
  9458. unBindMesh(): void;
  9459. /**
  9460. * Adds a fallback on the specified property.
  9461. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9462. * @param define The name of the define in the shader
  9463. */
  9464. addFallback(rank: number, define: string): void;
  9465. /**
  9466. * Sets the mesh to use CPU skinning when needing to fallback.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param mesh The mesh to use the fallbacks.
  9469. */
  9470. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9471. /**
  9472. * Checks to see if more fallbacks are still availible.
  9473. */
  9474. get hasMoreFallbacks(): boolean;
  9475. /**
  9476. * Removes the defines that should be removed when falling back.
  9477. * @param currentDefines defines the current define statements for the shader.
  9478. * @param effect defines the current effect we try to compile
  9479. * @returns The resulting defines with defines of the current rank removed.
  9480. */
  9481. reduce(currentDefines: string, effect: Effect): string;
  9482. }
  9483. }
  9484. declare module "babylonjs/Actions/action" {
  9485. import { Observable } from "babylonjs/Misc/observable";
  9486. import { Condition } from "babylonjs/Actions/condition";
  9487. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9488. import { Scene } from "babylonjs/scene";
  9489. import { ActionManager } from "babylonjs/Actions/actionManager";
  9490. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9491. import { Node } from "babylonjs/node";
  9492. /**
  9493. * Interface used to define Action
  9494. */
  9495. export interface IAction {
  9496. /**
  9497. * Trigger for the action
  9498. */
  9499. trigger: number;
  9500. /** Options of the trigger */
  9501. triggerOptions: any;
  9502. /**
  9503. * Gets the trigger parameters
  9504. * @returns the trigger parameters
  9505. */
  9506. getTriggerParameter(): any;
  9507. /**
  9508. * Internal only - executes current action event
  9509. * @hidden
  9510. */
  9511. _executeCurrent(evt?: ActionEvent): void;
  9512. /**
  9513. * Serialize placeholder for child classes
  9514. * @param parent of child
  9515. * @returns the serialized object
  9516. */
  9517. serialize(parent: any): any;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. _prepare(): void;
  9523. /**
  9524. * Internal only - manager for action
  9525. * @hidden
  9526. */
  9527. _actionManager: AbstractActionManager;
  9528. /**
  9529. * Adds action to chain of actions, may be a DoNothingAction
  9530. * @param action defines the next action to execute
  9531. * @returns The action passed in
  9532. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9533. */
  9534. then(action: IAction): IAction;
  9535. }
  9536. /**
  9537. * The action to be carried out following a trigger
  9538. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9539. */
  9540. export class Action implements IAction {
  9541. /** the trigger, with or without parameters, for the action */
  9542. triggerOptions: any;
  9543. /**
  9544. * Trigger for the action
  9545. */
  9546. trigger: number;
  9547. /**
  9548. * Internal only - manager for action
  9549. * @hidden
  9550. */
  9551. _actionManager: ActionManager;
  9552. private _nextActiveAction;
  9553. private _child;
  9554. private _condition?;
  9555. private _triggerParameter;
  9556. /**
  9557. * An event triggered prior to action being executed.
  9558. */
  9559. onBeforeExecuteObservable: Observable<Action>;
  9560. /**
  9561. * Creates a new Action
  9562. * @param triggerOptions the trigger, with or without parameters, for the action
  9563. * @param condition an optional determinant of action
  9564. */
  9565. constructor(
  9566. /** the trigger, with or without parameters, for the action */
  9567. triggerOptions: any, condition?: Condition);
  9568. /**
  9569. * Internal only
  9570. * @hidden
  9571. */
  9572. _prepare(): void;
  9573. /**
  9574. * Gets the trigger parameters
  9575. * @returns the trigger parameters
  9576. */
  9577. getTriggerParameter(): any;
  9578. /**
  9579. * Internal only - executes current action event
  9580. * @hidden
  9581. */
  9582. _executeCurrent(evt?: ActionEvent): void;
  9583. /**
  9584. * Execute placeholder for child classes
  9585. * @param evt optional action event
  9586. */
  9587. execute(evt?: ActionEvent): void;
  9588. /**
  9589. * Skips to next active action
  9590. */
  9591. skipToNextActiveAction(): void;
  9592. /**
  9593. * Adds action to chain of actions, may be a DoNothingAction
  9594. * @param action defines the next action to execute
  9595. * @returns The action passed in
  9596. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9597. */
  9598. then(action: Action): Action;
  9599. /**
  9600. * Internal only
  9601. * @hidden
  9602. */
  9603. _getProperty(propertyPath: string): string;
  9604. /**
  9605. * Internal only
  9606. * @hidden
  9607. */
  9608. _getEffectiveTarget(target: any, propertyPath: string): any;
  9609. /**
  9610. * Serialize placeholder for child classes
  9611. * @param parent of child
  9612. * @returns the serialized object
  9613. */
  9614. serialize(parent: any): any;
  9615. /**
  9616. * Internal only called by serialize
  9617. * @hidden
  9618. */
  9619. protected _serialize(serializedAction: any, parent?: any): any;
  9620. /**
  9621. * Internal only
  9622. * @hidden
  9623. */
  9624. static _SerializeValueAsString: (value: any) => string;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. static _GetTargetProperty: (target: Scene | Node) => {
  9630. name: string;
  9631. targetType: string;
  9632. value: string;
  9633. };
  9634. }
  9635. }
  9636. declare module "babylonjs/Actions/condition" {
  9637. import { ActionManager } from "babylonjs/Actions/actionManager";
  9638. /**
  9639. * A Condition applied to an Action
  9640. */
  9641. export class Condition {
  9642. /**
  9643. * Internal only - manager for action
  9644. * @hidden
  9645. */
  9646. _actionManager: ActionManager;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. _evaluationId: number;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. _currentResult: boolean;
  9657. /**
  9658. * Creates a new Condition
  9659. * @param actionManager the manager of the action the condition is applied to
  9660. */
  9661. constructor(actionManager: ActionManager);
  9662. /**
  9663. * Check if the current condition is valid
  9664. * @returns a boolean
  9665. */
  9666. isValid(): boolean;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. _getProperty(propertyPath: string): string;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. _getEffectiveTarget(target: any, propertyPath: string): any;
  9677. /**
  9678. * Serialize placeholder for child classes
  9679. * @returns the serialized object
  9680. */
  9681. serialize(): any;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. protected _serialize(serializedCondition: any): any;
  9687. }
  9688. /**
  9689. * Defines specific conditional operators as extensions of Condition
  9690. */
  9691. export class ValueCondition extends Condition {
  9692. /** path to specify the property of the target the conditional operator uses */
  9693. propertyPath: string;
  9694. /** the value compared by the conditional operator against the current value of the property */
  9695. value: any;
  9696. /** the conditional operator, default ValueCondition.IsEqual */
  9697. operator: number;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. private static _IsEqual;
  9703. /**
  9704. * Internal only
  9705. * @hidden
  9706. */
  9707. private static _IsDifferent;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private static _IsGreater;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private static _IsLesser;
  9718. /**
  9719. * returns the number for IsEqual
  9720. */
  9721. static get IsEqual(): number;
  9722. /**
  9723. * Returns the number for IsDifferent
  9724. */
  9725. static get IsDifferent(): number;
  9726. /**
  9727. * Returns the number for IsGreater
  9728. */
  9729. static get IsGreater(): number;
  9730. /**
  9731. * Returns the number for IsLesser
  9732. */
  9733. static get IsLesser(): number;
  9734. /**
  9735. * Internal only The action manager for the condition
  9736. * @hidden
  9737. */
  9738. _actionManager: ActionManager;
  9739. /**
  9740. * Internal only
  9741. * @hidden
  9742. */
  9743. private _target;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. private _effectiveTarget;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. private _property;
  9754. /**
  9755. * Creates a new ValueCondition
  9756. * @param actionManager manager for the action the condition applies to
  9757. * @param target for the action
  9758. * @param propertyPath path to specify the property of the target the conditional operator uses
  9759. * @param value the value compared by the conditional operator against the current value of the property
  9760. * @param operator the conditional operator, default ValueCondition.IsEqual
  9761. */
  9762. constructor(actionManager: ActionManager, target: any,
  9763. /** path to specify the property of the target the conditional operator uses */
  9764. propertyPath: string,
  9765. /** the value compared by the conditional operator against the current value of the property */
  9766. value: any,
  9767. /** the conditional operator, default ValueCondition.IsEqual */
  9768. operator?: number);
  9769. /**
  9770. * Compares the given value with the property value for the specified conditional operator
  9771. * @returns the result of the comparison
  9772. */
  9773. isValid(): boolean;
  9774. /**
  9775. * Serialize the ValueCondition into a JSON compatible object
  9776. * @returns serialization object
  9777. */
  9778. serialize(): any;
  9779. /**
  9780. * Gets the name of the conditional operator for the ValueCondition
  9781. * @param operator the conditional operator
  9782. * @returns the name
  9783. */
  9784. static GetOperatorName(operator: number): string;
  9785. }
  9786. /**
  9787. * Defines a predicate condition as an extension of Condition
  9788. */
  9789. export class PredicateCondition extends Condition {
  9790. /** defines the predicate function used to validate the condition */
  9791. predicate: () => boolean;
  9792. /**
  9793. * Internal only - manager for action
  9794. * @hidden
  9795. */
  9796. _actionManager: ActionManager;
  9797. /**
  9798. * Creates a new PredicateCondition
  9799. * @param actionManager manager for the action the condition applies to
  9800. * @param predicate defines the predicate function used to validate the condition
  9801. */
  9802. constructor(actionManager: ActionManager,
  9803. /** defines the predicate function used to validate the condition */
  9804. predicate: () => boolean);
  9805. /**
  9806. * @returns the validity of the predicate condition
  9807. */
  9808. isValid(): boolean;
  9809. }
  9810. /**
  9811. * Defines a state condition as an extension of Condition
  9812. */
  9813. export class StateCondition extends Condition {
  9814. /** Value to compare with target state */
  9815. value: string;
  9816. /**
  9817. * Internal only - manager for action
  9818. * @hidden
  9819. */
  9820. _actionManager: ActionManager;
  9821. /**
  9822. * Internal only
  9823. * @hidden
  9824. */
  9825. private _target;
  9826. /**
  9827. * Creates a new StateCondition
  9828. * @param actionManager manager for the action the condition applies to
  9829. * @param target of the condition
  9830. * @param value to compare with target state
  9831. */
  9832. constructor(actionManager: ActionManager, target: any,
  9833. /** Value to compare with target state */
  9834. value: string);
  9835. /**
  9836. * Gets a boolean indicating if the current condition is met
  9837. * @returns the validity of the state
  9838. */
  9839. isValid(): boolean;
  9840. /**
  9841. * Serialize the StateCondition into a JSON compatible object
  9842. * @returns serialization object
  9843. */
  9844. serialize(): any;
  9845. }
  9846. }
  9847. declare module "babylonjs/Actions/directActions" {
  9848. import { Action } from "babylonjs/Actions/action";
  9849. import { Condition } from "babylonjs/Actions/condition";
  9850. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9851. /**
  9852. * This defines an action responsible to toggle a boolean once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class SwitchBooleanAction extends Action {
  9856. /**
  9857. * The path to the boolean property in the target object
  9858. */
  9859. propertyPath: string;
  9860. private _target;
  9861. private _effectiveTarget;
  9862. private _property;
  9863. /**
  9864. * Instantiate the action
  9865. * @param triggerOptions defines the trigger options
  9866. * @param target defines the object containing the boolean
  9867. * @param propertyPath defines the path to the boolean property in the target object
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9871. /** @hidden */
  9872. _prepare(): void;
  9873. /**
  9874. * Execute the action toggle the boolean value.
  9875. */
  9876. execute(): void;
  9877. /**
  9878. * Serializes the actions and its related information.
  9879. * @param parent defines the object to serialize in
  9880. * @returns the serialized object
  9881. */
  9882. serialize(parent: any): any;
  9883. }
  9884. /**
  9885. * This defines an action responsible to set a the state field of the target
  9886. * to a desired value once triggered.
  9887. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9888. */
  9889. export class SetStateAction extends Action {
  9890. /**
  9891. * The value to store in the state field.
  9892. */
  9893. value: string;
  9894. private _target;
  9895. /**
  9896. * Instantiate the action
  9897. * @param triggerOptions defines the trigger options
  9898. * @param target defines the object containing the state property
  9899. * @param value defines the value to store in the state field
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9903. /**
  9904. * Execute the action and store the value on the target state property.
  9905. */
  9906. execute(): void;
  9907. /**
  9908. * Serializes the actions and its related information.
  9909. * @param parent defines the object to serialize in
  9910. * @returns the serialized object
  9911. */
  9912. serialize(parent: any): any;
  9913. }
  9914. /**
  9915. * This defines an action responsible to set a property of the target
  9916. * to a desired value once triggered.
  9917. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9918. */
  9919. export class SetValueAction extends Action {
  9920. /**
  9921. * The path of the property to set in the target.
  9922. */
  9923. propertyPath: string;
  9924. /**
  9925. * The value to set in the property
  9926. */
  9927. value: any;
  9928. private _target;
  9929. private _effectiveTarget;
  9930. private _property;
  9931. /**
  9932. * Instantiate the action
  9933. * @param triggerOptions defines the trigger options
  9934. * @param target defines the object containing the property
  9935. * @param propertyPath defines the path of the property to set in the target
  9936. * @param value defines the value to set in the property
  9937. * @param condition defines the trigger related conditions
  9938. */
  9939. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9940. /** @hidden */
  9941. _prepare(): void;
  9942. /**
  9943. * Execute the action and set the targetted property to the desired value.
  9944. */
  9945. execute(): void;
  9946. /**
  9947. * Serializes the actions and its related information.
  9948. * @param parent defines the object to serialize in
  9949. * @returns the serialized object
  9950. */
  9951. serialize(parent: any): any;
  9952. }
  9953. /**
  9954. * This defines an action responsible to increment the target value
  9955. * to a desired value once triggered.
  9956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class IncrementValueAction extends Action {
  9959. /**
  9960. * The path of the property to increment in the target.
  9961. */
  9962. propertyPath: string;
  9963. /**
  9964. * The value we should increment the property by.
  9965. */
  9966. value: any;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the property
  9974. * @param propertyPath defines the path of the property to increment in the target
  9975. * @param value defines the value value we should increment the property by
  9976. * @param condition defines the trigger related conditions
  9977. */
  9978. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9979. /** @hidden */
  9980. _prepare(): void;
  9981. /**
  9982. * Execute the action and increment the target of the value amount.
  9983. */
  9984. execute(): void;
  9985. /**
  9986. * Serializes the actions and its related information.
  9987. * @param parent defines the object to serialize in
  9988. * @returns the serialized object
  9989. */
  9990. serialize(parent: any): any;
  9991. }
  9992. /**
  9993. * This defines an action responsible to start an animation once triggered.
  9994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9995. */
  9996. export class PlayAnimationAction extends Action {
  9997. /**
  9998. * Where the animation should start (animation frame)
  9999. */
  10000. from: number;
  10001. /**
  10002. * Where the animation should stop (animation frame)
  10003. */
  10004. to: number;
  10005. /**
  10006. * Define if the animation should loop or stop after the first play.
  10007. */
  10008. loop?: boolean;
  10009. private _target;
  10010. /**
  10011. * Instantiate the action
  10012. * @param triggerOptions defines the trigger options
  10013. * @param target defines the target animation or animation name
  10014. * @param from defines from where the animation should start (animation frame)
  10015. * @param end defines where the animation should stop (animation frame)
  10016. * @param loop defines if the animation should loop or stop after the first play
  10017. * @param condition defines the trigger related conditions
  10018. */
  10019. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10020. /** @hidden */
  10021. _prepare(): void;
  10022. /**
  10023. * Execute the action and play the animation.
  10024. */
  10025. execute(): void;
  10026. /**
  10027. * Serializes the actions and its related information.
  10028. * @param parent defines the object to serialize in
  10029. * @returns the serialized object
  10030. */
  10031. serialize(parent: any): any;
  10032. }
  10033. /**
  10034. * This defines an action responsible to stop an animation once triggered.
  10035. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10036. */
  10037. export class StopAnimationAction extends Action {
  10038. private _target;
  10039. /**
  10040. * Instantiate the action
  10041. * @param triggerOptions defines the trigger options
  10042. * @param target defines the target animation or animation name
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and stop the animation.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible that does nothing once triggered.
  10061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10062. */
  10063. export class DoNothingAction extends Action {
  10064. /**
  10065. * Instantiate the action
  10066. * @param triggerOptions defines the trigger options
  10067. * @param condition defines the trigger related conditions
  10068. */
  10069. constructor(triggerOptions?: any, condition?: Condition);
  10070. /**
  10071. * Execute the action and do nothing.
  10072. */
  10073. execute(): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. /**
  10082. * This defines an action responsible to trigger several actions once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class CombineAction extends Action {
  10086. /**
  10087. * The list of aggregated animations to run.
  10088. */
  10089. children: Action[];
  10090. /**
  10091. * Instantiate the action
  10092. * @param triggerOptions defines the trigger options
  10093. * @param children defines the list of aggregated animations to run
  10094. * @param condition defines the trigger related conditions
  10095. */
  10096. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10097. /** @hidden */
  10098. _prepare(): void;
  10099. /**
  10100. * Execute the action and executes all the aggregated actions.
  10101. */
  10102. execute(evt: ActionEvent): void;
  10103. /**
  10104. * Serializes the actions and its related information.
  10105. * @param parent defines the object to serialize in
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. }
  10110. /**
  10111. * This defines an action responsible to run code (external event) once triggered.
  10112. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10113. */
  10114. export class ExecuteCodeAction extends Action {
  10115. /**
  10116. * The callback function to run.
  10117. */
  10118. func: (evt: ActionEvent) => void;
  10119. /**
  10120. * Instantiate the action
  10121. * @param triggerOptions defines the trigger options
  10122. * @param func defines the callback function to run
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10126. /**
  10127. * Execute the action and run the attached code.
  10128. */
  10129. execute(evt: ActionEvent): void;
  10130. }
  10131. /**
  10132. * This defines an action responsible to set the parent property of the target once triggered.
  10133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class SetParentAction extends Action {
  10136. private _parent;
  10137. private _target;
  10138. /**
  10139. * Instantiate the action
  10140. * @param triggerOptions defines the trigger options
  10141. * @param target defines the target containing the parent property
  10142. * @param parent defines from where the animation should start (animation frame)
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and set the parent property.
  10150. */
  10151. execute(): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. }
  10160. declare module "babylonjs/Actions/actionManager" {
  10161. import { Nullable } from "babylonjs/types";
  10162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10163. import { Scene } from "babylonjs/scene";
  10164. import { IAction } from "babylonjs/Actions/action";
  10165. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. /**
  10168. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10169. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10171. */
  10172. export class ActionManager extends AbstractActionManager {
  10173. /**
  10174. * Nothing
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly NothingTrigger: number;
  10178. /**
  10179. * On pick
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnPickTrigger: number;
  10183. /**
  10184. * On left pick
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnLeftPickTrigger: number;
  10188. /**
  10189. * On right pick
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnRightPickTrigger: number;
  10193. /**
  10194. * On center pick
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnCenterPickTrigger: number;
  10198. /**
  10199. * On pick down
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnPickDownTrigger: number;
  10203. /**
  10204. * On double pick
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnDoublePickTrigger: number;
  10208. /**
  10209. * On pick up
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnPickUpTrigger: number;
  10213. /**
  10214. * On pick out.
  10215. * This trigger will only be raised if you also declared a OnPickDown
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnPickOutTrigger: number;
  10219. /**
  10220. * On long press
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnLongPressTrigger: number;
  10224. /**
  10225. * On pointer over
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10227. */
  10228. static readonly OnPointerOverTrigger: number;
  10229. /**
  10230. * On pointer out
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10232. */
  10233. static readonly OnPointerOutTrigger: number;
  10234. /**
  10235. * On every frame
  10236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10237. */
  10238. static readonly OnEveryFrameTrigger: number;
  10239. /**
  10240. * On intersection enter
  10241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10242. */
  10243. static readonly OnIntersectionEnterTrigger: number;
  10244. /**
  10245. * On intersection exit
  10246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10247. */
  10248. static readonly OnIntersectionExitTrigger: number;
  10249. /**
  10250. * On key down
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10252. */
  10253. static readonly OnKeyDownTrigger: number;
  10254. /**
  10255. * On key up
  10256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10257. */
  10258. static readonly OnKeyUpTrigger: number;
  10259. private _scene;
  10260. /**
  10261. * Creates a new action manager
  10262. * @param scene defines the hosting scene
  10263. */
  10264. constructor(scene: Scene);
  10265. /**
  10266. * Releases all associated resources
  10267. */
  10268. dispose(): void;
  10269. /**
  10270. * Gets hosting scene
  10271. * @returns the hosting scene
  10272. */
  10273. getScene(): Scene;
  10274. /**
  10275. * Does this action manager handles actions of any of the given triggers
  10276. * @param triggers defines the triggers to be tested
  10277. * @return a boolean indicating whether one (or more) of the triggers is handled
  10278. */
  10279. hasSpecificTriggers(triggers: number[]): boolean;
  10280. /**
  10281. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10282. * speed.
  10283. * @param triggerA defines the trigger to be tested
  10284. * @param triggerB defines the trigger to be tested
  10285. * @return a boolean indicating whether one (or more) of the triggers is handled
  10286. */
  10287. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10288. /**
  10289. * Does this action manager handles actions of a given trigger
  10290. * @param trigger defines the trigger to be tested
  10291. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10292. * @return whether the trigger is handled
  10293. */
  10294. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10295. /**
  10296. * Does this action manager has pointer triggers
  10297. */
  10298. get hasPointerTriggers(): boolean;
  10299. /**
  10300. * Does this action manager has pick triggers
  10301. */
  10302. get hasPickTriggers(): boolean;
  10303. /**
  10304. * Registers an action to this action manager
  10305. * @param action defines the action to be registered
  10306. * @return the action amended (prepared) after registration
  10307. */
  10308. registerAction(action: IAction): Nullable<IAction>;
  10309. /**
  10310. * Unregisters an action to this action manager
  10311. * @param action defines the action to be unregistered
  10312. * @return a boolean indicating whether the action has been unregistered
  10313. */
  10314. unregisterAction(action: IAction): Boolean;
  10315. /**
  10316. * Process a specific trigger
  10317. * @param trigger defines the trigger to process
  10318. * @param evt defines the event details to be processed
  10319. */
  10320. processTrigger(trigger: number, evt?: IActionEvent): void;
  10321. /** @hidden */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /** @hidden */
  10324. _getProperty(propertyPath: string): string;
  10325. /**
  10326. * Serialize this manager to a JSON object
  10327. * @param name defines the property name to store this manager
  10328. * @returns a JSON representation of this manager
  10329. */
  10330. serialize(name: string): any;
  10331. /**
  10332. * Creates a new ActionManager from a JSON data
  10333. * @param parsedActions defines the JSON data to read from
  10334. * @param object defines the hosting mesh
  10335. * @param scene defines the hosting scene
  10336. */
  10337. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10338. /**
  10339. * Get a trigger name by index
  10340. * @param trigger defines the trigger index
  10341. * @returns a trigger name
  10342. */
  10343. static GetTriggerName(trigger: number): string;
  10344. }
  10345. }
  10346. declare module "babylonjs/Sprites/sprite" {
  10347. import { Vector3 } from "babylonjs/Maths/math.vector";
  10348. import { Nullable } from "babylonjs/types";
  10349. import { ActionManager } from "babylonjs/Actions/actionManager";
  10350. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10351. import { Color4 } from "babylonjs/Maths/math.color";
  10352. import { Observable } from "babylonjs/Misc/observable";
  10353. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10354. import { Animation } from "babylonjs/Animations/animation";
  10355. /**
  10356. * Class used to represent a sprite
  10357. * @see https://doc.babylonjs.com/babylon101/sprites
  10358. */
  10359. export class Sprite implements IAnimatable {
  10360. /** defines the name */
  10361. name: string;
  10362. /** Gets or sets the current world position */
  10363. position: Vector3;
  10364. /** Gets or sets the main color */
  10365. color: Color4;
  10366. /** Gets or sets the width */
  10367. width: number;
  10368. /** Gets or sets the height */
  10369. height: number;
  10370. /** Gets or sets rotation angle */
  10371. angle: number;
  10372. /** Gets or sets the cell index in the sprite sheet */
  10373. cellIndex: number;
  10374. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10375. cellRef: string;
  10376. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10377. invertU: boolean;
  10378. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10379. invertV: boolean;
  10380. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10381. disposeWhenFinishedAnimating: boolean;
  10382. /** Gets the list of attached animations */
  10383. animations: Nullable<Array<Animation>>;
  10384. /** Gets or sets a boolean indicating if the sprite can be picked */
  10385. isPickable: boolean;
  10386. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10387. useAlphaForPicking: boolean;
  10388. /** @hidden */
  10389. _xOffset: number;
  10390. /** @hidden */
  10391. _yOffset: number;
  10392. /** @hidden */
  10393. _xSize: number;
  10394. /** @hidden */
  10395. _ySize: number;
  10396. /**
  10397. * Gets or sets the associated action manager
  10398. */
  10399. actionManager: Nullable<ActionManager>;
  10400. /**
  10401. * An event triggered when the control has been disposed
  10402. */
  10403. onDisposeObservable: Observable<Sprite>;
  10404. private _animationStarted;
  10405. private _loopAnimation;
  10406. private _fromIndex;
  10407. private _toIndex;
  10408. private _delay;
  10409. private _direction;
  10410. private _manager;
  10411. private _time;
  10412. private _onAnimationEnd;
  10413. /**
  10414. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10415. */
  10416. isVisible: boolean;
  10417. /**
  10418. * Gets or sets the sprite size
  10419. */
  10420. get size(): number;
  10421. set size(value: number);
  10422. /**
  10423. * Returns a boolean indicating if the animation is started
  10424. */
  10425. get animationStarted(): boolean;
  10426. /**
  10427. * Gets or sets the unique id of the sprite
  10428. */
  10429. uniqueId: number;
  10430. /**
  10431. * Gets the manager of this sprite
  10432. */
  10433. get manager(): ISpriteManager;
  10434. /**
  10435. * Creates a new Sprite
  10436. * @param name defines the name
  10437. * @param manager defines the manager
  10438. */
  10439. constructor(
  10440. /** defines the name */
  10441. name: string, manager: ISpriteManager);
  10442. /**
  10443. * Returns the string "Sprite"
  10444. * @returns "Sprite"
  10445. */
  10446. getClassName(): string;
  10447. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10448. get fromIndex(): number;
  10449. set fromIndex(value: number);
  10450. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10451. get toIndex(): number;
  10452. set toIndex(value: number);
  10453. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10454. get loopAnimation(): boolean;
  10455. set loopAnimation(value: boolean);
  10456. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10457. get delay(): number;
  10458. set delay(value: number);
  10459. /**
  10460. * Starts an animation
  10461. * @param from defines the initial key
  10462. * @param to defines the end key
  10463. * @param loop defines if the animation must loop
  10464. * @param delay defines the start delay (in ms)
  10465. * @param onAnimationEnd defines a callback to call when animation ends
  10466. */
  10467. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10468. /** Stops current animation (if any) */
  10469. stopAnimation(): void;
  10470. /** @hidden */
  10471. _animate(deltaTime: number): void;
  10472. /** Release associated resources */
  10473. dispose(): void;
  10474. /**
  10475. * Serializes the sprite to a JSON object
  10476. * @returns the JSON object
  10477. */
  10478. serialize(): any;
  10479. /**
  10480. * Parses a JSON object to create a new sprite
  10481. * @param parsedSprite The JSON object to parse
  10482. * @param manager defines the hosting manager
  10483. * @returns the new sprite
  10484. */
  10485. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10486. }
  10487. }
  10488. declare module "babylonjs/Collisions/pickingInfo" {
  10489. import { Nullable } from "babylonjs/types";
  10490. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10492. import { Sprite } from "babylonjs/Sprites/sprite";
  10493. import { Ray } from "babylonjs/Culling/ray";
  10494. /**
  10495. * Information about the result of picking within a scene
  10496. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10497. */
  10498. export class PickingInfo {
  10499. /** @hidden */
  10500. _pickingUnavailable: boolean;
  10501. /**
  10502. * If the pick collided with an object
  10503. */
  10504. hit: boolean;
  10505. /**
  10506. * Distance away where the pick collided
  10507. */
  10508. distance: number;
  10509. /**
  10510. * The location of pick collision
  10511. */
  10512. pickedPoint: Nullable<Vector3>;
  10513. /**
  10514. * The mesh corresponding the the pick collision
  10515. */
  10516. pickedMesh: Nullable<AbstractMesh>;
  10517. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10518. bu: number;
  10519. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10520. bv: number;
  10521. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10522. faceId: number;
  10523. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10524. subMeshFaceId: number;
  10525. /** Id of the the submesh that was picked */
  10526. subMeshId: number;
  10527. /** If a sprite was picked, this will be the sprite the pick collided with */
  10528. pickedSprite: Nullable<Sprite>;
  10529. /**
  10530. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10531. */
  10532. originMesh: Nullable<AbstractMesh>;
  10533. /**
  10534. * The ray that was used to perform the picking.
  10535. */
  10536. ray: Nullable<Ray>;
  10537. /**
  10538. * Gets the normal correspodning to the face the pick collided with
  10539. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10540. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10541. * @returns The normal correspodning to the face the pick collided with
  10542. */
  10543. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10544. /**
  10545. * Gets the texture coordinates of where the pick occured
  10546. * @returns the vector containing the coordnates of the texture
  10547. */
  10548. getTextureCoordinates(): Nullable<Vector2>;
  10549. }
  10550. }
  10551. declare module "babylonjs/Culling/ray" {
  10552. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10555. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10556. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10557. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10558. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10559. import { Plane } from "babylonjs/Maths/math.plane";
  10560. /**
  10561. * Class representing a ray with position and direction
  10562. */
  10563. export class Ray {
  10564. /** origin point */
  10565. origin: Vector3;
  10566. /** direction */
  10567. direction: Vector3;
  10568. /** length of the ray */
  10569. length: number;
  10570. private static readonly TmpVector3;
  10571. private _tmpRay;
  10572. /**
  10573. * Creates a new ray
  10574. * @param origin origin point
  10575. * @param direction direction
  10576. * @param length length of the ray
  10577. */
  10578. constructor(
  10579. /** origin point */
  10580. origin: Vector3,
  10581. /** direction */
  10582. direction: Vector3,
  10583. /** length of the ray */
  10584. length?: number);
  10585. /**
  10586. * Checks if the ray intersects a box
  10587. * This does not account for the ray lenght by design to improve perfs.
  10588. * @param minimum bound of the box
  10589. * @param maximum bound of the box
  10590. * @param intersectionTreshold extra extend to be added to the box in all direction
  10591. * @returns if the box was hit
  10592. */
  10593. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10594. /**
  10595. * Checks if the ray intersects a box
  10596. * This does not account for the ray lenght by design to improve perfs.
  10597. * @param box the bounding box to check
  10598. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10599. * @returns if the box was hit
  10600. */
  10601. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10602. /**
  10603. * If the ray hits a sphere
  10604. * @param sphere the bounding sphere to check
  10605. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10606. * @returns true if it hits the sphere
  10607. */
  10608. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10609. /**
  10610. * If the ray hits a triange
  10611. * @param vertex0 triangle vertex
  10612. * @param vertex1 triangle vertex
  10613. * @param vertex2 triangle vertex
  10614. * @returns intersection information if hit
  10615. */
  10616. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10617. /**
  10618. * Checks if ray intersects a plane
  10619. * @param plane the plane to check
  10620. * @returns the distance away it was hit
  10621. */
  10622. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10623. /**
  10624. * Calculate the intercept of a ray on a given axis
  10625. * @param axis to check 'x' | 'y' | 'z'
  10626. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10627. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10628. */
  10629. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10630. /**
  10631. * Checks if ray intersects a mesh
  10632. * @param mesh the mesh to check
  10633. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10634. * @returns picking info of the intersecton
  10635. */
  10636. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10637. /**
  10638. * Checks if ray intersects a mesh
  10639. * @param meshes the meshes to check
  10640. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10641. * @param results array to store result in
  10642. * @returns Array of picking infos
  10643. */
  10644. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10645. private _comparePickingInfo;
  10646. private static smallnum;
  10647. private static rayl;
  10648. /**
  10649. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10650. * @param sega the first point of the segment to test the intersection against
  10651. * @param segb the second point of the segment to test the intersection against
  10652. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10653. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10654. */
  10655. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10656. /**
  10657. * Update the ray from viewport position
  10658. * @param x position
  10659. * @param y y position
  10660. * @param viewportWidth viewport width
  10661. * @param viewportHeight viewport height
  10662. * @param world world matrix
  10663. * @param view view matrix
  10664. * @param projection projection matrix
  10665. * @returns this ray updated
  10666. */
  10667. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10668. /**
  10669. * Creates a ray with origin and direction of 0,0,0
  10670. * @returns the new ray
  10671. */
  10672. static Zero(): Ray;
  10673. /**
  10674. * Creates a new ray from screen space and viewport
  10675. * @param x position
  10676. * @param y y position
  10677. * @param viewportWidth viewport width
  10678. * @param viewportHeight viewport height
  10679. * @param world world matrix
  10680. * @param view view matrix
  10681. * @param projection projection matrix
  10682. * @returns new ray
  10683. */
  10684. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10685. /**
  10686. * 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
  10687. * transformed to the given world matrix.
  10688. * @param origin The origin point
  10689. * @param end The end point
  10690. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10691. * @returns the new ray
  10692. */
  10693. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10694. /**
  10695. * Transforms a ray by a matrix
  10696. * @param ray ray to transform
  10697. * @param matrix matrix to apply
  10698. * @returns the resulting new ray
  10699. */
  10700. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10701. /**
  10702. * Transforms a ray by a matrix
  10703. * @param ray ray to transform
  10704. * @param matrix matrix to apply
  10705. * @param result ray to store result in
  10706. */
  10707. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10708. /**
  10709. * Unproject a ray from screen space to object space
  10710. * @param sourceX defines the screen space x coordinate to use
  10711. * @param sourceY defines the screen space y coordinate to use
  10712. * @param viewportWidth defines the current width of the viewport
  10713. * @param viewportHeight defines the current height of the viewport
  10714. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10715. * @param view defines the view matrix to use
  10716. * @param projection defines the projection matrix to use
  10717. */
  10718. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10719. }
  10720. /**
  10721. * Type used to define predicate used to select faces when a mesh intersection is detected
  10722. */
  10723. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10724. module "babylonjs/scene" {
  10725. interface Scene {
  10726. /** @hidden */
  10727. _tempPickingRay: Nullable<Ray>;
  10728. /** @hidden */
  10729. _cachedRayForTransform: Ray;
  10730. /** @hidden */
  10731. _pickWithRayInverseMatrix: Matrix;
  10732. /** @hidden */
  10733. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10734. /** @hidden */
  10735. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10736. }
  10737. }
  10738. }
  10739. declare module "babylonjs/sceneComponent" {
  10740. import { Scene } from "babylonjs/scene";
  10741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10743. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10744. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10745. import { Nullable } from "babylonjs/types";
  10746. import { Camera } from "babylonjs/Cameras/camera";
  10747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10748. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10749. import { AbstractScene } from "babylonjs/abstractScene";
  10750. import { Mesh } from "babylonjs/Meshes/mesh";
  10751. /**
  10752. * Groups all the scene component constants in one place to ease maintenance.
  10753. * @hidden
  10754. */
  10755. export class SceneComponentConstants {
  10756. static readonly NAME_EFFECTLAYER: string;
  10757. static readonly NAME_LAYER: string;
  10758. static readonly NAME_LENSFLARESYSTEM: string;
  10759. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10760. static readonly NAME_PARTICLESYSTEM: string;
  10761. static readonly NAME_GAMEPAD: string;
  10762. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10763. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10764. static readonly NAME_PREPASSRENDERER: string;
  10765. static readonly NAME_DEPTHRENDERER: string;
  10766. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10767. static readonly NAME_SPRITE: string;
  10768. static readonly NAME_OUTLINERENDERER: string;
  10769. static readonly NAME_PROCEDURALTEXTURE: string;
  10770. static readonly NAME_SHADOWGENERATOR: string;
  10771. static readonly NAME_OCTREE: string;
  10772. static readonly NAME_PHYSICSENGINE: string;
  10773. static readonly NAME_AUDIO: string;
  10774. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10775. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10776. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10777. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10778. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10779. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10780. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10781. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10782. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10783. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10784. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10785. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10786. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10787. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10788. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10789. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10790. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10791. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10792. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10793. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10794. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10795. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10796. static readonly STEP_AFTERRENDER_AUDIO: number;
  10797. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10798. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10799. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10800. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10801. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10802. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10803. static readonly STEP_POINTERMOVE_SPRITE: number;
  10804. static readonly STEP_POINTERDOWN_SPRITE: number;
  10805. static readonly STEP_POINTERUP_SPRITE: number;
  10806. }
  10807. /**
  10808. * This represents a scene component.
  10809. *
  10810. * This is used to decouple the dependency the scene is having on the different workloads like
  10811. * layers, post processes...
  10812. */
  10813. export interface ISceneComponent {
  10814. /**
  10815. * The name of the component. Each component must have a unique name.
  10816. */
  10817. name: string;
  10818. /**
  10819. * The scene the component belongs to.
  10820. */
  10821. scene: Scene;
  10822. /**
  10823. * Register the component to one instance of a scene.
  10824. */
  10825. register(): void;
  10826. /**
  10827. * Rebuilds the elements related to this component in case of
  10828. * context lost for instance.
  10829. */
  10830. rebuild(): void;
  10831. /**
  10832. * Disposes the component and the associated ressources.
  10833. */
  10834. dispose(): void;
  10835. }
  10836. /**
  10837. * This represents a SERIALIZABLE scene component.
  10838. *
  10839. * This extends Scene Component to add Serialization methods on top.
  10840. */
  10841. export interface ISceneSerializableComponent extends ISceneComponent {
  10842. /**
  10843. * Adds all the elements from the container to the scene
  10844. * @param container the container holding the elements
  10845. */
  10846. addFromContainer(container: AbstractScene): void;
  10847. /**
  10848. * Removes all the elements in the container from the scene
  10849. * @param container contains the elements to remove
  10850. * @param dispose if the removed element should be disposed (default: false)
  10851. */
  10852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10853. /**
  10854. * Serializes the component data to the specified json object
  10855. * @param serializationObject The object to serialize to
  10856. */
  10857. serialize(serializationObject: any): void;
  10858. }
  10859. /**
  10860. * Strong typing of a Mesh related stage step action
  10861. */
  10862. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10863. /**
  10864. * Strong typing of a Evaluate Sub Mesh related stage step action
  10865. */
  10866. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10867. /**
  10868. * Strong typing of a Active Mesh related stage step action
  10869. */
  10870. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10871. /**
  10872. * Strong typing of a Camera related stage step action
  10873. */
  10874. export type CameraStageAction = (camera: Camera) => void;
  10875. /**
  10876. * Strong typing of a Camera Frame buffer related stage step action
  10877. */
  10878. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10879. /**
  10880. * Strong typing of a Render Target related stage step action
  10881. */
  10882. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10883. /**
  10884. * Strong typing of a RenderingGroup related stage step action
  10885. */
  10886. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10887. /**
  10888. * Strong typing of a Mesh Render related stage step action
  10889. */
  10890. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10891. /**
  10892. * Strong typing of a simple stage step action
  10893. */
  10894. export type SimpleStageAction = () => void;
  10895. /**
  10896. * Strong typing of a render target action.
  10897. */
  10898. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10899. /**
  10900. * Strong typing of a pointer move action.
  10901. */
  10902. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10903. /**
  10904. * Strong typing of a pointer up/down action.
  10905. */
  10906. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10907. /**
  10908. * Representation of a stage in the scene (Basically a list of ordered steps)
  10909. * @hidden
  10910. */
  10911. export class Stage<T extends Function> extends Array<{
  10912. index: number;
  10913. component: ISceneComponent;
  10914. action: T;
  10915. }> {
  10916. /**
  10917. * Hide ctor from the rest of the world.
  10918. * @param items The items to add.
  10919. */
  10920. private constructor();
  10921. /**
  10922. * Creates a new Stage.
  10923. * @returns A new instance of a Stage
  10924. */
  10925. static Create<T extends Function>(): Stage<T>;
  10926. /**
  10927. * Registers a step in an ordered way in the targeted stage.
  10928. * @param index Defines the position to register the step in
  10929. * @param component Defines the component attached to the step
  10930. * @param action Defines the action to launch during the step
  10931. */
  10932. registerStep(index: number, component: ISceneComponent, action: T): void;
  10933. /**
  10934. * Clears all the steps from the stage.
  10935. */
  10936. clear(): void;
  10937. }
  10938. }
  10939. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10940. import { Nullable } from "babylonjs/types";
  10941. import { Observable } from "babylonjs/Misc/observable";
  10942. import { Scene } from "babylonjs/scene";
  10943. import { Sprite } from "babylonjs/Sprites/sprite";
  10944. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10945. import { Ray } from "babylonjs/Culling/ray";
  10946. import { Camera } from "babylonjs/Cameras/camera";
  10947. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10948. import { ISceneComponent } from "babylonjs/sceneComponent";
  10949. module "babylonjs/scene" {
  10950. interface Scene {
  10951. /** @hidden */
  10952. _pointerOverSprite: Nullable<Sprite>;
  10953. /** @hidden */
  10954. _pickedDownSprite: Nullable<Sprite>;
  10955. /** @hidden */
  10956. _tempSpritePickingRay: Nullable<Ray>;
  10957. /**
  10958. * All of the sprite managers added to this scene
  10959. * @see https://doc.babylonjs.com/babylon101/sprites
  10960. */
  10961. spriteManagers: Array<ISpriteManager>;
  10962. /**
  10963. * An event triggered when sprites rendering is about to start
  10964. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10965. */
  10966. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10967. /**
  10968. * An event triggered when sprites rendering is done
  10969. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10970. */
  10971. onAfterSpritesRenderingObservable: Observable<Scene>;
  10972. /** @hidden */
  10973. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10974. /** Launch a ray to try to pick a sprite in the scene
  10975. * @param x position on screen
  10976. * @param y position on screen
  10977. * @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
  10978. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10979. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10980. * @returns a PickingInfo
  10981. */
  10982. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10983. /** Use the given ray to pick a sprite in the scene
  10984. * @param ray The ray (in world space) to use to pick meshes
  10985. * @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
  10986. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10987. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10988. * @returns a PickingInfo
  10989. */
  10990. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10991. /** @hidden */
  10992. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10993. /** Launch a ray to try to pick sprites in the scene
  10994. * @param x position on screen
  10995. * @param y position on screen
  10996. * @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
  10997. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10998. * @returns a PickingInfo array
  10999. */
  11000. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11001. /** Use the given ray to pick sprites in the scene
  11002. * @param ray The ray (in world space) to use to pick meshes
  11003. * @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
  11004. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11005. * @returns a PickingInfo array
  11006. */
  11007. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11008. /**
  11009. * Force the sprite under the pointer
  11010. * @param sprite defines the sprite to use
  11011. */
  11012. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11013. /**
  11014. * Gets the sprite under the pointer
  11015. * @returns a Sprite or null if no sprite is under the pointer
  11016. */
  11017. getPointerOverSprite(): Nullable<Sprite>;
  11018. }
  11019. }
  11020. /**
  11021. * Defines the sprite scene component responsible to manage sprites
  11022. * in a given scene.
  11023. */
  11024. export class SpriteSceneComponent implements ISceneComponent {
  11025. /**
  11026. * The component name helpfull to identify the component in the list of scene components.
  11027. */
  11028. readonly name: string;
  11029. /**
  11030. * The scene the component belongs to.
  11031. */
  11032. scene: Scene;
  11033. /** @hidden */
  11034. private _spritePredicate;
  11035. /**
  11036. * Creates a new instance of the component for the given scene
  11037. * @param scene Defines the scene to register the component in
  11038. */
  11039. constructor(scene: Scene);
  11040. /**
  11041. * Registers the component in a given scene
  11042. */
  11043. register(): void;
  11044. /**
  11045. * Rebuilds the elements related to this component in case of
  11046. * context lost for instance.
  11047. */
  11048. rebuild(): void;
  11049. /**
  11050. * Disposes the component and the associated ressources.
  11051. */
  11052. dispose(): void;
  11053. private _pickSpriteButKeepRay;
  11054. private _pointerMove;
  11055. private _pointerDown;
  11056. private _pointerUp;
  11057. }
  11058. }
  11059. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11060. /** @hidden */
  11061. export var fogFragmentDeclaration: {
  11062. name: string;
  11063. shader: string;
  11064. };
  11065. }
  11066. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11067. /** @hidden */
  11068. export var fogFragment: {
  11069. name: string;
  11070. shader: string;
  11071. };
  11072. }
  11073. declare module "babylonjs/Shaders/sprites.fragment" {
  11074. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11075. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11076. /** @hidden */
  11077. export var spritesPixelShader: {
  11078. name: string;
  11079. shader: string;
  11080. };
  11081. }
  11082. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11083. /** @hidden */
  11084. export var fogVertexDeclaration: {
  11085. name: string;
  11086. shader: string;
  11087. };
  11088. }
  11089. declare module "babylonjs/Shaders/sprites.vertex" {
  11090. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11091. /** @hidden */
  11092. export var spritesVertexShader: {
  11093. name: string;
  11094. shader: string;
  11095. };
  11096. }
  11097. declare module "babylonjs/Sprites/spriteManager" {
  11098. import { IDisposable, Scene } from "babylonjs/scene";
  11099. import { Nullable } from "babylonjs/types";
  11100. import { Observable } from "babylonjs/Misc/observable";
  11101. import { Sprite } from "babylonjs/Sprites/sprite";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { Camera } from "babylonjs/Cameras/camera";
  11104. import { Texture } from "babylonjs/Materials/Textures/texture";
  11105. import "babylonjs/Shaders/sprites.fragment";
  11106. import "babylonjs/Shaders/sprites.vertex";
  11107. import { Ray } from "babylonjs/Culling/ray";
  11108. /**
  11109. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11110. */
  11111. export interface ISpriteManager extends IDisposable {
  11112. /**
  11113. * Gets manager's name
  11114. */
  11115. name: string;
  11116. /**
  11117. * Restricts the camera to viewing objects with the same layerMask.
  11118. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11119. */
  11120. layerMask: number;
  11121. /**
  11122. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11123. */
  11124. isPickable: boolean;
  11125. /**
  11126. * Gets the hosting scene
  11127. */
  11128. scene: Scene;
  11129. /**
  11130. * Specifies the rendering group id for this mesh (0 by default)
  11131. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11132. */
  11133. renderingGroupId: number;
  11134. /**
  11135. * Defines the list of sprites managed by the manager.
  11136. */
  11137. sprites: Array<Sprite>;
  11138. /**
  11139. * Gets or sets the spritesheet texture
  11140. */
  11141. texture: Texture;
  11142. /** Defines the default width of a cell in the spritesheet */
  11143. cellWidth: number;
  11144. /** Defines the default height of a cell in the spritesheet */
  11145. cellHeight: number;
  11146. /**
  11147. * Tests the intersection of a sprite with a specific ray.
  11148. * @param ray The ray we are sending to test the collision
  11149. * @param camera The camera space we are sending rays in
  11150. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11152. * @returns picking info or null.
  11153. */
  11154. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11155. /**
  11156. * Intersects the sprites with a ray
  11157. * @param ray defines the ray to intersect with
  11158. * @param camera defines the current active camera
  11159. * @param predicate defines a predicate used to select candidate sprites
  11160. * @returns null if no hit or a PickingInfo array
  11161. */
  11162. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11163. /**
  11164. * Renders the list of sprites on screen.
  11165. */
  11166. render(): void;
  11167. }
  11168. /**
  11169. * Class used to manage multiple sprites on the same spritesheet
  11170. * @see https://doc.babylonjs.com/babylon101/sprites
  11171. */
  11172. export class SpriteManager implements ISpriteManager {
  11173. /** defines the manager's name */
  11174. name: string;
  11175. /** Define the Url to load snippets */
  11176. static SnippetUrl: string;
  11177. /** Snippet ID if the manager was created from the snippet server */
  11178. snippetId: string;
  11179. /** Gets the list of sprites */
  11180. sprites: Sprite[];
  11181. /** Gets or sets the rendering group id (0 by default) */
  11182. renderingGroupId: number;
  11183. /** Gets or sets camera layer mask */
  11184. layerMask: number;
  11185. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11186. fogEnabled: boolean;
  11187. /** Gets or sets a boolean indicating if the sprites are pickable */
  11188. isPickable: boolean;
  11189. /** Defines the default width of a cell in the spritesheet */
  11190. cellWidth: number;
  11191. /** Defines the default height of a cell in the spritesheet */
  11192. cellHeight: number;
  11193. /** Associative array from JSON sprite data file */
  11194. private _cellData;
  11195. /** Array of sprite names from JSON sprite data file */
  11196. private _spriteMap;
  11197. /** True when packed cell data from JSON file is ready*/
  11198. private _packedAndReady;
  11199. private _textureContent;
  11200. /**
  11201. * An event triggered when the manager is disposed.
  11202. */
  11203. onDisposeObservable: Observable<SpriteManager>;
  11204. private _onDisposeObserver;
  11205. /**
  11206. * Callback called when the manager is disposed
  11207. */
  11208. set onDispose(callback: () => void);
  11209. private _capacity;
  11210. private _fromPacked;
  11211. private _spriteTexture;
  11212. private _epsilon;
  11213. private _scene;
  11214. private _vertexData;
  11215. private _buffer;
  11216. private _vertexBuffers;
  11217. private _indexBuffer;
  11218. private _effectBase;
  11219. private _effectFog;
  11220. /**
  11221. * Gets or sets the unique id of the sprite
  11222. */
  11223. uniqueId: number;
  11224. /**
  11225. * Gets the array of sprites
  11226. */
  11227. get children(): Sprite[];
  11228. /**
  11229. * Gets the hosting scene
  11230. */
  11231. get scene(): Scene;
  11232. /**
  11233. * Gets the capacity of the manager
  11234. */
  11235. get capacity(): number;
  11236. /**
  11237. * Gets or sets the spritesheet texture
  11238. */
  11239. get texture(): Texture;
  11240. set texture(value: Texture);
  11241. private _blendMode;
  11242. /**
  11243. * Blend mode use to render the particle, it can be any of
  11244. * the static Constants.ALPHA_x properties provided in this class.
  11245. * Default value is Constants.ALPHA_COMBINE
  11246. */
  11247. get blendMode(): number;
  11248. set blendMode(blendMode: number);
  11249. /** Disables writing to the depth buffer when rendering the sprites.
  11250. * It can be handy to disable depth writing when using textures without alpha channel
  11251. * and setting some specific blend modes.
  11252. */
  11253. disableDepthWrite: boolean;
  11254. /**
  11255. * Creates a new sprite manager
  11256. * @param name defines the manager's name
  11257. * @param imgUrl defines the sprite sheet url
  11258. * @param capacity defines the maximum allowed number of sprites
  11259. * @param cellSize defines the size of a sprite cell
  11260. * @param scene defines the hosting scene
  11261. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11262. * @param samplingMode defines the smapling mode to use with spritesheet
  11263. * @param fromPacked set to false; do not alter
  11264. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11265. */
  11266. constructor(
  11267. /** defines the manager's name */
  11268. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11269. /**
  11270. * Returns the string "SpriteManager"
  11271. * @returns "SpriteManager"
  11272. */
  11273. getClassName(): string;
  11274. private _makePacked;
  11275. private _appendSpriteVertex;
  11276. private _checkTextureAlpha;
  11277. /**
  11278. * Intersects the sprites with a ray
  11279. * @param ray defines the ray to intersect with
  11280. * @param camera defines the current active camera
  11281. * @param predicate defines a predicate used to select candidate sprites
  11282. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11283. * @returns null if no hit or a PickingInfo
  11284. */
  11285. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11286. /**
  11287. * Intersects the sprites with a ray
  11288. * @param ray defines the ray to intersect with
  11289. * @param camera defines the current active camera
  11290. * @param predicate defines a predicate used to select candidate sprites
  11291. * @returns null if no hit or a PickingInfo array
  11292. */
  11293. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11294. /**
  11295. * Render all child sprites
  11296. */
  11297. render(): void;
  11298. /**
  11299. * Release associated resources
  11300. */
  11301. dispose(): void;
  11302. /**
  11303. * Serializes the sprite manager to a JSON object
  11304. * @param serializeTexture defines if the texture must be serialized as well
  11305. * @returns the JSON object
  11306. */
  11307. serialize(serializeTexture?: boolean): any;
  11308. /**
  11309. * Parses a JSON object to create a new sprite manager.
  11310. * @param parsedManager The JSON object to parse
  11311. * @param scene The scene to create the sprite managerin
  11312. * @param rootUrl The root url to use to load external dependencies like texture
  11313. * @returns the new sprite manager
  11314. */
  11315. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11316. /**
  11317. * Creates a sprite manager from a snippet saved in a remote file
  11318. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11319. * @param url defines the url to load from
  11320. * @param scene defines the hosting scene
  11321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11322. * @returns a promise that will resolve to the new sprite manager
  11323. */
  11324. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11325. /**
  11326. * Creates a sprite manager from a snippet saved by the sprite editor
  11327. * @param snippetId defines the snippet to load
  11328. * @param scene defines the hosting scene
  11329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11330. * @returns a promise that will resolve to the new sprite manager
  11331. */
  11332. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11333. }
  11334. }
  11335. declare module "babylonjs/Misc/gradients" {
  11336. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11337. /** Interface used by value gradients (color, factor, ...) */
  11338. export interface IValueGradient {
  11339. /**
  11340. * Gets or sets the gradient value (between 0 and 1)
  11341. */
  11342. gradient: number;
  11343. }
  11344. /** Class used to store color4 gradient */
  11345. export class ColorGradient implements IValueGradient {
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number;
  11350. /**
  11351. * Gets or sets first associated color
  11352. */
  11353. color1: Color4;
  11354. /**
  11355. * Gets or sets second associated color
  11356. */
  11357. color2?: Color4 | undefined;
  11358. /**
  11359. * Creates a new color4 gradient
  11360. * @param gradient gets or sets the gradient value (between 0 and 1)
  11361. * @param color1 gets or sets first associated color
  11362. * @param color2 gets or sets first second color
  11363. */
  11364. constructor(
  11365. /**
  11366. * Gets or sets the gradient value (between 0 and 1)
  11367. */
  11368. gradient: number,
  11369. /**
  11370. * Gets or sets first associated color
  11371. */
  11372. color1: Color4,
  11373. /**
  11374. * Gets or sets second associated color
  11375. */
  11376. color2?: Color4 | undefined);
  11377. /**
  11378. * Will get a color picked randomly between color1 and color2.
  11379. * If color2 is undefined then color1 will be used
  11380. * @param result defines the target Color4 to store the result in
  11381. */
  11382. getColorToRef(result: Color4): void;
  11383. }
  11384. /** Class used to store color 3 gradient */
  11385. export class Color3Gradient implements IValueGradient {
  11386. /**
  11387. * Gets or sets the gradient value (between 0 and 1)
  11388. */
  11389. gradient: number;
  11390. /**
  11391. * Gets or sets the associated color
  11392. */
  11393. color: Color3;
  11394. /**
  11395. * Creates a new color3 gradient
  11396. * @param gradient gets or sets the gradient value (between 0 and 1)
  11397. * @param color gets or sets associated color
  11398. */
  11399. constructor(
  11400. /**
  11401. * Gets or sets the gradient value (between 0 and 1)
  11402. */
  11403. gradient: number,
  11404. /**
  11405. * Gets or sets the associated color
  11406. */
  11407. color: Color3);
  11408. }
  11409. /** Class used to store factor gradient */
  11410. export class FactorGradient implements IValueGradient {
  11411. /**
  11412. * Gets or sets the gradient value (between 0 and 1)
  11413. */
  11414. gradient: number;
  11415. /**
  11416. * Gets or sets first associated factor
  11417. */
  11418. factor1: number;
  11419. /**
  11420. * Gets or sets second associated factor
  11421. */
  11422. factor2?: number | undefined;
  11423. /**
  11424. * Creates a new factor gradient
  11425. * @param gradient gets or sets the gradient value (between 0 and 1)
  11426. * @param factor1 gets or sets first associated factor
  11427. * @param factor2 gets or sets second associated factor
  11428. */
  11429. constructor(
  11430. /**
  11431. * Gets or sets the gradient value (between 0 and 1)
  11432. */
  11433. gradient: number,
  11434. /**
  11435. * Gets or sets first associated factor
  11436. */
  11437. factor1: number,
  11438. /**
  11439. * Gets or sets second associated factor
  11440. */
  11441. factor2?: number | undefined);
  11442. /**
  11443. * Will get a number picked randomly between factor1 and factor2.
  11444. * If factor2 is undefined then factor1 will be used
  11445. * @returns the picked number
  11446. */
  11447. getFactor(): number;
  11448. }
  11449. /**
  11450. * Helper used to simplify some generic gradient tasks
  11451. */
  11452. export class GradientHelper {
  11453. /**
  11454. * Gets the current gradient from an array of IValueGradient
  11455. * @param ratio defines the current ratio to get
  11456. * @param gradients defines the array of IValueGradient
  11457. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11458. */
  11459. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11460. }
  11461. }
  11462. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11463. import { Nullable } from "babylonjs/types";
  11464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11465. import { Scene } from "babylonjs/scene";
  11466. module "babylonjs/Engines/thinEngine" {
  11467. interface ThinEngine {
  11468. /**
  11469. * Creates a raw texture
  11470. * @param data defines the data to store in the texture
  11471. * @param width defines the width of the texture
  11472. * @param height defines the height of the texture
  11473. * @param format defines the format of the data
  11474. * @param generateMipMaps defines if the engine should generate the mip levels
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11477. * @param compression defines the compression used (null by default)
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @returns the raw texture inside an InternalTexture
  11480. */
  11481. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11482. /**
  11483. * Update a raw texture
  11484. * @param texture defines the texture to update
  11485. * @param data defines the data to store in the texture
  11486. * @param format defines the format of the data
  11487. * @param invertY defines if data must be stored with Y axis inverted
  11488. */
  11489. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11490. /**
  11491. * Update a raw texture
  11492. * @param texture defines the texture to update
  11493. * @param data defines the data to store in the texture
  11494. * @param format defines the format of the data
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param compression defines the compression used (null by default)
  11497. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11498. */
  11499. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11500. /**
  11501. * Creates a new raw cube texture
  11502. * @param data defines the array of data to use to create each face
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param generateMipMaps defines if the engine should generate the mip levels
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11509. * @param compression defines the compression used (null by default)
  11510. * @returns the cube texture as an InternalTexture
  11511. */
  11512. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11513. /**
  11514. * Update a raw cube texture
  11515. * @param texture defines the texture to udpdate
  11516. * @param data defines the data to store
  11517. * @param format defines the data format
  11518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11519. * @param invertY defines if data must be stored with Y axis inverted
  11520. */
  11521. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11522. /**
  11523. * Update a raw cube texture
  11524. * @param texture defines the texture to udpdate
  11525. * @param data defines the data to store
  11526. * @param format defines the data format
  11527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param compression defines the compression used (null by default)
  11530. */
  11531. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11532. /**
  11533. * Update a raw cube texture
  11534. * @param texture defines the texture to udpdate
  11535. * @param data defines the data to store
  11536. * @param format defines the data format
  11537. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11538. * @param invertY defines if data must be stored with Y axis inverted
  11539. * @param compression defines the compression used (null by default)
  11540. * @param level defines which level of the texture to update
  11541. */
  11542. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11543. /**
  11544. * Creates a new raw cube texture from a specified url
  11545. * @param url defines the url where the data is located
  11546. * @param scene defines the current scene
  11547. * @param size defines the size of the textures
  11548. * @param format defines the format of the data
  11549. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11550. * @param noMipmap defines if the engine should avoid generating the mip levels
  11551. * @param callback defines a callback used to extract texture data from loaded data
  11552. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11553. * @param onLoad defines a callback called when texture is loaded
  11554. * @param onError defines a callback called if there is an error
  11555. * @returns the cube texture as an InternalTexture
  11556. */
  11557. 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;
  11558. /**
  11559. * Creates a new raw cube texture from a specified url
  11560. * @param url defines the url where the data is located
  11561. * @param scene defines the current scene
  11562. * @param size defines the size of the textures
  11563. * @param format defines the format of the data
  11564. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11565. * @param noMipmap defines if the engine should avoid generating the mip levels
  11566. * @param callback defines a callback used to extract texture data from loaded data
  11567. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11568. * @param onLoad defines a callback called when texture is loaded
  11569. * @param onError defines a callback called if there is an error
  11570. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. * @returns the cube texture as an InternalTexture
  11573. */
  11574. 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;
  11575. /**
  11576. * Creates a new raw 3D texture
  11577. * @param data defines the data used to create the texture
  11578. * @param width defines the width of the texture
  11579. * @param height defines the height of the texture
  11580. * @param depth defines the depth of the texture
  11581. * @param format defines the format of the texture
  11582. * @param generateMipMaps defines if the engine must generate mip levels
  11583. * @param invertY defines if data must be stored with Y axis inverted
  11584. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11585. * @param compression defines the compressed used (can be null)
  11586. * @param textureType defines the compressed used (can be null)
  11587. * @returns a new raw 3D texture (stored in an InternalTexture)
  11588. */
  11589. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11590. /**
  11591. * Update a raw 3D texture
  11592. * @param texture defines the texture to update
  11593. * @param data defines the data to store
  11594. * @param format defines the data format
  11595. * @param invertY defines if data must be stored with Y axis inverted
  11596. */
  11597. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11598. /**
  11599. * Update a raw 3D texture
  11600. * @param texture defines the texture to update
  11601. * @param data defines the data to store
  11602. * @param format defines the data format
  11603. * @param invertY defines if data must be stored with Y axis inverted
  11604. * @param compression defines the used compression (can be null)
  11605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11606. */
  11607. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11608. /**
  11609. * Creates a new raw 2D array texture
  11610. * @param data defines the data used to create the texture
  11611. * @param width defines the width of the texture
  11612. * @param height defines the height of the texture
  11613. * @param depth defines the number of layers of the texture
  11614. * @param format defines the format of the texture
  11615. * @param generateMipMaps defines if the engine must generate mip levels
  11616. * @param invertY defines if data must be stored with Y axis inverted
  11617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11618. * @param compression defines the compressed used (can be null)
  11619. * @param textureType defines the compressed used (can be null)
  11620. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11621. */
  11622. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11623. /**
  11624. * Update a raw 2D array texture
  11625. * @param texture defines the texture to update
  11626. * @param data defines the data to store
  11627. * @param format defines the data format
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. */
  11630. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11631. /**
  11632. * Update a raw 2D array texture
  11633. * @param texture defines the texture to update
  11634. * @param data defines the data to store
  11635. * @param format defines the data format
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @param compression defines the used compression (can be null)
  11638. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11639. */
  11640. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11641. }
  11642. }
  11643. }
  11644. declare module "babylonjs/Materials/Textures/rawTexture" {
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Texture } from "babylonjs/Materials/Textures/texture";
  11647. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11648. /**
  11649. * Raw texture can help creating a texture directly from an array of data.
  11650. * This can be super useful if you either get the data from an uncompressed source or
  11651. * if you wish to create your texture pixel by pixel.
  11652. */
  11653. export class RawTexture extends Texture {
  11654. /**
  11655. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11656. */
  11657. format: number;
  11658. /**
  11659. * Instantiates a new RawTexture.
  11660. * Raw texture can help creating a texture directly from an array of data.
  11661. * This can be super useful if you either get the data from an uncompressed source or
  11662. * if you wish to create your texture pixel by pixel.
  11663. * @param data define the array of data to use to create the texture
  11664. * @param width define the width of the texture
  11665. * @param height define the height of the texture
  11666. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11667. * @param scene define the scene the texture belongs to
  11668. * @param generateMipMaps define whether mip maps should be generated or not
  11669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11672. */
  11673. constructor(data: ArrayBufferView, width: number, height: number,
  11674. /**
  11675. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11676. */
  11677. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11678. /**
  11679. * Updates the texture underlying data.
  11680. * @param data Define the new data of the texture
  11681. */
  11682. update(data: ArrayBufferView): void;
  11683. /**
  11684. * Creates a luminance texture from some data.
  11685. * @param data Define the texture data
  11686. * @param width Define the width of the texture
  11687. * @param height Define the height of the texture
  11688. * @param scene Define the scene the texture belongs to
  11689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11692. * @returns the luminance texture
  11693. */
  11694. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11695. /**
  11696. * Creates a luminance alpha texture from some data.
  11697. * @param data Define the texture data
  11698. * @param width Define the width of the texture
  11699. * @param height Define the height of the texture
  11700. * @param scene Define the scene the texture belongs to
  11701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11704. * @returns the luminance alpha texture
  11705. */
  11706. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11707. /**
  11708. * Creates an alpha texture from some data.
  11709. * @param data Define the texture data
  11710. * @param width Define the width of the texture
  11711. * @param height Define the height of the texture
  11712. * @param scene Define the scene the texture belongs to
  11713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11716. * @returns the alpha texture
  11717. */
  11718. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11719. /**
  11720. * Creates a RGB texture from some data.
  11721. * @param data Define the texture data
  11722. * @param width Define the width of the texture
  11723. * @param height Define the height of the texture
  11724. * @param scene Define the scene the texture belongs to
  11725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11728. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11729. * @returns the RGB alpha texture
  11730. */
  11731. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11732. /**
  11733. * Creates a RGBA texture from some data.
  11734. * @param data Define the texture data
  11735. * @param width Define the width of the texture
  11736. * @param height Define the height of the texture
  11737. * @param scene Define the scene the texture belongs to
  11738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11742. * @returns the RGBA texture
  11743. */
  11744. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11745. /**
  11746. * Creates a R texture from some data.
  11747. * @param data Define the texture data
  11748. * @param width Define the width of the texture
  11749. * @param height Define the height of the texture
  11750. * @param scene Define the scene the texture belongs to
  11751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11755. * @returns the R texture
  11756. */
  11757. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11758. }
  11759. }
  11760. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11761. import { Scene } from "babylonjs/scene";
  11762. import { ISceneComponent } from "babylonjs/sceneComponent";
  11763. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11764. module "babylonjs/abstractScene" {
  11765. interface AbstractScene {
  11766. /**
  11767. * The list of procedural textures added to the scene
  11768. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11769. */
  11770. proceduralTextures: Array<ProceduralTexture>;
  11771. }
  11772. }
  11773. /**
  11774. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11775. * in a given scene.
  11776. */
  11777. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11778. /**
  11779. * The component name helpfull to identify the component in the list of scene components.
  11780. */
  11781. readonly name: string;
  11782. /**
  11783. * The scene the component belongs to.
  11784. */
  11785. scene: Scene;
  11786. /**
  11787. * Creates a new instance of the component for the given scene
  11788. * @param scene Defines the scene to register the component in
  11789. */
  11790. constructor(scene: Scene);
  11791. /**
  11792. * Registers the component in a given scene
  11793. */
  11794. register(): void;
  11795. /**
  11796. * Rebuilds the elements related to this component in case of
  11797. * context lost for instance.
  11798. */
  11799. rebuild(): void;
  11800. /**
  11801. * Disposes the component and the associated ressources.
  11802. */
  11803. dispose(): void;
  11804. private _beforeClear;
  11805. }
  11806. }
  11807. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11808. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11809. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11810. module "babylonjs/Engines/thinEngine" {
  11811. interface ThinEngine {
  11812. /**
  11813. * Creates a new render target cube texture
  11814. * @param size defines the size of the texture
  11815. * @param options defines the options used to create the texture
  11816. * @returns a new render target cube texture stored in an InternalTexture
  11817. */
  11818. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11819. }
  11820. }
  11821. }
  11822. declare module "babylonjs/Shaders/procedural.vertex" {
  11823. /** @hidden */
  11824. export var proceduralVertexShader: {
  11825. name: string;
  11826. shader: string;
  11827. };
  11828. }
  11829. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11830. import { Observable } from "babylonjs/Misc/observable";
  11831. import { Nullable } from "babylonjs/types";
  11832. import { Scene } from "babylonjs/scene";
  11833. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11834. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11835. import { Effect } from "babylonjs/Materials/effect";
  11836. import { Texture } from "babylonjs/Materials/Textures/texture";
  11837. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11838. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11839. import "babylonjs/Shaders/procedural.vertex";
  11840. /**
  11841. * 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.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. */
  11845. export class ProceduralTexture extends Texture {
  11846. isCube: boolean;
  11847. /**
  11848. * Define if the texture is enabled or not (disabled texture will not render)
  11849. */
  11850. isEnabled: boolean;
  11851. /**
  11852. * Define if the texture must be cleared before rendering (default is true)
  11853. */
  11854. autoClear: boolean;
  11855. /**
  11856. * Callback called when the texture is generated
  11857. */
  11858. onGenerated: () => void;
  11859. /**
  11860. * Event raised when the texture is generated
  11861. */
  11862. onGeneratedObservable: Observable<ProceduralTexture>;
  11863. /** @hidden */
  11864. _generateMipMaps: boolean;
  11865. /** @hidden **/
  11866. _effect: Effect;
  11867. /** @hidden */
  11868. _textures: {
  11869. [key: string]: Texture;
  11870. };
  11871. /** @hidden */
  11872. protected _fallbackTexture: Nullable<Texture>;
  11873. private _size;
  11874. private _currentRefreshId;
  11875. private _frameId;
  11876. private _refreshRate;
  11877. private _vertexBuffers;
  11878. private _indexBuffer;
  11879. private _uniforms;
  11880. private _samplers;
  11881. private _fragment;
  11882. private _floats;
  11883. private _ints;
  11884. private _floatsArrays;
  11885. private _colors3;
  11886. private _colors4;
  11887. private _vectors2;
  11888. private _vectors3;
  11889. private _matrices;
  11890. private _fallbackTextureUsed;
  11891. private _fullEngine;
  11892. private _cachedDefines;
  11893. private _contentUpdateId;
  11894. private _contentData;
  11895. /**
  11896. * Instantiates a new procedural texture.
  11897. * 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.
  11898. * This is the base class of any Procedural texture and contains most of the shareable code.
  11899. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11900. * @param name Define the name of the texture
  11901. * @param size Define the size of the texture to create
  11902. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11903. * @param scene Define the scene the texture belongs to
  11904. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11905. * @param generateMipMaps Define if the texture should creates mip maps or not
  11906. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11907. */
  11908. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11909. /**
  11910. * The effect that is created when initializing the post process.
  11911. * @returns The created effect corresponding the the postprocess.
  11912. */
  11913. getEffect(): Effect;
  11914. /**
  11915. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11916. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11917. */
  11918. getContent(): Nullable<ArrayBufferView>;
  11919. private _createIndexBuffer;
  11920. /** @hidden */
  11921. _rebuild(): void;
  11922. /**
  11923. * Resets the texture in order to recreate its associated resources.
  11924. * This can be called in case of context loss
  11925. */
  11926. reset(): void;
  11927. protected _getDefines(): string;
  11928. /**
  11929. * Is the texture ready to be used ? (rendered at least once)
  11930. * @returns true if ready, otherwise, false.
  11931. */
  11932. isReady(): boolean;
  11933. /**
  11934. * Resets the refresh counter of the texture and start bak from scratch.
  11935. * Could be useful to regenerate the texture if it is setup to render only once.
  11936. */
  11937. resetRefreshCounter(): void;
  11938. /**
  11939. * Set the fragment shader to use in order to render the texture.
  11940. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11941. */
  11942. setFragment(fragment: any): void;
  11943. /**
  11944. * Define the refresh rate of the texture or the rendering frequency.
  11945. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11946. */
  11947. get refreshRate(): number;
  11948. set refreshRate(value: number);
  11949. /** @hidden */
  11950. _shouldRender(): boolean;
  11951. /**
  11952. * Get the size the texture is rendering at.
  11953. * @returns the size (texture is always squared)
  11954. */
  11955. getRenderSize(): number;
  11956. /**
  11957. * Resize the texture to new value.
  11958. * @param size Define the new size the texture should have
  11959. * @param generateMipMaps Define whether the new texture should create mip maps
  11960. */
  11961. resize(size: number, generateMipMaps: boolean): void;
  11962. private _checkUniform;
  11963. /**
  11964. * Set a texture in the shader program used to render.
  11965. * @param name Define the name of the uniform samplers as defined in the shader
  11966. * @param texture Define the texture to bind to this sampler
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setTexture(name: string, texture: Texture): ProceduralTexture;
  11970. /**
  11971. * Set a float in the shader.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setFloat(name: string, value: number): ProceduralTexture;
  11977. /**
  11978. * Set a int in the shader.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setInt(name: string, value: number): ProceduralTexture;
  11984. /**
  11985. * Set an array of floats in the shader.
  11986. * @param name Define the name of the uniform as defined in the shader
  11987. * @param value Define the value to give to the uniform
  11988. * @return the texture itself allowing "fluent" like uniform updates
  11989. */
  11990. setFloats(name: string, value: number[]): ProceduralTexture;
  11991. /**
  11992. * Set a vec3 in the shader from a Color3.
  11993. * @param name Define the name of the uniform as defined in the shader
  11994. * @param value Define the value to give to the uniform
  11995. * @return the texture itself allowing "fluent" like uniform updates
  11996. */
  11997. setColor3(name: string, value: Color3): ProceduralTexture;
  11998. /**
  11999. * Set a vec4 in the shader from a Color4.
  12000. * @param name Define the name of the uniform as defined in the shader
  12001. * @param value Define the value to give to the uniform
  12002. * @return the texture itself allowing "fluent" like uniform updates
  12003. */
  12004. setColor4(name: string, value: Color4): ProceduralTexture;
  12005. /**
  12006. * Set a vec2 in the shader from a Vector2.
  12007. * @param name Define the name of the uniform as defined in the shader
  12008. * @param value Define the value to give to the uniform
  12009. * @return the texture itself allowing "fluent" like uniform updates
  12010. */
  12011. setVector2(name: string, value: Vector2): ProceduralTexture;
  12012. /**
  12013. * Set a vec3 in the shader from a Vector3.
  12014. * @param name Define the name of the uniform as defined in the shader
  12015. * @param value Define the value to give to the uniform
  12016. * @return the texture itself allowing "fluent" like uniform updates
  12017. */
  12018. setVector3(name: string, value: Vector3): ProceduralTexture;
  12019. /**
  12020. * Set a mat4 in the shader from a MAtrix.
  12021. * @param name Define the name of the uniform as defined in the shader
  12022. * @param value Define the value to give to the uniform
  12023. * @return the texture itself allowing "fluent" like uniform updates
  12024. */
  12025. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12026. /**
  12027. * Render the texture to its associated render target.
  12028. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12029. */
  12030. render(useCameraPostProcess?: boolean): void;
  12031. /**
  12032. * Clone the texture.
  12033. * @returns the cloned texture
  12034. */
  12035. clone(): ProceduralTexture;
  12036. /**
  12037. * Dispose the texture and release its asoociated resources.
  12038. */
  12039. dispose(): void;
  12040. }
  12041. }
  12042. declare module "babylonjs/Particles/baseParticleSystem" {
  12043. import { Nullable } from "babylonjs/types";
  12044. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12046. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12047. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12048. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12049. import { Scene } from "babylonjs/scene";
  12050. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12051. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12052. import { Texture } from "babylonjs/Materials/Textures/texture";
  12053. import { Color4 } from "babylonjs/Maths/math.color";
  12054. import { Animation } from "babylonjs/Animations/animation";
  12055. /**
  12056. * This represents the base class for particle system in Babylon.
  12057. * 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.
  12058. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12059. * @example https://doc.babylonjs.com/babylon101/particles
  12060. */
  12061. export class BaseParticleSystem {
  12062. /**
  12063. * Source color is added to the destination color without alpha affecting the result
  12064. */
  12065. static BLENDMODE_ONEONE: number;
  12066. /**
  12067. * Blend current color and particle color using particle’s alpha
  12068. */
  12069. static BLENDMODE_STANDARD: number;
  12070. /**
  12071. * Add current color and particle color multiplied by particle’s alpha
  12072. */
  12073. static BLENDMODE_ADD: number;
  12074. /**
  12075. * Multiply current color with particle color
  12076. */
  12077. static BLENDMODE_MULTIPLY: number;
  12078. /**
  12079. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12080. */
  12081. static BLENDMODE_MULTIPLYADD: number;
  12082. /**
  12083. * List of animations used by the particle system.
  12084. */
  12085. animations: Animation[];
  12086. /**
  12087. * Gets or sets the unique id of the particle system
  12088. */
  12089. uniqueId: number;
  12090. /**
  12091. * The id of the Particle system.
  12092. */
  12093. id: string;
  12094. /**
  12095. * The friendly name of the Particle system.
  12096. */
  12097. name: string;
  12098. /**
  12099. * Snippet ID if the particle system was created from the snippet server
  12100. */
  12101. snippetId: string;
  12102. /**
  12103. * The rendering group used by the Particle system to chose when to render.
  12104. */
  12105. renderingGroupId: number;
  12106. /**
  12107. * The emitter represents the Mesh or position we are attaching the particle system to.
  12108. */
  12109. emitter: Nullable<AbstractMesh | Vector3>;
  12110. /**
  12111. * The maximum number of particles to emit per frame
  12112. */
  12113. emitRate: number;
  12114. /**
  12115. * If you want to launch only a few particles at once, that can be done, as well.
  12116. */
  12117. manualEmitCount: number;
  12118. /**
  12119. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12120. */
  12121. updateSpeed: number;
  12122. /**
  12123. * The amount of time the particle system is running (depends of the overall update speed).
  12124. */
  12125. targetStopDuration: number;
  12126. /**
  12127. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12128. */
  12129. disposeOnStop: boolean;
  12130. /**
  12131. * Minimum power of emitting particles.
  12132. */
  12133. minEmitPower: number;
  12134. /**
  12135. * Maximum power of emitting particles.
  12136. */
  12137. maxEmitPower: number;
  12138. /**
  12139. * Minimum life time of emitting particles.
  12140. */
  12141. minLifeTime: number;
  12142. /**
  12143. * Maximum life time of emitting particles.
  12144. */
  12145. maxLifeTime: number;
  12146. /**
  12147. * Minimum Size of emitting particles.
  12148. */
  12149. minSize: number;
  12150. /**
  12151. * Maximum Size of emitting particles.
  12152. */
  12153. maxSize: number;
  12154. /**
  12155. * Minimum scale of emitting particles on X axis.
  12156. */
  12157. minScaleX: number;
  12158. /**
  12159. * Maximum scale of emitting particles on X axis.
  12160. */
  12161. maxScaleX: number;
  12162. /**
  12163. * Minimum scale of emitting particles on Y axis.
  12164. */
  12165. minScaleY: number;
  12166. /**
  12167. * Maximum scale of emitting particles on Y axis.
  12168. */
  12169. maxScaleY: number;
  12170. /**
  12171. * Gets or sets the minimal initial rotation in radians.
  12172. */
  12173. minInitialRotation: number;
  12174. /**
  12175. * Gets or sets the maximal initial rotation in radians.
  12176. */
  12177. maxInitialRotation: number;
  12178. /**
  12179. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12180. */
  12181. minAngularSpeed: number;
  12182. /**
  12183. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12184. */
  12185. maxAngularSpeed: number;
  12186. /**
  12187. * The texture used to render each particle. (this can be a spritesheet)
  12188. */
  12189. particleTexture: Nullable<Texture>;
  12190. /**
  12191. * The layer mask we are rendering the particles through.
  12192. */
  12193. layerMask: number;
  12194. /**
  12195. * This can help using your own shader to render the particle system.
  12196. * The according effect will be created
  12197. */
  12198. customShader: any;
  12199. /**
  12200. * By default particle system starts as soon as they are created. This prevents the
  12201. * automatic start to happen and let you decide when to start emitting particles.
  12202. */
  12203. preventAutoStart: boolean;
  12204. private _noiseTexture;
  12205. /**
  12206. * Gets or sets a texture used to add random noise to particle positions
  12207. */
  12208. get noiseTexture(): Nullable<ProceduralTexture>;
  12209. set noiseTexture(value: Nullable<ProceduralTexture>);
  12210. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12211. noiseStrength: Vector3;
  12212. /**
  12213. * Callback triggered when the particle animation is ending.
  12214. */
  12215. onAnimationEnd: Nullable<() => void>;
  12216. /**
  12217. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12218. */
  12219. blendMode: number;
  12220. /**
  12221. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12222. * to override the particles.
  12223. */
  12224. forceDepthWrite: boolean;
  12225. /** 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 */
  12226. preWarmCycles: number;
  12227. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12228. preWarmStepOffset: number;
  12229. /**
  12230. * 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)
  12231. */
  12232. spriteCellChangeSpeed: number;
  12233. /**
  12234. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12235. */
  12236. startSpriteCellID: number;
  12237. /**
  12238. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12239. */
  12240. endSpriteCellID: number;
  12241. /**
  12242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12243. */
  12244. spriteCellWidth: number;
  12245. /**
  12246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12247. */
  12248. spriteCellHeight: number;
  12249. /**
  12250. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12251. */
  12252. spriteRandomStartCell: boolean;
  12253. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12254. translationPivot: Vector2;
  12255. /** @hidden */
  12256. protected _isAnimationSheetEnabled: boolean;
  12257. /**
  12258. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12259. */
  12260. beginAnimationOnStart: boolean;
  12261. /**
  12262. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12263. */
  12264. beginAnimationFrom: number;
  12265. /**
  12266. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12267. */
  12268. beginAnimationTo: number;
  12269. /**
  12270. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12271. */
  12272. beginAnimationLoop: boolean;
  12273. /**
  12274. * Gets or sets a world offset applied to all particles
  12275. */
  12276. worldOffset: Vector3;
  12277. /**
  12278. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12279. */
  12280. get isAnimationSheetEnabled(): boolean;
  12281. set isAnimationSheetEnabled(value: boolean);
  12282. /**
  12283. * Get hosting scene
  12284. * @returns the scene
  12285. */
  12286. getScene(): Scene;
  12287. /**
  12288. * You can use gravity if you want to give an orientation to your particles.
  12289. */
  12290. gravity: Vector3;
  12291. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12292. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12293. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12294. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12295. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12296. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12297. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12298. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12299. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12300. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12301. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12302. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12303. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12304. /**
  12305. * Defines the delay in milliseconds before starting the system (0 by default)
  12306. */
  12307. startDelay: number;
  12308. /**
  12309. * Gets the current list of drag gradients.
  12310. * You must use addDragGradient and removeDragGradient to udpate this list
  12311. * @returns the list of drag gradients
  12312. */
  12313. getDragGradients(): Nullable<Array<FactorGradient>>;
  12314. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12315. limitVelocityDamping: number;
  12316. /**
  12317. * Gets the current list of limit velocity gradients.
  12318. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12319. * @returns the list of limit velocity gradients
  12320. */
  12321. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12322. /**
  12323. * Gets the current list of color gradients.
  12324. * You must use addColorGradient and removeColorGradient to udpate this list
  12325. * @returns the list of color gradients
  12326. */
  12327. getColorGradients(): Nullable<Array<ColorGradient>>;
  12328. /**
  12329. * Gets the current list of size gradients.
  12330. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12331. * @returns the list of size gradients
  12332. */
  12333. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12334. /**
  12335. * Gets the current list of color remap gradients.
  12336. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12337. * @returns the list of color remap gradients
  12338. */
  12339. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12340. /**
  12341. * Gets the current list of alpha remap gradients.
  12342. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12343. * @returns the list of alpha remap gradients
  12344. */
  12345. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12346. /**
  12347. * Gets the current list of life time gradients.
  12348. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12349. * @returns the list of life time gradients
  12350. */
  12351. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12352. /**
  12353. * Gets the current list of angular speed gradients.
  12354. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12355. * @returns the list of angular speed gradients
  12356. */
  12357. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12358. /**
  12359. * Gets the current list of velocity gradients.
  12360. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12361. * @returns the list of velocity gradients
  12362. */
  12363. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12364. /**
  12365. * Gets the current list of start size gradients.
  12366. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12367. * @returns the list of start size gradients
  12368. */
  12369. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12370. /**
  12371. * Gets the current list of emit rate gradients.
  12372. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12373. * @returns the list of emit rate gradients
  12374. */
  12375. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12376. /**
  12377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12378. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12379. */
  12380. get direction1(): Vector3;
  12381. set direction1(value: Vector3);
  12382. /**
  12383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12384. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12385. */
  12386. get direction2(): Vector3;
  12387. set direction2(value: Vector3);
  12388. /**
  12389. * 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.
  12390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12391. */
  12392. get minEmitBox(): Vector3;
  12393. set minEmitBox(value: Vector3);
  12394. /**
  12395. * 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.
  12396. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12397. */
  12398. get maxEmitBox(): Vector3;
  12399. set maxEmitBox(value: Vector3);
  12400. /**
  12401. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12402. */
  12403. color1: Color4;
  12404. /**
  12405. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12406. */
  12407. color2: Color4;
  12408. /**
  12409. * Color the particle will have at the end of its lifetime
  12410. */
  12411. colorDead: Color4;
  12412. /**
  12413. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12414. */
  12415. textureMask: Color4;
  12416. /**
  12417. * The particle emitter type defines the emitter used by the particle system.
  12418. * It can be for example box, sphere, or cone...
  12419. */
  12420. particleEmitterType: IParticleEmitterType;
  12421. /** @hidden */
  12422. _isSubEmitter: boolean;
  12423. /**
  12424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12426. */
  12427. billboardMode: number;
  12428. protected _isBillboardBased: boolean;
  12429. /**
  12430. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12431. */
  12432. get isBillboardBased(): boolean;
  12433. set isBillboardBased(value: boolean);
  12434. /**
  12435. * The scene the particle system belongs to.
  12436. */
  12437. protected _scene: Scene;
  12438. /**
  12439. * Local cache of defines for image processing.
  12440. */
  12441. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12442. /**
  12443. * Default configuration related to image processing available in the standard Material.
  12444. */
  12445. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12446. /**
  12447. * Gets the image processing configuration used either in this material.
  12448. */
  12449. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12450. /**
  12451. * Sets the Default image processing configuration used either in the this material.
  12452. *
  12453. * If sets to null, the scene one is in use.
  12454. */
  12455. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12456. /**
  12457. * Attaches a new image processing configuration to the Standard Material.
  12458. * @param configuration
  12459. */
  12460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12461. /** @hidden */
  12462. protected _reset(): void;
  12463. /** @hidden */
  12464. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12465. /**
  12466. * Instantiates a particle system.
  12467. * 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.
  12468. * @param name The name of the particle system
  12469. */
  12470. constructor(name: string);
  12471. /**
  12472. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12475. * @returns the emitter
  12476. */
  12477. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12478. /**
  12479. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12480. * @param radius The radius of the hemisphere to emit from
  12481. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12482. * @returns the emitter
  12483. */
  12484. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12485. /**
  12486. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12487. * @param radius The radius of the sphere to emit from
  12488. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12489. * @returns the emitter
  12490. */
  12491. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12492. /**
  12493. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12494. * @param radius The radius of the sphere to emit from
  12495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12497. * @returns the emitter
  12498. */
  12499. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12500. /**
  12501. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12502. * @param radius The radius of the emission cylinder
  12503. * @param height The height of the emission cylinder
  12504. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12505. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12506. * @returns the emitter
  12507. */
  12508. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12509. /**
  12510. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12511. * @param radius The radius of the cylinder to emit from
  12512. * @param height The height of the emission cylinder
  12513. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12516. * @returns the emitter
  12517. */
  12518. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12519. /**
  12520. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12521. * @param radius The radius of the cone to emit from
  12522. * @param angle The base angle of the cone
  12523. * @returns the emitter
  12524. */
  12525. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12526. /**
  12527. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12530. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12531. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12532. * @returns the emitter
  12533. */
  12534. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12535. }
  12536. }
  12537. declare module "babylonjs/Particles/subEmitter" {
  12538. import { Scene } from "babylonjs/scene";
  12539. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12540. /**
  12541. * Type of sub emitter
  12542. */
  12543. export enum SubEmitterType {
  12544. /**
  12545. * Attached to the particle over it's lifetime
  12546. */
  12547. ATTACHED = 0,
  12548. /**
  12549. * Created when the particle dies
  12550. */
  12551. END = 1
  12552. }
  12553. /**
  12554. * Sub emitter class used to emit particles from an existing particle
  12555. */
  12556. export class SubEmitter {
  12557. /**
  12558. * the particle system to be used by the sub emitter
  12559. */
  12560. particleSystem: ParticleSystem;
  12561. /**
  12562. * Type of the submitter (Default: END)
  12563. */
  12564. type: SubEmitterType;
  12565. /**
  12566. * 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)
  12567. * Note: This only is supported when using an emitter of type Mesh
  12568. */
  12569. inheritDirection: boolean;
  12570. /**
  12571. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12572. */
  12573. inheritedVelocityAmount: number;
  12574. /**
  12575. * Creates a sub emitter
  12576. * @param particleSystem the particle system to be used by the sub emitter
  12577. */
  12578. constructor(
  12579. /**
  12580. * the particle system to be used by the sub emitter
  12581. */
  12582. particleSystem: ParticleSystem);
  12583. /**
  12584. * Clones the sub emitter
  12585. * @returns the cloned sub emitter
  12586. */
  12587. clone(): SubEmitter;
  12588. /**
  12589. * Serialize current object to a JSON object
  12590. * @returns the serialized object
  12591. */
  12592. serialize(): any;
  12593. /** @hidden */
  12594. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12595. /**
  12596. * Creates a new SubEmitter from a serialized JSON version
  12597. * @param serializationObject defines the JSON object to read from
  12598. * @param scene defines the hosting scene
  12599. * @param rootUrl defines the rootUrl for data loading
  12600. * @returns a new SubEmitter
  12601. */
  12602. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12603. /** Release associated resources */
  12604. dispose(): void;
  12605. }
  12606. }
  12607. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12608. /** @hidden */
  12609. export var imageProcessingDeclaration: {
  12610. name: string;
  12611. shader: string;
  12612. };
  12613. }
  12614. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12615. /** @hidden */
  12616. export var imageProcessingFunctions: {
  12617. name: string;
  12618. shader: string;
  12619. };
  12620. }
  12621. declare module "babylonjs/Shaders/particles.fragment" {
  12622. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12623. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12625. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12626. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12627. /** @hidden */
  12628. export var particlesPixelShader: {
  12629. name: string;
  12630. shader: string;
  12631. };
  12632. }
  12633. declare module "babylonjs/Shaders/particles.vertex" {
  12634. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12636. /** @hidden */
  12637. export var particlesVertexShader: {
  12638. name: string;
  12639. shader: string;
  12640. };
  12641. }
  12642. declare module "babylonjs/Particles/particleSystem" {
  12643. import { Nullable } from "babylonjs/types";
  12644. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12645. import { Observable } from "babylonjs/Misc/observable";
  12646. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12647. import { Effect } from "babylonjs/Materials/effect";
  12648. import { Scene, IDisposable } from "babylonjs/scene";
  12649. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12650. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12651. import { Particle } from "babylonjs/Particles/particle";
  12652. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12654. import "babylonjs/Shaders/particles.fragment";
  12655. import "babylonjs/Shaders/particles.vertex";
  12656. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12657. /**
  12658. * This represents a particle system in Babylon.
  12659. * 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.
  12660. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12661. * @example https://doc.babylonjs.com/babylon101/particles
  12662. */
  12663. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12664. /**
  12665. * Billboard mode will only apply to Y axis
  12666. */
  12667. static readonly BILLBOARDMODE_Y: number;
  12668. /**
  12669. * Billboard mode will apply to all axes
  12670. */
  12671. static readonly BILLBOARDMODE_ALL: number;
  12672. /**
  12673. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12674. */
  12675. static readonly BILLBOARDMODE_STRETCHED: number;
  12676. /**
  12677. * This function can be defined to provide custom update for active particles.
  12678. * This function will be called instead of regular update (age, position, color, etc.).
  12679. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12680. */
  12681. updateFunction: (particles: Particle[]) => void;
  12682. private _emitterWorldMatrix;
  12683. /**
  12684. * This function can be defined to specify initial direction for every new particle.
  12685. * It by default use the emitterType defined function
  12686. */
  12687. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12688. /**
  12689. * This function can be defined to specify initial position for every new particle.
  12690. * It by default use the emitterType defined function
  12691. */
  12692. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12693. /**
  12694. * @hidden
  12695. */
  12696. _inheritedVelocityOffset: Vector3;
  12697. /**
  12698. * An event triggered when the system is disposed
  12699. */
  12700. onDisposeObservable: Observable<IParticleSystem>;
  12701. private _onDisposeObserver;
  12702. /**
  12703. * Sets a callback that will be triggered when the system is disposed
  12704. */
  12705. set onDispose(callback: () => void);
  12706. private _particles;
  12707. private _epsilon;
  12708. private _capacity;
  12709. private _stockParticles;
  12710. private _newPartsExcess;
  12711. private _vertexData;
  12712. private _vertexBuffer;
  12713. private _vertexBuffers;
  12714. private _spriteBuffer;
  12715. private _indexBuffer;
  12716. private _effect;
  12717. private _customEffect;
  12718. private _cachedDefines;
  12719. private _scaledColorStep;
  12720. private _colorDiff;
  12721. private _scaledDirection;
  12722. private _scaledGravity;
  12723. private _currentRenderId;
  12724. private _alive;
  12725. private _useInstancing;
  12726. private _started;
  12727. private _stopped;
  12728. private _actualFrame;
  12729. private _scaledUpdateSpeed;
  12730. private _vertexBufferSize;
  12731. /** @hidden */
  12732. _currentEmitRateGradient: Nullable<FactorGradient>;
  12733. /** @hidden */
  12734. _currentEmitRate1: number;
  12735. /** @hidden */
  12736. _currentEmitRate2: number;
  12737. /** @hidden */
  12738. _currentStartSizeGradient: Nullable<FactorGradient>;
  12739. /** @hidden */
  12740. _currentStartSize1: number;
  12741. /** @hidden */
  12742. _currentStartSize2: number;
  12743. private readonly _rawTextureWidth;
  12744. private _rampGradientsTexture;
  12745. private _useRampGradients;
  12746. /** Gets or sets a boolean indicating that ramp gradients must be used
  12747. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12748. */
  12749. get useRampGradients(): boolean;
  12750. set useRampGradients(value: boolean);
  12751. /**
  12752. * 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.
  12753. * 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: [])
  12754. */
  12755. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12756. private _subEmitters;
  12757. /**
  12758. * @hidden
  12759. * If the particle systems emitter should be disposed when the particle system is disposed
  12760. */
  12761. _disposeEmitterOnDispose: boolean;
  12762. /**
  12763. * The current active Sub-systems, this property is used by the root particle system only.
  12764. */
  12765. activeSubSystems: Array<ParticleSystem>;
  12766. /**
  12767. * Specifies if the particles are updated in emitter local space or world space
  12768. */
  12769. isLocal: boolean;
  12770. private _rootParticleSystem;
  12771. /**
  12772. * Gets the current list of active particles
  12773. */
  12774. get particles(): Particle[];
  12775. /**
  12776. * Gets the number of particles active at the same time.
  12777. * @returns The number of active particles.
  12778. */
  12779. getActiveCount(): number;
  12780. /**
  12781. * Returns the string "ParticleSystem"
  12782. * @returns a string containing the class name
  12783. */
  12784. getClassName(): string;
  12785. /**
  12786. * Gets a boolean indicating that the system is stopping
  12787. * @returns true if the system is currently stopping
  12788. */
  12789. isStopping(): boolean;
  12790. /**
  12791. * Gets the custom effect used to render the particles
  12792. * @param blendMode Blend mode for which the effect should be retrieved
  12793. * @returns The effect
  12794. */
  12795. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12796. /**
  12797. * Sets the custom effect used to render the particles
  12798. * @param effect The effect to set
  12799. * @param blendMode Blend mode for which the effect should be set
  12800. */
  12801. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12802. /** @hidden */
  12803. private _onBeforeDrawParticlesObservable;
  12804. /**
  12805. * Observable that will be called just before the particles are drawn
  12806. */
  12807. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12808. /**
  12809. * Gets the name of the particle vertex shader
  12810. */
  12811. get vertexShaderName(): string;
  12812. /**
  12813. * Instantiates a particle system.
  12814. * 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.
  12815. * @param name The name of the particle system
  12816. * @param capacity The max number of particles alive at the same time
  12817. * @param scene The scene the particle system belongs to
  12818. * @param customEffect a custom effect used to change the way particles are rendered by default
  12819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12820. * @param epsilon Offset used to render the particles
  12821. */
  12822. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12823. private _addFactorGradient;
  12824. private _removeFactorGradient;
  12825. /**
  12826. * Adds a new life time gradient
  12827. * @param gradient defines the gradient to use (between 0 and 1)
  12828. * @param factor defines the life time factor to affect to the specified gradient
  12829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12830. * @returns the current particle system
  12831. */
  12832. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12833. /**
  12834. * Remove a specific life time gradient
  12835. * @param gradient defines the gradient to remove
  12836. * @returns the current particle system
  12837. */
  12838. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12839. /**
  12840. * Adds a new size gradient
  12841. * @param gradient defines the gradient to use (between 0 and 1)
  12842. * @param factor defines the size factor to affect to the specified gradient
  12843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12844. * @returns the current particle system
  12845. */
  12846. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12847. /**
  12848. * Remove a specific size gradient
  12849. * @param gradient defines the gradient to remove
  12850. * @returns the current particle system
  12851. */
  12852. removeSizeGradient(gradient: number): IParticleSystem;
  12853. /**
  12854. * Adds a new color remap gradient
  12855. * @param gradient defines the gradient to use (between 0 and 1)
  12856. * @param min defines the color remap minimal range
  12857. * @param max defines the color remap maximal range
  12858. * @returns the current particle system
  12859. */
  12860. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12861. /**
  12862. * Remove a specific color remap gradient
  12863. * @param gradient defines the gradient to remove
  12864. * @returns the current particle system
  12865. */
  12866. removeColorRemapGradient(gradient: number): IParticleSystem;
  12867. /**
  12868. * Adds a new alpha remap gradient
  12869. * @param gradient defines the gradient to use (between 0 and 1)
  12870. * @param min defines the alpha remap minimal range
  12871. * @param max defines the alpha remap maximal range
  12872. * @returns the current particle system
  12873. */
  12874. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12875. /**
  12876. * Remove a specific alpha remap gradient
  12877. * @param gradient defines the gradient to remove
  12878. * @returns the current particle system
  12879. */
  12880. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12881. /**
  12882. * Adds a new angular speed gradient
  12883. * @param gradient defines the gradient to use (between 0 and 1)
  12884. * @param factor defines the angular speed to affect to the specified gradient
  12885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12886. * @returns the current particle system
  12887. */
  12888. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12889. /**
  12890. * Remove a specific angular speed gradient
  12891. * @param gradient defines the gradient to remove
  12892. * @returns the current particle system
  12893. */
  12894. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12895. /**
  12896. * Adds a new velocity gradient
  12897. * @param gradient defines the gradient to use (between 0 and 1)
  12898. * @param factor defines the velocity to affect to the specified gradient
  12899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12900. * @returns the current particle system
  12901. */
  12902. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12903. /**
  12904. * Remove a specific velocity gradient
  12905. * @param gradient defines the gradient to remove
  12906. * @returns the current particle system
  12907. */
  12908. removeVelocityGradient(gradient: number): IParticleSystem;
  12909. /**
  12910. * Adds a new limit velocity gradient
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the limit velocity value to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific limit velocity gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12923. /**
  12924. * Adds a new drag gradient
  12925. * @param gradient defines the gradient to use (between 0 and 1)
  12926. * @param factor defines the drag value to affect to the specified gradient
  12927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12928. * @returns the current particle system
  12929. */
  12930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12931. /**
  12932. * Remove a specific drag gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeDragGradient(gradient: number): IParticleSystem;
  12937. /**
  12938. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param factor defines the emit rate value to affect to the specified gradient
  12941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12942. * @returns the current particle system
  12943. */
  12944. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12945. /**
  12946. * Remove a specific emit rate gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns the current particle system
  12949. */
  12950. removeEmitRateGradient(gradient: number): IParticleSystem;
  12951. /**
  12952. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param factor defines the start size value to affect to the specified gradient
  12955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12956. * @returns the current particle system
  12957. */
  12958. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12959. /**
  12960. * Remove a specific start size gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeStartSizeGradient(gradient: number): IParticleSystem;
  12965. private _createRampGradientTexture;
  12966. /**
  12967. * Gets the current list of ramp gradients.
  12968. * You must use addRampGradient and removeRampGradient to udpate this list
  12969. * @returns the list of ramp gradients
  12970. */
  12971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12972. /** Force the system to rebuild all gradients that need to be resync */
  12973. forceRefreshGradients(): void;
  12974. private _syncRampGradientTexture;
  12975. /**
  12976. * Adds a new ramp gradient used to remap particle colors
  12977. * @param gradient defines the gradient to use (between 0 and 1)
  12978. * @param color defines the color to affect to the specified gradient
  12979. * @returns the current particle system
  12980. */
  12981. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12982. /**
  12983. * Remove a specific ramp gradient
  12984. * @param gradient defines the gradient to remove
  12985. * @returns the current particle system
  12986. */
  12987. removeRampGradient(gradient: number): ParticleSystem;
  12988. /**
  12989. * Adds a new color gradient
  12990. * @param gradient defines the gradient to use (between 0 and 1)
  12991. * @param color1 defines the color to affect to the specified gradient
  12992. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12993. * @returns this particle system
  12994. */
  12995. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12996. /**
  12997. * Remove a specific color gradient
  12998. * @param gradient defines the gradient to remove
  12999. * @returns this particle system
  13000. */
  13001. removeColorGradient(gradient: number): IParticleSystem;
  13002. private _fetchR;
  13003. protected _reset(): void;
  13004. private _resetEffect;
  13005. private _createVertexBuffers;
  13006. private _createIndexBuffer;
  13007. /**
  13008. * Gets the maximum number of particles active at the same time.
  13009. * @returns The max number of active particles.
  13010. */
  13011. getCapacity(): number;
  13012. /**
  13013. * Gets whether there are still active particles in the system.
  13014. * @returns True if it is alive, otherwise false.
  13015. */
  13016. isAlive(): boolean;
  13017. /**
  13018. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13019. * @returns True if it has been started, otherwise false.
  13020. */
  13021. isStarted(): boolean;
  13022. private _prepareSubEmitterInternalArray;
  13023. /**
  13024. * Starts the particle system and begins to emit
  13025. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13026. */
  13027. start(delay?: number): void;
  13028. /**
  13029. * Stops the particle system.
  13030. * @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.
  13031. */
  13032. stop(stopSubEmitters?: boolean): void;
  13033. /**
  13034. * Remove all active particles
  13035. */
  13036. reset(): void;
  13037. /**
  13038. * @hidden (for internal use only)
  13039. */
  13040. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13041. /**
  13042. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13043. * Its lifetime will start back at 0.
  13044. */
  13045. recycleParticle: (particle: Particle) => void;
  13046. private _stopSubEmitters;
  13047. private _createParticle;
  13048. private _removeFromRoot;
  13049. private _emitFromParticle;
  13050. private _update;
  13051. /** @hidden */
  13052. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13053. /** @hidden */
  13054. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13055. /**
  13056. * Fill the defines array according to the current settings of the particle system
  13057. * @param defines Array to be updated
  13058. * @param blendMode blend mode to take into account when updating the array
  13059. */
  13060. fillDefines(defines: Array<string>, blendMode: number): void;
  13061. /**
  13062. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13063. * @param uniforms Uniforms array to fill
  13064. * @param attributes Attributes array to fill
  13065. * @param samplers Samplers array to fill
  13066. */
  13067. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13068. /** @hidden */
  13069. private _getEffect;
  13070. /**
  13071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13073. */
  13074. animate(preWarmOnly?: boolean): void;
  13075. private _appendParticleVertices;
  13076. /**
  13077. * Rebuilds the particle system.
  13078. */
  13079. rebuild(): void;
  13080. /**
  13081. * Is this system ready to be used/rendered
  13082. * @return true if the system is ready
  13083. */
  13084. isReady(): boolean;
  13085. private _render;
  13086. /**
  13087. * Renders the particle system in its current state.
  13088. * @returns the current number of particles
  13089. */
  13090. render(): number;
  13091. /**
  13092. * Disposes the particle system and free the associated resources
  13093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13094. */
  13095. dispose(disposeTexture?: boolean): void;
  13096. /**
  13097. * Clones the particle system.
  13098. * @param name The name of the cloned object
  13099. * @param newEmitter The new emitter to use
  13100. * @returns the cloned particle system
  13101. */
  13102. clone(name: string, newEmitter: any): ParticleSystem;
  13103. /**
  13104. * Serializes the particle system to a JSON object
  13105. * @param serializeTexture defines if the texture must be serialized as well
  13106. * @returns the JSON object
  13107. */
  13108. serialize(serializeTexture?: boolean): any;
  13109. /** @hidden */
  13110. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13111. /** @hidden */
  13112. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13113. /**
  13114. * Parses a JSON object to create a particle system.
  13115. * @param parsedParticleSystem The JSON object to parse
  13116. * @param scene The scene to create the particle system in
  13117. * @param rootUrl The root url to use to load external dependencies like texture
  13118. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13119. * @returns the Parsed particle system
  13120. */
  13121. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13122. }
  13123. }
  13124. declare module "babylonjs/Particles/particle" {
  13125. import { Nullable } from "babylonjs/types";
  13126. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13127. import { Color4 } from "babylonjs/Maths/math.color";
  13128. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13129. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13130. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Effect } from "babylonjs/Materials/effect";
  13275. import { Particle } from "babylonjs/Particles/particle";
  13276. import { Scene } from "babylonjs/scene";
  13277. /**
  13278. * Particle emitter represents a volume emitting particles.
  13279. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13280. */
  13281. export interface IParticleEmitterType {
  13282. /**
  13283. * Called by the particle System when the direction is computed for the created particle.
  13284. * @param worldMatrix is the world matrix of the particle system
  13285. * @param directionToUpdate is the direction vector to update with the result
  13286. * @param particle is the particle we are computed the direction for
  13287. * @param isLocal defines if the direction should be set in local space
  13288. */
  13289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13290. /**
  13291. * Called by the particle System when the position is computed for the created particle.
  13292. * @param worldMatrix is the world matrix of the particle system
  13293. * @param positionToUpdate is the position vector to update with the result
  13294. * @param particle is the particle we are computed the position for
  13295. * @param isLocal defines if the position should be set in local space
  13296. */
  13297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13298. /**
  13299. * Clones the current emitter and returns a copy of it
  13300. * @returns the new emitter
  13301. */
  13302. clone(): IParticleEmitterType;
  13303. /**
  13304. * Called by the GPUParticleSystem to setup the update shader
  13305. * @param effect defines the update shader
  13306. */
  13307. applyToShader(effect: Effect): void;
  13308. /**
  13309. * Returns a string to use to update the GPU particles update shader
  13310. * @returns the effect defines string
  13311. */
  13312. getEffectDefines(): string;
  13313. /**
  13314. * Returns a string representing the class name
  13315. * @returns a string containing the class name
  13316. */
  13317. getClassName(): string;
  13318. /**
  13319. * Serializes the particle system to a JSON object.
  13320. * @returns the JSON object
  13321. */
  13322. serialize(): any;
  13323. /**
  13324. * Parse properties from a JSON object
  13325. * @param serializationObject defines the JSON object
  13326. * @param scene defines the hosting scene
  13327. */
  13328. parse(serializationObject: any, scene: Scene): void;
  13329. }
  13330. }
  13331. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13332. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13333. import { Effect } from "babylonjs/Materials/effect";
  13334. import { Particle } from "babylonjs/Particles/particle";
  13335. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13336. /**
  13337. * Particle emitter emitting particles from the inside of a box.
  13338. * It emits the particles randomly between 2 given directions.
  13339. */
  13340. export class BoxParticleEmitter implements IParticleEmitterType {
  13341. /**
  13342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13343. */
  13344. direction1: Vector3;
  13345. /**
  13346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13347. */
  13348. direction2: Vector3;
  13349. /**
  13350. * 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.
  13351. */
  13352. minEmitBox: Vector3;
  13353. /**
  13354. * 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.
  13355. */
  13356. maxEmitBox: Vector3;
  13357. /**
  13358. * Creates a new instance BoxParticleEmitter
  13359. */
  13360. constructor();
  13361. /**
  13362. * Called by the particle System when the direction is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param directionToUpdate is the direction vector to update with the result
  13365. * @param particle is the particle we are computed the direction for
  13366. * @param isLocal defines if the direction should be set in local space
  13367. */
  13368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Called by the particle System when the position is computed for the created particle.
  13371. * @param worldMatrix is the world matrix of the particle system
  13372. * @param positionToUpdate is the position vector to update with the result
  13373. * @param particle is the particle we are computed the position for
  13374. * @param isLocal defines if the position should be set in local space
  13375. */
  13376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13377. /**
  13378. * Clones the current emitter and returns a copy of it
  13379. * @returns the new emitter
  13380. */
  13381. clone(): BoxParticleEmitter;
  13382. /**
  13383. * Called by the GPUParticleSystem to setup the update shader
  13384. * @param effect defines the update shader
  13385. */
  13386. applyToShader(effect: Effect): void;
  13387. /**
  13388. * Returns a string to use to update the GPU particles update shader
  13389. * @returns a string containng the defines string
  13390. */
  13391. getEffectDefines(): string;
  13392. /**
  13393. * Returns the string "BoxParticleEmitter"
  13394. * @returns a string containing the class name
  13395. */
  13396. getClassName(): string;
  13397. /**
  13398. * Serializes the particle system to a JSON object.
  13399. * @returns the JSON object
  13400. */
  13401. serialize(): any;
  13402. /**
  13403. * Parse properties from a JSON object
  13404. * @param serializationObject defines the JSON object
  13405. */
  13406. parse(serializationObject: any): void;
  13407. }
  13408. }
  13409. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13410. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13411. import { Effect } from "babylonjs/Materials/effect";
  13412. import { Particle } from "babylonjs/Particles/particle";
  13413. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13414. /**
  13415. * Particle emitter emitting particles from the inside of a cone.
  13416. * It emits the particles alongside the cone volume from the base to the particle.
  13417. * The emission direction might be randomized.
  13418. */
  13419. export class ConeParticleEmitter implements IParticleEmitterType {
  13420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13421. directionRandomizer: number;
  13422. private _radius;
  13423. private _angle;
  13424. private _height;
  13425. /**
  13426. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13427. */
  13428. radiusRange: number;
  13429. /**
  13430. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13431. */
  13432. heightRange: number;
  13433. /**
  13434. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13435. */
  13436. emitFromSpawnPointOnly: boolean;
  13437. /**
  13438. * Gets or sets the radius of the emission cone
  13439. */
  13440. get radius(): number;
  13441. set radius(value: number);
  13442. /**
  13443. * Gets or sets the angle of the emission cone
  13444. */
  13445. get angle(): number;
  13446. set angle(value: number);
  13447. private _buildHeight;
  13448. /**
  13449. * Creates a new instance ConeParticleEmitter
  13450. * @param radius the radius of the emission cone (1 by default)
  13451. * @param angle the cone base angle (PI by default)
  13452. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13453. */
  13454. constructor(radius?: number, angle?: number,
  13455. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13456. directionRandomizer?: number);
  13457. /**
  13458. * Called by the particle System when the direction is computed for the created particle.
  13459. * @param worldMatrix is the world matrix of the particle system
  13460. * @param directionToUpdate is the direction vector to update with the result
  13461. * @param particle is the particle we are computed the direction for
  13462. * @param isLocal defines if the direction should be set in local space
  13463. */
  13464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13465. /**
  13466. * Called by the particle System when the position is computed for the created particle.
  13467. * @param worldMatrix is the world matrix of the particle system
  13468. * @param positionToUpdate is the position vector to update with the result
  13469. * @param particle is the particle we are computed the position for
  13470. * @param isLocal defines if the position should be set in local space
  13471. */
  13472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13473. /**
  13474. * Clones the current emitter and returns a copy of it
  13475. * @returns the new emitter
  13476. */
  13477. clone(): ConeParticleEmitter;
  13478. /**
  13479. * Called by the GPUParticleSystem to setup the update shader
  13480. * @param effect defines the update shader
  13481. */
  13482. applyToShader(effect: Effect): void;
  13483. /**
  13484. * Returns a string to use to update the GPU particles update shader
  13485. * @returns a string containng the defines string
  13486. */
  13487. getEffectDefines(): string;
  13488. /**
  13489. * Returns the string "ConeParticleEmitter"
  13490. * @returns a string containing the class name
  13491. */
  13492. getClassName(): string;
  13493. /**
  13494. * Serializes the particle system to a JSON object.
  13495. * @returns the JSON object
  13496. */
  13497. serialize(): any;
  13498. /**
  13499. * Parse properties from a JSON object
  13500. * @param serializationObject defines the JSON object
  13501. */
  13502. parse(serializationObject: any): void;
  13503. }
  13504. }
  13505. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13507. import { Effect } from "babylonjs/Materials/effect";
  13508. import { Particle } from "babylonjs/Particles/particle";
  13509. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13510. /**
  13511. * Particle emitter emitting particles from the inside of a cylinder.
  13512. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13513. */
  13514. export class CylinderParticleEmitter implements IParticleEmitterType {
  13515. /**
  13516. * The radius of the emission cylinder.
  13517. */
  13518. radius: number;
  13519. /**
  13520. * The height of the emission cylinder.
  13521. */
  13522. height: number;
  13523. /**
  13524. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13525. */
  13526. radiusRange: number;
  13527. /**
  13528. * How much to randomize the particle direction [0-1].
  13529. */
  13530. directionRandomizer: number;
  13531. /**
  13532. * Creates a new instance CylinderParticleEmitter
  13533. * @param radius the radius of the emission cylinder (1 by default)
  13534. * @param height the height of the emission cylinder (1 by default)
  13535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13536. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13537. */
  13538. constructor(
  13539. /**
  13540. * The radius of the emission cylinder.
  13541. */
  13542. radius?: number,
  13543. /**
  13544. * The height of the emission cylinder.
  13545. */
  13546. height?: number,
  13547. /**
  13548. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13549. */
  13550. radiusRange?: number,
  13551. /**
  13552. * How much to randomize the particle direction [0-1].
  13553. */
  13554. directionRandomizer?: number);
  13555. /**
  13556. * Called by the particle System when the direction is computed for the created particle.
  13557. * @param worldMatrix is the world matrix of the particle system
  13558. * @param directionToUpdate is the direction vector to update with the result
  13559. * @param particle is the particle we are computed the direction for
  13560. * @param isLocal defines if the direction should be set in local space
  13561. */
  13562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13563. /**
  13564. * Called by the particle System when the position is computed for the created particle.
  13565. * @param worldMatrix is the world matrix of the particle system
  13566. * @param positionToUpdate is the position vector to update with the result
  13567. * @param particle is the particle we are computed the position for
  13568. * @param isLocal defines if the position should be set in local space
  13569. */
  13570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13571. /**
  13572. * Clones the current emitter and returns a copy of it
  13573. * @returns the new emitter
  13574. */
  13575. clone(): CylinderParticleEmitter;
  13576. /**
  13577. * Called by the GPUParticleSystem to setup the update shader
  13578. * @param effect defines the update shader
  13579. */
  13580. applyToShader(effect: Effect): void;
  13581. /**
  13582. * Returns a string to use to update the GPU particles update shader
  13583. * @returns a string containng the defines string
  13584. */
  13585. getEffectDefines(): string;
  13586. /**
  13587. * Returns the string "CylinderParticleEmitter"
  13588. * @returns a string containing the class name
  13589. */
  13590. getClassName(): string;
  13591. /**
  13592. * Serializes the particle system to a JSON object.
  13593. * @returns the JSON object
  13594. */
  13595. serialize(): any;
  13596. /**
  13597. * Parse properties from a JSON object
  13598. * @param serializationObject defines the JSON object
  13599. */
  13600. parse(serializationObject: any): void;
  13601. }
  13602. /**
  13603. * Particle emitter emitting particles from the inside of a cylinder.
  13604. * It emits the particles randomly between two vectors.
  13605. */
  13606. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13607. /**
  13608. * The min limit of the emission direction.
  13609. */
  13610. direction1: Vector3;
  13611. /**
  13612. * The max limit of the emission direction.
  13613. */
  13614. direction2: Vector3;
  13615. /**
  13616. * Creates a new instance CylinderDirectedParticleEmitter
  13617. * @param radius the radius of the emission cylinder (1 by default)
  13618. * @param height the height of the emission cylinder (1 by default)
  13619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param direction1 the min limit of the emission direction (up vector by default)
  13621. * @param direction2 the max limit of the emission direction (up vector by default)
  13622. */
  13623. constructor(radius?: number, height?: number, radiusRange?: number,
  13624. /**
  13625. * The min limit of the emission direction.
  13626. */
  13627. direction1?: Vector3,
  13628. /**
  13629. * The max limit of the emission direction.
  13630. */
  13631. direction2?: Vector3);
  13632. /**
  13633. * Called by the particle System when the direction is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param directionToUpdate is the direction vector to update with the result
  13636. * @param particle is the particle we are computed the direction for
  13637. */
  13638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13639. /**
  13640. * Clones the current emitter and returns a copy of it
  13641. * @returns the new emitter
  13642. */
  13643. clone(): CylinderDirectedParticleEmitter;
  13644. /**
  13645. * Called by the GPUParticleSystem to setup the update shader
  13646. * @param effect defines the update shader
  13647. */
  13648. applyToShader(effect: Effect): void;
  13649. /**
  13650. * Returns a string to use to update the GPU particles update shader
  13651. * @returns a string containng the defines string
  13652. */
  13653. getEffectDefines(): string;
  13654. /**
  13655. * Returns the string "CylinderDirectedParticleEmitter"
  13656. * @returns a string containing the class name
  13657. */
  13658. getClassName(): string;
  13659. /**
  13660. * Serializes the particle system to a JSON object.
  13661. * @returns the JSON object
  13662. */
  13663. serialize(): any;
  13664. /**
  13665. * Parse properties from a JSON object
  13666. * @param serializationObject defines the JSON object
  13667. */
  13668. parse(serializationObject: any): void;
  13669. }
  13670. }
  13671. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13672. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13673. import { Effect } from "babylonjs/Materials/effect";
  13674. import { Particle } from "babylonjs/Particles/particle";
  13675. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a hemisphere.
  13678. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13679. */
  13680. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission hemisphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance HemisphericParticleEmitter
  13695. * @param radius the radius of the emission hemisphere (1 by default)
  13696. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission hemisphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): HemisphericParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "HemisphericParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. }
  13760. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13762. import { Effect } from "babylonjs/Materials/effect";
  13763. import { Particle } from "babylonjs/Particles/particle";
  13764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13765. /**
  13766. * Particle emitter emitting particles from a point.
  13767. * It emits the particles randomly between 2 given directions.
  13768. */
  13769. export class PointParticleEmitter implements IParticleEmitterType {
  13770. /**
  13771. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13772. */
  13773. direction1: Vector3;
  13774. /**
  13775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13776. */
  13777. direction2: Vector3;
  13778. /**
  13779. * Creates a new instance PointParticleEmitter
  13780. */
  13781. constructor();
  13782. /**
  13783. * Called by the particle System when the direction is computed for the created particle.
  13784. * @param worldMatrix is the world matrix of the particle system
  13785. * @param directionToUpdate is the direction vector to update with the result
  13786. * @param particle is the particle we are computed the direction for
  13787. * @param isLocal defines if the direction should be set in local space
  13788. */
  13789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13790. /**
  13791. * Called by the particle System when the position is computed for the created particle.
  13792. * @param worldMatrix is the world matrix of the particle system
  13793. * @param positionToUpdate is the position vector to update with the result
  13794. * @param particle is the particle we are computed the position for
  13795. * @param isLocal defines if the position should be set in local space
  13796. */
  13797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13798. /**
  13799. * Clones the current emitter and returns a copy of it
  13800. * @returns the new emitter
  13801. */
  13802. clone(): PointParticleEmitter;
  13803. /**
  13804. * Called by the GPUParticleSystem to setup the update shader
  13805. * @param effect defines the update shader
  13806. */
  13807. applyToShader(effect: Effect): void;
  13808. /**
  13809. * Returns a string to use to update the GPU particles update shader
  13810. * @returns a string containng the defines string
  13811. */
  13812. getEffectDefines(): string;
  13813. /**
  13814. * Returns the string "PointParticleEmitter"
  13815. * @returns a string containing the class name
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Serializes the particle system to a JSON object.
  13820. * @returns the JSON object
  13821. */
  13822. serialize(): any;
  13823. /**
  13824. * Parse properties from a JSON object
  13825. * @param serializationObject defines the JSON object
  13826. */
  13827. parse(serializationObject: any): void;
  13828. }
  13829. }
  13830. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13832. import { Effect } from "babylonjs/Materials/effect";
  13833. import { Particle } from "babylonjs/Particles/particle";
  13834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a sphere.
  13837. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13838. */
  13839. export class SphereParticleEmitter implements IParticleEmitterType {
  13840. /**
  13841. * The radius of the emission sphere.
  13842. */
  13843. radius: number;
  13844. /**
  13845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13846. */
  13847. radiusRange: number;
  13848. /**
  13849. * How much to randomize the particle direction [0-1].
  13850. */
  13851. directionRandomizer: number;
  13852. /**
  13853. * Creates a new instance SphereParticleEmitter
  13854. * @param radius the radius of the emission sphere (1 by default)
  13855. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13856. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13857. */
  13858. constructor(
  13859. /**
  13860. * The radius of the emission sphere.
  13861. */
  13862. radius?: number,
  13863. /**
  13864. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13865. */
  13866. radiusRange?: number,
  13867. /**
  13868. * How much to randomize the particle direction [0-1].
  13869. */
  13870. directionRandomizer?: number);
  13871. /**
  13872. * Called by the particle System when the direction is computed for the created particle.
  13873. * @param worldMatrix is the world matrix of the particle system
  13874. * @param directionToUpdate is the direction vector to update with the result
  13875. * @param particle is the particle we are computed the direction for
  13876. * @param isLocal defines if the direction should be set in local space
  13877. */
  13878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13879. /**
  13880. * Called by the particle System when the position is computed for the created particle.
  13881. * @param worldMatrix is the world matrix of the particle system
  13882. * @param positionToUpdate is the position vector to update with the result
  13883. * @param particle is the particle we are computed the position for
  13884. * @param isLocal defines if the position should be set in local space
  13885. */
  13886. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13887. /**
  13888. * Clones the current emitter and returns a copy of it
  13889. * @returns the new emitter
  13890. */
  13891. clone(): SphereParticleEmitter;
  13892. /**
  13893. * Called by the GPUParticleSystem to setup the update shader
  13894. * @param effect defines the update shader
  13895. */
  13896. applyToShader(effect: Effect): void;
  13897. /**
  13898. * Returns a string to use to update the GPU particles update shader
  13899. * @returns a string containng the defines string
  13900. */
  13901. getEffectDefines(): string;
  13902. /**
  13903. * Returns the string "SphereParticleEmitter"
  13904. * @returns a string containing the class name
  13905. */
  13906. getClassName(): string;
  13907. /**
  13908. * Serializes the particle system to a JSON object.
  13909. * @returns the JSON object
  13910. */
  13911. serialize(): any;
  13912. /**
  13913. * Parse properties from a JSON object
  13914. * @param serializationObject defines the JSON object
  13915. */
  13916. parse(serializationObject: any): void;
  13917. }
  13918. /**
  13919. * Particle emitter emitting particles from the inside of a sphere.
  13920. * It emits the particles randomly between two vectors.
  13921. */
  13922. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13923. /**
  13924. * The min limit of the emission direction.
  13925. */
  13926. direction1: Vector3;
  13927. /**
  13928. * The max limit of the emission direction.
  13929. */
  13930. direction2: Vector3;
  13931. /**
  13932. * Creates a new instance SphereDirectedParticleEmitter
  13933. * @param radius the radius of the emission sphere (1 by default)
  13934. * @param direction1 the min limit of the emission direction (up vector by default)
  13935. * @param direction2 the max limit of the emission direction (up vector by default)
  13936. */
  13937. constructor(radius?: number,
  13938. /**
  13939. * The min limit of the emission direction.
  13940. */
  13941. direction1?: Vector3,
  13942. /**
  13943. * The max limit of the emission direction.
  13944. */
  13945. direction2?: Vector3);
  13946. /**
  13947. * Called by the particle System when the direction is computed for the created particle.
  13948. * @param worldMatrix is the world matrix of the particle system
  13949. * @param directionToUpdate is the direction vector to update with the result
  13950. * @param particle is the particle we are computed the direction for
  13951. */
  13952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13953. /**
  13954. * Clones the current emitter and returns a copy of it
  13955. * @returns the new emitter
  13956. */
  13957. clone(): SphereDirectedParticleEmitter;
  13958. /**
  13959. * Called by the GPUParticleSystem to setup the update shader
  13960. * @param effect defines the update shader
  13961. */
  13962. applyToShader(effect: Effect): void;
  13963. /**
  13964. * Returns a string to use to update the GPU particles update shader
  13965. * @returns a string containng the defines string
  13966. */
  13967. getEffectDefines(): string;
  13968. /**
  13969. * Returns the string "SphereDirectedParticleEmitter"
  13970. * @returns a string containing the class name
  13971. */
  13972. getClassName(): string;
  13973. /**
  13974. * Serializes the particle system to a JSON object.
  13975. * @returns the JSON object
  13976. */
  13977. serialize(): any;
  13978. /**
  13979. * Parse properties from a JSON object
  13980. * @param serializationObject defines the JSON object
  13981. */
  13982. parse(serializationObject: any): void;
  13983. }
  13984. }
  13985. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13987. import { Effect } from "babylonjs/Materials/effect";
  13988. import { Particle } from "babylonjs/Particles/particle";
  13989. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13990. import { Nullable } from "babylonjs/types";
  13991. /**
  13992. * Particle emitter emitting particles from a custom list of positions.
  13993. */
  13994. export class CustomParticleEmitter implements IParticleEmitterType {
  13995. /**
  13996. * Gets or sets the position generator that will create the inital position of each particle.
  13997. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13998. */
  13999. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14000. /**
  14001. * Gets or sets the destination generator that will create the final destination of each particle.
  14002. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14003. */
  14004. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14005. /**
  14006. * Creates a new instance CustomParticleEmitter
  14007. */
  14008. constructor();
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): CustomParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "PointParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. */
  14054. parse(serializationObject: any): void;
  14055. }
  14056. }
  14057. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14059. import { Effect } from "babylonjs/Materials/effect";
  14060. import { Particle } from "babylonjs/Particles/particle";
  14061. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14062. import { Nullable } from "babylonjs/types";
  14063. import { Scene } from "babylonjs/scene";
  14064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14065. /**
  14066. * Particle emitter emitting particles from the inside of a box.
  14067. * It emits the particles randomly between 2 given directions.
  14068. */
  14069. export class MeshParticleEmitter implements IParticleEmitterType {
  14070. private _indices;
  14071. private _positions;
  14072. private _normals;
  14073. private _storedNormal;
  14074. private _mesh;
  14075. /**
  14076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14077. */
  14078. direction1: Vector3;
  14079. /**
  14080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14081. */
  14082. direction2: Vector3;
  14083. /**
  14084. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14085. */
  14086. useMeshNormalsForDirection: boolean;
  14087. /** Defines the mesh to use as source */
  14088. get mesh(): Nullable<AbstractMesh>;
  14089. set mesh(value: Nullable<AbstractMesh>);
  14090. /**
  14091. * Creates a new instance MeshParticleEmitter
  14092. * @param mesh defines the mesh to use as source
  14093. */
  14094. constructor(mesh?: Nullable<AbstractMesh>);
  14095. /**
  14096. * Called by the particle System when the direction is computed for the created particle.
  14097. * @param worldMatrix is the world matrix of the particle system
  14098. * @param directionToUpdate is the direction vector to update with the result
  14099. * @param particle is the particle we are computed the direction for
  14100. * @param isLocal defines if the direction should be set in local space
  14101. */
  14102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14103. /**
  14104. * Called by the particle System when the position is computed for the created particle.
  14105. * @param worldMatrix is the world matrix of the particle system
  14106. * @param positionToUpdate is the position vector to update with the result
  14107. * @param particle is the particle we are computed the position for
  14108. * @param isLocal defines if the position should be set in local space
  14109. */
  14110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14111. /**
  14112. * Clones the current emitter and returns a copy of it
  14113. * @returns the new emitter
  14114. */
  14115. clone(): MeshParticleEmitter;
  14116. /**
  14117. * Called by the GPUParticleSystem to setup the update shader
  14118. * @param effect defines the update shader
  14119. */
  14120. applyToShader(effect: Effect): void;
  14121. /**
  14122. * Returns a string to use to update the GPU particles update shader
  14123. * @returns a string containng the defines string
  14124. */
  14125. getEffectDefines(): string;
  14126. /**
  14127. * Returns the string "BoxParticleEmitter"
  14128. * @returns a string containing the class name
  14129. */
  14130. getClassName(): string;
  14131. /**
  14132. * Serializes the particle system to a JSON object.
  14133. * @returns the JSON object
  14134. */
  14135. serialize(): any;
  14136. /**
  14137. * Parse properties from a JSON object
  14138. * @param serializationObject defines the JSON object
  14139. * @param scene defines the hosting scene
  14140. */
  14141. parse(serializationObject: any, scene: Scene): void;
  14142. }
  14143. }
  14144. declare module "babylonjs/Particles/EmitterTypes/index" {
  14145. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14146. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14147. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14148. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14149. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14150. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14151. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14152. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14153. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14154. }
  14155. declare module "babylonjs/Particles/IParticleSystem" {
  14156. import { Nullable } from "babylonjs/types";
  14157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14158. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14161. import { Texture } from "babylonjs/Materials/Textures/texture";
  14162. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14163. import { Scene } from "babylonjs/scene";
  14164. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14165. import { Effect } from "babylonjs/Materials/effect";
  14166. import { Observable } from "babylonjs/Misc/observable";
  14167. import { Animation } from "babylonjs/Animations/animation";
  14168. /**
  14169. * Interface representing a particle system in Babylon.js.
  14170. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14171. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14172. */
  14173. export interface IParticleSystem {
  14174. /**
  14175. * List of animations used by the particle system.
  14176. */
  14177. animations: Animation[];
  14178. /**
  14179. * The id of the Particle system.
  14180. */
  14181. id: string;
  14182. /**
  14183. * The name of the Particle system.
  14184. */
  14185. name: string;
  14186. /**
  14187. * The emitter represents the Mesh or position we are attaching the particle system to.
  14188. */
  14189. emitter: Nullable<AbstractMesh | Vector3>;
  14190. /**
  14191. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14192. */
  14193. isBillboardBased: boolean;
  14194. /**
  14195. * The rendering group used by the Particle system to chose when to render.
  14196. */
  14197. renderingGroupId: number;
  14198. /**
  14199. * The layer mask we are rendering the particles through.
  14200. */
  14201. layerMask: number;
  14202. /**
  14203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14204. */
  14205. updateSpeed: number;
  14206. /**
  14207. * The amount of time the particle system is running (depends of the overall update speed).
  14208. */
  14209. targetStopDuration: number;
  14210. /**
  14211. * The texture used to render each particle. (this can be a spritesheet)
  14212. */
  14213. particleTexture: Nullable<Texture>;
  14214. /**
  14215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14216. */
  14217. blendMode: number;
  14218. /**
  14219. * Minimum life time of emitting particles.
  14220. */
  14221. minLifeTime: number;
  14222. /**
  14223. * Maximum life time of emitting particles.
  14224. */
  14225. maxLifeTime: number;
  14226. /**
  14227. * Minimum Size of emitting particles.
  14228. */
  14229. minSize: number;
  14230. /**
  14231. * Maximum Size of emitting particles.
  14232. */
  14233. maxSize: number;
  14234. /**
  14235. * Minimum scale of emitting particles on X axis.
  14236. */
  14237. minScaleX: number;
  14238. /**
  14239. * Maximum scale of emitting particles on X axis.
  14240. */
  14241. maxScaleX: number;
  14242. /**
  14243. * Minimum scale of emitting particles on Y axis.
  14244. */
  14245. minScaleY: number;
  14246. /**
  14247. * Maximum scale of emitting particles on Y axis.
  14248. */
  14249. maxScaleY: number;
  14250. /**
  14251. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14252. */
  14253. color1: Color4;
  14254. /**
  14255. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14256. */
  14257. color2: Color4;
  14258. /**
  14259. * Color the particle will have at the end of its lifetime.
  14260. */
  14261. colorDead: Color4;
  14262. /**
  14263. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14264. */
  14265. emitRate: number;
  14266. /**
  14267. * You can use gravity if you want to give an orientation to your particles.
  14268. */
  14269. gravity: Vector3;
  14270. /**
  14271. * Minimum power of emitting particles.
  14272. */
  14273. minEmitPower: number;
  14274. /**
  14275. * Maximum power of emitting particles.
  14276. */
  14277. maxEmitPower: number;
  14278. /**
  14279. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14280. */
  14281. minAngularSpeed: number;
  14282. /**
  14283. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14284. */
  14285. maxAngularSpeed: number;
  14286. /**
  14287. * Gets or sets the minimal initial rotation in radians.
  14288. */
  14289. minInitialRotation: number;
  14290. /**
  14291. * Gets or sets the maximal initial rotation in radians.
  14292. */
  14293. maxInitialRotation: number;
  14294. /**
  14295. * The particle emitter type defines the emitter used by the particle system.
  14296. * It can be for example box, sphere, or cone...
  14297. */
  14298. particleEmitterType: Nullable<IParticleEmitterType>;
  14299. /**
  14300. * Defines the delay in milliseconds before starting the system (0 by default)
  14301. */
  14302. startDelay: number;
  14303. /**
  14304. * 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
  14305. */
  14306. preWarmCycles: number;
  14307. /**
  14308. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14309. */
  14310. preWarmStepOffset: number;
  14311. /**
  14312. * 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)
  14313. */
  14314. spriteCellChangeSpeed: number;
  14315. /**
  14316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14317. */
  14318. startSpriteCellID: number;
  14319. /**
  14320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14321. */
  14322. endSpriteCellID: number;
  14323. /**
  14324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14325. */
  14326. spriteCellWidth: number;
  14327. /**
  14328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14329. */
  14330. spriteCellHeight: number;
  14331. /**
  14332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14333. */
  14334. spriteRandomStartCell: boolean;
  14335. /**
  14336. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14337. */
  14338. isAnimationSheetEnabled: boolean;
  14339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14340. translationPivot: Vector2;
  14341. /**
  14342. * Gets or sets a texture used to add random noise to particle positions
  14343. */
  14344. noiseTexture: Nullable<BaseTexture>;
  14345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14346. noiseStrength: Vector3;
  14347. /**
  14348. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14349. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14350. */
  14351. billboardMode: number;
  14352. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14353. limitVelocityDamping: number;
  14354. /**
  14355. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14356. */
  14357. beginAnimationOnStart: boolean;
  14358. /**
  14359. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14360. */
  14361. beginAnimationFrom: number;
  14362. /**
  14363. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14364. */
  14365. beginAnimationTo: number;
  14366. /**
  14367. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14368. */
  14369. beginAnimationLoop: boolean;
  14370. /**
  14371. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14372. */
  14373. disposeOnStop: boolean;
  14374. /**
  14375. * Specifies if the particles are updated in emitter local space or world space
  14376. */
  14377. isLocal: boolean;
  14378. /** Snippet ID if the particle system was created from the snippet server */
  14379. snippetId: string;
  14380. /**
  14381. * Gets the maximum number of particles active at the same time.
  14382. * @returns The max number of active particles.
  14383. */
  14384. getCapacity(): number;
  14385. /**
  14386. * Gets the number of particles active at the same time.
  14387. * @returns The number of active particles.
  14388. */
  14389. getActiveCount(): number;
  14390. /**
  14391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14392. * @returns True if it has been started, otherwise false.
  14393. */
  14394. isStarted(): boolean;
  14395. /**
  14396. * Animates the particle system for this frame.
  14397. */
  14398. animate(): void;
  14399. /**
  14400. * Renders the particle system in its current state.
  14401. * @returns the current number of particles
  14402. */
  14403. render(): number;
  14404. /**
  14405. * Dispose the particle system and frees its associated resources.
  14406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14407. */
  14408. dispose(disposeTexture?: boolean): void;
  14409. /**
  14410. * An event triggered when the system is disposed
  14411. */
  14412. onDisposeObservable: Observable<IParticleSystem>;
  14413. /**
  14414. * Clones the particle system.
  14415. * @param name The name of the cloned object
  14416. * @param newEmitter The new emitter to use
  14417. * @returns the cloned particle system
  14418. */
  14419. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14420. /**
  14421. * Serializes the particle system to a JSON object
  14422. * @param serializeTexture defines if the texture must be serialized as well
  14423. * @returns the JSON object
  14424. */
  14425. serialize(serializeTexture: boolean): any;
  14426. /**
  14427. * Rebuild the particle system
  14428. */
  14429. rebuild(): void;
  14430. /** Force the system to rebuild all gradients that need to be resync */
  14431. forceRefreshGradients(): void;
  14432. /**
  14433. * Starts the particle system and begins to emit
  14434. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14435. */
  14436. start(delay?: number): void;
  14437. /**
  14438. * Stops the particle system.
  14439. */
  14440. stop(): void;
  14441. /**
  14442. * Remove all active particles
  14443. */
  14444. reset(): void;
  14445. /**
  14446. * Gets a boolean indicating that the system is stopping
  14447. * @returns true if the system is currently stopping
  14448. */
  14449. isStopping(): boolean;
  14450. /**
  14451. * Is this system ready to be used/rendered
  14452. * @return true if the system is ready
  14453. */
  14454. isReady(): boolean;
  14455. /**
  14456. * Returns the string "ParticleSystem"
  14457. * @returns a string containing the class name
  14458. */
  14459. getClassName(): string;
  14460. /**
  14461. * Gets the custom effect used to render the particles
  14462. * @param blendMode Blend mode for which the effect should be retrieved
  14463. * @returns The effect
  14464. */
  14465. getCustomEffect(blendMode: number): Nullable<Effect>;
  14466. /**
  14467. * Sets the custom effect used to render the particles
  14468. * @param effect The effect to set
  14469. * @param blendMode Blend mode for which the effect should be set
  14470. */
  14471. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14472. /**
  14473. * Fill the defines array according to the current settings of the particle system
  14474. * @param defines Array to be updated
  14475. * @param blendMode blend mode to take into account when updating the array
  14476. */
  14477. fillDefines(defines: Array<string>, blendMode: number): void;
  14478. /**
  14479. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14480. * @param uniforms Uniforms array to fill
  14481. * @param attributes Attributes array to fill
  14482. * @param samplers Samplers array to fill
  14483. */
  14484. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14485. /**
  14486. * Observable that will be called just before the particles are drawn
  14487. */
  14488. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14489. /**
  14490. * Gets the name of the particle vertex shader
  14491. */
  14492. vertexShaderName: string;
  14493. /**
  14494. * Adds a new color gradient
  14495. * @param gradient defines the gradient to use (between 0 and 1)
  14496. * @param color1 defines the color to affect to the specified gradient
  14497. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14498. * @returns the current particle system
  14499. */
  14500. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14501. /**
  14502. * Remove a specific color gradient
  14503. * @param gradient defines the gradient to remove
  14504. * @returns the current particle system
  14505. */
  14506. removeColorGradient(gradient: number): IParticleSystem;
  14507. /**
  14508. * Adds a new size gradient
  14509. * @param gradient defines the gradient to use (between 0 and 1)
  14510. * @param factor defines the size factor to affect to the specified gradient
  14511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14512. * @returns the current particle system
  14513. */
  14514. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14515. /**
  14516. * Remove a specific size gradient
  14517. * @param gradient defines the gradient to remove
  14518. * @returns the current particle system
  14519. */
  14520. removeSizeGradient(gradient: number): IParticleSystem;
  14521. /**
  14522. * Gets the current list of color gradients.
  14523. * You must use addColorGradient and removeColorGradient to udpate this list
  14524. * @returns the list of color gradients
  14525. */
  14526. getColorGradients(): Nullable<Array<ColorGradient>>;
  14527. /**
  14528. * Gets the current list of size gradients.
  14529. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14530. * @returns the list of size gradients
  14531. */
  14532. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Gets the current list of angular speed gradients.
  14535. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14536. * @returns the list of angular speed gradients
  14537. */
  14538. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14539. /**
  14540. * Adds a new angular speed gradient
  14541. * @param gradient defines the gradient to use (between 0 and 1)
  14542. * @param factor defines the angular speed to affect to the specified gradient
  14543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14544. * @returns the current particle system
  14545. */
  14546. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14547. /**
  14548. * Remove a specific angular speed gradient
  14549. * @param gradient defines the gradient to remove
  14550. * @returns the current particle system
  14551. */
  14552. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14553. /**
  14554. * Gets the current list of velocity gradients.
  14555. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14556. * @returns the list of velocity gradients
  14557. */
  14558. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14559. /**
  14560. * Adds a new velocity gradient
  14561. * @param gradient defines the gradient to use (between 0 and 1)
  14562. * @param factor defines the velocity to affect to the specified gradient
  14563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14564. * @returns the current particle system
  14565. */
  14566. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14567. /**
  14568. * Remove a specific velocity gradient
  14569. * @param gradient defines the gradient to remove
  14570. * @returns the current particle system
  14571. */
  14572. removeVelocityGradient(gradient: number): IParticleSystem;
  14573. /**
  14574. * Gets the current list of limit velocity gradients.
  14575. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14576. * @returns the list of limit velocity gradients
  14577. */
  14578. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14579. /**
  14580. * Adds a new limit velocity gradient
  14581. * @param gradient defines the gradient to use (between 0 and 1)
  14582. * @param factor defines the limit velocity to affect to the specified gradient
  14583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14584. * @returns the current particle system
  14585. */
  14586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14587. /**
  14588. * Remove a specific limit velocity gradient
  14589. * @param gradient defines the gradient to remove
  14590. * @returns the current particle system
  14591. */
  14592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14593. /**
  14594. * Adds a new drag gradient
  14595. * @param gradient defines the gradient to use (between 0 and 1)
  14596. * @param factor defines the drag to affect to the specified gradient
  14597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14598. * @returns the current particle system
  14599. */
  14600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14601. /**
  14602. * Remove a specific drag gradient
  14603. * @param gradient defines the gradient to remove
  14604. * @returns the current particle system
  14605. */
  14606. removeDragGradient(gradient: number): IParticleSystem;
  14607. /**
  14608. * Gets the current list of drag gradients.
  14609. * You must use addDragGradient and removeDragGradient to udpate this list
  14610. * @returns the list of drag gradients
  14611. */
  14612. getDragGradients(): Nullable<Array<FactorGradient>>;
  14613. /**
  14614. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param factor defines the emit rate to affect to the specified gradient
  14617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14618. * @returns the current particle system
  14619. */
  14620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14621. /**
  14622. * Remove a specific emit rate gradient
  14623. * @param gradient defines the gradient to remove
  14624. * @returns the current particle system
  14625. */
  14626. removeEmitRateGradient(gradient: number): IParticleSystem;
  14627. /**
  14628. * Gets the current list of emit rate gradients.
  14629. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14630. * @returns the list of emit rate gradients
  14631. */
  14632. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14633. /**
  14634. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14635. * @param gradient defines the gradient to use (between 0 and 1)
  14636. * @param factor defines the start size to affect to the specified gradient
  14637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14638. * @returns the current particle system
  14639. */
  14640. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14641. /**
  14642. * Remove a specific start size gradient
  14643. * @param gradient defines the gradient to remove
  14644. * @returns the current particle system
  14645. */
  14646. removeStartSizeGradient(gradient: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of start size gradients.
  14649. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14650. * @returns the list of start size gradients
  14651. */
  14652. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new life time gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param factor defines the life time factor to affect to the specified gradient
  14657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14658. * @returns the current particle system
  14659. */
  14660. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14661. /**
  14662. * Remove a specific life time gradient
  14663. * @param gradient defines the gradient to remove
  14664. * @returns the current particle system
  14665. */
  14666. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14667. /**
  14668. * Gets the current list of life time gradients.
  14669. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14670. * @returns the list of life time gradients
  14671. */
  14672. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14673. /**
  14674. * Gets the current list of color gradients.
  14675. * You must use addColorGradient and removeColorGradient to udpate this list
  14676. * @returns the list of color gradients
  14677. */
  14678. getColorGradients(): Nullable<Array<ColorGradient>>;
  14679. /**
  14680. * Adds a new ramp gradient used to remap particle colors
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color defines the color to affect to the specified gradient
  14683. * @returns the current particle system
  14684. */
  14685. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14686. /**
  14687. * Gets the current list of ramp gradients.
  14688. * You must use addRampGradient and removeRampGradient to udpate this list
  14689. * @returns the list of ramp gradients
  14690. */
  14691. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14692. /** Gets or sets a boolean indicating that ramp gradients must be used
  14693. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14694. */
  14695. useRampGradients: boolean;
  14696. /**
  14697. * Adds a new color remap gradient
  14698. * @param gradient defines the gradient to use (between 0 and 1)
  14699. * @param min defines the color remap minimal range
  14700. * @param max defines the color remap maximal range
  14701. * @returns the current particle system
  14702. */
  14703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14704. /**
  14705. * Gets the current list of color remap gradients.
  14706. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14707. * @returns the list of color remap gradients
  14708. */
  14709. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14710. /**
  14711. * Adds a new alpha remap gradient
  14712. * @param gradient defines the gradient to use (between 0 and 1)
  14713. * @param min defines the alpha remap minimal range
  14714. * @param max defines the alpha remap maximal range
  14715. * @returns the current particle system
  14716. */
  14717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14718. /**
  14719. * Gets the current list of alpha remap gradients.
  14720. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14721. * @returns the list of alpha remap gradients
  14722. */
  14723. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14724. /**
  14725. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14728. * @returns the emitter
  14729. */
  14730. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14731. /**
  14732. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14733. * @param radius The radius of the hemisphere to emit from
  14734. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14735. * @returns the emitter
  14736. */
  14737. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14738. /**
  14739. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14740. * @param radius The radius of the sphere to emit from
  14741. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14742. * @returns the emitter
  14743. */
  14744. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14745. /**
  14746. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14747. * @param radius The radius of the sphere to emit from
  14748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14750. * @returns the emitter
  14751. */
  14752. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14753. /**
  14754. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14755. * @param radius The radius of the emission cylinder
  14756. * @param height The height of the emission cylinder
  14757. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14758. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14759. * @returns the emitter
  14760. */
  14761. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14762. /**
  14763. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14764. * @param radius The radius of the cylinder to emit from
  14765. * @param height The height of the emission cylinder
  14766. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14769. * @returns the emitter
  14770. */
  14771. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14772. /**
  14773. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14774. * @param radius The radius of the cone to emit from
  14775. * @param angle The base angle of the cone
  14776. * @returns the emitter
  14777. */
  14778. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14779. /**
  14780. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14783. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14784. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14785. * @returns the emitter
  14786. */
  14787. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14788. /**
  14789. * Get hosting scene
  14790. * @returns the scene
  14791. */
  14792. getScene(): Scene;
  14793. }
  14794. }
  14795. declare module "babylonjs/Meshes/transformNode" {
  14796. import { DeepImmutable } from "babylonjs/types";
  14797. import { Observable } from "babylonjs/Misc/observable";
  14798. import { Nullable } from "babylonjs/types";
  14799. import { Camera } from "babylonjs/Cameras/camera";
  14800. import { Scene } from "babylonjs/scene";
  14801. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14802. import { Node } from "babylonjs/node";
  14803. import { Bone } from "babylonjs/Bones/bone";
  14804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14805. import { Space } from "babylonjs/Maths/math.axis";
  14806. /**
  14807. * 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.
  14808. * @see https://doc.babylonjs.com/how_to/transformnode
  14809. */
  14810. export class TransformNode extends Node {
  14811. /**
  14812. * Object will not rotate to face the camera
  14813. */
  14814. static BILLBOARDMODE_NONE: number;
  14815. /**
  14816. * Object will rotate to face the camera but only on the x axis
  14817. */
  14818. static BILLBOARDMODE_X: number;
  14819. /**
  14820. * Object will rotate to face the camera but only on the y axis
  14821. */
  14822. static BILLBOARDMODE_Y: number;
  14823. /**
  14824. * Object will rotate to face the camera but only on the z axis
  14825. */
  14826. static BILLBOARDMODE_Z: number;
  14827. /**
  14828. * Object will rotate to face the camera
  14829. */
  14830. static BILLBOARDMODE_ALL: number;
  14831. /**
  14832. * Object will rotate to face the camera's position instead of orientation
  14833. */
  14834. static BILLBOARDMODE_USE_POSITION: number;
  14835. private static _TmpRotation;
  14836. private static _TmpScaling;
  14837. private static _TmpTranslation;
  14838. private _forward;
  14839. private _forwardInverted;
  14840. private _up;
  14841. private _right;
  14842. private _rightInverted;
  14843. private _position;
  14844. private _rotation;
  14845. private _rotationQuaternion;
  14846. protected _scaling: Vector3;
  14847. protected _isDirty: boolean;
  14848. private _transformToBoneReferal;
  14849. private _isAbsoluteSynced;
  14850. private _billboardMode;
  14851. /**
  14852. * Gets or sets the billboard mode. Default is 0.
  14853. *
  14854. * | Value | Type | Description |
  14855. * | --- | --- | --- |
  14856. * | 0 | BILLBOARDMODE_NONE | |
  14857. * | 1 | BILLBOARDMODE_X | |
  14858. * | 2 | BILLBOARDMODE_Y | |
  14859. * | 4 | BILLBOARDMODE_Z | |
  14860. * | 7 | BILLBOARDMODE_ALL | |
  14861. *
  14862. */
  14863. get billboardMode(): number;
  14864. set billboardMode(value: number);
  14865. private _preserveParentRotationForBillboard;
  14866. /**
  14867. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14868. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14869. */
  14870. get preserveParentRotationForBillboard(): boolean;
  14871. set preserveParentRotationForBillboard(value: boolean);
  14872. /**
  14873. * 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
  14874. */
  14875. scalingDeterminant: number;
  14876. private _infiniteDistance;
  14877. /**
  14878. * Gets or sets the distance of the object to max, often used by skybox
  14879. */
  14880. get infiniteDistance(): boolean;
  14881. set infiniteDistance(value: boolean);
  14882. /**
  14883. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14884. * By default the system will update normals to compensate
  14885. */
  14886. ignoreNonUniformScaling: boolean;
  14887. /**
  14888. * 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
  14889. */
  14890. reIntegrateRotationIntoRotationQuaternion: boolean;
  14891. /** @hidden */
  14892. _poseMatrix: Nullable<Matrix>;
  14893. /** @hidden */
  14894. _localMatrix: Matrix;
  14895. private _usePivotMatrix;
  14896. private _absolutePosition;
  14897. private _absoluteScaling;
  14898. private _absoluteRotationQuaternion;
  14899. private _pivotMatrix;
  14900. private _pivotMatrixInverse;
  14901. protected _postMultiplyPivotMatrix: boolean;
  14902. protected _isWorldMatrixFrozen: boolean;
  14903. /** @hidden */
  14904. _indexInSceneTransformNodesArray: number;
  14905. /**
  14906. * An event triggered after the world matrix is updated
  14907. */
  14908. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14909. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14910. /**
  14911. * Gets a string identifying the name of the class
  14912. * @returns "TransformNode" string
  14913. */
  14914. getClassName(): string;
  14915. /**
  14916. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14917. */
  14918. get position(): Vector3;
  14919. set position(newPosition: Vector3);
  14920. /**
  14921. * 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)).
  14922. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14923. */
  14924. get rotation(): Vector3;
  14925. set rotation(newRotation: Vector3);
  14926. /**
  14927. * 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)).
  14928. */
  14929. get scaling(): Vector3;
  14930. set scaling(newScaling: Vector3);
  14931. /**
  14932. * 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).
  14933. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14934. */
  14935. get rotationQuaternion(): Nullable<Quaternion>;
  14936. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14937. /**
  14938. * The forward direction of that transform in world space.
  14939. */
  14940. get forward(): Vector3;
  14941. /**
  14942. * The up direction of that transform in world space.
  14943. */
  14944. get up(): Vector3;
  14945. /**
  14946. * The right direction of that transform in world space.
  14947. */
  14948. get right(): Vector3;
  14949. /**
  14950. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14951. * @param matrix the matrix to copy the pose from
  14952. * @returns this TransformNode.
  14953. */
  14954. updatePoseMatrix(matrix: Matrix): TransformNode;
  14955. /**
  14956. * Returns the mesh Pose matrix.
  14957. * @returns the pose matrix
  14958. */
  14959. getPoseMatrix(): Matrix;
  14960. /** @hidden */
  14961. _isSynchronized(): boolean;
  14962. /** @hidden */
  14963. _initCache(): void;
  14964. /**
  14965. * Flag the transform node as dirty (Forcing it to update everything)
  14966. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14967. * @returns this transform node
  14968. */
  14969. markAsDirty(property: string): TransformNode;
  14970. /**
  14971. * Returns the current mesh absolute position.
  14972. * Returns a Vector3.
  14973. */
  14974. get absolutePosition(): Vector3;
  14975. /**
  14976. * Returns the current mesh absolute scaling.
  14977. * Returns a Vector3.
  14978. */
  14979. get absoluteScaling(): Vector3;
  14980. /**
  14981. * Returns the current mesh absolute rotation.
  14982. * Returns a Quaternion.
  14983. */
  14984. get absoluteRotationQuaternion(): Quaternion;
  14985. /**
  14986. * Sets a new matrix to apply before all other transformation
  14987. * @param matrix defines the transform matrix
  14988. * @returns the current TransformNode
  14989. */
  14990. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14991. /**
  14992. * Sets a new pivot matrix to the current node
  14993. * @param matrix defines the new pivot matrix to use
  14994. * @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
  14995. * @returns the current TransformNode
  14996. */
  14997. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14998. /**
  14999. * Returns the mesh pivot matrix.
  15000. * Default : Identity.
  15001. * @returns the matrix
  15002. */
  15003. getPivotMatrix(): Matrix;
  15004. /**
  15005. * Instantiate (when possible) or clone that node with its hierarchy
  15006. * @param newParent defines the new parent to use for the instance (or clone)
  15007. * @param options defines options to configure how copy is done
  15008. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15009. * @returns an instance (or a clone) of the current node with its hiearchy
  15010. */
  15011. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15012. doNotInstantiate: boolean;
  15013. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15014. /**
  15015. * Prevents the World matrix to be computed any longer
  15016. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15017. * @returns the TransformNode.
  15018. */
  15019. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15020. /**
  15021. * Allows back the World matrix computation.
  15022. * @returns the TransformNode.
  15023. */
  15024. unfreezeWorldMatrix(): this;
  15025. /**
  15026. * True if the World matrix has been frozen.
  15027. */
  15028. get isWorldMatrixFrozen(): boolean;
  15029. /**
  15030. * Retuns the mesh absolute position in the World.
  15031. * @returns a Vector3.
  15032. */
  15033. getAbsolutePosition(): Vector3;
  15034. /**
  15035. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15036. * @param absolutePosition the absolute position to set
  15037. * @returns the TransformNode.
  15038. */
  15039. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15040. /**
  15041. * Sets the mesh position in its local space.
  15042. * @param vector3 the position to set in localspace
  15043. * @returns the TransformNode.
  15044. */
  15045. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15046. /**
  15047. * Returns the mesh position in the local space from the current World matrix values.
  15048. * @returns a new Vector3.
  15049. */
  15050. getPositionExpressedInLocalSpace(): Vector3;
  15051. /**
  15052. * Translates the mesh along the passed Vector3 in its local space.
  15053. * @param vector3 the distance to translate in localspace
  15054. * @returns the TransformNode.
  15055. */
  15056. locallyTranslate(vector3: Vector3): TransformNode;
  15057. private static _lookAtVectorCache;
  15058. /**
  15059. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15060. * @param targetPoint the position (must be in same space as current mesh) to look at
  15061. * @param yawCor optional yaw (y-axis) correction in radians
  15062. * @param pitchCor optional pitch (x-axis) correction in radians
  15063. * @param rollCor optional roll (z-axis) correction in radians
  15064. * @param space the choosen space of the target
  15065. * @returns the TransformNode.
  15066. */
  15067. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15068. /**
  15069. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15070. * This Vector3 is expressed in the World space.
  15071. * @param localAxis axis to rotate
  15072. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15073. */
  15074. getDirection(localAxis: Vector3): Vector3;
  15075. /**
  15076. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15077. * localAxis is expressed in the mesh local space.
  15078. * result is computed in the Wordl space from the mesh World matrix.
  15079. * @param localAxis axis to rotate
  15080. * @param result the resulting transformnode
  15081. * @returns this TransformNode.
  15082. */
  15083. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15084. /**
  15085. * Sets this transform node rotation to the given local axis.
  15086. * @param localAxis the axis in local space
  15087. * @param yawCor optional yaw (y-axis) correction in radians
  15088. * @param pitchCor optional pitch (x-axis) correction in radians
  15089. * @param rollCor optional roll (z-axis) correction in radians
  15090. * @returns this TransformNode
  15091. */
  15092. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15093. /**
  15094. * Sets a new pivot point to the current node
  15095. * @param point defines the new pivot point to use
  15096. * @param space defines if the point is in world or local space (local by default)
  15097. * @returns the current TransformNode
  15098. */
  15099. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15100. /**
  15101. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15102. * @returns the pivot point
  15103. */
  15104. getPivotPoint(): Vector3;
  15105. /**
  15106. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15107. * @param result the vector3 to store the result
  15108. * @returns this TransformNode.
  15109. */
  15110. getPivotPointToRef(result: Vector3): TransformNode;
  15111. /**
  15112. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15113. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15114. */
  15115. getAbsolutePivotPoint(): Vector3;
  15116. /**
  15117. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15118. * @param result vector3 to store the result
  15119. * @returns this TransformNode.
  15120. */
  15121. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15122. /**
  15123. * Defines the passed node as the parent of the current node.
  15124. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15125. * @see https://doc.babylonjs.com/how_to/parenting
  15126. * @param node the node ot set as the parent
  15127. * @returns this TransformNode.
  15128. */
  15129. setParent(node: Nullable<Node>): TransformNode;
  15130. private _nonUniformScaling;
  15131. /**
  15132. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15133. */
  15134. get nonUniformScaling(): boolean;
  15135. /** @hidden */
  15136. _updateNonUniformScalingState(value: boolean): boolean;
  15137. /**
  15138. * Attach the current TransformNode to another TransformNode associated with a bone
  15139. * @param bone Bone affecting the TransformNode
  15140. * @param affectedTransformNode TransformNode associated with the bone
  15141. * @returns this object
  15142. */
  15143. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15144. /**
  15145. * Detach the transform node if its associated with a bone
  15146. * @returns this object
  15147. */
  15148. detachFromBone(): TransformNode;
  15149. private static _rotationAxisCache;
  15150. /**
  15151. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15152. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15153. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15154. * The passed axis is also normalized.
  15155. * @param axis the axis to rotate around
  15156. * @param amount the amount to rotate in radians
  15157. * @param space Space to rotate in (Default: local)
  15158. * @returns the TransformNode.
  15159. */
  15160. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15161. /**
  15162. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15163. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15164. * The passed axis is also normalized. .
  15165. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15166. * @param point the point to rotate around
  15167. * @param axis the axis to rotate around
  15168. * @param amount the amount to rotate in radians
  15169. * @returns the TransformNode
  15170. */
  15171. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15172. /**
  15173. * Translates the mesh along the axis vector for the passed distance in the given space.
  15174. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15175. * @param axis the axis to translate in
  15176. * @param distance the distance to translate
  15177. * @param space Space to rotate in (Default: local)
  15178. * @returns the TransformNode.
  15179. */
  15180. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15181. /**
  15182. * Adds a rotation step to the mesh current rotation.
  15183. * x, y, z are Euler angles expressed in radians.
  15184. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15185. * This means this rotation is made in the mesh local space only.
  15186. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15187. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15188. * ```javascript
  15189. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15190. * ```
  15191. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15192. * 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.
  15193. * @param x Rotation to add
  15194. * @param y Rotation to add
  15195. * @param z Rotation to add
  15196. * @returns the TransformNode.
  15197. */
  15198. addRotation(x: number, y: number, z: number): TransformNode;
  15199. /**
  15200. * @hidden
  15201. */
  15202. protected _getEffectiveParent(): Nullable<Node>;
  15203. /**
  15204. * Computes the world matrix of the node
  15205. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15206. * @returns the world matrix
  15207. */
  15208. computeWorldMatrix(force?: boolean): Matrix;
  15209. /**
  15210. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15211. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15212. */
  15213. resetLocalMatrix(independentOfChildren?: boolean): void;
  15214. protected _afterComputeWorldMatrix(): void;
  15215. /**
  15216. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15217. * @param func callback function to add
  15218. *
  15219. * @returns the TransformNode.
  15220. */
  15221. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15222. /**
  15223. * Removes a registered callback function.
  15224. * @param func callback function to remove
  15225. * @returns the TransformNode.
  15226. */
  15227. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15228. /**
  15229. * Gets the position of the current mesh in camera space
  15230. * @param camera defines the camera to use
  15231. * @returns a position
  15232. */
  15233. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15234. /**
  15235. * Returns the distance from the mesh to the active camera
  15236. * @param camera defines the camera to use
  15237. * @returns the distance
  15238. */
  15239. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15240. /**
  15241. * Clone the current transform node
  15242. * @param name Name of the new clone
  15243. * @param newParent New parent for the clone
  15244. * @param doNotCloneChildren Do not clone children hierarchy
  15245. * @returns the new transform node
  15246. */
  15247. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15248. /**
  15249. * Serializes the objects information.
  15250. * @param currentSerializationObject defines the object to serialize in
  15251. * @returns the serialized object
  15252. */
  15253. serialize(currentSerializationObject?: any): any;
  15254. /**
  15255. * Returns a new TransformNode object parsed from the source provided.
  15256. * @param parsedTransformNode is the source.
  15257. * @param scene the scne the object belongs to
  15258. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15259. * @returns a new TransformNode object parsed from the source provided.
  15260. */
  15261. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15262. /**
  15263. * Get all child-transformNodes of this node
  15264. * @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
  15265. * @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
  15266. * @returns an array of TransformNode
  15267. */
  15268. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15269. /**
  15270. * Releases resources associated with this transform node.
  15271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15273. */
  15274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15275. /**
  15276. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15277. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15278. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15279. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15280. * @returns the current mesh
  15281. */
  15282. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15283. private _syncAbsoluteScalingAndRotation;
  15284. }
  15285. }
  15286. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15287. /**
  15288. * Class used to override all child animations of a given target
  15289. */
  15290. export class AnimationPropertiesOverride {
  15291. /**
  15292. * Gets or sets a value indicating if animation blending must be used
  15293. */
  15294. enableBlending: boolean;
  15295. /**
  15296. * Gets or sets the blending speed to use when enableBlending is true
  15297. */
  15298. blendingSpeed: number;
  15299. /**
  15300. * Gets or sets the default loop mode to use
  15301. */
  15302. loopMode: number;
  15303. }
  15304. }
  15305. declare module "babylonjs/Bones/bone" {
  15306. import { Skeleton } from "babylonjs/Bones/skeleton";
  15307. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15308. import { Nullable } from "babylonjs/types";
  15309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15311. import { Node } from "babylonjs/node";
  15312. import { Space } from "babylonjs/Maths/math.axis";
  15313. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15314. /**
  15315. * Class used to store bone information
  15316. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15317. */
  15318. export class Bone extends Node {
  15319. /**
  15320. * defines the bone name
  15321. */
  15322. name: string;
  15323. private static _tmpVecs;
  15324. private static _tmpQuat;
  15325. private static _tmpMats;
  15326. /**
  15327. * Gets the list of child bones
  15328. */
  15329. children: Bone[];
  15330. /** Gets the animations associated with this bone */
  15331. animations: import("babylonjs/Animations/animation").Animation[];
  15332. /**
  15333. * Gets or sets bone length
  15334. */
  15335. length: number;
  15336. /**
  15337. * @hidden Internal only
  15338. * Set this value to map this bone to a different index in the transform matrices
  15339. * Set this value to -1 to exclude the bone from the transform matrices
  15340. */
  15341. _index: Nullable<number>;
  15342. private _skeleton;
  15343. private _localMatrix;
  15344. private _restPose;
  15345. private _baseMatrix;
  15346. private _absoluteTransform;
  15347. private _invertedAbsoluteTransform;
  15348. private _parent;
  15349. private _scalingDeterminant;
  15350. private _worldTransform;
  15351. private _localScaling;
  15352. private _localRotation;
  15353. private _localPosition;
  15354. private _needToDecompose;
  15355. private _needToCompose;
  15356. /** @hidden */
  15357. _linkedTransformNode: Nullable<TransformNode>;
  15358. /** @hidden */
  15359. _waitingTransformNodeId: Nullable<string>;
  15360. /** @hidden */
  15361. get _matrix(): Matrix;
  15362. /** @hidden */
  15363. set _matrix(value: Matrix);
  15364. /**
  15365. * Create a new bone
  15366. * @param name defines the bone name
  15367. * @param skeleton defines the parent skeleton
  15368. * @param parentBone defines the parent (can be null if the bone is the root)
  15369. * @param localMatrix defines the local matrix
  15370. * @param restPose defines the rest pose matrix
  15371. * @param baseMatrix defines the base matrix
  15372. * @param index defines index of the bone in the hiearchy
  15373. */
  15374. constructor(
  15375. /**
  15376. * defines the bone name
  15377. */
  15378. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15379. /**
  15380. * Gets the current object class name.
  15381. * @return the class name
  15382. */
  15383. getClassName(): string;
  15384. /**
  15385. * Gets the parent skeleton
  15386. * @returns a skeleton
  15387. */
  15388. getSkeleton(): Skeleton;
  15389. /**
  15390. * Gets parent bone
  15391. * @returns a bone or null if the bone is the root of the bone hierarchy
  15392. */
  15393. getParent(): Nullable<Bone>;
  15394. /**
  15395. * Returns an array containing the root bones
  15396. * @returns an array containing the root bones
  15397. */
  15398. getChildren(): Array<Bone>;
  15399. /**
  15400. * Gets the node index in matrix array generated for rendering
  15401. * @returns the node index
  15402. */
  15403. getIndex(): number;
  15404. /**
  15405. * Sets the parent bone
  15406. * @param parent defines the parent (can be null if the bone is the root)
  15407. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15408. */
  15409. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15410. /**
  15411. * Gets the local matrix
  15412. * @returns a matrix
  15413. */
  15414. getLocalMatrix(): Matrix;
  15415. /**
  15416. * Gets the base matrix (initial matrix which remains unchanged)
  15417. * @returns a matrix
  15418. */
  15419. getBaseMatrix(): Matrix;
  15420. /**
  15421. * Gets the rest pose matrix
  15422. * @returns a matrix
  15423. */
  15424. getRestPose(): Matrix;
  15425. /**
  15426. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15427. */
  15428. getWorldMatrix(): Matrix;
  15429. /**
  15430. * Sets the local matrix to rest pose matrix
  15431. */
  15432. returnToRest(): void;
  15433. /**
  15434. * Gets the inverse of the absolute transform matrix.
  15435. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15436. * @returns a matrix
  15437. */
  15438. getInvertedAbsoluteTransform(): Matrix;
  15439. /**
  15440. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15441. * @returns a matrix
  15442. */
  15443. getAbsoluteTransform(): Matrix;
  15444. /**
  15445. * Links with the given transform node.
  15446. * The local matrix of this bone is copied from the transform node every frame.
  15447. * @param transformNode defines the transform node to link to
  15448. */
  15449. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15450. /**
  15451. * Gets the node used to drive the bone's transformation
  15452. * @returns a transform node or null
  15453. */
  15454. getTransformNode(): Nullable<TransformNode>;
  15455. /** Gets or sets current position (in local space) */
  15456. get position(): Vector3;
  15457. set position(newPosition: Vector3);
  15458. /** Gets or sets current rotation (in local space) */
  15459. get rotation(): Vector3;
  15460. set rotation(newRotation: Vector3);
  15461. /** Gets or sets current rotation quaternion (in local space) */
  15462. get rotationQuaternion(): Quaternion;
  15463. set rotationQuaternion(newRotation: Quaternion);
  15464. /** Gets or sets current scaling (in local space) */
  15465. get scaling(): Vector3;
  15466. set scaling(newScaling: Vector3);
  15467. /**
  15468. * Gets the animation properties override
  15469. */
  15470. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15471. private _decompose;
  15472. private _compose;
  15473. /**
  15474. * Update the base and local matrices
  15475. * @param matrix defines the new base or local matrix
  15476. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15477. * @param updateLocalMatrix defines if the local matrix should be updated
  15478. */
  15479. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15480. /** @hidden */
  15481. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15482. /**
  15483. * Flag the bone as dirty (Forcing it to update everything)
  15484. */
  15485. markAsDirty(): void;
  15486. /** @hidden */
  15487. _markAsDirtyAndCompose(): void;
  15488. private _markAsDirtyAndDecompose;
  15489. /**
  15490. * Translate the bone in local or world space
  15491. * @param vec The amount to translate the bone
  15492. * @param space The space that the translation is in
  15493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15494. */
  15495. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15496. /**
  15497. * Set the postion of the bone in local or world space
  15498. * @param position The position to set the bone
  15499. * @param space The space that the position is in
  15500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15501. */
  15502. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15503. /**
  15504. * Set the absolute position of the bone (world space)
  15505. * @param position The position to set the bone
  15506. * @param mesh The mesh that this bone is attached to
  15507. */
  15508. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15509. /**
  15510. * Scale the bone on the x, y and z axes (in local space)
  15511. * @param x The amount to scale the bone on the x axis
  15512. * @param y The amount to scale the bone on the y axis
  15513. * @param z The amount to scale the bone on the z axis
  15514. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15515. */
  15516. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15517. /**
  15518. * Set the bone scaling in local space
  15519. * @param scale defines the scaling vector
  15520. */
  15521. setScale(scale: Vector3): void;
  15522. /**
  15523. * Gets the current scaling in local space
  15524. * @returns the current scaling vector
  15525. */
  15526. getScale(): Vector3;
  15527. /**
  15528. * Gets the current scaling in local space and stores it in a target vector
  15529. * @param result defines the target vector
  15530. */
  15531. getScaleToRef(result: Vector3): void;
  15532. /**
  15533. * Set the yaw, pitch, and roll of the bone in local or world space
  15534. * @param yaw The rotation of the bone on the y axis
  15535. * @param pitch The rotation of the bone on the x axis
  15536. * @param roll The rotation of the bone on the z axis
  15537. * @param space The space that the axes of rotation are in
  15538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15539. */
  15540. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15541. /**
  15542. * Add a rotation to the bone on an axis in local or world space
  15543. * @param axis The axis to rotate the bone on
  15544. * @param amount The amount to rotate the bone
  15545. * @param space The space that the axis is in
  15546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15547. */
  15548. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15549. /**
  15550. * Set the rotation of the bone to a particular axis angle in local or world space
  15551. * @param axis The axis to rotate the bone on
  15552. * @param angle The angle that the bone should be rotated to
  15553. * @param space The space that the axis is in
  15554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15555. */
  15556. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15557. /**
  15558. * Set the euler rotation of the bone in local of world space
  15559. * @param rotation The euler rotation that the bone should be set to
  15560. * @param space The space that the rotation is in
  15561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15562. */
  15563. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15564. /**
  15565. * Set the quaternion rotation of the bone in local of world space
  15566. * @param quat The quaternion rotation that the bone should be set to
  15567. * @param space The space that the rotation is in
  15568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15569. */
  15570. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15571. /**
  15572. * Set the rotation matrix of the bone in local of world space
  15573. * @param rotMat The rotation matrix that the bone should be set to
  15574. * @param space The space that the rotation is in
  15575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15576. */
  15577. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15578. private _rotateWithMatrix;
  15579. private _getNegativeRotationToRef;
  15580. /**
  15581. * Get the position of the bone in local or world space
  15582. * @param space The space that the returned position is in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. * @returns The position of the bone
  15585. */
  15586. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15587. /**
  15588. * Copy the position of the bone to a vector3 in local or world space
  15589. * @param space The space that the returned position is in
  15590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15591. * @param result The vector3 to copy the position to
  15592. */
  15593. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15594. /**
  15595. * Get the absolute position of the bone (world space)
  15596. * @param mesh The mesh that this bone is attached to
  15597. * @returns The absolute position of the bone
  15598. */
  15599. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15600. /**
  15601. * Copy the absolute position of the bone (world space) to the result param
  15602. * @param mesh The mesh that this bone is attached to
  15603. * @param result The vector3 to copy the absolute position to
  15604. */
  15605. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15606. /**
  15607. * Compute the absolute transforms of this bone and its children
  15608. */
  15609. computeAbsoluteTransforms(): void;
  15610. /**
  15611. * Get the world direction from an axis that is in the local space of the bone
  15612. * @param localAxis The local direction that is used to compute the world direction
  15613. * @param mesh The mesh that this bone is attached to
  15614. * @returns The world direction
  15615. */
  15616. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15617. /**
  15618. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15619. * @param localAxis The local direction that is used to compute the world direction
  15620. * @param mesh The mesh that this bone is attached to
  15621. * @param result The vector3 that the world direction will be copied to
  15622. */
  15623. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15624. /**
  15625. * Get the euler rotation of the bone in local or world space
  15626. * @param space The space that the rotation should be in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. * @returns The euler rotation
  15629. */
  15630. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15631. /**
  15632. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15633. * @param space The space that the rotation should be in
  15634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15635. * @param result The vector3 that the rotation should be copied to
  15636. */
  15637. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15638. /**
  15639. * Get the quaternion rotation of the bone in either local or world space
  15640. * @param space The space that the rotation should be in
  15641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15642. * @returns The quaternion rotation
  15643. */
  15644. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15645. /**
  15646. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15647. * @param space The space that the rotation should be in
  15648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15649. * @param result The quaternion that the rotation should be copied to
  15650. */
  15651. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15652. /**
  15653. * Get the rotation matrix of the bone in local or world space
  15654. * @param space The space that the rotation should be in
  15655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15656. * @returns The rotation matrix
  15657. */
  15658. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15659. /**
  15660. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15661. * @param space The space that the rotation should be in
  15662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15663. * @param result The quaternion that the rotation should be copied to
  15664. */
  15665. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15666. /**
  15667. * Get the world position of a point that is in the local space of the bone
  15668. * @param position The local position
  15669. * @param mesh The mesh that this bone is attached to
  15670. * @returns The world position
  15671. */
  15672. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15673. /**
  15674. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15675. * @param position The local position
  15676. * @param mesh The mesh that this bone is attached to
  15677. * @param result The vector3 that the world position should be copied to
  15678. */
  15679. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15680. /**
  15681. * Get the local position of a point that is in world space
  15682. * @param position The world position
  15683. * @param mesh The mesh that this bone is attached to
  15684. * @returns The local position
  15685. */
  15686. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15687. /**
  15688. * Get the local position of a point that is in world space and copy it to the result param
  15689. * @param position The world position
  15690. * @param mesh The mesh that this bone is attached to
  15691. * @param result The vector3 that the local position should be copied to
  15692. */
  15693. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15694. }
  15695. }
  15696. declare module "babylonjs/Animations/runtimeAnimation" {
  15697. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15698. import { Animatable } from "babylonjs/Animations/animatable";
  15699. import { Scene } from "babylonjs/scene";
  15700. /**
  15701. * Defines a runtime animation
  15702. */
  15703. export class RuntimeAnimation {
  15704. private _events;
  15705. /**
  15706. * The current frame of the runtime animation
  15707. */
  15708. private _currentFrame;
  15709. /**
  15710. * The animation used by the runtime animation
  15711. */
  15712. private _animation;
  15713. /**
  15714. * The target of the runtime animation
  15715. */
  15716. private _target;
  15717. /**
  15718. * The initiating animatable
  15719. */
  15720. private _host;
  15721. /**
  15722. * The original value of the runtime animation
  15723. */
  15724. private _originalValue;
  15725. /**
  15726. * The original blend value of the runtime animation
  15727. */
  15728. private _originalBlendValue;
  15729. /**
  15730. * The offsets cache of the runtime animation
  15731. */
  15732. private _offsetsCache;
  15733. /**
  15734. * The high limits cache of the runtime animation
  15735. */
  15736. private _highLimitsCache;
  15737. /**
  15738. * Specifies if the runtime animation has been stopped
  15739. */
  15740. private _stopped;
  15741. /**
  15742. * The blending factor of the runtime animation
  15743. */
  15744. private _blendingFactor;
  15745. /**
  15746. * The BabylonJS scene
  15747. */
  15748. private _scene;
  15749. /**
  15750. * The current value of the runtime animation
  15751. */
  15752. private _currentValue;
  15753. /** @hidden */
  15754. _animationState: _IAnimationState;
  15755. /**
  15756. * The active target of the runtime animation
  15757. */
  15758. private _activeTargets;
  15759. private _currentActiveTarget;
  15760. private _directTarget;
  15761. /**
  15762. * The target path of the runtime animation
  15763. */
  15764. private _targetPath;
  15765. /**
  15766. * The weight of the runtime animation
  15767. */
  15768. private _weight;
  15769. /**
  15770. * The ratio offset of the runtime animation
  15771. */
  15772. private _ratioOffset;
  15773. /**
  15774. * The previous delay of the runtime animation
  15775. */
  15776. private _previousDelay;
  15777. /**
  15778. * The previous ratio of the runtime animation
  15779. */
  15780. private _previousRatio;
  15781. private _enableBlending;
  15782. private _keys;
  15783. private _minFrame;
  15784. private _maxFrame;
  15785. private _minValue;
  15786. private _maxValue;
  15787. private _targetIsArray;
  15788. /**
  15789. * Gets the current frame of the runtime animation
  15790. */
  15791. get currentFrame(): number;
  15792. /**
  15793. * Gets the weight of the runtime animation
  15794. */
  15795. get weight(): number;
  15796. /**
  15797. * Gets the current value of the runtime animation
  15798. */
  15799. get currentValue(): any;
  15800. /**
  15801. * Gets the target path of the runtime animation
  15802. */
  15803. get targetPath(): string;
  15804. /**
  15805. * Gets the actual target of the runtime animation
  15806. */
  15807. get target(): any;
  15808. /**
  15809. * Gets the additive state of the runtime animation
  15810. */
  15811. get isAdditive(): boolean;
  15812. /** @hidden */
  15813. _onLoop: () => void;
  15814. /**
  15815. * Create a new RuntimeAnimation object
  15816. * @param target defines the target of the animation
  15817. * @param animation defines the source animation object
  15818. * @param scene defines the hosting scene
  15819. * @param host defines the initiating Animatable
  15820. */
  15821. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15822. private _preparePath;
  15823. /**
  15824. * Gets the animation from the runtime animation
  15825. */
  15826. get animation(): Animation;
  15827. /**
  15828. * Resets the runtime animation to the beginning
  15829. * @param restoreOriginal defines whether to restore the target property to the original value
  15830. */
  15831. reset(restoreOriginal?: boolean): void;
  15832. /**
  15833. * Specifies if the runtime animation is stopped
  15834. * @returns Boolean specifying if the runtime animation is stopped
  15835. */
  15836. isStopped(): boolean;
  15837. /**
  15838. * Disposes of the runtime animation
  15839. */
  15840. dispose(): void;
  15841. /**
  15842. * Apply the interpolated value to the target
  15843. * @param currentValue defines the value computed by the animation
  15844. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15845. */
  15846. setValue(currentValue: any, weight: number): void;
  15847. private _getOriginalValues;
  15848. private _setValue;
  15849. /**
  15850. * Gets the loop pmode of the runtime animation
  15851. * @returns Loop Mode
  15852. */
  15853. private _getCorrectLoopMode;
  15854. /**
  15855. * Move the current animation to a given frame
  15856. * @param frame defines the frame to move to
  15857. */
  15858. goToFrame(frame: number): void;
  15859. /**
  15860. * @hidden Internal use only
  15861. */
  15862. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15863. /**
  15864. * Execute the current animation
  15865. * @param delay defines the delay to add to the current frame
  15866. * @param from defines the lower bound of the animation range
  15867. * @param to defines the upper bound of the animation range
  15868. * @param loop defines if the current animation must loop
  15869. * @param speedRatio defines the current speed ratio
  15870. * @param weight defines the weight of the animation (default is -1 so no weight)
  15871. * @param onLoop optional callback called when animation loops
  15872. * @returns a boolean indicating if the animation is running
  15873. */
  15874. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15875. }
  15876. }
  15877. declare module "babylonjs/Animations/animatable" {
  15878. import { Animation } from "babylonjs/Animations/animation";
  15879. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15880. import { Nullable } from "babylonjs/types";
  15881. import { Observable } from "babylonjs/Misc/observable";
  15882. import { Scene } from "babylonjs/scene";
  15883. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15884. import { Node } from "babylonjs/node";
  15885. /**
  15886. * Class used to store an actual running animation
  15887. */
  15888. export class Animatable {
  15889. /** defines the target object */
  15890. target: any;
  15891. /** defines the starting frame number (default is 0) */
  15892. fromFrame: number;
  15893. /** defines the ending frame number (default is 100) */
  15894. toFrame: number;
  15895. /** defines if the animation must loop (default is false) */
  15896. loopAnimation: boolean;
  15897. /** defines a callback to call when animation ends if it is not looping */
  15898. onAnimationEnd?: (() => void) | null | undefined;
  15899. /** defines a callback to call when animation loops */
  15900. onAnimationLoop?: (() => void) | null | undefined;
  15901. /** defines whether the animation should be evaluated additively */
  15902. isAdditive: boolean;
  15903. private _localDelayOffset;
  15904. private _pausedDelay;
  15905. private _runtimeAnimations;
  15906. private _paused;
  15907. private _scene;
  15908. private _speedRatio;
  15909. private _weight;
  15910. private _syncRoot;
  15911. /**
  15912. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15913. * This will only apply for non looping animation (default is true)
  15914. */
  15915. disposeOnEnd: boolean;
  15916. /**
  15917. * Gets a boolean indicating if the animation has started
  15918. */
  15919. animationStarted: boolean;
  15920. /**
  15921. * Observer raised when the animation ends
  15922. */
  15923. onAnimationEndObservable: Observable<Animatable>;
  15924. /**
  15925. * Observer raised when the animation loops
  15926. */
  15927. onAnimationLoopObservable: Observable<Animatable>;
  15928. /**
  15929. * Gets the root Animatable used to synchronize and normalize animations
  15930. */
  15931. get syncRoot(): Nullable<Animatable>;
  15932. /**
  15933. * Gets the current frame of the first RuntimeAnimation
  15934. * Used to synchronize Animatables
  15935. */
  15936. get masterFrame(): number;
  15937. /**
  15938. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15939. */
  15940. get weight(): number;
  15941. set weight(value: number);
  15942. /**
  15943. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15944. */
  15945. get speedRatio(): number;
  15946. set speedRatio(value: number);
  15947. /**
  15948. * Creates a new Animatable
  15949. * @param scene defines the hosting scene
  15950. * @param target defines the target object
  15951. * @param fromFrame defines the starting frame number (default is 0)
  15952. * @param toFrame defines the ending frame number (default is 100)
  15953. * @param loopAnimation defines if the animation must loop (default is false)
  15954. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15955. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15956. * @param animations defines a group of animation to add to the new Animatable
  15957. * @param onAnimationLoop defines a callback to call when animation loops
  15958. * @param isAdditive defines whether the animation should be evaluated additively
  15959. */
  15960. constructor(scene: Scene,
  15961. /** defines the target object */
  15962. target: any,
  15963. /** defines the starting frame number (default is 0) */
  15964. fromFrame?: number,
  15965. /** defines the ending frame number (default is 100) */
  15966. toFrame?: number,
  15967. /** defines if the animation must loop (default is false) */
  15968. loopAnimation?: boolean, speedRatio?: number,
  15969. /** defines a callback to call when animation ends if it is not looping */
  15970. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15971. /** defines a callback to call when animation loops */
  15972. onAnimationLoop?: (() => void) | null | undefined,
  15973. /** defines whether the animation should be evaluated additively */
  15974. isAdditive?: boolean);
  15975. /**
  15976. * Synchronize and normalize current Animatable with a source Animatable
  15977. * This is useful when using animation weights and when animations are not of the same length
  15978. * @param root defines the root Animatable to synchronize with
  15979. * @returns the current Animatable
  15980. */
  15981. syncWith(root: Animatable): Animatable;
  15982. /**
  15983. * Gets the list of runtime animations
  15984. * @returns an array of RuntimeAnimation
  15985. */
  15986. getAnimations(): RuntimeAnimation[];
  15987. /**
  15988. * Adds more animations to the current animatable
  15989. * @param target defines the target of the animations
  15990. * @param animations defines the new animations to add
  15991. */
  15992. appendAnimations(target: any, animations: Animation[]): void;
  15993. /**
  15994. * Gets the source animation for a specific property
  15995. * @param property defines the propertyu to look for
  15996. * @returns null or the source animation for the given property
  15997. */
  15998. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15999. /**
  16000. * Gets the runtime animation for a specific property
  16001. * @param property defines the propertyu to look for
  16002. * @returns null or the runtime animation for the given property
  16003. */
  16004. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16005. /**
  16006. * Resets the animatable to its original state
  16007. */
  16008. reset(): void;
  16009. /**
  16010. * Allows the animatable to blend with current running animations
  16011. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16012. * @param blendingSpeed defines the blending speed to use
  16013. */
  16014. enableBlending(blendingSpeed: number): void;
  16015. /**
  16016. * Disable animation blending
  16017. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16018. */
  16019. disableBlending(): void;
  16020. /**
  16021. * Jump directly to a given frame
  16022. * @param frame defines the frame to jump to
  16023. */
  16024. goToFrame(frame: number): void;
  16025. /**
  16026. * Pause the animation
  16027. */
  16028. pause(): void;
  16029. /**
  16030. * Restart the animation
  16031. */
  16032. restart(): void;
  16033. private _raiseOnAnimationEnd;
  16034. /**
  16035. * Stop and delete the current animation
  16036. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16037. * @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)
  16038. */
  16039. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16040. /**
  16041. * Wait asynchronously for the animation to end
  16042. * @returns a promise which will be fullfilled when the animation ends
  16043. */
  16044. waitAsync(): Promise<Animatable>;
  16045. /** @hidden */
  16046. _animate(delay: number): boolean;
  16047. }
  16048. module "babylonjs/scene" {
  16049. interface Scene {
  16050. /** @hidden */
  16051. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16052. /** @hidden */
  16053. _processLateAnimationBindingsForMatrices(holder: {
  16054. totalWeight: number;
  16055. totalAdditiveWeight: number;
  16056. animations: RuntimeAnimation[];
  16057. additiveAnimations: RuntimeAnimation[];
  16058. originalValue: Matrix;
  16059. }): any;
  16060. /** @hidden */
  16061. _processLateAnimationBindingsForQuaternions(holder: {
  16062. totalWeight: number;
  16063. totalAdditiveWeight: number;
  16064. animations: RuntimeAnimation[];
  16065. additiveAnimations: RuntimeAnimation[];
  16066. originalValue: Quaternion;
  16067. }, refQuaternion: Quaternion): Quaternion;
  16068. /** @hidden */
  16069. _processLateAnimationBindings(): void;
  16070. /**
  16071. * Will start the animation sequence of a given target
  16072. * @param target defines the target
  16073. * @param from defines from which frame should animation start
  16074. * @param to defines until which frame should animation run.
  16075. * @param weight defines the weight to apply to the animation (1.0 by default)
  16076. * @param loop defines if the animation loops
  16077. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16078. * @param onAnimationEnd defines the function to be executed when the animation ends
  16079. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16080. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16081. * @param onAnimationLoop defines the callback to call when an animation loops
  16082. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16083. * @returns the animatable object created for this animation
  16084. */
  16085. 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;
  16086. /**
  16087. * Will start the animation sequence of a given target
  16088. * @param target defines the target
  16089. * @param from defines from which frame should animation start
  16090. * @param to defines until which frame should animation run.
  16091. * @param loop defines if the animation loops
  16092. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16093. * @param onAnimationEnd defines the function to be executed when the animation ends
  16094. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16095. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16096. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16097. * @param onAnimationLoop defines the callback to call when an animation loops
  16098. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16099. * @returns the animatable object created for this animation
  16100. */
  16101. 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;
  16102. /**
  16103. * Will start the animation sequence of a given target and its hierarchy
  16104. * @param target defines the target
  16105. * @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.
  16106. * @param from defines from which frame should animation start
  16107. * @param to defines until which frame should animation run.
  16108. * @param loop defines if the animation loops
  16109. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16110. * @param onAnimationEnd defines the function to be executed when the animation ends
  16111. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16112. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16113. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16114. * @param onAnimationLoop defines the callback to call when an animation loops
  16115. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16116. * @returns the list of created animatables
  16117. */
  16118. 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[];
  16119. /**
  16120. * Begin a new animation on a given node
  16121. * @param target defines the target where the animation will take place
  16122. * @param animations defines the list of animations to start
  16123. * @param from defines the initial value
  16124. * @param to defines the final value
  16125. * @param loop defines if you want animation to loop (off by default)
  16126. * @param speedRatio defines the speed ratio to apply to all animations
  16127. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16128. * @param onAnimationLoop defines the callback to call when an animation loops
  16129. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16130. * @returns the list of created animatables
  16131. */
  16132. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16133. /**
  16134. * Begin a new animation on a given node and its hierarchy
  16135. * @param target defines the root node where the animation will take place
  16136. * @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.
  16137. * @param animations defines the list of animations to start
  16138. * @param from defines the initial value
  16139. * @param to defines the final value
  16140. * @param loop defines if you want animation to loop (off by default)
  16141. * @param speedRatio defines the speed ratio to apply to all animations
  16142. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16143. * @param onAnimationLoop defines the callback to call when an animation loops
  16144. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16145. * @returns the list of animatables created for all nodes
  16146. */
  16147. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16148. /**
  16149. * Gets the animatable associated with a specific target
  16150. * @param target defines the target of the animatable
  16151. * @returns the required animatable if found
  16152. */
  16153. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16154. /**
  16155. * Gets all animatables associated with a given target
  16156. * @param target defines the target to look animatables for
  16157. * @returns an array of Animatables
  16158. */
  16159. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16160. /**
  16161. * Stops and removes all animations that have been applied to the scene
  16162. */
  16163. stopAllAnimations(): void;
  16164. /**
  16165. * Gets the current delta time used by animation engine
  16166. */
  16167. deltaTime: number;
  16168. }
  16169. }
  16170. module "babylonjs/Bones/bone" {
  16171. interface Bone {
  16172. /**
  16173. * Copy an animation range from another bone
  16174. * @param source defines the source bone
  16175. * @param rangeName defines the range name to copy
  16176. * @param frameOffset defines the frame offset
  16177. * @param rescaleAsRequired defines if rescaling must be applied if required
  16178. * @param skelDimensionsRatio defines the scaling ratio
  16179. * @returns true if operation was successful
  16180. */
  16181. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16182. }
  16183. }
  16184. }
  16185. declare module "babylonjs/Bones/skeleton" {
  16186. import { Bone } from "babylonjs/Bones/bone";
  16187. import { Observable } from "babylonjs/Misc/observable";
  16188. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16189. import { Scene } from "babylonjs/scene";
  16190. import { Nullable } from "babylonjs/types";
  16191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16192. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16193. import { Animatable } from "babylonjs/Animations/animatable";
  16194. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16195. import { Animation } from "babylonjs/Animations/animation";
  16196. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16197. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16198. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16199. /**
  16200. * Class used to handle skinning animations
  16201. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16202. */
  16203. export class Skeleton implements IAnimatable {
  16204. /** defines the skeleton name */
  16205. name: string;
  16206. /** defines the skeleton Id */
  16207. id: string;
  16208. /**
  16209. * Defines the list of child bones
  16210. */
  16211. bones: Bone[];
  16212. /**
  16213. * Defines an estimate of the dimension of the skeleton at rest
  16214. */
  16215. dimensionsAtRest: Vector3;
  16216. /**
  16217. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16218. */
  16219. needInitialSkinMatrix: boolean;
  16220. /**
  16221. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16222. */
  16223. overrideMesh: Nullable<AbstractMesh>;
  16224. /**
  16225. * Gets the list of animations attached to this skeleton
  16226. */
  16227. animations: Array<Animation>;
  16228. private _scene;
  16229. private _isDirty;
  16230. private _transformMatrices;
  16231. private _transformMatrixTexture;
  16232. private _meshesWithPoseMatrix;
  16233. private _animatables;
  16234. private _identity;
  16235. private _synchronizedWithMesh;
  16236. private _ranges;
  16237. private _lastAbsoluteTransformsUpdateId;
  16238. private _canUseTextureForBones;
  16239. private _uniqueId;
  16240. /** @hidden */
  16241. _numBonesWithLinkedTransformNode: number;
  16242. /** @hidden */
  16243. _hasWaitingData: Nullable<boolean>;
  16244. /**
  16245. * Specifies if the skeleton should be serialized
  16246. */
  16247. doNotSerialize: boolean;
  16248. private _useTextureToStoreBoneMatrices;
  16249. /**
  16250. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16251. * Please note that this option is not available if the hardware does not support it
  16252. */
  16253. get useTextureToStoreBoneMatrices(): boolean;
  16254. set useTextureToStoreBoneMatrices(value: boolean);
  16255. private _animationPropertiesOverride;
  16256. /**
  16257. * Gets or sets the animation properties override
  16258. */
  16259. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16260. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16261. /**
  16262. * List of inspectable custom properties (used by the Inspector)
  16263. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16264. */
  16265. inspectableCustomProperties: IInspectable[];
  16266. /**
  16267. * An observable triggered before computing the skeleton's matrices
  16268. */
  16269. onBeforeComputeObservable: Observable<Skeleton>;
  16270. /**
  16271. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16272. */
  16273. get isUsingTextureForMatrices(): boolean;
  16274. /**
  16275. * Gets the unique ID of this skeleton
  16276. */
  16277. get uniqueId(): number;
  16278. /**
  16279. * Creates a new skeleton
  16280. * @param name defines the skeleton name
  16281. * @param id defines the skeleton Id
  16282. * @param scene defines the hosting scene
  16283. */
  16284. constructor(
  16285. /** defines the skeleton name */
  16286. name: string,
  16287. /** defines the skeleton Id */
  16288. id: string, scene: Scene);
  16289. /**
  16290. * Gets the current object class name.
  16291. * @return the class name
  16292. */
  16293. getClassName(): string;
  16294. /**
  16295. * Returns an array containing the root bones
  16296. * @returns an array containing the root bones
  16297. */
  16298. getChildren(): Array<Bone>;
  16299. /**
  16300. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16301. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16302. * @returns a Float32Array containing matrices data
  16303. */
  16304. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16305. /**
  16306. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16307. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16308. * @returns a raw texture containing the data
  16309. */
  16310. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16311. /**
  16312. * Gets the current hosting scene
  16313. * @returns a scene object
  16314. */
  16315. getScene(): Scene;
  16316. /**
  16317. * Gets a string representing the current skeleton data
  16318. * @param fullDetails defines a boolean indicating if we want a verbose version
  16319. * @returns a string representing the current skeleton data
  16320. */
  16321. toString(fullDetails?: boolean): string;
  16322. /**
  16323. * Get bone's index searching by name
  16324. * @param name defines bone's name to search for
  16325. * @return the indice of the bone. Returns -1 if not found
  16326. */
  16327. getBoneIndexByName(name: string): number;
  16328. /**
  16329. * Creater a new animation range
  16330. * @param name defines the name of the range
  16331. * @param from defines the start key
  16332. * @param to defines the end key
  16333. */
  16334. createAnimationRange(name: string, from: number, to: number): void;
  16335. /**
  16336. * Delete a specific animation range
  16337. * @param name defines the name of the range
  16338. * @param deleteFrames defines if frames must be removed as well
  16339. */
  16340. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16341. /**
  16342. * Gets a specific animation range
  16343. * @param name defines the name of the range to look for
  16344. * @returns the requested animation range or null if not found
  16345. */
  16346. getAnimationRange(name: string): Nullable<AnimationRange>;
  16347. /**
  16348. * Gets the list of all animation ranges defined on this skeleton
  16349. * @returns an array
  16350. */
  16351. getAnimationRanges(): Nullable<AnimationRange>[];
  16352. /**
  16353. * Copy animation range from a source skeleton.
  16354. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16355. * @param source defines the source skeleton
  16356. * @param name defines the name of the range to copy
  16357. * @param rescaleAsRequired defines if rescaling must be applied if required
  16358. * @returns true if operation was successful
  16359. */
  16360. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16361. /**
  16362. * Forces the skeleton to go to rest pose
  16363. */
  16364. returnToRest(): void;
  16365. private _getHighestAnimationFrame;
  16366. /**
  16367. * Begin a specific animation range
  16368. * @param name defines the name of the range to start
  16369. * @param loop defines if looping must be turned on (false by default)
  16370. * @param speedRatio defines the speed ratio to apply (1 by default)
  16371. * @param onAnimationEnd defines a callback which will be called when animation will end
  16372. * @returns a new animatable
  16373. */
  16374. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16375. /**
  16376. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16377. * @param skeleton defines the Skeleton containing the animation range to convert
  16378. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16379. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16380. * @returns the original skeleton
  16381. */
  16382. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16383. /** @hidden */
  16384. _markAsDirty(): void;
  16385. /** @hidden */
  16386. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16387. /** @hidden */
  16388. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16389. private _computeTransformMatrices;
  16390. /**
  16391. * Build all resources required to render a skeleton
  16392. */
  16393. prepare(): void;
  16394. /**
  16395. * Gets the list of animatables currently running for this skeleton
  16396. * @returns an array of animatables
  16397. */
  16398. getAnimatables(): IAnimatable[];
  16399. /**
  16400. * Clone the current skeleton
  16401. * @param name defines the name of the new skeleton
  16402. * @param id defines the id of the new skeleton
  16403. * @returns the new skeleton
  16404. */
  16405. clone(name: string, id?: string): Skeleton;
  16406. /**
  16407. * Enable animation blending for this skeleton
  16408. * @param blendingSpeed defines the blending speed to apply
  16409. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16410. */
  16411. enableBlending(blendingSpeed?: number): void;
  16412. /**
  16413. * Releases all resources associated with the current skeleton
  16414. */
  16415. dispose(): void;
  16416. /**
  16417. * Serialize the skeleton in a JSON object
  16418. * @returns a JSON object
  16419. */
  16420. serialize(): any;
  16421. /**
  16422. * Creates a new skeleton from serialized data
  16423. * @param parsedSkeleton defines the serialized data
  16424. * @param scene defines the hosting scene
  16425. * @returns a new skeleton
  16426. */
  16427. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16428. /**
  16429. * Compute all node absolute transforms
  16430. * @param forceUpdate defines if computation must be done even if cache is up to date
  16431. */
  16432. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16433. /**
  16434. * Gets the root pose matrix
  16435. * @returns a matrix
  16436. */
  16437. getPoseMatrix(): Nullable<Matrix>;
  16438. /**
  16439. * Sorts bones per internal index
  16440. */
  16441. sortBones(): void;
  16442. private _sortBones;
  16443. }
  16444. }
  16445. declare module "babylonjs/Meshes/instancedMesh" {
  16446. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16447. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16448. import { Camera } from "babylonjs/Cameras/camera";
  16449. import { Node } from "babylonjs/node";
  16450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16451. import { Mesh } from "babylonjs/Meshes/mesh";
  16452. import { Material } from "babylonjs/Materials/material";
  16453. import { Skeleton } from "babylonjs/Bones/skeleton";
  16454. import { Light } from "babylonjs/Lights/light";
  16455. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16456. /**
  16457. * Creates an instance based on a source mesh.
  16458. */
  16459. export class InstancedMesh extends AbstractMesh {
  16460. private _sourceMesh;
  16461. private _currentLOD;
  16462. /** @hidden */
  16463. _indexInSourceMeshInstanceArray: number;
  16464. constructor(name: string, source: Mesh);
  16465. /**
  16466. * Returns the string "InstancedMesh".
  16467. */
  16468. getClassName(): string;
  16469. /** Gets the list of lights affecting that mesh */
  16470. get lightSources(): Light[];
  16471. _resyncLightSources(): void;
  16472. _resyncLightSource(light: Light): void;
  16473. _removeLightSource(light: Light, dispose: boolean): void;
  16474. /**
  16475. * If the source mesh receives shadows
  16476. */
  16477. get receiveShadows(): boolean;
  16478. /**
  16479. * The material of the source mesh
  16480. */
  16481. get material(): Nullable<Material>;
  16482. /**
  16483. * Visibility of the source mesh
  16484. */
  16485. get visibility(): number;
  16486. /**
  16487. * Skeleton of the source mesh
  16488. */
  16489. get skeleton(): Nullable<Skeleton>;
  16490. /**
  16491. * Rendering ground id of the source mesh
  16492. */
  16493. get renderingGroupId(): number;
  16494. set renderingGroupId(value: number);
  16495. /**
  16496. * Returns the total number of vertices (integer).
  16497. */
  16498. getTotalVertices(): number;
  16499. /**
  16500. * Returns a positive integer : the total number of indices in this mesh geometry.
  16501. * @returns the numner of indices or zero if the mesh has no geometry.
  16502. */
  16503. getTotalIndices(): number;
  16504. /**
  16505. * The source mesh of the instance
  16506. */
  16507. get sourceMesh(): Mesh;
  16508. /**
  16509. * Creates a new InstancedMesh object from the mesh model.
  16510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16511. * @param name defines the name of the new instance
  16512. * @returns a new InstancedMesh
  16513. */
  16514. createInstance(name: string): InstancedMesh;
  16515. /**
  16516. * Is this node ready to be used/rendered
  16517. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16518. * @return {boolean} is it ready
  16519. */
  16520. isReady(completeCheck?: boolean): boolean;
  16521. /**
  16522. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16523. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16524. * @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.
  16525. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16526. */
  16527. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16528. /**
  16529. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16530. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16531. * The `data` are either a numeric array either a Float32Array.
  16532. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16533. * 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).
  16534. * Note that a new underlying VertexBuffer object is created each call.
  16535. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16536. *
  16537. * Possible `kind` values :
  16538. * - VertexBuffer.PositionKind
  16539. * - VertexBuffer.UVKind
  16540. * - VertexBuffer.UV2Kind
  16541. * - VertexBuffer.UV3Kind
  16542. * - VertexBuffer.UV4Kind
  16543. * - VertexBuffer.UV5Kind
  16544. * - VertexBuffer.UV6Kind
  16545. * - VertexBuffer.ColorKind
  16546. * - VertexBuffer.MatricesIndicesKind
  16547. * - VertexBuffer.MatricesIndicesExtraKind
  16548. * - VertexBuffer.MatricesWeightsKind
  16549. * - VertexBuffer.MatricesWeightsExtraKind
  16550. *
  16551. * Returns the Mesh.
  16552. */
  16553. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16554. /**
  16555. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16556. * If the mesh has no geometry, it is simply returned as it is.
  16557. * The `data` are either a numeric array either a Float32Array.
  16558. * No new underlying VertexBuffer object is created.
  16559. * 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.
  16560. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16561. *
  16562. * Possible `kind` values :
  16563. * - VertexBuffer.PositionKind
  16564. * - VertexBuffer.UVKind
  16565. * - VertexBuffer.UV2Kind
  16566. * - VertexBuffer.UV3Kind
  16567. * - VertexBuffer.UV4Kind
  16568. * - VertexBuffer.UV5Kind
  16569. * - VertexBuffer.UV6Kind
  16570. * - VertexBuffer.ColorKind
  16571. * - VertexBuffer.MatricesIndicesKind
  16572. * - VertexBuffer.MatricesIndicesExtraKind
  16573. * - VertexBuffer.MatricesWeightsKind
  16574. * - VertexBuffer.MatricesWeightsExtraKind
  16575. *
  16576. * Returns the Mesh.
  16577. */
  16578. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16579. /**
  16580. * Sets the mesh indices.
  16581. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16583. * This method creates a new index buffer each call.
  16584. * Returns the Mesh.
  16585. */
  16586. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16587. /**
  16588. * Boolean : True if the mesh owns the requested kind of data.
  16589. */
  16590. isVerticesDataPresent(kind: string): boolean;
  16591. /**
  16592. * Returns an array of indices (IndicesArray).
  16593. */
  16594. getIndices(): Nullable<IndicesArray>;
  16595. get _positions(): Nullable<Vector3[]>;
  16596. /**
  16597. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16598. * This means the mesh underlying bounding box and sphere are recomputed.
  16599. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16600. * @returns the current mesh
  16601. */
  16602. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16603. /** @hidden */
  16604. _preActivate(): InstancedMesh;
  16605. /** @hidden */
  16606. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16607. /** @hidden */
  16608. _postActivate(): void;
  16609. getWorldMatrix(): Matrix;
  16610. get isAnInstance(): boolean;
  16611. /**
  16612. * Returns the current associated LOD AbstractMesh.
  16613. */
  16614. getLOD(camera: Camera): AbstractMesh;
  16615. /** @hidden */
  16616. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16617. /** @hidden */
  16618. _syncSubMeshes(): InstancedMesh;
  16619. /** @hidden */
  16620. _generatePointsArray(): boolean;
  16621. /**
  16622. * Creates a new InstancedMesh from the current mesh.
  16623. * - name (string) : the cloned mesh name
  16624. * - newParent (optional Node) : the optional Node to parent the clone to.
  16625. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16626. *
  16627. * Returns the clone.
  16628. */
  16629. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16630. /**
  16631. * Disposes the InstancedMesh.
  16632. * Returns nothing.
  16633. */
  16634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16635. }
  16636. module "babylonjs/Meshes/mesh" {
  16637. interface Mesh {
  16638. /**
  16639. * Register a custom buffer that will be instanced
  16640. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16641. * @param kind defines the buffer kind
  16642. * @param stride defines the stride in floats
  16643. */
  16644. registerInstancedBuffer(kind: string, stride: number): void;
  16645. /**
  16646. * true to use the edge renderer for all instances of this mesh
  16647. */
  16648. edgesShareWithInstances: boolean;
  16649. /** @hidden */
  16650. _userInstancedBuffersStorage: {
  16651. data: {
  16652. [key: string]: Float32Array;
  16653. };
  16654. sizes: {
  16655. [key: string]: number;
  16656. };
  16657. vertexBuffers: {
  16658. [key: string]: Nullable<VertexBuffer>;
  16659. };
  16660. strides: {
  16661. [key: string]: number;
  16662. };
  16663. };
  16664. }
  16665. }
  16666. module "babylonjs/Meshes/abstractMesh" {
  16667. interface AbstractMesh {
  16668. /**
  16669. * Object used to store instanced buffers defined by user
  16670. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16671. */
  16672. instancedBuffers: {
  16673. [key: string]: any;
  16674. };
  16675. }
  16676. }
  16677. }
  16678. declare module "babylonjs/Materials/shaderMaterial" {
  16679. import { Nullable } from "babylonjs/types";
  16680. import { Scene } from "babylonjs/scene";
  16681. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16683. import { Mesh } from "babylonjs/Meshes/mesh";
  16684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16686. import { Effect } from "babylonjs/Materials/effect";
  16687. import { Material } from "babylonjs/Materials/material";
  16688. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16689. /**
  16690. * Defines the options associated with the creation of a shader material.
  16691. */
  16692. export interface IShaderMaterialOptions {
  16693. /**
  16694. * Does the material work in alpha blend mode
  16695. */
  16696. needAlphaBlending: boolean;
  16697. /**
  16698. * Does the material work in alpha test mode
  16699. */
  16700. needAlphaTesting: boolean;
  16701. /**
  16702. * The list of attribute names used in the shader
  16703. */
  16704. attributes: string[];
  16705. /**
  16706. * The list of unifrom names used in the shader
  16707. */
  16708. uniforms: string[];
  16709. /**
  16710. * The list of UBO names used in the shader
  16711. */
  16712. uniformBuffers: string[];
  16713. /**
  16714. * The list of sampler names used in the shader
  16715. */
  16716. samplers: string[];
  16717. /**
  16718. * The list of defines used in the shader
  16719. */
  16720. defines: string[];
  16721. }
  16722. /**
  16723. * 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.
  16724. *
  16725. * This returned material effects how the mesh will look based on the code in the shaders.
  16726. *
  16727. * @see https://doc.babylonjs.com/how_to/shader_material
  16728. */
  16729. export class ShaderMaterial extends Material {
  16730. private _shaderPath;
  16731. private _options;
  16732. private _textures;
  16733. private _textureArrays;
  16734. private _floats;
  16735. private _ints;
  16736. private _floatsArrays;
  16737. private _colors3;
  16738. private _colors3Arrays;
  16739. private _colors4;
  16740. private _colors4Arrays;
  16741. private _vectors2;
  16742. private _vectors3;
  16743. private _vectors4;
  16744. private _matrices;
  16745. private _matrixArrays;
  16746. private _matrices3x3;
  16747. private _matrices2x2;
  16748. private _vectors2Arrays;
  16749. private _vectors3Arrays;
  16750. private _vectors4Arrays;
  16751. private _cachedWorldViewMatrix;
  16752. private _cachedWorldViewProjectionMatrix;
  16753. private _renderId;
  16754. private _multiview;
  16755. private _cachedDefines;
  16756. /** Define the Url to load snippets */
  16757. static SnippetUrl: string;
  16758. /** Snippet ID if the material was created from the snippet server */
  16759. snippetId: string;
  16760. /**
  16761. * Instantiate a new shader material.
  16762. * 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.
  16763. * This returned material effects how the mesh will look based on the code in the shaders.
  16764. * @see https://doc.babylonjs.com/how_to/shader_material
  16765. * @param name Define the name of the material in the scene
  16766. * @param scene Define the scene the material belongs to
  16767. * @param shaderPath Defines the route to the shader code in one of three ways:
  16768. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16769. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16770. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16771. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16772. * @param options Define the options used to create the shader
  16773. */
  16774. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16775. /**
  16776. * Gets the shader path used to define the shader code
  16777. * It can be modified to trigger a new compilation
  16778. */
  16779. get shaderPath(): any;
  16780. /**
  16781. * Sets the shader path used to define the shader code
  16782. * It can be modified to trigger a new compilation
  16783. */
  16784. set shaderPath(shaderPath: any);
  16785. /**
  16786. * Gets the options used to compile the shader.
  16787. * They can be modified to trigger a new compilation
  16788. */
  16789. get options(): IShaderMaterialOptions;
  16790. /**
  16791. * Gets the current class name of the material e.g. "ShaderMaterial"
  16792. * Mainly use in serialization.
  16793. * @returns the class name
  16794. */
  16795. getClassName(): string;
  16796. /**
  16797. * Specifies if the material will require alpha blending
  16798. * @returns a boolean specifying if alpha blending is needed
  16799. */
  16800. needAlphaBlending(): boolean;
  16801. /**
  16802. * Specifies if this material should be rendered in alpha test mode
  16803. * @returns a boolean specifying if an alpha test is needed.
  16804. */
  16805. needAlphaTesting(): boolean;
  16806. private _checkUniform;
  16807. /**
  16808. * Set a texture in the shader.
  16809. * @param name Define the name of the uniform samplers as defined in the shader
  16810. * @param texture Define the texture to bind to this sampler
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16814. /**
  16815. * Set a texture array in the shader.
  16816. * @param name Define the name of the uniform sampler array as defined in the shader
  16817. * @param textures Define the list of textures to bind to this sampler
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16821. /**
  16822. * Set a float in the shader.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setFloat(name: string, value: number): ShaderMaterial;
  16828. /**
  16829. * Set a int in the shader.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setInt(name: string, value: number): ShaderMaterial;
  16835. /**
  16836. * Set an array of floats in the shader.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setFloats(name: string, value: number[]): ShaderMaterial;
  16842. /**
  16843. * Set a vec3 in the shader from a Color3.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setColor3(name: string, value: Color3): ShaderMaterial;
  16849. /**
  16850. * Set a vec3 array in the shader from a Color3 array.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16856. /**
  16857. * Set a vec4 in the shader from a Color4.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the material itself allowing "fluent" like uniform updates
  16861. */
  16862. setColor4(name: string, value: Color4): ShaderMaterial;
  16863. /**
  16864. * Set a vec4 array in the shader from a Color4 array.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the material itself allowing "fluent" like uniform updates
  16868. */
  16869. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16870. /**
  16871. * Set a vec2 in the shader from a Vector2.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the material itself allowing "fluent" like uniform updates
  16875. */
  16876. setVector2(name: string, value: Vector2): ShaderMaterial;
  16877. /**
  16878. * Set a vec3 in the shader from a Vector3.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the material itself allowing "fluent" like uniform updates
  16882. */
  16883. setVector3(name: string, value: Vector3): ShaderMaterial;
  16884. /**
  16885. * Set a vec4 in the shader from a Vector4.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the material itself allowing "fluent" like uniform updates
  16889. */
  16890. setVector4(name: string, value: Vector4): ShaderMaterial;
  16891. /**
  16892. * Set a mat4 in the shader from a Matrix.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16898. /**
  16899. * Set a float32Array in the shader from a matrix array.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the material itself allowing "fluent" like uniform updates
  16903. */
  16904. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16905. /**
  16906. * Set a mat3 in the shader from a Float32Array.
  16907. * @param name Define the name of the uniform as defined in the shader
  16908. * @param value Define the value to give to the uniform
  16909. * @return the material itself allowing "fluent" like uniform updates
  16910. */
  16911. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16912. /**
  16913. * Set a mat2 in the shader from a Float32Array.
  16914. * @param name Define the name of the uniform as defined in the shader
  16915. * @param value Define the value to give to the uniform
  16916. * @return the material itself allowing "fluent" like uniform updates
  16917. */
  16918. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16919. /**
  16920. * Set a vec2 array in the shader from a number array.
  16921. * @param name Define the name of the uniform as defined in the shader
  16922. * @param value Define the value to give to the uniform
  16923. * @return the material itself allowing "fluent" like uniform updates
  16924. */
  16925. setArray2(name: string, value: number[]): ShaderMaterial;
  16926. /**
  16927. * Set a vec3 array in the shader from a number array.
  16928. * @param name Define the name of the uniform as defined in the shader
  16929. * @param value Define the value to give to the uniform
  16930. * @return the material itself allowing "fluent" like uniform updates
  16931. */
  16932. setArray3(name: string, value: number[]): ShaderMaterial;
  16933. /**
  16934. * Set a vec4 array in the shader from a number array.
  16935. * @param name Define the name of the uniform as defined in the shader
  16936. * @param value Define the value to give to the uniform
  16937. * @return the material itself allowing "fluent" like uniform updates
  16938. */
  16939. setArray4(name: string, value: number[]): ShaderMaterial;
  16940. private _checkCache;
  16941. /**
  16942. * Specifies that the submesh is ready to be used
  16943. * @param mesh defines the mesh to check
  16944. * @param subMesh defines which submesh to check
  16945. * @param useInstances specifies that instances should be used
  16946. * @returns a boolean indicating that the submesh is ready or not
  16947. */
  16948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16949. /**
  16950. * Checks if the material is ready to render the requested mesh
  16951. * @param mesh Define the mesh to render
  16952. * @param useInstances Define whether or not the material is used with instances
  16953. * @returns true if ready, otherwise false
  16954. */
  16955. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16956. /**
  16957. * Binds the world matrix to the material
  16958. * @param world defines the world transformation matrix
  16959. * @param effectOverride - If provided, use this effect instead of internal effect
  16960. */
  16961. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16962. /**
  16963. * Binds the submesh to this material by preparing the effect and shader to draw
  16964. * @param world defines the world transformation matrix
  16965. * @param mesh defines the mesh containing the submesh
  16966. * @param subMesh defines the submesh to bind the material to
  16967. */
  16968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16969. /**
  16970. * Binds the material to the mesh
  16971. * @param world defines the world transformation matrix
  16972. * @param mesh defines the mesh to bind the material to
  16973. * @param effectOverride - If provided, use this effect instead of internal effect
  16974. */
  16975. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16976. protected _afterBind(mesh?: Mesh): void;
  16977. /**
  16978. * Gets the active textures from the material
  16979. * @returns an array of textures
  16980. */
  16981. getActiveTextures(): BaseTexture[];
  16982. /**
  16983. * Specifies if the material uses a texture
  16984. * @param texture defines the texture to check against the material
  16985. * @returns a boolean specifying if the material uses the texture
  16986. */
  16987. hasTexture(texture: BaseTexture): boolean;
  16988. /**
  16989. * Makes a duplicate of the material, and gives it a new name
  16990. * @param name defines the new name for the duplicated material
  16991. * @returns the cloned material
  16992. */
  16993. clone(name: string): ShaderMaterial;
  16994. /**
  16995. * Disposes the material
  16996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16999. */
  17000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17001. /**
  17002. * Serializes this material in a JSON representation
  17003. * @returns the serialized material object
  17004. */
  17005. serialize(): any;
  17006. /**
  17007. * Creates a shader material from parsed shader material data
  17008. * @param source defines the JSON represnetation of the material
  17009. * @param scene defines the hosting scene
  17010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17011. * @returns a new material
  17012. */
  17013. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17014. /**
  17015. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17016. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17017. * @param url defines the url to load from
  17018. * @param scene defines the hosting scene
  17019. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17020. * @returns a promise that will resolve to the new ShaderMaterial
  17021. */
  17022. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17023. /**
  17024. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17025. * @param snippetId defines the snippet to load
  17026. * @param scene defines the hosting scene
  17027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17028. * @returns a promise that will resolve to the new ShaderMaterial
  17029. */
  17030. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17031. }
  17032. }
  17033. declare module "babylonjs/Shaders/color.fragment" {
  17034. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17035. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17036. /** @hidden */
  17037. export var colorPixelShader: {
  17038. name: string;
  17039. shader: string;
  17040. };
  17041. }
  17042. declare module "babylonjs/Shaders/color.vertex" {
  17043. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17044. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17045. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17046. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17047. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17048. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17049. /** @hidden */
  17050. export var colorVertexShader: {
  17051. name: string;
  17052. shader: string;
  17053. };
  17054. }
  17055. declare module "babylonjs/Meshes/linesMesh" {
  17056. import { Nullable } from "babylonjs/types";
  17057. import { Scene } from "babylonjs/scene";
  17058. import { Color3 } from "babylonjs/Maths/math.color";
  17059. import { Node } from "babylonjs/node";
  17060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17061. import { Mesh } from "babylonjs/Meshes/mesh";
  17062. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17063. import { Effect } from "babylonjs/Materials/effect";
  17064. import { Material } from "babylonjs/Materials/material";
  17065. import "babylonjs/Shaders/color.fragment";
  17066. import "babylonjs/Shaders/color.vertex";
  17067. /**
  17068. * Line mesh
  17069. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17070. */
  17071. export class LinesMesh extends Mesh {
  17072. /**
  17073. * If vertex color should be applied to the mesh
  17074. */
  17075. readonly useVertexColor?: boolean | undefined;
  17076. /**
  17077. * If vertex alpha should be applied to the mesh
  17078. */
  17079. readonly useVertexAlpha?: boolean | undefined;
  17080. /**
  17081. * Color of the line (Default: White)
  17082. */
  17083. color: Color3;
  17084. /**
  17085. * Alpha of the line (Default: 1)
  17086. */
  17087. alpha: number;
  17088. /**
  17089. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17090. * This margin is expressed in world space coordinates, so its value may vary.
  17091. * Default value is 0.1
  17092. */
  17093. intersectionThreshold: number;
  17094. private _colorShader;
  17095. private color4;
  17096. /**
  17097. * Creates a new LinesMesh
  17098. * @param name defines the name
  17099. * @param scene defines the hosting scene
  17100. * @param parent defines the parent mesh if any
  17101. * @param source defines the optional source LinesMesh used to clone data from
  17102. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17103. * When false, achieved by calling a clone(), also passing False.
  17104. * This will make creation of children, recursive.
  17105. * @param useVertexColor defines if this LinesMesh supports vertex color
  17106. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17107. */
  17108. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17109. /**
  17110. * If vertex color should be applied to the mesh
  17111. */
  17112. useVertexColor?: boolean | undefined,
  17113. /**
  17114. * If vertex alpha should be applied to the mesh
  17115. */
  17116. useVertexAlpha?: boolean | undefined);
  17117. private _addClipPlaneDefine;
  17118. private _removeClipPlaneDefine;
  17119. isReady(): boolean;
  17120. /**
  17121. * Returns the string "LineMesh"
  17122. */
  17123. getClassName(): string;
  17124. /**
  17125. * @hidden
  17126. */
  17127. get material(): Material;
  17128. /**
  17129. * @hidden
  17130. */
  17131. set material(value: Material);
  17132. /**
  17133. * @hidden
  17134. */
  17135. get checkCollisions(): boolean;
  17136. /** @hidden */
  17137. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17138. /** @hidden */
  17139. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17140. /**
  17141. * Disposes of the line mesh
  17142. * @param doNotRecurse If children should be disposed
  17143. */
  17144. dispose(doNotRecurse?: boolean): void;
  17145. /**
  17146. * Returns a new LineMesh object cloned from the current one.
  17147. */
  17148. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17149. /**
  17150. * Creates a new InstancedLinesMesh object from the mesh model.
  17151. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17152. * @param name defines the name of the new instance
  17153. * @returns a new InstancedLinesMesh
  17154. */
  17155. createInstance(name: string): InstancedLinesMesh;
  17156. }
  17157. /**
  17158. * Creates an instance based on a source LinesMesh
  17159. */
  17160. export class InstancedLinesMesh extends InstancedMesh {
  17161. /**
  17162. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17163. * This margin is expressed in world space coordinates, so its value may vary.
  17164. * Initilized with the intersectionThreshold value of the source LinesMesh
  17165. */
  17166. intersectionThreshold: number;
  17167. constructor(name: string, source: LinesMesh);
  17168. /**
  17169. * Returns the string "InstancedLinesMesh".
  17170. */
  17171. getClassName(): string;
  17172. }
  17173. }
  17174. declare module "babylonjs/Shaders/line.fragment" {
  17175. /** @hidden */
  17176. export var linePixelShader: {
  17177. name: string;
  17178. shader: string;
  17179. };
  17180. }
  17181. declare module "babylonjs/Shaders/line.vertex" {
  17182. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17183. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17184. /** @hidden */
  17185. export var lineVertexShader: {
  17186. name: string;
  17187. shader: string;
  17188. };
  17189. }
  17190. declare module "babylonjs/Rendering/edgesRenderer" {
  17191. import { Nullable } from "babylonjs/types";
  17192. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17194. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17195. import { IDisposable } from "babylonjs/scene";
  17196. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17197. import "babylonjs/Shaders/line.fragment";
  17198. import "babylonjs/Shaders/line.vertex";
  17199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17200. import { SmartArray } from "babylonjs/Misc/smartArray";
  17201. module "babylonjs/scene" {
  17202. interface Scene {
  17203. /** @hidden */
  17204. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17205. }
  17206. }
  17207. module "babylonjs/Meshes/abstractMesh" {
  17208. interface AbstractMesh {
  17209. /**
  17210. * Gets the edgesRenderer associated with the mesh
  17211. */
  17212. edgesRenderer: Nullable<EdgesRenderer>;
  17213. }
  17214. }
  17215. module "babylonjs/Meshes/linesMesh" {
  17216. interface LinesMesh {
  17217. /**
  17218. * Enables the edge rendering mode on the mesh.
  17219. * This mode makes the mesh edges visible
  17220. * @param epsilon defines the maximal distance between two angles to detect a face
  17221. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17222. * @returns the currentAbstractMesh
  17223. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17224. */
  17225. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17226. }
  17227. }
  17228. module "babylonjs/Meshes/linesMesh" {
  17229. interface InstancedLinesMesh {
  17230. /**
  17231. * Enables the edge rendering mode on the mesh.
  17232. * This mode makes the mesh edges visible
  17233. * @param epsilon defines the maximal distance between two angles to detect a face
  17234. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17235. * @returns the current InstancedLinesMesh
  17236. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17237. */
  17238. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17239. }
  17240. }
  17241. /**
  17242. * Defines the minimum contract an Edges renderer should follow.
  17243. */
  17244. export interface IEdgesRenderer extends IDisposable {
  17245. /**
  17246. * Gets or sets a boolean indicating if the edgesRenderer is active
  17247. */
  17248. isEnabled: boolean;
  17249. /**
  17250. * Renders the edges of the attached mesh,
  17251. */
  17252. render(): void;
  17253. /**
  17254. * Checks wether or not the edges renderer is ready to render.
  17255. * @return true if ready, otherwise false.
  17256. */
  17257. isReady(): boolean;
  17258. /**
  17259. * List of instances to render in case the source mesh has instances
  17260. */
  17261. customInstances: SmartArray<Matrix>;
  17262. }
  17263. /**
  17264. * Defines the additional options of the edges renderer
  17265. */
  17266. export interface IEdgesRendererOptions {
  17267. /**
  17268. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17269. * If not defined, the default value is true
  17270. */
  17271. useAlternateEdgeFinder?: boolean;
  17272. /**
  17273. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17274. * If not defined, the default value is true.
  17275. * 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)
  17276. * This option is used only if useAlternateEdgeFinder = true
  17277. */
  17278. useFastVertexMerger?: boolean;
  17279. /**
  17280. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17281. * The default value is 1e-6
  17282. * This option is used only if useAlternateEdgeFinder = true
  17283. */
  17284. epsilonVertexMerge?: number;
  17285. /**
  17286. * 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
  17287. * 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.
  17288. * This option is used only if useAlternateEdgeFinder = true
  17289. */
  17290. applyTessellation?: boolean;
  17291. /**
  17292. * 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
  17293. * The default value is 1e-6
  17294. * This option is used only if useAlternateEdgeFinder = true
  17295. */
  17296. epsilonVertexAligned?: number;
  17297. }
  17298. /**
  17299. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17300. */
  17301. export class EdgesRenderer implements IEdgesRenderer {
  17302. /**
  17303. * Define the size of the edges with an orthographic camera
  17304. */
  17305. edgesWidthScalerForOrthographic: number;
  17306. /**
  17307. * Define the size of the edges with a perspective camera
  17308. */
  17309. edgesWidthScalerForPerspective: number;
  17310. protected _source: AbstractMesh;
  17311. protected _linesPositions: number[];
  17312. protected _linesNormals: number[];
  17313. protected _linesIndices: number[];
  17314. protected _epsilon: number;
  17315. protected _indicesCount: number;
  17316. protected _lineShader: ShaderMaterial;
  17317. protected _ib: DataBuffer;
  17318. protected _buffers: {
  17319. [key: string]: Nullable<VertexBuffer>;
  17320. };
  17321. protected _buffersForInstances: {
  17322. [key: string]: Nullable<VertexBuffer>;
  17323. };
  17324. protected _checkVerticesInsteadOfIndices: boolean;
  17325. protected _options: Nullable<IEdgesRendererOptions>;
  17326. private _meshRebuildObserver;
  17327. private _meshDisposeObserver;
  17328. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17329. isEnabled: boolean;
  17330. /**
  17331. * List of instances to render in case the source mesh has instances
  17332. */
  17333. customInstances: SmartArray<Matrix>;
  17334. private static GetShader;
  17335. /**
  17336. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17337. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17338. * @param source Mesh used to create edges
  17339. * @param epsilon sum of angles in adjacency to check for edge
  17340. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17341. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17342. * @param options The options to apply when generating the edges
  17343. */
  17344. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17345. protected _prepareRessources(): void;
  17346. /** @hidden */
  17347. _rebuild(): void;
  17348. /**
  17349. * Releases the required resources for the edges renderer
  17350. */
  17351. dispose(): void;
  17352. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17353. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17354. /**
  17355. * Checks if the pair of p0 and p1 is en edge
  17356. * @param faceIndex
  17357. * @param edge
  17358. * @param faceNormals
  17359. * @param p0
  17360. * @param p1
  17361. * @private
  17362. */
  17363. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17364. /**
  17365. * push line into the position, normal and index buffer
  17366. * @protected
  17367. */
  17368. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17369. /**
  17370. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17371. */
  17372. private _tessellateTriangle;
  17373. private _generateEdgesLinesAlternate;
  17374. /**
  17375. * Generates lines edges from adjacencjes
  17376. * @private
  17377. */
  17378. _generateEdgesLines(): void;
  17379. /**
  17380. * Checks wether or not the edges renderer is ready to render.
  17381. * @return true if ready, otherwise false.
  17382. */
  17383. isReady(): boolean;
  17384. /**
  17385. * Renders the edges of the attached mesh,
  17386. */
  17387. render(): void;
  17388. }
  17389. /**
  17390. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17391. */
  17392. export class LineEdgesRenderer extends EdgesRenderer {
  17393. /**
  17394. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17395. * @param source LineMesh used to generate edges
  17396. * @param epsilon not important (specified angle for edge detection)
  17397. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17398. */
  17399. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17400. /**
  17401. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17402. */
  17403. _generateEdgesLines(): void;
  17404. }
  17405. }
  17406. declare module "babylonjs/Rendering/renderingGroup" {
  17407. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17408. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17410. import { Nullable } from "babylonjs/types";
  17411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17412. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17413. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17414. import { Material } from "babylonjs/Materials/material";
  17415. import { Scene } from "babylonjs/scene";
  17416. /**
  17417. * This represents the object necessary to create a rendering group.
  17418. * This is exclusively used and created by the rendering manager.
  17419. * To modify the behavior, you use the available helpers in your scene or meshes.
  17420. * @hidden
  17421. */
  17422. export class RenderingGroup {
  17423. index: number;
  17424. private static _zeroVector;
  17425. private _scene;
  17426. private _opaqueSubMeshes;
  17427. private _transparentSubMeshes;
  17428. private _alphaTestSubMeshes;
  17429. private _depthOnlySubMeshes;
  17430. private _particleSystems;
  17431. private _spriteManagers;
  17432. private _opaqueSortCompareFn;
  17433. private _alphaTestSortCompareFn;
  17434. private _transparentSortCompareFn;
  17435. private _renderOpaque;
  17436. private _renderAlphaTest;
  17437. private _renderTransparent;
  17438. /** @hidden */
  17439. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17440. onBeforeTransparentRendering: () => void;
  17441. /**
  17442. * Set the opaque sort comparison function.
  17443. * If null the sub meshes will be render in the order they were created
  17444. */
  17445. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17446. /**
  17447. * Set the alpha test sort comparison function.
  17448. * If null the sub meshes will be render in the order they were created
  17449. */
  17450. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17451. /**
  17452. * Set the transparent sort comparison function.
  17453. * If null the sub meshes will be render in the order they were created
  17454. */
  17455. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17456. /**
  17457. * Creates a new rendering group.
  17458. * @param index The rendering group index
  17459. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17460. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17461. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17462. */
  17463. 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>);
  17464. /**
  17465. * Render all the sub meshes contained in the group.
  17466. * @param customRenderFunction Used to override the default render behaviour of the group.
  17467. * @returns true if rendered some submeshes.
  17468. */
  17469. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17470. /**
  17471. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17472. * @param subMeshes The submeshes to render
  17473. */
  17474. private renderOpaqueSorted;
  17475. /**
  17476. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17477. * @param subMeshes The submeshes to render
  17478. */
  17479. private renderAlphaTestSorted;
  17480. /**
  17481. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17482. * @param subMeshes The submeshes to render
  17483. */
  17484. private renderTransparentSorted;
  17485. /**
  17486. * Renders the submeshes in a specified order.
  17487. * @param subMeshes The submeshes to sort before render
  17488. * @param sortCompareFn The comparison function use to sort
  17489. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17490. * @param transparent Specifies to activate blending if true
  17491. */
  17492. private static renderSorted;
  17493. /**
  17494. * Renders the submeshes in the order they were dispatched (no sort applied).
  17495. * @param subMeshes The submeshes to render
  17496. */
  17497. private static renderUnsorted;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered back to front if in the same alpha index.
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17509. * are rendered back to front.
  17510. *
  17511. * @param a The first submesh
  17512. * @param b The second submesh
  17513. * @returns The result of the comparison
  17514. */
  17515. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17516. /**
  17517. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17518. * are rendered front to back (prevent overdraw).
  17519. *
  17520. * @param a The first submesh
  17521. * @param b The second submesh
  17522. * @returns The result of the comparison
  17523. */
  17524. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17525. /**
  17526. * Resets the different lists of submeshes to prepare a new frame.
  17527. */
  17528. prepare(): void;
  17529. dispose(): void;
  17530. /**
  17531. * Inserts the submesh in its correct queue depending on its material.
  17532. * @param subMesh The submesh to dispatch
  17533. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17534. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17535. */
  17536. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17537. dispatchSprites(spriteManager: ISpriteManager): void;
  17538. dispatchParticles(particleSystem: IParticleSystem): void;
  17539. private _renderParticles;
  17540. private _renderSprites;
  17541. }
  17542. }
  17543. declare module "babylonjs/Rendering/renderingManager" {
  17544. import { Nullable } from "babylonjs/types";
  17545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17547. import { SmartArray } from "babylonjs/Misc/smartArray";
  17548. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17549. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17550. import { Material } from "babylonjs/Materials/material";
  17551. import { Scene } from "babylonjs/scene";
  17552. import { Camera } from "babylonjs/Cameras/camera";
  17553. /**
  17554. * Interface describing the different options available in the rendering manager
  17555. * regarding Auto Clear between groups.
  17556. */
  17557. export interface IRenderingManagerAutoClearSetup {
  17558. /**
  17559. * Defines whether or not autoclear is enable.
  17560. */
  17561. autoClear: boolean;
  17562. /**
  17563. * Defines whether or not to autoclear the depth buffer.
  17564. */
  17565. depth: boolean;
  17566. /**
  17567. * Defines whether or not to autoclear the stencil buffer.
  17568. */
  17569. stencil: boolean;
  17570. }
  17571. /**
  17572. * This class is used by the onRenderingGroupObservable
  17573. */
  17574. export class RenderingGroupInfo {
  17575. /**
  17576. * The Scene that being rendered
  17577. */
  17578. scene: Scene;
  17579. /**
  17580. * The camera currently used for the rendering pass
  17581. */
  17582. camera: Nullable<Camera>;
  17583. /**
  17584. * The ID of the renderingGroup being processed
  17585. */
  17586. renderingGroupId: number;
  17587. }
  17588. /**
  17589. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17590. * It is enable to manage the different groups as well as the different necessary sort functions.
  17591. * This should not be used directly aside of the few static configurations
  17592. */
  17593. export class RenderingManager {
  17594. /**
  17595. * The max id used for rendering groups (not included)
  17596. */
  17597. static MAX_RENDERINGGROUPS: number;
  17598. /**
  17599. * The min id used for rendering groups (included)
  17600. */
  17601. static MIN_RENDERINGGROUPS: number;
  17602. /**
  17603. * Used to globally prevent autoclearing scenes.
  17604. */
  17605. static AUTOCLEAR: boolean;
  17606. /**
  17607. * @hidden
  17608. */
  17609. _useSceneAutoClearSetup: boolean;
  17610. private _scene;
  17611. private _renderingGroups;
  17612. private _depthStencilBufferAlreadyCleaned;
  17613. private _autoClearDepthStencil;
  17614. private _customOpaqueSortCompareFn;
  17615. private _customAlphaTestSortCompareFn;
  17616. private _customTransparentSortCompareFn;
  17617. private _renderingGroupInfo;
  17618. /**
  17619. * Instantiates a new rendering group for a particular scene
  17620. * @param scene Defines the scene the groups belongs to
  17621. */
  17622. constructor(scene: Scene);
  17623. private _clearDepthStencilBuffer;
  17624. /**
  17625. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17626. * @hidden
  17627. */
  17628. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17629. /**
  17630. * Resets the different information of the group to prepare a new frame
  17631. * @hidden
  17632. */
  17633. reset(): void;
  17634. /**
  17635. * Dispose and release the group and its associated resources.
  17636. * @hidden
  17637. */
  17638. dispose(): void;
  17639. /**
  17640. * Clear the info related to rendering groups preventing retention points during dispose.
  17641. */
  17642. freeRenderingGroups(): void;
  17643. private _prepareRenderingGroup;
  17644. /**
  17645. * Add a sprite manager to the rendering manager in order to render it this frame.
  17646. * @param spriteManager Define the sprite manager to render
  17647. */
  17648. dispatchSprites(spriteManager: ISpriteManager): void;
  17649. /**
  17650. * Add a particle system to the rendering manager in order to render it this frame.
  17651. * @param particleSystem Define the particle system to render
  17652. */
  17653. dispatchParticles(particleSystem: IParticleSystem): void;
  17654. /**
  17655. * Add a submesh to the manager in order to render it this frame
  17656. * @param subMesh The submesh to dispatch
  17657. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17658. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17659. */
  17660. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17661. /**
  17662. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17663. * This allowed control for front to back rendering or reversly depending of the special needs.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17667. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17668. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17669. */
  17670. 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;
  17671. /**
  17672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17673. *
  17674. * @param renderingGroupId The rendering group id corresponding to its index
  17675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17676. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17677. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17678. */
  17679. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17680. /**
  17681. * Gets the current auto clear configuration for one rendering group of the rendering
  17682. * manager.
  17683. * @param index the rendering group index to get the information for
  17684. * @returns The auto clear setup for the requested rendering group
  17685. */
  17686. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17687. }
  17688. }
  17689. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17690. import { SmartArray } from "babylonjs/Misc/smartArray";
  17691. import { Nullable } from "babylonjs/types";
  17692. import { Scene } from "babylonjs/scene";
  17693. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17696. import { Mesh } from "babylonjs/Meshes/mesh";
  17697. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17698. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17699. import { Effect } from "babylonjs/Materials/effect";
  17700. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17701. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17702. import "babylonjs/Shaders/shadowMap.fragment";
  17703. import "babylonjs/Shaders/shadowMap.vertex";
  17704. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17705. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17706. import { Observable } from "babylonjs/Misc/observable";
  17707. /**
  17708. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17709. */
  17710. export interface ICustomShaderOptions {
  17711. /**
  17712. * Gets or sets the custom shader name to use
  17713. */
  17714. shaderName: string;
  17715. /**
  17716. * The list of attribute names used in the shader
  17717. */
  17718. attributes?: string[];
  17719. /**
  17720. * The list of unifrom names used in the shader
  17721. */
  17722. uniforms?: string[];
  17723. /**
  17724. * The list of sampler names used in the shader
  17725. */
  17726. samplers?: string[];
  17727. /**
  17728. * The list of defines used in the shader
  17729. */
  17730. defines?: string[];
  17731. }
  17732. /**
  17733. * Interface to implement to create a shadow generator compatible with BJS.
  17734. */
  17735. export interface IShadowGenerator {
  17736. /**
  17737. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17738. * @returns The render target texture if present otherwise, null
  17739. */
  17740. getShadowMap(): Nullable<RenderTargetTexture>;
  17741. /**
  17742. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17743. * @param subMesh The submesh we want to render in the shadow map
  17744. * @param useInstances Defines wether will draw in the map using instances
  17745. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17746. * @returns true if ready otherwise, false
  17747. */
  17748. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17749. /**
  17750. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17751. * @param defines Defines of the material we want to update
  17752. * @param lightIndex Index of the light in the enabled light list of the material
  17753. */
  17754. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17755. /**
  17756. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17757. * defined in the generator but impacting the effect).
  17758. * It implies the unifroms available on the materials are the standard BJS ones.
  17759. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17760. * @param effect The effect we are binfing the information for
  17761. */
  17762. bindShadowLight(lightIndex: string, effect: Effect): void;
  17763. /**
  17764. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17765. * (eq to shadow prjection matrix * light transform matrix)
  17766. * @returns The transform matrix used to create the shadow map
  17767. */
  17768. getTransformMatrix(): Matrix;
  17769. /**
  17770. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17771. * Cube and 2D textures for instance.
  17772. */
  17773. recreateShadowMap(): void;
  17774. /**
  17775. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17776. * @param onCompiled Callback triggered at the and of the effects compilation
  17777. * @param options Sets of optional options forcing the compilation with different modes
  17778. */
  17779. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17780. useInstances: boolean;
  17781. }>): void;
  17782. /**
  17783. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17784. * @param options Sets of optional options forcing the compilation with different modes
  17785. * @returns A promise that resolves when the compilation completes
  17786. */
  17787. forceCompilationAsync(options?: Partial<{
  17788. useInstances: boolean;
  17789. }>): Promise<void>;
  17790. /**
  17791. * Serializes the shadow generator setup to a json object.
  17792. * @returns The serialized JSON object
  17793. */
  17794. serialize(): any;
  17795. /**
  17796. * Disposes the Shadow map and related Textures and effects.
  17797. */
  17798. dispose(): void;
  17799. }
  17800. /**
  17801. * Default implementation IShadowGenerator.
  17802. * This is the main object responsible of generating shadows in the framework.
  17803. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17804. */
  17805. export class ShadowGenerator implements IShadowGenerator {
  17806. /**
  17807. * Name of the shadow generator class
  17808. */
  17809. static CLASSNAME: string;
  17810. /**
  17811. * Shadow generator mode None: no filtering applied.
  17812. */
  17813. static readonly FILTER_NONE: number;
  17814. /**
  17815. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17816. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17817. */
  17818. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17819. /**
  17820. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17821. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17822. */
  17823. static readonly FILTER_POISSONSAMPLING: number;
  17824. /**
  17825. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17826. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17827. */
  17828. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17829. /**
  17830. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17831. * edge artifacts on steep falloff.
  17832. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17833. */
  17834. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17835. /**
  17836. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17837. * edge artifacts on steep falloff.
  17838. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17839. */
  17840. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17841. /**
  17842. * Shadow generator mode PCF: Percentage Closer Filtering
  17843. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17844. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17845. */
  17846. static readonly FILTER_PCF: number;
  17847. /**
  17848. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17849. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17850. * Contact Hardening
  17851. */
  17852. static readonly FILTER_PCSS: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * Highest Quality.
  17856. *
  17857. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17858. *
  17859. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17860. */
  17861. static readonly QUALITY_HIGH: number;
  17862. /**
  17863. * Reserved for PCF and PCSS
  17864. * Good tradeoff for quality/perf cross devices
  17865. *
  17866. * Execute PCF on a 3*3 kernel.
  17867. *
  17868. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17869. */
  17870. static readonly QUALITY_MEDIUM: number;
  17871. /**
  17872. * Reserved for PCF and PCSS
  17873. * The lowest quality but the fastest.
  17874. *
  17875. * Execute PCF on a 1*1 kernel.
  17876. *
  17877. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17878. */
  17879. static readonly QUALITY_LOW: number;
  17880. /** Gets or sets the custom shader name to use */
  17881. customShaderOptions: ICustomShaderOptions;
  17882. /**
  17883. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17884. */
  17885. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17886. /**
  17887. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17888. */
  17889. onAfterShadowMapRenderObservable: Observable<Effect>;
  17890. /**
  17891. * Observable triggered before a mesh is rendered in the shadow map.
  17892. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17893. */
  17894. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17895. /**
  17896. * Observable triggered after a mesh is rendered in the shadow map.
  17897. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17898. */
  17899. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17900. protected _bias: number;
  17901. /**
  17902. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17903. */
  17904. get bias(): number;
  17905. /**
  17906. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17907. */
  17908. set bias(bias: number);
  17909. protected _normalBias: number;
  17910. /**
  17911. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17912. */
  17913. get normalBias(): number;
  17914. /**
  17915. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17916. */
  17917. set normalBias(normalBias: number);
  17918. protected _blurBoxOffset: number;
  17919. /**
  17920. * Gets the blur box offset: offset applied during the blur pass.
  17921. * Only useful if useKernelBlur = false
  17922. */
  17923. get blurBoxOffset(): number;
  17924. /**
  17925. * Sets the blur box offset: offset applied during the blur pass.
  17926. * Only useful if useKernelBlur = false
  17927. */
  17928. set blurBoxOffset(value: number);
  17929. protected _blurScale: number;
  17930. /**
  17931. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17932. * 2 means half of the size.
  17933. */
  17934. get blurScale(): number;
  17935. /**
  17936. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17937. * 2 means half of the size.
  17938. */
  17939. set blurScale(value: number);
  17940. protected _blurKernel: number;
  17941. /**
  17942. * Gets the blur kernel: kernel size of the blur pass.
  17943. * Only useful if useKernelBlur = true
  17944. */
  17945. get blurKernel(): number;
  17946. /**
  17947. * Sets the blur kernel: kernel size of the blur pass.
  17948. * Only useful if useKernelBlur = true
  17949. */
  17950. set blurKernel(value: number);
  17951. protected _useKernelBlur: boolean;
  17952. /**
  17953. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17954. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17955. */
  17956. get useKernelBlur(): boolean;
  17957. /**
  17958. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17959. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17960. */
  17961. set useKernelBlur(value: boolean);
  17962. protected _depthScale: number;
  17963. /**
  17964. * Gets the depth scale used in ESM mode.
  17965. */
  17966. get depthScale(): number;
  17967. /**
  17968. * Sets the depth scale used in ESM mode.
  17969. * This can override the scale stored on the light.
  17970. */
  17971. set depthScale(value: number);
  17972. protected _validateFilter(filter: number): number;
  17973. protected _filter: number;
  17974. /**
  17975. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17976. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17977. */
  17978. get filter(): number;
  17979. /**
  17980. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17981. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17982. */
  17983. set filter(value: number);
  17984. /**
  17985. * Gets if the current filter is set to Poisson Sampling.
  17986. */
  17987. get usePoissonSampling(): boolean;
  17988. /**
  17989. * Sets the current filter to Poisson Sampling.
  17990. */
  17991. set usePoissonSampling(value: boolean);
  17992. /**
  17993. * Gets if the current filter is set to ESM.
  17994. */
  17995. get useExponentialShadowMap(): boolean;
  17996. /**
  17997. * Sets the current filter is to ESM.
  17998. */
  17999. set useExponentialShadowMap(value: boolean);
  18000. /**
  18001. * Gets if the current filter is set to filtered ESM.
  18002. */
  18003. get useBlurExponentialShadowMap(): boolean;
  18004. /**
  18005. * Gets if the current filter is set to filtered ESM.
  18006. */
  18007. set useBlurExponentialShadowMap(value: boolean);
  18008. /**
  18009. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18010. * exponential to prevent steep falloff artifacts).
  18011. */
  18012. get useCloseExponentialShadowMap(): boolean;
  18013. /**
  18014. * Sets the current filter to "close ESM" (using the inverse of the
  18015. * exponential to prevent steep falloff artifacts).
  18016. */
  18017. set useCloseExponentialShadowMap(value: boolean);
  18018. /**
  18019. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18020. * exponential to prevent steep falloff artifacts).
  18021. */
  18022. get useBlurCloseExponentialShadowMap(): boolean;
  18023. /**
  18024. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18025. * exponential to prevent steep falloff artifacts).
  18026. */
  18027. set useBlurCloseExponentialShadowMap(value: boolean);
  18028. /**
  18029. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18030. */
  18031. get usePercentageCloserFiltering(): boolean;
  18032. /**
  18033. * Sets the current filter to "PCF" (percentage closer filtering).
  18034. */
  18035. set usePercentageCloserFiltering(value: boolean);
  18036. protected _filteringQuality: number;
  18037. /**
  18038. * Gets the PCF or PCSS Quality.
  18039. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18040. */
  18041. get filteringQuality(): number;
  18042. /**
  18043. * Sets the PCF or PCSS Quality.
  18044. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18045. */
  18046. set filteringQuality(filteringQuality: number);
  18047. /**
  18048. * Gets if the current filter is set to "PCSS" (contact hardening).
  18049. */
  18050. get useContactHardeningShadow(): boolean;
  18051. /**
  18052. * Sets the current filter to "PCSS" (contact hardening).
  18053. */
  18054. set useContactHardeningShadow(value: boolean);
  18055. protected _contactHardeningLightSizeUVRatio: number;
  18056. /**
  18057. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18058. * Using a ratio helps keeping shape stability independently of the map size.
  18059. *
  18060. * It does not account for the light projection as it was having too much
  18061. * instability during the light setup or during light position changes.
  18062. *
  18063. * Only valid if useContactHardeningShadow is true.
  18064. */
  18065. get contactHardeningLightSizeUVRatio(): number;
  18066. /**
  18067. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18068. * Using a ratio helps keeping shape stability independently of the map size.
  18069. *
  18070. * It does not account for the light projection as it was having too much
  18071. * instability during the light setup or during light position changes.
  18072. *
  18073. * Only valid if useContactHardeningShadow is true.
  18074. */
  18075. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18076. protected _darkness: number;
  18077. /** Gets or sets the actual darkness of a shadow */
  18078. get darkness(): number;
  18079. set darkness(value: number);
  18080. /**
  18081. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18082. * 0 means strongest and 1 would means no shadow.
  18083. * @returns the darkness.
  18084. */
  18085. getDarkness(): number;
  18086. /**
  18087. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18088. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18089. * @returns the shadow generator allowing fluent coding.
  18090. */
  18091. setDarkness(darkness: number): ShadowGenerator;
  18092. protected _transparencyShadow: boolean;
  18093. /** Gets or sets the ability to have transparent shadow */
  18094. get transparencyShadow(): boolean;
  18095. set transparencyShadow(value: boolean);
  18096. /**
  18097. * Sets the ability to have transparent shadow (boolean).
  18098. * @param transparent True if transparent else False
  18099. * @returns the shadow generator allowing fluent coding
  18100. */
  18101. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18102. /**
  18103. * Enables or disables shadows with varying strength based on the transparency
  18104. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18105. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18106. * mesh.visibility * alphaTexture.a
  18107. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18108. */
  18109. enableSoftTransparentShadow: boolean;
  18110. protected _shadowMap: Nullable<RenderTargetTexture>;
  18111. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18112. /**
  18113. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18114. * @returns The render target texture if present otherwise, null
  18115. */
  18116. getShadowMap(): Nullable<RenderTargetTexture>;
  18117. /**
  18118. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18119. * @returns The render target texture if the shadow map is present otherwise, null
  18120. */
  18121. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18122. /**
  18123. * Gets the class name of that object
  18124. * @returns "ShadowGenerator"
  18125. */
  18126. getClassName(): string;
  18127. /**
  18128. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18129. * @param mesh Mesh to add
  18130. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18131. * @returns the Shadow Generator itself
  18132. */
  18133. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18134. /**
  18135. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18136. * @param mesh Mesh to remove
  18137. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18138. * @returns the Shadow Generator itself
  18139. */
  18140. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18141. /**
  18142. * Controls the extent to which the shadows fade out at the edge of the frustum
  18143. */
  18144. frustumEdgeFalloff: number;
  18145. protected _light: IShadowLight;
  18146. /**
  18147. * Returns the associated light object.
  18148. * @returns the light generating the shadow
  18149. */
  18150. getLight(): IShadowLight;
  18151. /**
  18152. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18153. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18154. * It might on the other hand introduce peter panning.
  18155. */
  18156. forceBackFacesOnly: boolean;
  18157. protected _scene: Scene;
  18158. protected _lightDirection: Vector3;
  18159. protected _effect: Effect;
  18160. protected _viewMatrix: Matrix;
  18161. protected _projectionMatrix: Matrix;
  18162. protected _transformMatrix: Matrix;
  18163. protected _cachedPosition: Vector3;
  18164. protected _cachedDirection: Vector3;
  18165. protected _cachedDefines: string;
  18166. protected _currentRenderID: number;
  18167. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18168. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18169. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18170. protected _blurPostProcesses: PostProcess[];
  18171. protected _mapSize: number;
  18172. protected _currentFaceIndex: number;
  18173. protected _currentFaceIndexCache: number;
  18174. protected _textureType: number;
  18175. protected _defaultTextureMatrix: Matrix;
  18176. protected _storedUniqueId: Nullable<number>;
  18177. /** @hidden */
  18178. static _SceneComponentInitialization: (scene: Scene) => void;
  18179. /**
  18180. * Creates a ShadowGenerator object.
  18181. * A ShadowGenerator is the required tool to use the shadows.
  18182. * Each light casting shadows needs to use its own ShadowGenerator.
  18183. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18184. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18185. * @param light The light object generating the shadows.
  18186. * @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.
  18187. */
  18188. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18189. protected _initializeGenerator(): void;
  18190. protected _createTargetRenderTexture(): void;
  18191. protected _initializeShadowMap(): void;
  18192. protected _initializeBlurRTTAndPostProcesses(): void;
  18193. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18194. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18195. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18196. protected _applyFilterValues(): void;
  18197. /**
  18198. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18199. * @param onCompiled Callback triggered at the and of the effects compilation
  18200. * @param options Sets of optional options forcing the compilation with different modes
  18201. */
  18202. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18203. useInstances: boolean;
  18204. }>): void;
  18205. /**
  18206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18207. * @param options Sets of optional options forcing the compilation with different modes
  18208. * @returns A promise that resolves when the compilation completes
  18209. */
  18210. forceCompilationAsync(options?: Partial<{
  18211. useInstances: boolean;
  18212. }>): Promise<void>;
  18213. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18214. private _prepareShadowDefines;
  18215. /**
  18216. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18217. * @param subMesh The submesh we want to render in the shadow map
  18218. * @param useInstances Defines wether will draw in the map using instances
  18219. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18220. * @returns true if ready otherwise, false
  18221. */
  18222. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18223. /**
  18224. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18225. * @param defines Defines of the material we want to update
  18226. * @param lightIndex Index of the light in the enabled light list of the material
  18227. */
  18228. prepareDefines(defines: any, lightIndex: number): void;
  18229. /**
  18230. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18231. * defined in the generator but impacting the effect).
  18232. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18233. * @param effect The effect we are binfing the information for
  18234. */
  18235. bindShadowLight(lightIndex: string, effect: Effect): void;
  18236. /**
  18237. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18238. * (eq to shadow prjection matrix * light transform matrix)
  18239. * @returns The transform matrix used to create the shadow map
  18240. */
  18241. getTransformMatrix(): Matrix;
  18242. /**
  18243. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18244. * Cube and 2D textures for instance.
  18245. */
  18246. recreateShadowMap(): void;
  18247. protected _disposeBlurPostProcesses(): void;
  18248. protected _disposeRTTandPostProcesses(): void;
  18249. /**
  18250. * Disposes the ShadowGenerator.
  18251. * Returns nothing.
  18252. */
  18253. dispose(): void;
  18254. /**
  18255. * Serializes the shadow generator setup to a json object.
  18256. * @returns The serialized JSON object
  18257. */
  18258. serialize(): any;
  18259. /**
  18260. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18261. * @param parsedShadowGenerator The JSON object to parse
  18262. * @param scene The scene to create the shadow map for
  18263. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18264. * @returns The parsed shadow generator
  18265. */
  18266. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18267. }
  18268. }
  18269. declare module "babylonjs/Lights/light" {
  18270. import { Nullable } from "babylonjs/types";
  18271. import { Scene } from "babylonjs/scene";
  18272. import { Vector3 } from "babylonjs/Maths/math.vector";
  18273. import { Color3 } from "babylonjs/Maths/math.color";
  18274. import { Node } from "babylonjs/node";
  18275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18276. import { Effect } from "babylonjs/Materials/effect";
  18277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18278. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18279. /**
  18280. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18281. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18282. * 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.
  18283. */
  18284. export abstract class Light extends Node {
  18285. /**
  18286. * Falloff Default: light is falling off following the material specification:
  18287. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18288. */
  18289. static readonly FALLOFF_DEFAULT: number;
  18290. /**
  18291. * Falloff Physical: light is falling off following the inverse squared distance law.
  18292. */
  18293. static readonly FALLOFF_PHYSICAL: number;
  18294. /**
  18295. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18296. * to enhance interoperability with other engines.
  18297. */
  18298. static readonly FALLOFF_GLTF: number;
  18299. /**
  18300. * Falloff Standard: light is falling off like in the standard material
  18301. * to enhance interoperability with other materials.
  18302. */
  18303. static readonly FALLOFF_STANDARD: number;
  18304. /**
  18305. * If every light affecting the material is in this lightmapMode,
  18306. * material.lightmapTexture adds or multiplies
  18307. * (depends on material.useLightmapAsShadowmap)
  18308. * after every other light calculations.
  18309. */
  18310. static readonly LIGHTMAP_DEFAULT: number;
  18311. /**
  18312. * material.lightmapTexture as only diffuse lighting from this light
  18313. * adds only specular lighting from this light
  18314. * adds dynamic shadows
  18315. */
  18316. static readonly LIGHTMAP_SPECULAR: number;
  18317. /**
  18318. * material.lightmapTexture as only lighting
  18319. * no light calculation from this light
  18320. * only adds dynamic shadows from this light
  18321. */
  18322. static readonly LIGHTMAP_SHADOWSONLY: number;
  18323. /**
  18324. * Each light type uses the default quantity according to its type:
  18325. * point/spot lights use luminous intensity
  18326. * directional lights use illuminance
  18327. */
  18328. static readonly INTENSITYMODE_AUTOMATIC: number;
  18329. /**
  18330. * lumen (lm)
  18331. */
  18332. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18333. /**
  18334. * candela (lm/sr)
  18335. */
  18336. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18337. /**
  18338. * lux (lm/m^2)
  18339. */
  18340. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18341. /**
  18342. * nit (cd/m^2)
  18343. */
  18344. static readonly INTENSITYMODE_LUMINANCE: number;
  18345. /**
  18346. * Light type const id of the point light.
  18347. */
  18348. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18349. /**
  18350. * Light type const id of the directional light.
  18351. */
  18352. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18353. /**
  18354. * Light type const id of the spot light.
  18355. */
  18356. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18357. /**
  18358. * Light type const id of the hemispheric light.
  18359. */
  18360. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18361. /**
  18362. * Diffuse gives the basic color to an object.
  18363. */
  18364. diffuse: Color3;
  18365. /**
  18366. * Specular produces a highlight color on an object.
  18367. * Note: This is note affecting PBR materials.
  18368. */
  18369. specular: Color3;
  18370. /**
  18371. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18372. * falling off base on range or angle.
  18373. * This can be set to any values in Light.FALLOFF_x.
  18374. *
  18375. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18376. * other types of materials.
  18377. */
  18378. falloffType: number;
  18379. /**
  18380. * Strength of the light.
  18381. * Note: By default it is define in the framework own unit.
  18382. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18383. */
  18384. intensity: number;
  18385. private _range;
  18386. protected _inverseSquaredRange: number;
  18387. /**
  18388. * Defines how far from the source the light is impacting in scene units.
  18389. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18390. */
  18391. get range(): number;
  18392. /**
  18393. * Defines how far from the source the light is impacting in scene units.
  18394. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18395. */
  18396. set range(value: number);
  18397. /**
  18398. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18399. * of light.
  18400. */
  18401. private _photometricScale;
  18402. private _intensityMode;
  18403. /**
  18404. * Gets the photometric scale used to interpret the intensity.
  18405. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18406. */
  18407. get intensityMode(): number;
  18408. /**
  18409. * Sets the photometric scale used to interpret the intensity.
  18410. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18411. */
  18412. set intensityMode(value: number);
  18413. private _radius;
  18414. /**
  18415. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18416. */
  18417. get radius(): number;
  18418. /**
  18419. * sets the light radius used by PBR Materials to simulate soft area lights.
  18420. */
  18421. set radius(value: number);
  18422. private _renderPriority;
  18423. /**
  18424. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18425. * exceeding the number allowed of the materials.
  18426. */
  18427. renderPriority: number;
  18428. private _shadowEnabled;
  18429. /**
  18430. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18431. * the current shadow generator.
  18432. */
  18433. get shadowEnabled(): boolean;
  18434. /**
  18435. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18436. * the current shadow generator.
  18437. */
  18438. set shadowEnabled(value: boolean);
  18439. private _includedOnlyMeshes;
  18440. /**
  18441. * Gets the only meshes impacted by this light.
  18442. */
  18443. get includedOnlyMeshes(): AbstractMesh[];
  18444. /**
  18445. * Sets the only meshes impacted by this light.
  18446. */
  18447. set includedOnlyMeshes(value: AbstractMesh[]);
  18448. private _excludedMeshes;
  18449. /**
  18450. * Gets the meshes not impacted by this light.
  18451. */
  18452. get excludedMeshes(): AbstractMesh[];
  18453. /**
  18454. * Sets the meshes not impacted by this light.
  18455. */
  18456. set excludedMeshes(value: AbstractMesh[]);
  18457. private _excludeWithLayerMask;
  18458. /**
  18459. * Gets the layer id use to find what meshes are not impacted by the light.
  18460. * Inactive if 0
  18461. */
  18462. get excludeWithLayerMask(): number;
  18463. /**
  18464. * Sets the layer id use to find what meshes are not impacted by the light.
  18465. * Inactive if 0
  18466. */
  18467. set excludeWithLayerMask(value: number);
  18468. private _includeOnlyWithLayerMask;
  18469. /**
  18470. * Gets the layer id use to find what meshes are impacted by the light.
  18471. * Inactive if 0
  18472. */
  18473. get includeOnlyWithLayerMask(): number;
  18474. /**
  18475. * Sets the layer id use to find what meshes are impacted by the light.
  18476. * Inactive if 0
  18477. */
  18478. set includeOnlyWithLayerMask(value: number);
  18479. private _lightmapMode;
  18480. /**
  18481. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18482. */
  18483. get lightmapMode(): number;
  18484. /**
  18485. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18486. */
  18487. set lightmapMode(value: number);
  18488. /**
  18489. * Shadow generator associted to the light.
  18490. * @hidden Internal use only.
  18491. */
  18492. _shadowGenerator: Nullable<IShadowGenerator>;
  18493. /**
  18494. * @hidden Internal use only.
  18495. */
  18496. _excludedMeshesIds: string[];
  18497. /**
  18498. * @hidden Internal use only.
  18499. */
  18500. _includedOnlyMeshesIds: string[];
  18501. /**
  18502. * The current light unifom buffer.
  18503. * @hidden Internal use only.
  18504. */
  18505. _uniformBuffer: UniformBuffer;
  18506. /** @hidden */
  18507. _renderId: number;
  18508. /**
  18509. * Creates a Light object in the scene.
  18510. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18511. * @param name The firendly name of the light
  18512. * @param scene The scene the light belongs too
  18513. */
  18514. constructor(name: string, scene: Scene);
  18515. protected abstract _buildUniformLayout(): void;
  18516. /**
  18517. * Sets the passed Effect "effect" with the Light information.
  18518. * @param effect The effect to update
  18519. * @param lightIndex The index of the light in the effect to update
  18520. * @returns The light
  18521. */
  18522. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18523. /**
  18524. * Sets the passed Effect "effect" with the Light textures.
  18525. * @param effect The effect to update
  18526. * @param lightIndex The index of the light in the effect to update
  18527. * @returns The light
  18528. */
  18529. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18530. /**
  18531. * Binds the lights information from the scene to the effect for the given mesh.
  18532. * @param lightIndex Light index
  18533. * @param scene The scene where the light belongs to
  18534. * @param effect The effect we are binding the data to
  18535. * @param useSpecular Defines if specular is supported
  18536. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18537. */
  18538. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18539. /**
  18540. * Sets the passed Effect "effect" with the Light information.
  18541. * @param effect The effect to update
  18542. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18543. * @returns The light
  18544. */
  18545. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18546. /**
  18547. * Returns the string "Light".
  18548. * @returns the class name
  18549. */
  18550. getClassName(): string;
  18551. /** @hidden */
  18552. readonly _isLight: boolean;
  18553. /**
  18554. * Converts the light information to a readable string for debug purpose.
  18555. * @param fullDetails Supports for multiple levels of logging within scene loading
  18556. * @returns the human readable light info
  18557. */
  18558. toString(fullDetails?: boolean): string;
  18559. /** @hidden */
  18560. protected _syncParentEnabledState(): void;
  18561. /**
  18562. * Set the enabled state of this node.
  18563. * @param value - the new enabled state
  18564. */
  18565. setEnabled(value: boolean): void;
  18566. /**
  18567. * Returns the Light associated shadow generator if any.
  18568. * @return the associated shadow generator.
  18569. */
  18570. getShadowGenerator(): Nullable<IShadowGenerator>;
  18571. /**
  18572. * Returns a Vector3, the absolute light position in the World.
  18573. * @returns the world space position of the light
  18574. */
  18575. getAbsolutePosition(): Vector3;
  18576. /**
  18577. * Specifies if the light will affect the passed mesh.
  18578. * @param mesh The mesh to test against the light
  18579. * @return true the mesh is affected otherwise, false.
  18580. */
  18581. canAffectMesh(mesh: AbstractMesh): boolean;
  18582. /**
  18583. * Sort function to order lights for rendering.
  18584. * @param a First Light object to compare to second.
  18585. * @param b Second Light object to compare first.
  18586. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18587. */
  18588. static CompareLightsPriority(a: Light, b: Light): number;
  18589. /**
  18590. * Releases resources associated with this node.
  18591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18593. */
  18594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18595. /**
  18596. * Returns the light type ID (integer).
  18597. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18598. */
  18599. getTypeID(): number;
  18600. /**
  18601. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18602. * @returns the scaled intensity in intensity mode unit
  18603. */
  18604. getScaledIntensity(): number;
  18605. /**
  18606. * Returns a new Light object, named "name", from the current one.
  18607. * @param name The name of the cloned light
  18608. * @param newParent The parent of this light, if it has one
  18609. * @returns the new created light
  18610. */
  18611. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18612. /**
  18613. * Serializes the current light into a Serialization object.
  18614. * @returns the serialized object.
  18615. */
  18616. serialize(): any;
  18617. /**
  18618. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18619. * This new light is named "name" and added to the passed scene.
  18620. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18621. * @param name The friendly name of the light
  18622. * @param scene The scene the new light will belong to
  18623. * @returns the constructor function
  18624. */
  18625. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18626. /**
  18627. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18628. * @param parsedLight The JSON representation of the light
  18629. * @param scene The scene to create the parsed light in
  18630. * @returns the created light after parsing
  18631. */
  18632. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18633. private _hookArrayForExcluded;
  18634. private _hookArrayForIncludedOnly;
  18635. private _resyncMeshes;
  18636. /**
  18637. * Forces the meshes to update their light related information in their rendering used effects
  18638. * @hidden Internal Use Only
  18639. */
  18640. _markMeshesAsLightDirty(): void;
  18641. /**
  18642. * Recomputes the cached photometric scale if needed.
  18643. */
  18644. private _computePhotometricScale;
  18645. /**
  18646. * Returns the Photometric Scale according to the light type and intensity mode.
  18647. */
  18648. private _getPhotometricScale;
  18649. /**
  18650. * Reorder the light in the scene according to their defined priority.
  18651. * @hidden Internal Use Only
  18652. */
  18653. _reorderLightsInScene(): void;
  18654. /**
  18655. * Prepares the list of defines specific to the light type.
  18656. * @param defines the list of defines
  18657. * @param lightIndex defines the index of the light for the effect
  18658. */
  18659. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18660. }
  18661. }
  18662. declare module "babylonjs/Cameras/targetCamera" {
  18663. import { Nullable } from "babylonjs/types";
  18664. import { Camera } from "babylonjs/Cameras/camera";
  18665. import { Scene } from "babylonjs/scene";
  18666. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18667. /**
  18668. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18669. * This is the base of the follow, arc rotate cameras and Free camera
  18670. * @see https://doc.babylonjs.com/features/cameras
  18671. */
  18672. export class TargetCamera extends Camera {
  18673. private static _RigCamTransformMatrix;
  18674. private static _TargetTransformMatrix;
  18675. private static _TargetFocalPoint;
  18676. private _tmpUpVector;
  18677. private _tmpTargetVector;
  18678. /**
  18679. * Define the current direction the camera is moving to
  18680. */
  18681. cameraDirection: Vector3;
  18682. /**
  18683. * Define the current rotation the camera is rotating to
  18684. */
  18685. cameraRotation: Vector2;
  18686. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18687. ignoreParentScaling: boolean;
  18688. /**
  18689. * When set, the up vector of the camera will be updated by the rotation of the camera
  18690. */
  18691. updateUpVectorFromRotation: boolean;
  18692. private _tmpQuaternion;
  18693. /**
  18694. * Define the current rotation of the camera
  18695. */
  18696. rotation: Vector3;
  18697. /**
  18698. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18699. */
  18700. rotationQuaternion: Quaternion;
  18701. /**
  18702. * Define the current speed of the camera
  18703. */
  18704. speed: number;
  18705. /**
  18706. * Add constraint to the camera to prevent it to move freely in all directions and
  18707. * around all axis.
  18708. */
  18709. noRotationConstraint: boolean;
  18710. /**
  18711. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18712. * panning
  18713. */
  18714. invertRotation: boolean;
  18715. /**
  18716. * Speed multiplier for inverse camera panning
  18717. */
  18718. inverseRotationSpeed: number;
  18719. /**
  18720. * Define the current target of the camera as an object or a position.
  18721. */
  18722. lockedTarget: any;
  18723. /** @hidden */
  18724. _currentTarget: Vector3;
  18725. /** @hidden */
  18726. _initialFocalDistance: number;
  18727. /** @hidden */
  18728. _viewMatrix: Matrix;
  18729. /** @hidden */
  18730. _camMatrix: Matrix;
  18731. /** @hidden */
  18732. _cameraTransformMatrix: Matrix;
  18733. /** @hidden */
  18734. _cameraRotationMatrix: Matrix;
  18735. /** @hidden */
  18736. _referencePoint: Vector3;
  18737. /** @hidden */
  18738. _transformedReferencePoint: Vector3;
  18739. /** @hidden */
  18740. _reset: () => void;
  18741. private _defaultUp;
  18742. /**
  18743. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18744. * This is the base of the follow, arc rotate cameras and Free camera
  18745. * @see https://doc.babylonjs.com/features/cameras
  18746. * @param name Defines the name of the camera in the scene
  18747. * @param position Defines the start position of the camera in the scene
  18748. * @param scene Defines the scene the camera belongs to
  18749. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18750. */
  18751. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18752. /**
  18753. * Gets the position in front of the camera at a given distance.
  18754. * @param distance The distance from the camera we want the position to be
  18755. * @returns the position
  18756. */
  18757. getFrontPosition(distance: number): Vector3;
  18758. /** @hidden */
  18759. _getLockedTargetPosition(): Nullable<Vector3>;
  18760. private _storedPosition;
  18761. private _storedRotation;
  18762. private _storedRotationQuaternion;
  18763. /**
  18764. * Store current camera state of the camera (fov, position, rotation, etc..)
  18765. * @returns the camera
  18766. */
  18767. storeState(): Camera;
  18768. /**
  18769. * Restored camera state. You must call storeState() first
  18770. * @returns whether it was successful or not
  18771. * @hidden
  18772. */
  18773. _restoreStateValues(): boolean;
  18774. /** @hidden */
  18775. _initCache(): void;
  18776. /** @hidden */
  18777. _updateCache(ignoreParentClass?: boolean): void;
  18778. /** @hidden */
  18779. _isSynchronizedViewMatrix(): boolean;
  18780. /** @hidden */
  18781. _computeLocalCameraSpeed(): number;
  18782. /**
  18783. * Defines the target the camera should look at.
  18784. * @param target Defines the new target as a Vector or a mesh
  18785. */
  18786. setTarget(target: Vector3): void;
  18787. /**
  18788. * Return the current target position of the camera. This value is expressed in local space.
  18789. * @returns the target position
  18790. */
  18791. getTarget(): Vector3;
  18792. /** @hidden */
  18793. _decideIfNeedsToMove(): boolean;
  18794. /** @hidden */
  18795. _updatePosition(): void;
  18796. /** @hidden */
  18797. _checkInputs(): void;
  18798. protected _updateCameraRotationMatrix(): void;
  18799. /**
  18800. * 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)
  18801. * @returns the current camera
  18802. */
  18803. private _rotateUpVectorWithCameraRotationMatrix;
  18804. private _cachedRotationZ;
  18805. private _cachedQuaternionRotationZ;
  18806. /** @hidden */
  18807. _getViewMatrix(): Matrix;
  18808. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18809. /**
  18810. * @hidden
  18811. */
  18812. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18813. /**
  18814. * @hidden
  18815. */
  18816. _updateRigCameras(): void;
  18817. private _getRigCamPositionAndTarget;
  18818. /**
  18819. * Gets the current object class name.
  18820. * @return the class name
  18821. */
  18822. getClassName(): string;
  18823. }
  18824. }
  18825. declare module "babylonjs/Events/keyboardEvents" {
  18826. /**
  18827. * Gather the list of keyboard event types as constants.
  18828. */
  18829. export class KeyboardEventTypes {
  18830. /**
  18831. * The keydown event is fired when a key becomes active (pressed).
  18832. */
  18833. static readonly KEYDOWN: number;
  18834. /**
  18835. * The keyup event is fired when a key has been released.
  18836. */
  18837. static readonly KEYUP: number;
  18838. }
  18839. /**
  18840. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18841. */
  18842. export class KeyboardInfo {
  18843. /**
  18844. * Defines the type of event (KeyboardEventTypes)
  18845. */
  18846. type: number;
  18847. /**
  18848. * Defines the related dom event
  18849. */
  18850. event: KeyboardEvent;
  18851. /**
  18852. * Instantiates a new keyboard info.
  18853. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18854. * @param type Defines the type of event (KeyboardEventTypes)
  18855. * @param event Defines the related dom event
  18856. */
  18857. constructor(
  18858. /**
  18859. * Defines the type of event (KeyboardEventTypes)
  18860. */
  18861. type: number,
  18862. /**
  18863. * Defines the related dom event
  18864. */
  18865. event: KeyboardEvent);
  18866. }
  18867. /**
  18868. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18869. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18870. */
  18871. export class KeyboardInfoPre extends KeyboardInfo {
  18872. /**
  18873. * Defines the type of event (KeyboardEventTypes)
  18874. */
  18875. type: number;
  18876. /**
  18877. * Defines the related dom event
  18878. */
  18879. event: KeyboardEvent;
  18880. /**
  18881. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18882. */
  18883. skipOnPointerObservable: boolean;
  18884. /**
  18885. * Instantiates a new keyboard pre info.
  18886. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18887. * @param type Defines the type of event (KeyboardEventTypes)
  18888. * @param event Defines the related dom event
  18889. */
  18890. constructor(
  18891. /**
  18892. * Defines the type of event (KeyboardEventTypes)
  18893. */
  18894. type: number,
  18895. /**
  18896. * Defines the related dom event
  18897. */
  18898. event: KeyboardEvent);
  18899. }
  18900. }
  18901. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18902. import { Nullable } from "babylonjs/types";
  18903. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18904. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18905. /**
  18906. * Manage the keyboard inputs to control the movement of a free camera.
  18907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18908. */
  18909. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18910. /**
  18911. * Defines the camera the input is attached to.
  18912. */
  18913. camera: FreeCamera;
  18914. /**
  18915. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18916. */
  18917. keysUp: number[];
  18918. /**
  18919. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18920. */
  18921. keysUpward: number[];
  18922. /**
  18923. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18924. */
  18925. keysDown: number[];
  18926. /**
  18927. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18928. */
  18929. keysDownward: number[];
  18930. /**
  18931. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18932. */
  18933. keysLeft: number[];
  18934. /**
  18935. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18936. */
  18937. keysRight: number[];
  18938. private _keys;
  18939. private _onCanvasBlurObserver;
  18940. private _onKeyboardObserver;
  18941. private _engine;
  18942. private _scene;
  18943. /**
  18944. * Attach the input controls to a specific dom element to get the input from.
  18945. * @param element Defines the element the controls should be listened from
  18946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18947. */
  18948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18949. /**
  18950. * Detach the current controls from the specified dom element.
  18951. * @param element Defines the element to stop listening the inputs from
  18952. */
  18953. detachControl(element: Nullable<HTMLElement>): void;
  18954. /**
  18955. * Update the current camera state depending on the inputs that have been used this frame.
  18956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18957. */
  18958. checkInputs(): void;
  18959. /**
  18960. * Gets the class name of the current intput.
  18961. * @returns the class name
  18962. */
  18963. getClassName(): string;
  18964. /** @hidden */
  18965. _onLostFocus(): void;
  18966. /**
  18967. * Get the friendly name associated with the input class.
  18968. * @returns the input friendly name
  18969. */
  18970. getSimpleName(): string;
  18971. }
  18972. }
  18973. declare module "babylonjs/Events/pointerEvents" {
  18974. import { Nullable } from "babylonjs/types";
  18975. import { Vector2 } from "babylonjs/Maths/math.vector";
  18976. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18977. import { Ray } from "babylonjs/Culling/ray";
  18978. /**
  18979. * Gather the list of pointer event types as constants.
  18980. */
  18981. export class PointerEventTypes {
  18982. /**
  18983. * 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.
  18984. */
  18985. static readonly POINTERDOWN: number;
  18986. /**
  18987. * The pointerup event is fired when a pointer is no longer active.
  18988. */
  18989. static readonly POINTERUP: number;
  18990. /**
  18991. * The pointermove event is fired when a pointer changes coordinates.
  18992. */
  18993. static readonly POINTERMOVE: number;
  18994. /**
  18995. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18996. */
  18997. static readonly POINTERWHEEL: number;
  18998. /**
  18999. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19000. */
  19001. static readonly POINTERPICK: number;
  19002. /**
  19003. * The pointertap event is fired when a the object has been touched and released without drag.
  19004. */
  19005. static readonly POINTERTAP: number;
  19006. /**
  19007. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19008. */
  19009. static readonly POINTERDOUBLETAP: number;
  19010. }
  19011. /**
  19012. * Base class of pointer info types.
  19013. */
  19014. export class PointerInfoBase {
  19015. /**
  19016. * Defines the type of event (PointerEventTypes)
  19017. */
  19018. type: number;
  19019. /**
  19020. * Defines the related dom event
  19021. */
  19022. event: PointerEvent | MouseWheelEvent;
  19023. /**
  19024. * Instantiates the base class of pointers info.
  19025. * @param type Defines the type of event (PointerEventTypes)
  19026. * @param event Defines the related dom event
  19027. */
  19028. constructor(
  19029. /**
  19030. * Defines the type of event (PointerEventTypes)
  19031. */
  19032. type: number,
  19033. /**
  19034. * Defines the related dom event
  19035. */
  19036. event: PointerEvent | MouseWheelEvent);
  19037. }
  19038. /**
  19039. * This class is used to store pointer related info for the onPrePointerObservable event.
  19040. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19041. */
  19042. export class PointerInfoPre extends PointerInfoBase {
  19043. /**
  19044. * Ray from a pointer if availible (eg. 6dof controller)
  19045. */
  19046. ray: Nullable<Ray>;
  19047. /**
  19048. * Defines the local position of the pointer on the canvas.
  19049. */
  19050. localPosition: Vector2;
  19051. /**
  19052. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19053. */
  19054. skipOnPointerObservable: boolean;
  19055. /**
  19056. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19057. * @param type Defines the type of event (PointerEventTypes)
  19058. * @param event Defines the related dom event
  19059. * @param localX Defines the local x coordinates of the pointer when the event occured
  19060. * @param localY Defines the local y coordinates of the pointer when the event occured
  19061. */
  19062. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19063. }
  19064. /**
  19065. * This type contains all the data related to a pointer event in Babylon.js.
  19066. * 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.
  19067. */
  19068. export class PointerInfo extends PointerInfoBase {
  19069. /**
  19070. * Defines the picking info associated to the info (if any)\
  19071. */
  19072. pickInfo: Nullable<PickingInfo>;
  19073. /**
  19074. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19075. * @param type Defines the type of event (PointerEventTypes)
  19076. * @param event Defines the related dom event
  19077. * @param pickInfo Defines the picking info associated to the info (if any)\
  19078. */
  19079. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19080. /**
  19081. * Defines the picking info associated to the info (if any)\
  19082. */
  19083. pickInfo: Nullable<PickingInfo>);
  19084. }
  19085. /**
  19086. * Data relating to a touch event on the screen.
  19087. */
  19088. export interface PointerTouch {
  19089. /**
  19090. * X coordinate of touch.
  19091. */
  19092. x: number;
  19093. /**
  19094. * Y coordinate of touch.
  19095. */
  19096. y: number;
  19097. /**
  19098. * Id of touch. Unique for each finger.
  19099. */
  19100. pointerId: number;
  19101. /**
  19102. * Event type passed from DOM.
  19103. */
  19104. type: any;
  19105. }
  19106. }
  19107. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19108. import { Observable } from "babylonjs/Misc/observable";
  19109. import { Nullable } from "babylonjs/types";
  19110. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19111. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19112. /**
  19113. * Manage the mouse inputs to control the movement of a free camera.
  19114. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19115. */
  19116. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19117. /**
  19118. * Define if touch is enabled in the mouse input
  19119. */
  19120. touchEnabled: boolean;
  19121. /**
  19122. * Defines the camera the input is attached to.
  19123. */
  19124. camera: FreeCamera;
  19125. /**
  19126. * Defines the buttons associated with the input to handle camera move.
  19127. */
  19128. buttons: number[];
  19129. /**
  19130. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19131. */
  19132. angularSensibility: number;
  19133. private _pointerInput;
  19134. private _onMouseMove;
  19135. private _observer;
  19136. private previousPosition;
  19137. /**
  19138. * Observable for when a pointer move event occurs containing the move offset
  19139. */
  19140. onPointerMovedObservable: Observable<{
  19141. offsetX: number;
  19142. offsetY: number;
  19143. }>;
  19144. /**
  19145. * @hidden
  19146. * If the camera should be rotated automatically based on pointer movement
  19147. */
  19148. _allowCameraRotation: boolean;
  19149. /**
  19150. * Manage the mouse inputs to control the movement of a free camera.
  19151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19152. * @param touchEnabled Defines if touch is enabled or not
  19153. */
  19154. constructor(
  19155. /**
  19156. * Define if touch is enabled in the mouse input
  19157. */
  19158. touchEnabled?: boolean);
  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. * Called on JS contextmenu event.
  19167. * Override this method to provide functionality.
  19168. */
  19169. protected onContextMenu(evt: PointerEvent): void;
  19170. /**
  19171. * Detach the current controls from the specified dom element.
  19172. * @param element Defines the element to stop listening the inputs from
  19173. */
  19174. detachControl(element: Nullable<HTMLElement>): void;
  19175. /**
  19176. * Gets the class name of the current intput.
  19177. * @returns the class name
  19178. */
  19179. getClassName(): string;
  19180. /**
  19181. * Get the friendly name associated with the input class.
  19182. * @returns the input friendly name
  19183. */
  19184. getSimpleName(): string;
  19185. }
  19186. }
  19187. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19188. import { Nullable } from "babylonjs/types";
  19189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19190. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19191. /**
  19192. * Manage the touch inputs to control the movement of a free camera.
  19193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19194. */
  19195. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19196. /**
  19197. * Defines the camera the input is attached to.
  19198. */
  19199. camera: FreeCamera;
  19200. /**
  19201. * Defines the touch sensibility for rotation.
  19202. * The higher the faster.
  19203. */
  19204. touchAngularSensibility: number;
  19205. /**
  19206. * Defines the touch sensibility for move.
  19207. * The higher the faster.
  19208. */
  19209. touchMoveSensibility: number;
  19210. private _offsetX;
  19211. private _offsetY;
  19212. private _pointerPressed;
  19213. private _pointerInput;
  19214. private _observer;
  19215. private _onLostFocus;
  19216. /**
  19217. * Attach the input controls to a specific dom element to get the input from.
  19218. * @param element Defines the element the controls should be listened from
  19219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19220. */
  19221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19222. /**
  19223. * Detach the current controls from the specified dom element.
  19224. * @param element Defines the element to stop listening the inputs from
  19225. */
  19226. detachControl(element: Nullable<HTMLElement>): void;
  19227. /**
  19228. * Update the current camera state depending on the inputs that have been used this frame.
  19229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19230. */
  19231. checkInputs(): void;
  19232. /**
  19233. * Gets the class name of the current intput.
  19234. * @returns the class name
  19235. */
  19236. getClassName(): string;
  19237. /**
  19238. * Get the friendly name associated with the input class.
  19239. * @returns the input friendly name
  19240. */
  19241. getSimpleName(): string;
  19242. }
  19243. }
  19244. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19246. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19247. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19248. import { Nullable } from "babylonjs/types";
  19249. /**
  19250. * Default Inputs manager for the FreeCamera.
  19251. * It groups all the default supported inputs for ease of use.
  19252. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19253. */
  19254. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19255. /**
  19256. * @hidden
  19257. */
  19258. _mouseInput: Nullable<FreeCameraMouseInput>;
  19259. /**
  19260. * Instantiates a new FreeCameraInputsManager.
  19261. * @param camera Defines the camera the inputs belong to
  19262. */
  19263. constructor(camera: FreeCamera);
  19264. /**
  19265. * Add keyboard input support to the input manager.
  19266. * @returns the current input manager
  19267. */
  19268. addKeyboard(): FreeCameraInputsManager;
  19269. /**
  19270. * Add mouse input support to the input manager.
  19271. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19272. * @returns the current input manager
  19273. */
  19274. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19275. /**
  19276. * Removes the mouse input support from the manager
  19277. * @returns the current input manager
  19278. */
  19279. removeMouse(): FreeCameraInputsManager;
  19280. /**
  19281. * Add touch input support to the input manager.
  19282. * @returns the current input manager
  19283. */
  19284. addTouch(): FreeCameraInputsManager;
  19285. /**
  19286. * Remove all attached input methods from a camera
  19287. */
  19288. clear(): void;
  19289. }
  19290. }
  19291. declare module "babylonjs/Cameras/freeCamera" {
  19292. import { Vector3 } from "babylonjs/Maths/math.vector";
  19293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19294. import { Scene } from "babylonjs/scene";
  19295. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19296. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19297. /**
  19298. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19299. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19300. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19301. */
  19302. export class FreeCamera extends TargetCamera {
  19303. /**
  19304. * Define the collision ellipsoid of the camera.
  19305. * This is helpful to simulate a camera body like the player body around the camera
  19306. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19307. */
  19308. ellipsoid: Vector3;
  19309. /**
  19310. * Define an offset for the position of the ellipsoid around the camera.
  19311. * This can be helpful to determine the center of the body near the gravity center of the body
  19312. * instead of its head.
  19313. */
  19314. ellipsoidOffset: Vector3;
  19315. /**
  19316. * Enable or disable collisions of the camera with the rest of the scene objects.
  19317. */
  19318. checkCollisions: boolean;
  19319. /**
  19320. * Enable or disable gravity on the camera.
  19321. */
  19322. applyGravity: boolean;
  19323. /**
  19324. * Define the input manager associated to the camera.
  19325. */
  19326. inputs: FreeCameraInputsManager;
  19327. /**
  19328. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19329. * Higher values reduce sensitivity.
  19330. */
  19331. get angularSensibility(): number;
  19332. /**
  19333. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19334. * Higher values reduce sensitivity.
  19335. */
  19336. set angularSensibility(value: number);
  19337. /**
  19338. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19339. */
  19340. get keysUp(): number[];
  19341. set keysUp(value: number[]);
  19342. /**
  19343. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19344. */
  19345. get keysUpward(): number[];
  19346. set keysUpward(value: number[]);
  19347. /**
  19348. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19349. */
  19350. get keysDown(): number[];
  19351. set keysDown(value: number[]);
  19352. /**
  19353. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19354. */
  19355. get keysDownward(): number[];
  19356. set keysDownward(value: number[]);
  19357. /**
  19358. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19359. */
  19360. get keysLeft(): number[];
  19361. set keysLeft(value: number[]);
  19362. /**
  19363. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19364. */
  19365. get keysRight(): number[];
  19366. set keysRight(value: number[]);
  19367. /**
  19368. * Event raised when the camera collide with a mesh in the scene.
  19369. */
  19370. onCollide: (collidedMesh: AbstractMesh) => void;
  19371. private _collider;
  19372. private _needMoveForGravity;
  19373. private _oldPosition;
  19374. private _diffPosition;
  19375. private _newPosition;
  19376. /** @hidden */
  19377. _localDirection: Vector3;
  19378. /** @hidden */
  19379. _transformedDirection: Vector3;
  19380. /**
  19381. * Instantiates a Free Camera.
  19382. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19383. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19384. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19385. * @param name Define the name of the camera in the scene
  19386. * @param position Define the start position of the camera in the scene
  19387. * @param scene Define the scene the camera belongs to
  19388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19389. */
  19390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19391. /**
  19392. * Attached controls to the current camera.
  19393. * @param element Defines the element the controls should be listened from
  19394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19395. */
  19396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19397. /**
  19398. * Detach the current controls from the camera.
  19399. * The camera will stop reacting to inputs.
  19400. * @param element Defines the element to stop listening the inputs from
  19401. */
  19402. detachControl(element: HTMLElement): void;
  19403. private _collisionMask;
  19404. /**
  19405. * Define a collision mask to limit the list of object the camera can collide with
  19406. */
  19407. get collisionMask(): number;
  19408. set collisionMask(mask: number);
  19409. /** @hidden */
  19410. _collideWithWorld(displacement: Vector3): void;
  19411. private _onCollisionPositionChange;
  19412. /** @hidden */
  19413. _checkInputs(): void;
  19414. /** @hidden */
  19415. _decideIfNeedsToMove(): boolean;
  19416. /** @hidden */
  19417. _updatePosition(): void;
  19418. /**
  19419. * Destroy the camera and release the current resources hold by it.
  19420. */
  19421. dispose(): void;
  19422. /**
  19423. * Gets the current object class name.
  19424. * @return the class name
  19425. */
  19426. getClassName(): string;
  19427. }
  19428. }
  19429. declare module "babylonjs/Gamepads/gamepad" {
  19430. import { Observable } from "babylonjs/Misc/observable";
  19431. /**
  19432. * Represents a gamepad control stick position
  19433. */
  19434. export class StickValues {
  19435. /**
  19436. * The x component of the control stick
  19437. */
  19438. x: number;
  19439. /**
  19440. * The y component of the control stick
  19441. */
  19442. y: number;
  19443. /**
  19444. * Initializes the gamepad x and y control stick values
  19445. * @param x The x component of the gamepad control stick value
  19446. * @param y The y component of the gamepad control stick value
  19447. */
  19448. constructor(
  19449. /**
  19450. * The x component of the control stick
  19451. */
  19452. x: number,
  19453. /**
  19454. * The y component of the control stick
  19455. */
  19456. y: number);
  19457. }
  19458. /**
  19459. * An interface which manages callbacks for gamepad button changes
  19460. */
  19461. export interface GamepadButtonChanges {
  19462. /**
  19463. * Called when a gamepad has been changed
  19464. */
  19465. changed: boolean;
  19466. /**
  19467. * Called when a gamepad press event has been triggered
  19468. */
  19469. pressChanged: boolean;
  19470. /**
  19471. * Called when a touch event has been triggered
  19472. */
  19473. touchChanged: boolean;
  19474. /**
  19475. * Called when a value has changed
  19476. */
  19477. valueChanged: boolean;
  19478. }
  19479. /**
  19480. * Represents a gamepad
  19481. */
  19482. export class Gamepad {
  19483. /**
  19484. * The id of the gamepad
  19485. */
  19486. id: string;
  19487. /**
  19488. * The index of the gamepad
  19489. */
  19490. index: number;
  19491. /**
  19492. * The browser gamepad
  19493. */
  19494. browserGamepad: any;
  19495. /**
  19496. * Specifies what type of gamepad this represents
  19497. */
  19498. type: number;
  19499. private _leftStick;
  19500. private _rightStick;
  19501. /** @hidden */
  19502. _isConnected: boolean;
  19503. private _leftStickAxisX;
  19504. private _leftStickAxisY;
  19505. private _rightStickAxisX;
  19506. private _rightStickAxisY;
  19507. /**
  19508. * Triggered when the left control stick has been changed
  19509. */
  19510. private _onleftstickchanged;
  19511. /**
  19512. * Triggered when the right control stick has been changed
  19513. */
  19514. private _onrightstickchanged;
  19515. /**
  19516. * Represents a gamepad controller
  19517. */
  19518. static GAMEPAD: number;
  19519. /**
  19520. * Represents a generic controller
  19521. */
  19522. static GENERIC: number;
  19523. /**
  19524. * Represents an XBox controller
  19525. */
  19526. static XBOX: number;
  19527. /**
  19528. * Represents a pose-enabled controller
  19529. */
  19530. static POSE_ENABLED: number;
  19531. /**
  19532. * Represents an Dual Shock controller
  19533. */
  19534. static DUALSHOCK: number;
  19535. /**
  19536. * Specifies whether the left control stick should be Y-inverted
  19537. */
  19538. protected _invertLeftStickY: boolean;
  19539. /**
  19540. * Specifies if the gamepad has been connected
  19541. */
  19542. get isConnected(): boolean;
  19543. /**
  19544. * Initializes the gamepad
  19545. * @param id The id of the gamepad
  19546. * @param index The index of the gamepad
  19547. * @param browserGamepad The browser gamepad
  19548. * @param leftStickX The x component of the left joystick
  19549. * @param leftStickY The y component of the left joystick
  19550. * @param rightStickX The x component of the right joystick
  19551. * @param rightStickY The y component of the right joystick
  19552. */
  19553. constructor(
  19554. /**
  19555. * The id of the gamepad
  19556. */
  19557. id: string,
  19558. /**
  19559. * The index of the gamepad
  19560. */
  19561. index: number,
  19562. /**
  19563. * The browser gamepad
  19564. */
  19565. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19566. /**
  19567. * Callback triggered when the left joystick has changed
  19568. * @param callback
  19569. */
  19570. onleftstickchanged(callback: (values: StickValues) => void): void;
  19571. /**
  19572. * Callback triggered when the right joystick has changed
  19573. * @param callback
  19574. */
  19575. onrightstickchanged(callback: (values: StickValues) => void): void;
  19576. /**
  19577. * Gets the left joystick
  19578. */
  19579. get leftStick(): StickValues;
  19580. /**
  19581. * Sets the left joystick values
  19582. */
  19583. set leftStick(newValues: StickValues);
  19584. /**
  19585. * Gets the right joystick
  19586. */
  19587. get rightStick(): StickValues;
  19588. /**
  19589. * Sets the right joystick value
  19590. */
  19591. set rightStick(newValues: StickValues);
  19592. /**
  19593. * Updates the gamepad joystick positions
  19594. */
  19595. update(): void;
  19596. /**
  19597. * Disposes the gamepad
  19598. */
  19599. dispose(): void;
  19600. }
  19601. /**
  19602. * Represents a generic gamepad
  19603. */
  19604. export class GenericPad extends Gamepad {
  19605. private _buttons;
  19606. private _onbuttondown;
  19607. private _onbuttonup;
  19608. /**
  19609. * Observable triggered when a button has been pressed
  19610. */
  19611. onButtonDownObservable: Observable<number>;
  19612. /**
  19613. * Observable triggered when a button has been released
  19614. */
  19615. onButtonUpObservable: Observable<number>;
  19616. /**
  19617. * Callback triggered when a button has been pressed
  19618. * @param callback Called when a button has been pressed
  19619. */
  19620. onbuttondown(callback: (buttonPressed: number) => void): void;
  19621. /**
  19622. * Callback triggered when a button has been released
  19623. * @param callback Called when a button has been released
  19624. */
  19625. onbuttonup(callback: (buttonReleased: number) => void): void;
  19626. /**
  19627. * Initializes the generic gamepad
  19628. * @param id The id of the generic gamepad
  19629. * @param index The index of the generic gamepad
  19630. * @param browserGamepad The browser gamepad
  19631. */
  19632. constructor(id: string, index: number, browserGamepad: any);
  19633. private _setButtonValue;
  19634. /**
  19635. * Updates the generic gamepad
  19636. */
  19637. update(): void;
  19638. /**
  19639. * Disposes the generic gamepad
  19640. */
  19641. dispose(): void;
  19642. }
  19643. }
  19644. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19645. import { Observable } from "babylonjs/Misc/observable";
  19646. import { Nullable } from "babylonjs/types";
  19647. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19648. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19650. import { Ray } from "babylonjs/Culling/ray";
  19651. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19652. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19653. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19654. /**
  19655. * Defines the types of pose enabled controllers that are supported
  19656. */
  19657. export enum PoseEnabledControllerType {
  19658. /**
  19659. * HTC Vive
  19660. */
  19661. VIVE = 0,
  19662. /**
  19663. * Oculus Rift
  19664. */
  19665. OCULUS = 1,
  19666. /**
  19667. * Windows mixed reality
  19668. */
  19669. WINDOWS = 2,
  19670. /**
  19671. * Samsung gear VR
  19672. */
  19673. GEAR_VR = 3,
  19674. /**
  19675. * Google Daydream
  19676. */
  19677. DAYDREAM = 4,
  19678. /**
  19679. * Generic
  19680. */
  19681. GENERIC = 5
  19682. }
  19683. /**
  19684. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19685. */
  19686. export interface MutableGamepadButton {
  19687. /**
  19688. * Value of the button/trigger
  19689. */
  19690. value: number;
  19691. /**
  19692. * If the button/trigger is currently touched
  19693. */
  19694. touched: boolean;
  19695. /**
  19696. * If the button/trigger is currently pressed
  19697. */
  19698. pressed: boolean;
  19699. }
  19700. /**
  19701. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19702. * @hidden
  19703. */
  19704. export interface ExtendedGamepadButton extends GamepadButton {
  19705. /**
  19706. * If the button/trigger is currently pressed
  19707. */
  19708. readonly pressed: boolean;
  19709. /**
  19710. * If the button/trigger is currently touched
  19711. */
  19712. readonly touched: boolean;
  19713. /**
  19714. * Value of the button/trigger
  19715. */
  19716. readonly value: number;
  19717. }
  19718. /** @hidden */
  19719. export interface _GamePadFactory {
  19720. /**
  19721. * Returns whether or not the current gamepad can be created for this type of controller.
  19722. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19723. * @returns true if it can be created, otherwise false
  19724. */
  19725. canCreate(gamepadInfo: any): boolean;
  19726. /**
  19727. * Creates a new instance of the Gamepad.
  19728. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19729. * @returns the new gamepad instance
  19730. */
  19731. create(gamepadInfo: any): Gamepad;
  19732. }
  19733. /**
  19734. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19735. */
  19736. export class PoseEnabledControllerHelper {
  19737. /** @hidden */
  19738. static _ControllerFactories: _GamePadFactory[];
  19739. /** @hidden */
  19740. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19741. /**
  19742. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19743. * @param vrGamepad the gamepad to initialized
  19744. * @returns a vr controller of the type the gamepad identified as
  19745. */
  19746. static InitiateController(vrGamepad: any): Gamepad;
  19747. }
  19748. /**
  19749. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19750. */
  19751. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19752. /**
  19753. * If the controller is used in a webXR session
  19754. */
  19755. isXR: boolean;
  19756. private _deviceRoomPosition;
  19757. private _deviceRoomRotationQuaternion;
  19758. /**
  19759. * The device position in babylon space
  19760. */
  19761. devicePosition: Vector3;
  19762. /**
  19763. * The device rotation in babylon space
  19764. */
  19765. deviceRotationQuaternion: Quaternion;
  19766. /**
  19767. * The scale factor of the device in babylon space
  19768. */
  19769. deviceScaleFactor: number;
  19770. /**
  19771. * (Likely devicePosition should be used instead) The device position in its room space
  19772. */
  19773. position: Vector3;
  19774. /**
  19775. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19776. */
  19777. rotationQuaternion: Quaternion;
  19778. /**
  19779. * The type of controller (Eg. Windows mixed reality)
  19780. */
  19781. controllerType: PoseEnabledControllerType;
  19782. protected _calculatedPosition: Vector3;
  19783. private _calculatedRotation;
  19784. /**
  19785. * The raw pose from the device
  19786. */
  19787. rawPose: DevicePose;
  19788. private _trackPosition;
  19789. private _maxRotationDistFromHeadset;
  19790. private _draggedRoomRotation;
  19791. /**
  19792. * @hidden
  19793. */
  19794. _disableTrackPosition(fixedPosition: Vector3): void;
  19795. /**
  19796. * Internal, the mesh attached to the controller
  19797. * @hidden
  19798. */
  19799. _mesh: Nullable<AbstractMesh>;
  19800. private _poseControlledCamera;
  19801. private _leftHandSystemQuaternion;
  19802. /**
  19803. * Internal, matrix used to convert room space to babylon space
  19804. * @hidden
  19805. */
  19806. _deviceToWorld: Matrix;
  19807. /**
  19808. * Node to be used when casting a ray from the controller
  19809. * @hidden
  19810. */
  19811. _pointingPoseNode: Nullable<TransformNode>;
  19812. /**
  19813. * Name of the child mesh that can be used to cast a ray from the controller
  19814. */
  19815. static readonly POINTING_POSE: string;
  19816. /**
  19817. * Creates a new PoseEnabledController from a gamepad
  19818. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19819. */
  19820. constructor(browserGamepad: any);
  19821. private _workingMatrix;
  19822. /**
  19823. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19824. */
  19825. update(): void;
  19826. /**
  19827. * Updates only the pose device and mesh without doing any button event checking
  19828. */
  19829. protected _updatePoseAndMesh(): void;
  19830. /**
  19831. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19832. * @param poseData raw pose fromthe device
  19833. */
  19834. updateFromDevice(poseData: DevicePose): void;
  19835. /**
  19836. * @hidden
  19837. */
  19838. _meshAttachedObservable: Observable<AbstractMesh>;
  19839. /**
  19840. * Attaches a mesh to the controller
  19841. * @param mesh the mesh to be attached
  19842. */
  19843. attachToMesh(mesh: AbstractMesh): void;
  19844. /**
  19845. * Attaches the controllers mesh to a camera
  19846. * @param camera the camera the mesh should be attached to
  19847. */
  19848. attachToPoseControlledCamera(camera: TargetCamera): void;
  19849. /**
  19850. * Disposes of the controller
  19851. */
  19852. dispose(): void;
  19853. /**
  19854. * The mesh that is attached to the controller
  19855. */
  19856. get mesh(): Nullable<AbstractMesh>;
  19857. /**
  19858. * Gets the ray of the controller in the direction the controller is pointing
  19859. * @param length the length the resulting ray should be
  19860. * @returns a ray in the direction the controller is pointing
  19861. */
  19862. getForwardRay(length?: number): Ray;
  19863. }
  19864. }
  19865. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19866. import { Observable } from "babylonjs/Misc/observable";
  19867. import { Scene } from "babylonjs/scene";
  19868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19869. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19870. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19871. import { Nullable } from "babylonjs/types";
  19872. /**
  19873. * Defines the WebVRController object that represents controllers tracked in 3D space
  19874. */
  19875. export abstract class WebVRController extends PoseEnabledController {
  19876. /**
  19877. * Internal, the default controller model for the controller
  19878. */
  19879. protected _defaultModel: Nullable<AbstractMesh>;
  19880. /**
  19881. * Fired when the trigger state has changed
  19882. */
  19883. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19884. /**
  19885. * Fired when the main button state has changed
  19886. */
  19887. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19888. /**
  19889. * Fired when the secondary button state has changed
  19890. */
  19891. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19892. /**
  19893. * Fired when the pad state has changed
  19894. */
  19895. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19896. /**
  19897. * Fired when controllers stick values have changed
  19898. */
  19899. onPadValuesChangedObservable: Observable<StickValues>;
  19900. /**
  19901. * Array of button availible on the controller
  19902. */
  19903. protected _buttons: Array<MutableGamepadButton>;
  19904. private _onButtonStateChange;
  19905. /**
  19906. * Fired when a controller button's state has changed
  19907. * @param callback the callback containing the button that was modified
  19908. */
  19909. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19910. /**
  19911. * X and Y axis corresponding to the controllers joystick
  19912. */
  19913. pad: StickValues;
  19914. /**
  19915. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19916. */
  19917. hand: string;
  19918. /**
  19919. * The default controller model for the controller
  19920. */
  19921. get defaultModel(): Nullable<AbstractMesh>;
  19922. /**
  19923. * Creates a new WebVRController from a gamepad
  19924. * @param vrGamepad the gamepad that the WebVRController should be created from
  19925. */
  19926. constructor(vrGamepad: any);
  19927. /**
  19928. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19929. */
  19930. update(): void;
  19931. /**
  19932. * Function to be called when a button is modified
  19933. */
  19934. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19935. /**
  19936. * Loads a mesh and attaches it to the controller
  19937. * @param scene the scene the mesh should be added to
  19938. * @param meshLoaded callback for when the mesh has been loaded
  19939. */
  19940. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19941. private _setButtonValue;
  19942. private _changes;
  19943. private _checkChanges;
  19944. /**
  19945. * Disposes of th webVRCOntroller
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Lights/hemisphericLight" {
  19951. import { Nullable } from "babylonjs/types";
  19952. import { Scene } from "babylonjs/scene";
  19953. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { Color3 } from "babylonjs/Maths/math.color";
  19955. import { Effect } from "babylonjs/Materials/effect";
  19956. import { Light } from "babylonjs/Lights/light";
  19957. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19958. /**
  19959. * The HemisphericLight simulates the ambient environment light,
  19960. * so the passed direction is the light reflection direction, not the incoming direction.
  19961. */
  19962. export class HemisphericLight extends Light {
  19963. /**
  19964. * The groundColor is the light in the opposite direction to the one specified during creation.
  19965. * 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.
  19966. */
  19967. groundColor: Color3;
  19968. /**
  19969. * The light reflection direction, not the incoming direction.
  19970. */
  19971. direction: Vector3;
  19972. /**
  19973. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19974. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19975. * The HemisphericLight can't cast shadows.
  19976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19977. * @param name The friendly name of the light
  19978. * @param direction The direction of the light reflection
  19979. * @param scene The scene the light belongs to
  19980. */
  19981. constructor(name: string, direction: Vector3, scene: Scene);
  19982. protected _buildUniformLayout(): void;
  19983. /**
  19984. * Returns the string "HemisphericLight".
  19985. * @return The class name
  19986. */
  19987. getClassName(): string;
  19988. /**
  19989. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19990. * Returns the updated direction.
  19991. * @param target The target the direction should point to
  19992. * @return The computed direction
  19993. */
  19994. setDirectionToTarget(target: Vector3): Vector3;
  19995. /**
  19996. * Returns the shadow generator associated to the light.
  19997. * @returns Always null for hemispheric lights because it does not support shadows.
  19998. */
  19999. getShadowGenerator(): Nullable<IShadowGenerator>;
  20000. /**
  20001. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20002. * @param effect The effect to update
  20003. * @param lightIndex The index of the light in the effect to update
  20004. * @returns The hemispheric light
  20005. */
  20006. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20007. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20008. /**
  20009. * Computes the world matrix of the node
  20010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20011. * @param useWasUpdatedFlag defines a reserved property
  20012. * @returns the world matrix
  20013. */
  20014. computeWorldMatrix(): Matrix;
  20015. /**
  20016. * Returns the integer 3.
  20017. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20018. */
  20019. getTypeID(): number;
  20020. /**
  20021. * Prepares the list of defines specific to the light type.
  20022. * @param defines the list of defines
  20023. * @param lightIndex defines the index of the light for the effect
  20024. */
  20025. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20026. }
  20027. }
  20028. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20029. /** @hidden */
  20030. export var vrMultiviewToSingleviewPixelShader: {
  20031. name: string;
  20032. shader: string;
  20033. };
  20034. }
  20035. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20037. import { Scene } from "babylonjs/scene";
  20038. /**
  20039. * Renders to multiple views with a single draw call
  20040. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20041. */
  20042. export class MultiviewRenderTarget extends RenderTargetTexture {
  20043. /**
  20044. * Creates a multiview render target
  20045. * @param scene scene used with the render target
  20046. * @param size the size of the render target (used for each view)
  20047. */
  20048. constructor(scene: Scene, size?: number | {
  20049. width: number;
  20050. height: number;
  20051. } | {
  20052. ratio: number;
  20053. });
  20054. /**
  20055. * @hidden
  20056. * @param faceIndex the face index, if its a cube texture
  20057. */
  20058. _bindFrameBuffer(faceIndex?: number): void;
  20059. /**
  20060. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20061. * @returns the view count
  20062. */
  20063. getViewCount(): number;
  20064. }
  20065. }
  20066. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20067. import { Camera } from "babylonjs/Cameras/camera";
  20068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20069. import { Nullable } from "babylonjs/types";
  20070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20071. import { Matrix } from "babylonjs/Maths/math.vector";
  20072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20073. module "babylonjs/Engines/engine" {
  20074. interface Engine {
  20075. /**
  20076. * Creates a new multiview render target
  20077. * @param width defines the width of the texture
  20078. * @param height defines the height of the texture
  20079. * @returns the created multiview texture
  20080. */
  20081. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20082. /**
  20083. * Binds a multiview framebuffer to be drawn to
  20084. * @param multiviewTexture texture to bind
  20085. */
  20086. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20087. }
  20088. }
  20089. module "babylonjs/Cameras/camera" {
  20090. interface Camera {
  20091. /**
  20092. * @hidden
  20093. * 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)
  20094. */
  20095. _useMultiviewToSingleView: boolean;
  20096. /**
  20097. * @hidden
  20098. * 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)
  20099. */
  20100. _multiviewTexture: Nullable<RenderTargetTexture>;
  20101. /**
  20102. * @hidden
  20103. * ensures the multiview texture of the camera exists and has the specified width/height
  20104. * @param width height to set on the multiview texture
  20105. * @param height width to set on the multiview texture
  20106. */
  20107. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20108. }
  20109. }
  20110. module "babylonjs/scene" {
  20111. interface Scene {
  20112. /** @hidden */
  20113. _transformMatrixR: Matrix;
  20114. /** @hidden */
  20115. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20116. /** @hidden */
  20117. _createMultiviewUbo(): void;
  20118. /** @hidden */
  20119. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20120. /** @hidden */
  20121. _renderMultiviewToSingleView(camera: Camera): void;
  20122. }
  20123. }
  20124. }
  20125. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20126. import { Camera } from "babylonjs/Cameras/camera";
  20127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20128. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20129. import "babylonjs/Engines/Extensions/engine.multiview";
  20130. /**
  20131. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20132. * This will not be used for webXR as it supports displaying texture arrays directly
  20133. */
  20134. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20135. /**
  20136. * Initializes a VRMultiviewToSingleview
  20137. * @param name name of the post process
  20138. * @param camera camera to be applied to
  20139. * @param scaleFactor scaling factor to the size of the output texture
  20140. */
  20141. constructor(name: string, camera: Camera, scaleFactor: number);
  20142. }
  20143. }
  20144. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20145. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20146. import { Nullable } from "babylonjs/types";
  20147. import { Size } from "babylonjs/Maths/math.size";
  20148. import { Observable } from "babylonjs/Misc/observable";
  20149. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20150. /**
  20151. * Interface used to define additional presentation attributes
  20152. */
  20153. export interface IVRPresentationAttributes {
  20154. /**
  20155. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20156. */
  20157. highRefreshRate: boolean;
  20158. /**
  20159. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20160. */
  20161. foveationLevel: number;
  20162. }
  20163. module "babylonjs/Engines/engine" {
  20164. interface Engine {
  20165. /** @hidden */
  20166. _vrDisplay: any;
  20167. /** @hidden */
  20168. _vrSupported: boolean;
  20169. /** @hidden */
  20170. _oldSize: Size;
  20171. /** @hidden */
  20172. _oldHardwareScaleFactor: number;
  20173. /** @hidden */
  20174. _vrExclusivePointerMode: boolean;
  20175. /** @hidden */
  20176. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20177. /** @hidden */
  20178. _onVRDisplayPointerRestricted: () => void;
  20179. /** @hidden */
  20180. _onVRDisplayPointerUnrestricted: () => void;
  20181. /** @hidden */
  20182. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20183. /** @hidden */
  20184. _onVrDisplayDisconnect: Nullable<() => void>;
  20185. /** @hidden */
  20186. _onVrDisplayPresentChange: Nullable<() => void>;
  20187. /**
  20188. * Observable signaled when VR display mode changes
  20189. */
  20190. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20191. /**
  20192. * Observable signaled when VR request present is complete
  20193. */
  20194. onVRRequestPresentComplete: Observable<boolean>;
  20195. /**
  20196. * Observable signaled when VR request present starts
  20197. */
  20198. onVRRequestPresentStart: Observable<Engine>;
  20199. /**
  20200. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20201. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20202. */
  20203. isInVRExclusivePointerMode: boolean;
  20204. /**
  20205. * Gets a boolean indicating if a webVR device was detected
  20206. * @returns true if a webVR device was detected
  20207. */
  20208. isVRDevicePresent(): boolean;
  20209. /**
  20210. * Gets the current webVR device
  20211. * @returns the current webVR device (or null)
  20212. */
  20213. getVRDevice(): any;
  20214. /**
  20215. * Initializes a webVR display and starts listening to display change events
  20216. * The onVRDisplayChangedObservable will be notified upon these changes
  20217. * @returns A promise containing a VRDisplay and if vr is supported
  20218. */
  20219. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20220. /** @hidden */
  20221. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20222. /**
  20223. * Gets or sets the presentation attributes used to configure VR rendering
  20224. */
  20225. vrPresentationAttributes?: IVRPresentationAttributes;
  20226. /**
  20227. * Call this function to switch to webVR mode
  20228. * Will do nothing if webVR is not supported or if there is no webVR device
  20229. * @param options the webvr options provided to the camera. mainly used for multiview
  20230. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20231. */
  20232. enableVR(options: WebVROptions): void;
  20233. /** @hidden */
  20234. _onVRFullScreenTriggered(): void;
  20235. }
  20236. }
  20237. }
  20238. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20239. import { Nullable } from "babylonjs/types";
  20240. import { Observable } from "babylonjs/Misc/observable";
  20241. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20242. import { Scene } from "babylonjs/scene";
  20243. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20245. import { Node } from "babylonjs/node";
  20246. import { Ray } from "babylonjs/Culling/ray";
  20247. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20248. import "babylonjs/Engines/Extensions/engine.webVR";
  20249. /**
  20250. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20251. * IMPORTANT!! The data is right-hand data.
  20252. * @export
  20253. * @interface DevicePose
  20254. */
  20255. export interface DevicePose {
  20256. /**
  20257. * The position of the device, values in array are [x,y,z].
  20258. */
  20259. readonly position: Nullable<Float32Array>;
  20260. /**
  20261. * The linearVelocity of the device, values in array are [x,y,z].
  20262. */
  20263. readonly linearVelocity: Nullable<Float32Array>;
  20264. /**
  20265. * The linearAcceleration of the device, values in array are [x,y,z].
  20266. */
  20267. readonly linearAcceleration: Nullable<Float32Array>;
  20268. /**
  20269. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20270. */
  20271. readonly orientation: Nullable<Float32Array>;
  20272. /**
  20273. * The angularVelocity of the device, values in array are [x,y,z].
  20274. */
  20275. readonly angularVelocity: Nullable<Float32Array>;
  20276. /**
  20277. * The angularAcceleration of the device, values in array are [x,y,z].
  20278. */
  20279. readonly angularAcceleration: Nullable<Float32Array>;
  20280. }
  20281. /**
  20282. * Interface representing a pose controlled object in Babylon.
  20283. * A pose controlled object has both regular pose values as well as pose values
  20284. * from an external device such as a VR head mounted display
  20285. */
  20286. export interface PoseControlled {
  20287. /**
  20288. * The position of the object in babylon space.
  20289. */
  20290. position: Vector3;
  20291. /**
  20292. * The rotation quaternion of the object in babylon space.
  20293. */
  20294. rotationQuaternion: Quaternion;
  20295. /**
  20296. * The position of the device in babylon space.
  20297. */
  20298. devicePosition?: Vector3;
  20299. /**
  20300. * The rotation quaternion of the device in babylon space.
  20301. */
  20302. deviceRotationQuaternion: Quaternion;
  20303. /**
  20304. * The raw pose coming from the device.
  20305. */
  20306. rawPose: Nullable<DevicePose>;
  20307. /**
  20308. * The scale of the device to be used when translating from device space to babylon space.
  20309. */
  20310. deviceScaleFactor: number;
  20311. /**
  20312. * Updates the poseControlled values based on the input device pose.
  20313. * @param poseData the pose data to update the object with
  20314. */
  20315. updateFromDevice(poseData: DevicePose): void;
  20316. }
  20317. /**
  20318. * Set of options to customize the webVRCamera
  20319. */
  20320. export interface WebVROptions {
  20321. /**
  20322. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20323. */
  20324. trackPosition?: boolean;
  20325. /**
  20326. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20327. */
  20328. positionScale?: number;
  20329. /**
  20330. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20331. */
  20332. displayName?: string;
  20333. /**
  20334. * Should the native controller meshes be initialized. (default: true)
  20335. */
  20336. controllerMeshes?: boolean;
  20337. /**
  20338. * Creating a default HemiLight only on controllers. (default: true)
  20339. */
  20340. defaultLightingOnControllers?: boolean;
  20341. /**
  20342. * If you don't want to use the default VR button of the helper. (default: false)
  20343. */
  20344. useCustomVRButton?: boolean;
  20345. /**
  20346. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20347. */
  20348. customVRButton?: HTMLButtonElement;
  20349. /**
  20350. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20351. */
  20352. rayLength?: number;
  20353. /**
  20354. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20355. */
  20356. defaultHeight?: number;
  20357. /**
  20358. * If multiview should be used if availible (default: false)
  20359. */
  20360. useMultiview?: boolean;
  20361. }
  20362. /**
  20363. * This represents a WebVR camera.
  20364. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20365. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20366. */
  20367. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20368. private webVROptions;
  20369. /**
  20370. * @hidden
  20371. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20372. */
  20373. _vrDevice: any;
  20374. /**
  20375. * The rawPose of the vrDevice.
  20376. */
  20377. rawPose: Nullable<DevicePose>;
  20378. private _onVREnabled;
  20379. private _specsVersion;
  20380. private _attached;
  20381. private _frameData;
  20382. protected _descendants: Array<Node>;
  20383. private _deviceRoomPosition;
  20384. /** @hidden */
  20385. _deviceRoomRotationQuaternion: Quaternion;
  20386. private _standingMatrix;
  20387. /**
  20388. * Represents device position in babylon space.
  20389. */
  20390. devicePosition: Vector3;
  20391. /**
  20392. * Represents device rotation in babylon space.
  20393. */
  20394. deviceRotationQuaternion: Quaternion;
  20395. /**
  20396. * The scale of the device to be used when translating from device space to babylon space.
  20397. */
  20398. deviceScaleFactor: number;
  20399. private _deviceToWorld;
  20400. private _worldToDevice;
  20401. /**
  20402. * References to the webVR controllers for the vrDevice.
  20403. */
  20404. controllers: Array<WebVRController>;
  20405. /**
  20406. * Emits an event when a controller is attached.
  20407. */
  20408. onControllersAttachedObservable: Observable<WebVRController[]>;
  20409. /**
  20410. * Emits an event when a controller's mesh has been loaded;
  20411. */
  20412. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20413. /**
  20414. * Emits an event when the HMD's pose has been updated.
  20415. */
  20416. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20417. private _poseSet;
  20418. /**
  20419. * If the rig cameras be used as parent instead of this camera.
  20420. */
  20421. rigParenting: boolean;
  20422. private _lightOnControllers;
  20423. private _defaultHeight?;
  20424. /**
  20425. * Instantiates a WebVRFreeCamera.
  20426. * @param name The name of the WebVRFreeCamera
  20427. * @param position The starting anchor position for the camera
  20428. * @param scene The scene the camera belongs to
  20429. * @param webVROptions a set of customizable options for the webVRCamera
  20430. */
  20431. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20432. /**
  20433. * Gets the device distance from the ground in meters.
  20434. * @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.
  20435. */
  20436. deviceDistanceToRoomGround(): number;
  20437. /**
  20438. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20439. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20440. */
  20441. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20442. /**
  20443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20444. * @returns A promise with a boolean set to if the standing matrix is supported.
  20445. */
  20446. useStandingMatrixAsync(): Promise<boolean>;
  20447. /**
  20448. * Disposes the camera
  20449. */
  20450. dispose(): void;
  20451. /**
  20452. * Gets a vrController by name.
  20453. * @param name The name of the controller to retreive
  20454. * @returns the controller matching the name specified or null if not found
  20455. */
  20456. getControllerByName(name: string): Nullable<WebVRController>;
  20457. private _leftController;
  20458. /**
  20459. * The controller corresponding to the users left hand.
  20460. */
  20461. get leftController(): Nullable<WebVRController>;
  20462. private _rightController;
  20463. /**
  20464. * The controller corresponding to the users right hand.
  20465. */
  20466. get rightController(): Nullable<WebVRController>;
  20467. /**
  20468. * Casts a ray forward from the vrCamera's gaze.
  20469. * @param length Length of the ray (default: 100)
  20470. * @returns the ray corresponding to the gaze
  20471. */
  20472. getForwardRay(length?: number): Ray;
  20473. /**
  20474. * @hidden
  20475. * Updates the camera based on device's frame data
  20476. */
  20477. _checkInputs(): void;
  20478. /**
  20479. * Updates the poseControlled values based on the input device pose.
  20480. * @param poseData Pose coming from the device
  20481. */
  20482. updateFromDevice(poseData: DevicePose): void;
  20483. private _htmlElementAttached;
  20484. private _detachIfAttached;
  20485. /**
  20486. * WebVR's attach control will start broadcasting frames to the device.
  20487. * Note that in certain browsers (chrome for example) this function must be called
  20488. * within a user-interaction callback. Example:
  20489. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20490. *
  20491. * @param element html element to attach the vrDevice to
  20492. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20493. */
  20494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20495. /**
  20496. * Detaches the camera from the html element and disables VR
  20497. *
  20498. * @param element html element to detach from
  20499. */
  20500. detachControl(element: HTMLElement): void;
  20501. /**
  20502. * @returns the name of this class
  20503. */
  20504. getClassName(): string;
  20505. /**
  20506. * Calls resetPose on the vrDisplay
  20507. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20508. */
  20509. resetToCurrentRotation(): void;
  20510. /**
  20511. * @hidden
  20512. * Updates the rig cameras (left and right eye)
  20513. */
  20514. _updateRigCameras(): void;
  20515. private _workingVector;
  20516. private _oneVector;
  20517. private _workingMatrix;
  20518. private updateCacheCalled;
  20519. private _correctPositionIfNotTrackPosition;
  20520. /**
  20521. * @hidden
  20522. * Updates the cached values of the camera
  20523. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20524. */
  20525. _updateCache(ignoreParentClass?: boolean): void;
  20526. /**
  20527. * @hidden
  20528. * Get current device position in babylon world
  20529. */
  20530. _computeDevicePosition(): void;
  20531. /**
  20532. * Updates the current device position and rotation in the babylon world
  20533. */
  20534. update(): void;
  20535. /**
  20536. * @hidden
  20537. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20538. * @returns an identity matrix
  20539. */
  20540. _getViewMatrix(): Matrix;
  20541. private _tmpMatrix;
  20542. /**
  20543. * This function is called by the two RIG cameras.
  20544. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20545. * @hidden
  20546. */
  20547. _getWebVRViewMatrix(): Matrix;
  20548. /** @hidden */
  20549. _getWebVRProjectionMatrix(): Matrix;
  20550. private _onGamepadConnectedObserver;
  20551. private _onGamepadDisconnectedObserver;
  20552. private _updateCacheWhenTrackingDisabledObserver;
  20553. /**
  20554. * Initializes the controllers and their meshes
  20555. */
  20556. initControllers(): void;
  20557. }
  20558. }
  20559. declare module "babylonjs/Materials/materialHelper" {
  20560. import { Nullable } from "babylonjs/types";
  20561. import { Scene } from "babylonjs/scene";
  20562. import { Engine } from "babylonjs/Engines/engine";
  20563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20564. import { Light } from "babylonjs/Lights/light";
  20565. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20566. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20568. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20569. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20570. /**
  20571. * "Static Class" containing the most commonly used helper while dealing with material for
  20572. * rendering purpose.
  20573. *
  20574. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20575. *
  20576. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20577. */
  20578. export class MaterialHelper {
  20579. /**
  20580. * Bind the current view position to an effect.
  20581. * @param effect The effect to be bound
  20582. * @param scene The scene the eyes position is used from
  20583. * @param variableName name of the shader variable that will hold the eye position
  20584. */
  20585. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20586. /**
  20587. * Helps preparing the defines values about the UVs in used in the effect.
  20588. * UVs are shared as much as we can accross channels in the shaders.
  20589. * @param texture The texture we are preparing the UVs for
  20590. * @param defines The defines to update
  20591. * @param key The channel key "diffuse", "specular"... used in the shader
  20592. */
  20593. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20594. /**
  20595. * Binds a texture matrix value to its corrsponding uniform
  20596. * @param texture The texture to bind the matrix for
  20597. * @param uniformBuffer The uniform buffer receivin the data
  20598. * @param key The channel key "diffuse", "specular"... used in the shader
  20599. */
  20600. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20601. /**
  20602. * Gets the current status of the fog (should it be enabled?)
  20603. * @param mesh defines the mesh to evaluate for fog support
  20604. * @param scene defines the hosting scene
  20605. * @returns true if fog must be enabled
  20606. */
  20607. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20608. /**
  20609. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20610. * @param mesh defines the current mesh
  20611. * @param scene defines the current scene
  20612. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20613. * @param pointsCloud defines if point cloud rendering has to be turned on
  20614. * @param fogEnabled defines if fog has to be turned on
  20615. * @param alphaTest defines if alpha testing has to be turned on
  20616. * @param defines defines the current list of defines
  20617. */
  20618. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20619. /**
  20620. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20621. * @param scene defines the current scene
  20622. * @param engine defines the current engine
  20623. * @param defines specifies the list of active defines
  20624. * @param useInstances defines if instances have to be turned on
  20625. * @param useClipPlane defines if clip plane have to be turned on
  20626. * @param useInstances defines if instances have to be turned on
  20627. * @param useThinInstances defines if thin instances have to be turned on
  20628. */
  20629. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20630. /**
  20631. * Prepares the defines for bones
  20632. * @param mesh The mesh containing the geometry data we will draw
  20633. * @param defines The defines to update
  20634. */
  20635. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20636. /**
  20637. * Prepares the defines for morph targets
  20638. * @param mesh The mesh containing the geometry data we will draw
  20639. * @param defines The defines to update
  20640. */
  20641. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20642. /**
  20643. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20644. * @param mesh The mesh containing the geometry data we will draw
  20645. * @param defines The defines to update
  20646. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20647. * @param useBones Precise whether bones should be used or not (override mesh info)
  20648. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20649. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20650. * @returns false if defines are considered not dirty and have not been checked
  20651. */
  20652. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20653. /**
  20654. * Prepares the defines related to multiview
  20655. * @param scene The scene we are intending to draw
  20656. * @param defines The defines to update
  20657. */
  20658. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20659. /**
  20660. * Prepares the defines related to the prepass
  20661. * @param scene The scene we are intending to draw
  20662. * @param defines The defines to update
  20663. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20664. */
  20665. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20666. /**
  20667. * Prepares the defines related to the light information passed in parameter
  20668. * @param scene The scene we are intending to draw
  20669. * @param mesh The mesh the effect is compiling for
  20670. * @param light The light the effect is compiling for
  20671. * @param lightIndex The index of the light
  20672. * @param defines The defines to update
  20673. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20674. * @param state Defines the current state regarding what is needed (normals, etc...)
  20675. */
  20676. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20677. needNormals: boolean;
  20678. needRebuild: boolean;
  20679. shadowEnabled: boolean;
  20680. specularEnabled: boolean;
  20681. lightmapMode: boolean;
  20682. }): void;
  20683. /**
  20684. * Prepares the defines related to the light information passed in parameter
  20685. * @param scene The scene we are intending to draw
  20686. * @param mesh The mesh the effect is compiling for
  20687. * @param defines The defines to update
  20688. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20689. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20690. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20691. * @returns true if normals will be required for the rest of the effect
  20692. */
  20693. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20694. /**
  20695. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20696. * @param lightIndex defines the light index
  20697. * @param uniformsList The uniform list
  20698. * @param samplersList The sampler list
  20699. * @param projectedLightTexture defines if projected texture must be used
  20700. * @param uniformBuffersList defines an optional list of uniform buffers
  20701. */
  20702. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20703. /**
  20704. * Prepares the uniforms and samplers list to be used in the effect
  20705. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20706. * @param samplersList The sampler list
  20707. * @param defines The defines helping in the list generation
  20708. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20709. */
  20710. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20711. /**
  20712. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20713. * @param defines The defines to update while falling back
  20714. * @param fallbacks The authorized effect fallbacks
  20715. * @param maxSimultaneousLights The maximum number of lights allowed
  20716. * @param rank the current rank of the Effect
  20717. * @returns The newly affected rank
  20718. */
  20719. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20720. private static _TmpMorphInfluencers;
  20721. /**
  20722. * Prepares the list of attributes required for morph targets according to the effect defines.
  20723. * @param attribs The current list of supported attribs
  20724. * @param mesh The mesh to prepare the morph targets attributes for
  20725. * @param influencers The number of influencers
  20726. */
  20727. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20728. /**
  20729. * Prepares the list of attributes required for morph targets according to the effect defines.
  20730. * @param attribs The current list of supported attribs
  20731. * @param mesh The mesh to prepare the morph targets attributes for
  20732. * @param defines The current Defines of the effect
  20733. */
  20734. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20735. /**
  20736. * Prepares the list of attributes required for bones according to the effect defines.
  20737. * @param attribs The current list of supported attribs
  20738. * @param mesh The mesh to prepare the bones attributes for
  20739. * @param defines The current Defines of the effect
  20740. * @param fallbacks The current efffect fallback strategy
  20741. */
  20742. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20743. /**
  20744. * Check and prepare the list of attributes required for instances according to the effect defines.
  20745. * @param attribs The current list of supported attribs
  20746. * @param defines The current MaterialDefines of the effect
  20747. */
  20748. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20749. /**
  20750. * Add the list of attributes required for instances to the attribs array.
  20751. * @param attribs The current list of supported attribs
  20752. */
  20753. static PushAttributesForInstances(attribs: string[]): void;
  20754. /**
  20755. * Binds the light information to the effect.
  20756. * @param light The light containing the generator
  20757. * @param effect The effect we are binding the data to
  20758. * @param lightIndex The light index in the effect used to render
  20759. */
  20760. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20761. /**
  20762. * Binds the lights information from the scene to the effect for the given mesh.
  20763. * @param light Light to bind
  20764. * @param lightIndex Light index
  20765. * @param scene The scene where the light belongs to
  20766. * @param effect The effect we are binding the data to
  20767. * @param useSpecular Defines if specular is supported
  20768. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20769. */
  20770. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20771. /**
  20772. * Binds the lights information from the scene to the effect for the given mesh.
  20773. * @param scene The scene the lights belongs to
  20774. * @param mesh The mesh we are binding the information to render
  20775. * @param effect The effect we are binding the data to
  20776. * @param defines The generated defines for the effect
  20777. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20778. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20779. */
  20780. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20781. private static _tempFogColor;
  20782. /**
  20783. * Binds the fog information from the scene to the effect for the given mesh.
  20784. * @param scene The scene the lights belongs to
  20785. * @param mesh The mesh we are binding the information to render
  20786. * @param effect The effect we are binding the data to
  20787. * @param linearSpace Defines if the fog effect is applied in linear space
  20788. */
  20789. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20790. /**
  20791. * Binds the bones information from the mesh to the effect.
  20792. * @param mesh The mesh we are binding the information to render
  20793. * @param effect The effect we are binding the data to
  20794. */
  20795. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20796. /**
  20797. * Binds the morph targets information from the mesh to the effect.
  20798. * @param abstractMesh The mesh we are binding the information to render
  20799. * @param effect The effect we are binding the data to
  20800. */
  20801. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20802. /**
  20803. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20804. * @param defines The generated defines used in the effect
  20805. * @param effect The effect we are binding the data to
  20806. * @param scene The scene we are willing to render with logarithmic scale for
  20807. */
  20808. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20809. /**
  20810. * Binds the clip plane information from the scene to the effect.
  20811. * @param scene The scene the clip plane information are extracted from
  20812. * @param effect The effect we are binding the data to
  20813. */
  20814. static BindClipPlane(effect: Effect, scene: Scene): void;
  20815. }
  20816. }
  20817. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20819. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20820. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20821. import { Nullable } from "babylonjs/types";
  20822. import { Effect } from "babylonjs/Materials/effect";
  20823. import { Matrix } from "babylonjs/Maths/math.vector";
  20824. import { Scene } from "babylonjs/scene";
  20825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20827. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20828. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20829. import { Observable } from "babylonjs/Misc/observable";
  20830. /**
  20831. * Block used to expose an input value
  20832. */
  20833. export class InputBlock extends NodeMaterialBlock {
  20834. private _mode;
  20835. private _associatedVariableName;
  20836. private _storedValue;
  20837. private _valueCallback;
  20838. private _type;
  20839. private _animationType;
  20840. /** Gets or set a value used to limit the range of float values */
  20841. min: number;
  20842. /** Gets or set a value used to limit the range of float values */
  20843. max: number;
  20844. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20845. isBoolean: boolean;
  20846. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20847. matrixMode: number;
  20848. /** @hidden */
  20849. _systemValue: Nullable<NodeMaterialSystemValues>;
  20850. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20851. visibleInInspector: boolean;
  20852. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20853. isConstant: boolean;
  20854. /** Gets or sets the group to use to display this block in the Inspector */
  20855. groupInInspector: string;
  20856. /** Gets an observable raised when the value is changed */
  20857. onValueChangedObservable: Observable<InputBlock>;
  20858. /**
  20859. * Gets or sets the connection point type (default is float)
  20860. */
  20861. get type(): NodeMaterialBlockConnectionPointTypes;
  20862. /**
  20863. * Creates a new InputBlock
  20864. * @param name defines the block name
  20865. * @param target defines the target of that block (Vertex by default)
  20866. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20867. */
  20868. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20869. /**
  20870. * Validates if a name is a reserve word.
  20871. * @param newName the new name to be given to the node.
  20872. * @returns false if the name is a reserve word, else true.
  20873. */
  20874. validateBlockName(newName: string): boolean;
  20875. /**
  20876. * Gets the output component
  20877. */
  20878. get output(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Set the source of this connection point to a vertex attribute
  20881. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20882. * @returns the current connection point
  20883. */
  20884. setAsAttribute(attributeName?: string): InputBlock;
  20885. /**
  20886. * Set the source of this connection point to a system value
  20887. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20888. * @returns the current connection point
  20889. */
  20890. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20891. /**
  20892. * Gets or sets the value of that point.
  20893. * Please note that this value will be ignored if valueCallback is defined
  20894. */
  20895. get value(): any;
  20896. set value(value: any);
  20897. /**
  20898. * Gets or sets a callback used to get the value of that point.
  20899. * Please note that setting this value will force the connection point to ignore the value property
  20900. */
  20901. get valueCallback(): () => any;
  20902. set valueCallback(value: () => any);
  20903. /**
  20904. * Gets or sets the associated variable name in the shader
  20905. */
  20906. get associatedVariableName(): string;
  20907. set associatedVariableName(value: string);
  20908. /** Gets or sets the type of animation applied to the input */
  20909. get animationType(): AnimatedInputBlockTypes;
  20910. set animationType(value: AnimatedInputBlockTypes);
  20911. /**
  20912. * Gets a boolean indicating that this connection point not defined yet
  20913. */
  20914. get isUndefined(): boolean;
  20915. /**
  20916. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20917. * In this case the connection point name must be the name of the uniform to use.
  20918. * Can only be set on inputs
  20919. */
  20920. get isUniform(): boolean;
  20921. set isUniform(value: boolean);
  20922. /**
  20923. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20924. * In this case the connection point name must be the name of the attribute to use
  20925. * Can only be set on inputs
  20926. */
  20927. get isAttribute(): boolean;
  20928. set isAttribute(value: boolean);
  20929. /**
  20930. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20931. * Can only be set on exit points
  20932. */
  20933. get isVarying(): boolean;
  20934. set isVarying(value: boolean);
  20935. /**
  20936. * Gets a boolean indicating that the current connection point is a system value
  20937. */
  20938. get isSystemValue(): boolean;
  20939. /**
  20940. * Gets or sets the current well known value or null if not defined as a system value
  20941. */
  20942. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20943. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20944. /**
  20945. * Gets the current class name
  20946. * @returns the class name
  20947. */
  20948. getClassName(): string;
  20949. /**
  20950. * Animate the input if animationType !== None
  20951. * @param scene defines the rendering scene
  20952. */
  20953. animate(scene: Scene): void;
  20954. private _emitDefine;
  20955. initialize(state: NodeMaterialBuildState): void;
  20956. /**
  20957. * Set the input block to its default value (based on its type)
  20958. */
  20959. setDefaultValue(): void;
  20960. private _emitConstant;
  20961. /** @hidden */
  20962. get _noContextSwitch(): boolean;
  20963. private _emit;
  20964. /** @hidden */
  20965. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20966. /** @hidden */
  20967. _transmit(effect: Effect, scene: Scene): void;
  20968. protected _buildBlock(state: NodeMaterialBuildState): void;
  20969. protected _dumpPropertiesCode(): string;
  20970. dispose(): void;
  20971. serialize(): any;
  20972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20973. }
  20974. }
  20975. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20976. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20977. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20978. import { Nullable } from "babylonjs/types";
  20979. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20980. import { Observable } from "babylonjs/Misc/observable";
  20981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20982. /**
  20983. * Enum used to define the compatibility state between two connection points
  20984. */
  20985. export enum NodeMaterialConnectionPointCompatibilityStates {
  20986. /** Points are compatibles */
  20987. Compatible = 0,
  20988. /** Points are incompatible because of their types */
  20989. TypeIncompatible = 1,
  20990. /** Points are incompatible because of their targets (vertex vs fragment) */
  20991. TargetIncompatible = 2
  20992. }
  20993. /**
  20994. * Defines the direction of a connection point
  20995. */
  20996. export enum NodeMaterialConnectionPointDirection {
  20997. /** Input */
  20998. Input = 0,
  20999. /** Output */
  21000. Output = 1
  21001. }
  21002. /**
  21003. * Defines a connection point for a block
  21004. */
  21005. export class NodeMaterialConnectionPoint {
  21006. /** @hidden */
  21007. _ownerBlock: NodeMaterialBlock;
  21008. /** @hidden */
  21009. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21010. private _endpoints;
  21011. private _associatedVariableName;
  21012. private _direction;
  21013. /** @hidden */
  21014. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21015. /** @hidden */
  21016. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21017. private _type;
  21018. /** @hidden */
  21019. _enforceAssociatedVariableName: boolean;
  21020. /** Gets the direction of the point */
  21021. get direction(): NodeMaterialConnectionPointDirection;
  21022. /** Indicates that this connection point needs dual validation before being connected to another point */
  21023. needDualDirectionValidation: boolean;
  21024. /**
  21025. * Gets or sets the additional types supported by this connection point
  21026. */
  21027. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21028. /**
  21029. * Gets or sets the additional types excluded by this connection point
  21030. */
  21031. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21032. /**
  21033. * Observable triggered when this point is connected
  21034. */
  21035. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21036. /**
  21037. * Gets or sets the associated variable name in the shader
  21038. */
  21039. get associatedVariableName(): string;
  21040. set associatedVariableName(value: string);
  21041. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21042. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21043. /**
  21044. * Gets or sets the connection point type (default is float)
  21045. */
  21046. get type(): NodeMaterialBlockConnectionPointTypes;
  21047. set type(value: NodeMaterialBlockConnectionPointTypes);
  21048. /**
  21049. * Gets or sets the connection point name
  21050. */
  21051. name: string;
  21052. /**
  21053. * Gets or sets the connection point name
  21054. */
  21055. displayName: string;
  21056. /**
  21057. * Gets or sets a boolean indicating that this connection point can be omitted
  21058. */
  21059. isOptional: boolean;
  21060. /**
  21061. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21062. */
  21063. isExposedOnFrame: boolean;
  21064. /**
  21065. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21066. */
  21067. define: string;
  21068. /** @hidden */
  21069. _prioritizeVertex: boolean;
  21070. private _target;
  21071. /** Gets or sets the target of that connection point */
  21072. get target(): NodeMaterialBlockTargets;
  21073. set target(value: NodeMaterialBlockTargets);
  21074. /**
  21075. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21076. */
  21077. get isConnected(): boolean;
  21078. /**
  21079. * Gets a boolean indicating that the current point is connected to an input block
  21080. */
  21081. get isConnectedToInputBlock(): boolean;
  21082. /**
  21083. * Gets a the connected input block (if any)
  21084. */
  21085. get connectInputBlock(): Nullable<InputBlock>;
  21086. /** Get the other side of the connection (if any) */
  21087. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21088. /** Get the block that owns this connection point */
  21089. get ownerBlock(): NodeMaterialBlock;
  21090. /** Get the block connected on the other side of this connection (if any) */
  21091. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21092. /** Get the block connected on the endpoints of this connection (if any) */
  21093. get connectedBlocks(): Array<NodeMaterialBlock>;
  21094. /** Gets the list of connected endpoints */
  21095. get endpoints(): NodeMaterialConnectionPoint[];
  21096. /** Gets a boolean indicating if that output point is connected to at least one input */
  21097. get hasEndpoints(): boolean;
  21098. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21099. get isConnectedInVertexShader(): boolean;
  21100. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21101. get isConnectedInFragmentShader(): boolean;
  21102. /**
  21103. * Creates a block suitable to be used as an input for this input point.
  21104. * If null is returned, a block based on the point type will be created.
  21105. * @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
  21106. */
  21107. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21108. /**
  21109. * Creates a new connection point
  21110. * @param name defines the connection point name
  21111. * @param ownerBlock defines the block hosting this connection point
  21112. * @param direction defines the direction of the connection point
  21113. */
  21114. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21115. /**
  21116. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21117. * @returns the class name
  21118. */
  21119. getClassName(): string;
  21120. /**
  21121. * Gets a boolean indicating if the current point can be connected to another point
  21122. * @param connectionPoint defines the other connection point
  21123. * @returns a boolean
  21124. */
  21125. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21126. /**
  21127. * Gets a number indicating if the current point can be connected to another point
  21128. * @param connectionPoint defines the other connection point
  21129. * @returns a number defining the compatibility state
  21130. */
  21131. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21132. /**
  21133. * Connect this point to another connection point
  21134. * @param connectionPoint defines the other connection point
  21135. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21136. * @returns the current connection point
  21137. */
  21138. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21139. /**
  21140. * Disconnect this point from one of his endpoint
  21141. * @param endpoint defines the other connection point
  21142. * @returns the current connection point
  21143. */
  21144. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21145. /**
  21146. * Serializes this point in a JSON representation
  21147. * @param isInput defines if the connection point is an input (default is true)
  21148. * @returns the serialized point object
  21149. */
  21150. serialize(isInput?: boolean): any;
  21151. /**
  21152. * Release resources
  21153. */
  21154. dispose(): void;
  21155. }
  21156. }
  21157. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21158. /**
  21159. * Enum used to define the material modes
  21160. */
  21161. export enum NodeMaterialModes {
  21162. /** Regular material */
  21163. Material = 0,
  21164. /** For post process */
  21165. PostProcess = 1,
  21166. /** For particle system */
  21167. Particle = 2
  21168. }
  21169. }
  21170. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21173. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21176. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21177. import { Effect } from "babylonjs/Materials/effect";
  21178. import { Mesh } from "babylonjs/Meshes/mesh";
  21179. import { Nullable } from "babylonjs/types";
  21180. import { Texture } from "babylonjs/Materials/Textures/texture";
  21181. import { Scene } from "babylonjs/scene";
  21182. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21183. /**
  21184. * Block used to read a texture from a sampler
  21185. */
  21186. export class TextureBlock extends NodeMaterialBlock {
  21187. private _defineName;
  21188. private _linearDefineName;
  21189. private _gammaDefineName;
  21190. private _tempTextureRead;
  21191. private _samplerName;
  21192. private _transformedUVName;
  21193. private _textureTransformName;
  21194. private _textureInfoName;
  21195. private _mainUVName;
  21196. private _mainUVDefineName;
  21197. private _fragmentOnly;
  21198. /**
  21199. * Gets or sets the texture associated with the node
  21200. */
  21201. texture: Nullable<Texture>;
  21202. /**
  21203. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21204. */
  21205. convertToGammaSpace: boolean;
  21206. /**
  21207. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21208. */
  21209. convertToLinearSpace: boolean;
  21210. /**
  21211. * Create a new TextureBlock
  21212. * @param name defines the block name
  21213. */
  21214. constructor(name: string, fragmentOnly?: boolean);
  21215. /**
  21216. * Gets the current class name
  21217. * @returns the class name
  21218. */
  21219. getClassName(): string;
  21220. /**
  21221. * Gets the uv input component
  21222. */
  21223. get uv(): NodeMaterialConnectionPoint;
  21224. /**
  21225. * Gets the rgba output component
  21226. */
  21227. get rgba(): NodeMaterialConnectionPoint;
  21228. /**
  21229. * Gets the rgb output component
  21230. */
  21231. get rgb(): NodeMaterialConnectionPoint;
  21232. /**
  21233. * Gets the r output component
  21234. */
  21235. get r(): NodeMaterialConnectionPoint;
  21236. /**
  21237. * Gets the g output component
  21238. */
  21239. get g(): NodeMaterialConnectionPoint;
  21240. /**
  21241. * Gets the b output component
  21242. */
  21243. get b(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the a output component
  21246. */
  21247. get a(): NodeMaterialConnectionPoint;
  21248. get target(): NodeMaterialBlockTargets;
  21249. autoConfigure(material: NodeMaterial): void;
  21250. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21252. isReady(): boolean;
  21253. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21254. private get _isMixed();
  21255. private _injectVertexCode;
  21256. private _writeTextureRead;
  21257. private _writeOutput;
  21258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21259. protected _dumpPropertiesCode(): string;
  21260. serialize(): any;
  21261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21262. }
  21263. }
  21264. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21265. /** @hidden */
  21266. export var reflectionFunction: {
  21267. name: string;
  21268. shader: string;
  21269. };
  21270. }
  21271. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21277. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21278. import { Effect } from "babylonjs/Materials/effect";
  21279. import { Mesh } from "babylonjs/Meshes/mesh";
  21280. import { Nullable } from "babylonjs/types";
  21281. import { Scene } from "babylonjs/scene";
  21282. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21283. /**
  21284. * Base block used to read a reflection texture from a sampler
  21285. */
  21286. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21287. /** @hidden */
  21288. _define3DName: string;
  21289. /** @hidden */
  21290. _defineCubicName: string;
  21291. /** @hidden */
  21292. _defineExplicitName: string;
  21293. /** @hidden */
  21294. _defineProjectionName: string;
  21295. /** @hidden */
  21296. _defineLocalCubicName: string;
  21297. /** @hidden */
  21298. _defineSphericalName: string;
  21299. /** @hidden */
  21300. _definePlanarName: string;
  21301. /** @hidden */
  21302. _defineEquirectangularName: string;
  21303. /** @hidden */
  21304. _defineMirroredEquirectangularFixedName: string;
  21305. /** @hidden */
  21306. _defineEquirectangularFixedName: string;
  21307. /** @hidden */
  21308. _defineSkyboxName: string;
  21309. /** @hidden */
  21310. _defineOppositeZ: string;
  21311. /** @hidden */
  21312. _cubeSamplerName: string;
  21313. /** @hidden */
  21314. _2DSamplerName: string;
  21315. protected _positionUVWName: string;
  21316. protected _directionWName: string;
  21317. protected _reflectionVectorName: string;
  21318. /** @hidden */
  21319. _reflectionCoordsName: string;
  21320. /** @hidden */
  21321. _reflectionMatrixName: string;
  21322. protected _reflectionColorName: string;
  21323. /**
  21324. * Gets or sets the texture associated with the node
  21325. */
  21326. texture: Nullable<BaseTexture>;
  21327. /**
  21328. * Create a new ReflectionTextureBaseBlock
  21329. * @param name defines the block name
  21330. */
  21331. constructor(name: string);
  21332. /**
  21333. * Gets the current class name
  21334. * @returns the class name
  21335. */
  21336. getClassName(): string;
  21337. /**
  21338. * Gets the world position input component
  21339. */
  21340. abstract get position(): NodeMaterialConnectionPoint;
  21341. /**
  21342. * Gets the world position input component
  21343. */
  21344. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21345. /**
  21346. * Gets the world normal input component
  21347. */
  21348. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21349. /**
  21350. * Gets the world input component
  21351. */
  21352. abstract get world(): NodeMaterialConnectionPoint;
  21353. /**
  21354. * Gets the camera (or eye) position component
  21355. */
  21356. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21357. /**
  21358. * Gets the view input component
  21359. */
  21360. abstract get view(): NodeMaterialConnectionPoint;
  21361. protected _getTexture(): Nullable<BaseTexture>;
  21362. autoConfigure(material: NodeMaterial): void;
  21363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21364. isReady(): boolean;
  21365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21366. /**
  21367. * Gets the code to inject in the vertex shader
  21368. * @param state current state of the node material building
  21369. * @returns the shader code
  21370. */
  21371. handleVertexSide(state: NodeMaterialBuildState): string;
  21372. /**
  21373. * Handles the inits for the fragment code path
  21374. * @param state node material build state
  21375. */
  21376. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21377. /**
  21378. * Generates the reflection coords code for the fragment code path
  21379. * @param worldNormalVarName name of the world normal variable
  21380. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21381. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21382. * @returns the shader code
  21383. */
  21384. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21385. /**
  21386. * Generates the reflection color code for the fragment code path
  21387. * @param lodVarName name of the lod variable
  21388. * @param swizzleLookupTexture swizzle to use for the final color variable
  21389. * @returns the shader code
  21390. */
  21391. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21392. /**
  21393. * Generates the code corresponding to the connected output points
  21394. * @param state node material build state
  21395. * @param varName name of the variable to output
  21396. * @returns the shader code
  21397. */
  21398. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21399. protected _buildBlock(state: NodeMaterialBuildState): this;
  21400. protected _dumpPropertiesCode(): string;
  21401. serialize(): any;
  21402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21403. }
  21404. }
  21405. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21407. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21408. import { Nullable } from "babylonjs/types";
  21409. /**
  21410. * Defines a connection point to be used for points with a custom object type
  21411. */
  21412. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21413. private _blockType;
  21414. private _blockName;
  21415. private _nameForCheking?;
  21416. /**
  21417. * Creates a new connection point
  21418. * @param name defines the connection point name
  21419. * @param ownerBlock defines the block hosting this connection point
  21420. * @param direction defines the direction of the connection point
  21421. */
  21422. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21423. /**
  21424. * Gets a number indicating if the current point can be connected to another point
  21425. * @param connectionPoint defines the other connection point
  21426. * @returns a number defining the compatibility state
  21427. */
  21428. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21429. /**
  21430. * Creates a block suitable to be used as an input for this input point.
  21431. * If null is returned, a block based on the point type will be created.
  21432. * @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
  21433. */
  21434. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21435. }
  21436. }
  21437. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21438. /**
  21439. * Enum defining the type of properties that can be edited in the property pages in the NME
  21440. */
  21441. export enum PropertyTypeForEdition {
  21442. /** property is a boolean */
  21443. Boolean = 0,
  21444. /** property is a float */
  21445. Float = 1,
  21446. /** property is a Vector2 */
  21447. Vector2 = 2,
  21448. /** property is a list of values */
  21449. List = 3
  21450. }
  21451. /**
  21452. * Interface that defines an option in a variable of type list
  21453. */
  21454. export interface IEditablePropertyListOption {
  21455. /** label of the option */
  21456. "label": string;
  21457. /** value of the option */
  21458. "value": number;
  21459. }
  21460. /**
  21461. * Interface that defines the options available for an editable property
  21462. */
  21463. export interface IEditablePropertyOption {
  21464. /** min value */
  21465. "min"?: number;
  21466. /** max value */
  21467. "max"?: number;
  21468. /** notifiers: indicates which actions to take when the property is changed */
  21469. "notifiers"?: {
  21470. /** the material should be rebuilt */
  21471. "rebuild"?: boolean;
  21472. /** the preview should be updated */
  21473. "update"?: boolean;
  21474. };
  21475. /** list of the options for a variable of type list */
  21476. "options"?: IEditablePropertyListOption[];
  21477. }
  21478. /**
  21479. * Interface that describes an editable property
  21480. */
  21481. export interface IPropertyDescriptionForEdition {
  21482. /** name of the property */
  21483. "propertyName": string;
  21484. /** display name of the property */
  21485. "displayName": string;
  21486. /** type of the property */
  21487. "type": PropertyTypeForEdition;
  21488. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21489. "groupName": string;
  21490. /** options for the property */
  21491. "options": IEditablePropertyOption;
  21492. }
  21493. /**
  21494. * Decorator that flags a property in a node material block as being editable
  21495. */
  21496. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21497. }
  21498. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21501. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21503. import { Nullable } from "babylonjs/types";
  21504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21505. import { Mesh } from "babylonjs/Meshes/mesh";
  21506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21507. import { Effect } from "babylonjs/Materials/effect";
  21508. import { Scene } from "babylonjs/scene";
  21509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21510. /**
  21511. * Block used to implement the refraction part of the sub surface module of the PBR material
  21512. */
  21513. export class RefractionBlock extends NodeMaterialBlock {
  21514. /** @hidden */
  21515. _define3DName: string;
  21516. /** @hidden */
  21517. _refractionMatrixName: string;
  21518. /** @hidden */
  21519. _defineLODRefractionAlpha: string;
  21520. /** @hidden */
  21521. _defineLinearSpecularRefraction: string;
  21522. /** @hidden */
  21523. _defineOppositeZ: string;
  21524. /** @hidden */
  21525. _cubeSamplerName: string;
  21526. /** @hidden */
  21527. _2DSamplerName: string;
  21528. /** @hidden */
  21529. _vRefractionMicrosurfaceInfosName: string;
  21530. /** @hidden */
  21531. _vRefractionInfosName: string;
  21532. private _scene;
  21533. /**
  21534. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21535. * Materials half opaque for instance using refraction could benefit from this control.
  21536. */
  21537. linkRefractionWithTransparency: boolean;
  21538. /**
  21539. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21540. */
  21541. invertRefractionY: boolean;
  21542. /**
  21543. * Gets or sets the texture associated with the node
  21544. */
  21545. texture: Nullable<BaseTexture>;
  21546. /**
  21547. * Create a new RefractionBlock
  21548. * @param name defines the block name
  21549. */
  21550. constructor(name: string);
  21551. /**
  21552. * Gets the current class name
  21553. * @returns the class name
  21554. */
  21555. getClassName(): string;
  21556. /**
  21557. * Gets the intensity input component
  21558. */
  21559. get intensity(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the index of refraction input component
  21562. */
  21563. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the tint at distance input component
  21566. */
  21567. get tintAtDistance(): NodeMaterialConnectionPoint;
  21568. /**
  21569. * Gets the view input component
  21570. */
  21571. get view(): NodeMaterialConnectionPoint;
  21572. /**
  21573. * Gets the refraction object output component
  21574. */
  21575. get refraction(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Returns true if the block has a texture
  21578. */
  21579. get hasTexture(): boolean;
  21580. protected _getTexture(): Nullable<BaseTexture>;
  21581. autoConfigure(material: NodeMaterial): void;
  21582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21583. isReady(): boolean;
  21584. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21585. /**
  21586. * Gets the main code of the block (fragment side)
  21587. * @param state current state of the node material building
  21588. * @returns the shader code
  21589. */
  21590. getCode(state: NodeMaterialBuildState): string;
  21591. protected _buildBlock(state: NodeMaterialBuildState): this;
  21592. protected _dumpPropertiesCode(): string;
  21593. serialize(): any;
  21594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21595. }
  21596. }
  21597. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21600. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21603. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21605. import { Nullable } from "babylonjs/types";
  21606. import { Scene } from "babylonjs/scene";
  21607. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21608. /**
  21609. * Base block used as input for post process
  21610. */
  21611. export class CurrentScreenBlock extends NodeMaterialBlock {
  21612. private _samplerName;
  21613. private _linearDefineName;
  21614. private _gammaDefineName;
  21615. private _mainUVName;
  21616. private _tempTextureRead;
  21617. /**
  21618. * Gets or sets the texture associated with the node
  21619. */
  21620. texture: Nullable<BaseTexture>;
  21621. /**
  21622. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21623. */
  21624. convertToGammaSpace: boolean;
  21625. /**
  21626. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21627. */
  21628. convertToLinearSpace: boolean;
  21629. /**
  21630. * Create a new CurrentScreenBlock
  21631. * @param name defines the block name
  21632. */
  21633. constructor(name: string);
  21634. /**
  21635. * Gets the current class name
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Gets the uv input component
  21641. */
  21642. get uv(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the rgba output component
  21645. */
  21646. get rgba(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the rgb output component
  21649. */
  21650. get rgb(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the r output component
  21653. */
  21654. get r(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the g output component
  21657. */
  21658. get g(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the b output component
  21661. */
  21662. get b(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the a output component
  21665. */
  21666. get a(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Initialize the block and prepare the context for build
  21669. * @param state defines the state that will be used for the build
  21670. */
  21671. initialize(state: NodeMaterialBuildState): void;
  21672. get target(): NodeMaterialBlockTargets;
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21674. isReady(): boolean;
  21675. private _injectVertexCode;
  21676. private _writeTextureRead;
  21677. private _writeOutput;
  21678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21679. serialize(): any;
  21680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21681. }
  21682. }
  21683. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21688. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21689. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21690. import { Nullable } from "babylonjs/types";
  21691. import { Scene } from "babylonjs/scene";
  21692. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21693. /**
  21694. * Base block used for the particle texture
  21695. */
  21696. export class ParticleTextureBlock extends NodeMaterialBlock {
  21697. private _samplerName;
  21698. private _linearDefineName;
  21699. private _gammaDefineName;
  21700. private _tempTextureRead;
  21701. /**
  21702. * Gets or sets the texture associated with the node
  21703. */
  21704. texture: Nullable<BaseTexture>;
  21705. /**
  21706. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21707. */
  21708. convertToGammaSpace: boolean;
  21709. /**
  21710. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21711. */
  21712. convertToLinearSpace: boolean;
  21713. /**
  21714. * Create a new ParticleTextureBlock
  21715. * @param name defines the block name
  21716. */
  21717. constructor(name: string);
  21718. /**
  21719. * Gets the current class name
  21720. * @returns the class name
  21721. */
  21722. getClassName(): string;
  21723. /**
  21724. * Gets the uv input component
  21725. */
  21726. get uv(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Gets the rgba output component
  21729. */
  21730. get rgba(): NodeMaterialConnectionPoint;
  21731. /**
  21732. * Gets the rgb output component
  21733. */
  21734. get rgb(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Gets the r output component
  21737. */
  21738. get r(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the g output component
  21741. */
  21742. get g(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the b output component
  21745. */
  21746. get b(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Gets the a output component
  21749. */
  21750. get a(): NodeMaterialConnectionPoint;
  21751. /**
  21752. * Initialize the block and prepare the context for build
  21753. * @param state defines the state that will be used for the build
  21754. */
  21755. initialize(state: NodeMaterialBuildState): void;
  21756. autoConfigure(material: NodeMaterial): void;
  21757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21758. isReady(): boolean;
  21759. private _writeOutput;
  21760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21761. serialize(): any;
  21762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21763. }
  21764. }
  21765. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21768. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21769. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21770. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21771. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21772. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21773. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21774. import { Scene } from "babylonjs/scene";
  21775. /**
  21776. * Class used to store shared data between 2 NodeMaterialBuildState
  21777. */
  21778. export class NodeMaterialBuildStateSharedData {
  21779. /**
  21780. * Gets the list of emitted varyings
  21781. */
  21782. temps: string[];
  21783. /**
  21784. * Gets the list of emitted varyings
  21785. */
  21786. varyings: string[];
  21787. /**
  21788. * Gets the varying declaration string
  21789. */
  21790. varyingDeclaration: string;
  21791. /**
  21792. * Input blocks
  21793. */
  21794. inputBlocks: InputBlock[];
  21795. /**
  21796. * Input blocks
  21797. */
  21798. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21799. /**
  21800. * Bindable blocks (Blocks that need to set data to the effect)
  21801. */
  21802. bindableBlocks: NodeMaterialBlock[];
  21803. /**
  21804. * List of blocks that can provide a compilation fallback
  21805. */
  21806. blocksWithFallbacks: NodeMaterialBlock[];
  21807. /**
  21808. * List of blocks that can provide a define update
  21809. */
  21810. blocksWithDefines: NodeMaterialBlock[];
  21811. /**
  21812. * List of blocks that can provide a repeatable content
  21813. */
  21814. repeatableContentBlocks: NodeMaterialBlock[];
  21815. /**
  21816. * List of blocks that can provide a dynamic list of uniforms
  21817. */
  21818. dynamicUniformBlocks: NodeMaterialBlock[];
  21819. /**
  21820. * List of blocks that can block the isReady function for the material
  21821. */
  21822. blockingBlocks: NodeMaterialBlock[];
  21823. /**
  21824. * Gets the list of animated inputs
  21825. */
  21826. animatedInputs: InputBlock[];
  21827. /**
  21828. * Build Id used to avoid multiple recompilations
  21829. */
  21830. buildId: number;
  21831. /** List of emitted variables */
  21832. variableNames: {
  21833. [key: string]: number;
  21834. };
  21835. /** List of emitted defines */
  21836. defineNames: {
  21837. [key: string]: number;
  21838. };
  21839. /** Should emit comments? */
  21840. emitComments: boolean;
  21841. /** Emit build activity */
  21842. verbose: boolean;
  21843. /** Gets or sets the hosting scene */
  21844. scene: Scene;
  21845. /**
  21846. * Gets the compilation hints emitted at compilation time
  21847. */
  21848. hints: {
  21849. needWorldViewMatrix: boolean;
  21850. needWorldViewProjectionMatrix: boolean;
  21851. needAlphaBlending: boolean;
  21852. needAlphaTesting: boolean;
  21853. };
  21854. /**
  21855. * List of compilation checks
  21856. */
  21857. checks: {
  21858. emitVertex: boolean;
  21859. emitFragment: boolean;
  21860. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21861. };
  21862. /**
  21863. * Is vertex program allowed to be empty?
  21864. */
  21865. allowEmptyVertexProgram: boolean;
  21866. /** Creates a new shared data */
  21867. constructor();
  21868. /**
  21869. * Emits console errors and exceptions if there is a failing check
  21870. */
  21871. emitErrors(): void;
  21872. }
  21873. }
  21874. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21875. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21876. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21877. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21878. /**
  21879. * Class used to store node based material build state
  21880. */
  21881. export class NodeMaterialBuildState {
  21882. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21883. supportUniformBuffers: boolean;
  21884. /**
  21885. * Gets the list of emitted attributes
  21886. */
  21887. attributes: string[];
  21888. /**
  21889. * Gets the list of emitted uniforms
  21890. */
  21891. uniforms: string[];
  21892. /**
  21893. * Gets the list of emitted constants
  21894. */
  21895. constants: string[];
  21896. /**
  21897. * Gets the list of emitted samplers
  21898. */
  21899. samplers: string[];
  21900. /**
  21901. * Gets the list of emitted functions
  21902. */
  21903. functions: {
  21904. [key: string]: string;
  21905. };
  21906. /**
  21907. * Gets the list of emitted extensions
  21908. */
  21909. extensions: {
  21910. [key: string]: string;
  21911. };
  21912. /**
  21913. * Gets the target of the compilation state
  21914. */
  21915. target: NodeMaterialBlockTargets;
  21916. /**
  21917. * Gets the list of emitted counters
  21918. */
  21919. counters: {
  21920. [key: string]: number;
  21921. };
  21922. /**
  21923. * Shared data between multiple NodeMaterialBuildState instances
  21924. */
  21925. sharedData: NodeMaterialBuildStateSharedData;
  21926. /** @hidden */
  21927. _vertexState: NodeMaterialBuildState;
  21928. /** @hidden */
  21929. _attributeDeclaration: string;
  21930. /** @hidden */
  21931. _uniformDeclaration: string;
  21932. /** @hidden */
  21933. _constantDeclaration: string;
  21934. /** @hidden */
  21935. _samplerDeclaration: string;
  21936. /** @hidden */
  21937. _varyingTransfer: string;
  21938. /** @hidden */
  21939. _injectAtEnd: string;
  21940. private _repeatableContentAnchorIndex;
  21941. /** @hidden */
  21942. _builtCompilationString: string;
  21943. /**
  21944. * Gets the emitted compilation strings
  21945. */
  21946. compilationString: string;
  21947. /**
  21948. * Finalize the compilation strings
  21949. * @param state defines the current compilation state
  21950. */
  21951. finalize(state: NodeMaterialBuildState): void;
  21952. /** @hidden */
  21953. get _repeatableContentAnchor(): string;
  21954. /** @hidden */
  21955. _getFreeVariableName(prefix: string): string;
  21956. /** @hidden */
  21957. _getFreeDefineName(prefix: string): string;
  21958. /** @hidden */
  21959. _excludeVariableName(name: string): void;
  21960. /** @hidden */
  21961. _emit2DSampler(name: string): void;
  21962. /** @hidden */
  21963. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21964. /** @hidden */
  21965. _emitExtension(name: string, extension: string, define?: string): void;
  21966. /** @hidden */
  21967. _emitFunction(name: string, code: string, comments: string): void;
  21968. /** @hidden */
  21969. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21970. replaceStrings?: {
  21971. search: RegExp;
  21972. replace: string;
  21973. }[];
  21974. repeatKey?: string;
  21975. }): string;
  21976. /** @hidden */
  21977. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21978. repeatKey?: string;
  21979. removeAttributes?: boolean;
  21980. removeUniforms?: boolean;
  21981. removeVaryings?: boolean;
  21982. removeIfDef?: boolean;
  21983. replaceStrings?: {
  21984. search: RegExp;
  21985. replace: string;
  21986. }[];
  21987. }, storeKey?: string): void;
  21988. /** @hidden */
  21989. _registerTempVariable(name: string): boolean;
  21990. /** @hidden */
  21991. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21992. /** @hidden */
  21993. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21994. /** @hidden */
  21995. _emitFloat(value: number): string;
  21996. }
  21997. }
  21998. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21999. /**
  22000. * Helper class used to generate session unique ID
  22001. */
  22002. export class UniqueIdGenerator {
  22003. private static _UniqueIdCounter;
  22004. /**
  22005. * Gets an unique (relatively to the current scene) Id
  22006. */
  22007. static get UniqueId(): number;
  22008. }
  22009. }
  22010. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22011. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22013. import { Nullable } from "babylonjs/types";
  22014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22016. import { Effect } from "babylonjs/Materials/effect";
  22017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22018. import { Mesh } from "babylonjs/Meshes/mesh";
  22019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22020. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22021. import { Scene } from "babylonjs/scene";
  22022. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22023. /**
  22024. * Defines a block that can be used inside a node based material
  22025. */
  22026. export class NodeMaterialBlock {
  22027. private _buildId;
  22028. private _buildTarget;
  22029. private _target;
  22030. private _isFinalMerger;
  22031. private _isInput;
  22032. private _name;
  22033. protected _isUnique: boolean;
  22034. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22035. inputsAreExclusive: boolean;
  22036. /** @hidden */
  22037. _codeVariableName: string;
  22038. /** @hidden */
  22039. _inputs: NodeMaterialConnectionPoint[];
  22040. /** @hidden */
  22041. _outputs: NodeMaterialConnectionPoint[];
  22042. /** @hidden */
  22043. _preparationId: number;
  22044. /**
  22045. * Gets the name of the block
  22046. */
  22047. get name(): string;
  22048. /**
  22049. * Sets the name of the block. Will check if the name is valid.
  22050. */
  22051. set name(newName: string);
  22052. /**
  22053. * Gets or sets the unique id of the node
  22054. */
  22055. uniqueId: number;
  22056. /**
  22057. * Gets or sets the comments associated with this block
  22058. */
  22059. comments: string;
  22060. /**
  22061. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22062. */
  22063. get isUnique(): boolean;
  22064. /**
  22065. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22066. */
  22067. get isFinalMerger(): boolean;
  22068. /**
  22069. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22070. */
  22071. get isInput(): boolean;
  22072. /**
  22073. * Gets or sets the build Id
  22074. */
  22075. get buildId(): number;
  22076. set buildId(value: number);
  22077. /**
  22078. * Gets or sets the target of the block
  22079. */
  22080. get target(): NodeMaterialBlockTargets;
  22081. set target(value: NodeMaterialBlockTargets);
  22082. /**
  22083. * Gets the list of input points
  22084. */
  22085. get inputs(): NodeMaterialConnectionPoint[];
  22086. /** Gets the list of output points */
  22087. get outputs(): NodeMaterialConnectionPoint[];
  22088. /**
  22089. * Find an input by its name
  22090. * @param name defines the name of the input to look for
  22091. * @returns the input or null if not found
  22092. */
  22093. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22094. /**
  22095. * Find an output by its name
  22096. * @param name defines the name of the outputto look for
  22097. * @returns the output or null if not found
  22098. */
  22099. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22100. /**
  22101. * Creates a new NodeMaterialBlock
  22102. * @param name defines the block name
  22103. * @param target defines the target of that block (Vertex by default)
  22104. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22105. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22106. */
  22107. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22108. /**
  22109. * Initialize the block and prepare the context for build
  22110. * @param state defines the state that will be used for the build
  22111. */
  22112. initialize(state: NodeMaterialBuildState): void;
  22113. /**
  22114. * Bind data to effect. Will only be called for blocks with isBindable === true
  22115. * @param effect defines the effect to bind data to
  22116. * @param nodeMaterial defines the hosting NodeMaterial
  22117. * @param mesh defines the mesh that will be rendered
  22118. * @param subMesh defines the submesh that will be rendered
  22119. */
  22120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22121. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22122. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22123. protected _writeFloat(value: number): string;
  22124. /**
  22125. * Gets the current class name e.g. "NodeMaterialBlock"
  22126. * @returns the class name
  22127. */
  22128. getClassName(): string;
  22129. /**
  22130. * Register a new input. Must be called inside a block constructor
  22131. * @param name defines the connection point name
  22132. * @param type defines the connection point type
  22133. * @param isOptional defines a boolean indicating that this input can be omitted
  22134. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22135. * @param point an already created connection point. If not provided, create a new one
  22136. * @returns the current block
  22137. */
  22138. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22139. /**
  22140. * Register a new output. Must be called inside a block constructor
  22141. * @param name defines the connection point name
  22142. * @param type defines the connection point type
  22143. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22144. * @param point an already created connection point. If not provided, create a new one
  22145. * @returns the current block
  22146. */
  22147. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22148. /**
  22149. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22150. * @param forOutput defines an optional connection point to check compatibility with
  22151. * @returns the first available input or null
  22152. */
  22153. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22154. /**
  22155. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22156. * @param forBlock defines an optional block to check compatibility with
  22157. * @returns the first available input or null
  22158. */
  22159. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22160. /**
  22161. * Gets the sibling of the given output
  22162. * @param current defines the current output
  22163. * @returns the next output in the list or null
  22164. */
  22165. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22166. /**
  22167. * Connect current block with another block
  22168. * @param other defines the block to connect with
  22169. * @param options define the various options to help pick the right connections
  22170. * @returns the current block
  22171. */
  22172. connectTo(other: NodeMaterialBlock, options?: {
  22173. input?: string;
  22174. output?: string;
  22175. outputSwizzle?: string;
  22176. }): this | undefined;
  22177. protected _buildBlock(state: NodeMaterialBuildState): void;
  22178. /**
  22179. * Add uniforms, samplers and uniform buffers at compilation time
  22180. * @param state defines the state to update
  22181. * @param nodeMaterial defines the node material requesting the update
  22182. * @param defines defines the material defines to update
  22183. * @param uniformBuffers defines the list of uniform buffer names
  22184. */
  22185. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22186. /**
  22187. * Add potential fallbacks if shader compilation fails
  22188. * @param mesh defines the mesh to be rendered
  22189. * @param fallbacks defines the current prioritized list of fallbacks
  22190. */
  22191. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22192. /**
  22193. * Initialize defines for shader compilation
  22194. * @param mesh defines the mesh to be rendered
  22195. * @param nodeMaterial defines the node material requesting the update
  22196. * @param defines defines the material defines to update
  22197. * @param useInstances specifies that instances should be used
  22198. */
  22199. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22200. /**
  22201. * Update defines for shader compilation
  22202. * @param mesh defines the mesh to be rendered
  22203. * @param nodeMaterial defines the node material requesting the update
  22204. * @param defines defines the material defines to update
  22205. * @param useInstances specifies that instances should be used
  22206. * @param subMesh defines which submesh to render
  22207. */
  22208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22209. /**
  22210. * Lets the block try to connect some inputs automatically
  22211. * @param material defines the hosting NodeMaterial
  22212. */
  22213. autoConfigure(material: NodeMaterial): void;
  22214. /**
  22215. * Function called when a block is declared as repeatable content generator
  22216. * @param vertexShaderState defines the current compilation state for the vertex shader
  22217. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22218. * @param mesh defines the mesh to be rendered
  22219. * @param defines defines the material defines to update
  22220. */
  22221. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22222. /**
  22223. * Checks if the block is ready
  22224. * @param mesh defines the mesh to be rendered
  22225. * @param nodeMaterial defines the node material requesting the update
  22226. * @param defines defines the material defines to update
  22227. * @param useInstances specifies that instances should be used
  22228. * @returns true if the block is ready
  22229. */
  22230. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22231. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22232. private _processBuild;
  22233. /**
  22234. * Validates the new name for the block node.
  22235. * @param newName the new name to be given to the node.
  22236. * @returns false if the name is a reserve word, else true.
  22237. */
  22238. validateBlockName(newName: string): boolean;
  22239. /**
  22240. * Compile the current node and generate the shader code
  22241. * @param state defines the current compilation state (uniforms, samplers, current string)
  22242. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22243. * @returns true if already built
  22244. */
  22245. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22246. protected _inputRename(name: string): string;
  22247. protected _outputRename(name: string): string;
  22248. protected _dumpPropertiesCode(): string;
  22249. /** @hidden */
  22250. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22251. /** @hidden */
  22252. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22253. /**
  22254. * Clone the current block to a new identical block
  22255. * @param scene defines the hosting scene
  22256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22257. * @returns a copy of the current block
  22258. */
  22259. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22260. /**
  22261. * Serializes this block in a JSON representation
  22262. * @returns the serialized block object
  22263. */
  22264. serialize(): any;
  22265. /** @hidden */
  22266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22267. private _deserializePortDisplayNamesAndExposedOnFrame;
  22268. /**
  22269. * Release resources
  22270. */
  22271. dispose(): void;
  22272. }
  22273. }
  22274. declare module "babylonjs/Materials/pushMaterial" {
  22275. import { Nullable } from "babylonjs/types";
  22276. import { Scene } from "babylonjs/scene";
  22277. import { Matrix } from "babylonjs/Maths/math.vector";
  22278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22279. import { Mesh } from "babylonjs/Meshes/mesh";
  22280. import { Material } from "babylonjs/Materials/material";
  22281. import { Effect } from "babylonjs/Materials/effect";
  22282. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22283. /**
  22284. * Base class of materials working in push mode in babylon JS
  22285. * @hidden
  22286. */
  22287. export class PushMaterial extends Material {
  22288. protected _activeEffect: Effect;
  22289. protected _normalMatrix: Matrix;
  22290. constructor(name: string, scene: Scene);
  22291. getEffect(): Effect;
  22292. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22293. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22294. /**
  22295. * Binds the given world matrix to the active effect
  22296. *
  22297. * @param world the matrix to bind
  22298. */
  22299. bindOnlyWorldMatrix(world: Matrix): void;
  22300. /**
  22301. * Binds the given normal matrix to the active effect
  22302. *
  22303. * @param normalMatrix the matrix to bind
  22304. */
  22305. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22306. bind(world: Matrix, mesh?: Mesh): void;
  22307. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22308. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22309. }
  22310. }
  22311. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22313. /**
  22314. * Root class for all node material optimizers
  22315. */
  22316. export class NodeMaterialOptimizer {
  22317. /**
  22318. * Function used to optimize a NodeMaterial graph
  22319. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22320. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22321. */
  22322. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22323. }
  22324. }
  22325. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22329. import { Scene } from "babylonjs/scene";
  22330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22333. /**
  22334. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22335. */
  22336. export class TransformBlock extends NodeMaterialBlock {
  22337. /**
  22338. * Defines the value to use to complement W value to transform it to a Vector4
  22339. */
  22340. complementW: number;
  22341. /**
  22342. * Defines the value to use to complement z value to transform it to a Vector4
  22343. */
  22344. complementZ: number;
  22345. /**
  22346. * Creates a new TransformBlock
  22347. * @param name defines the block name
  22348. */
  22349. constructor(name: string);
  22350. /**
  22351. * Gets the current class name
  22352. * @returns the class name
  22353. */
  22354. getClassName(): string;
  22355. /**
  22356. * Gets the vector input
  22357. */
  22358. get vector(): NodeMaterialConnectionPoint;
  22359. /**
  22360. * Gets the output component
  22361. */
  22362. get output(): NodeMaterialConnectionPoint;
  22363. /**
  22364. * Gets the xyz output component
  22365. */
  22366. get xyz(): NodeMaterialConnectionPoint;
  22367. /**
  22368. * Gets the matrix transform input
  22369. */
  22370. get transform(): NodeMaterialConnectionPoint;
  22371. protected _buildBlock(state: NodeMaterialBuildState): this;
  22372. /**
  22373. * Update defines for shader compilation
  22374. * @param mesh defines the mesh to be rendered
  22375. * @param nodeMaterial defines the node material requesting the update
  22376. * @param defines defines the material defines to update
  22377. * @param useInstances specifies that instances should be used
  22378. * @param subMesh defines which submesh to render
  22379. */
  22380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22381. serialize(): any;
  22382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22383. protected _dumpPropertiesCode(): string;
  22384. }
  22385. }
  22386. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22390. /**
  22391. * Block used to output the vertex position
  22392. */
  22393. export class VertexOutputBlock extends NodeMaterialBlock {
  22394. /**
  22395. * Creates a new VertexOutputBlock
  22396. * @param name defines the block name
  22397. */
  22398. constructor(name: string);
  22399. /**
  22400. * Gets the current class name
  22401. * @returns the class name
  22402. */
  22403. getClassName(): string;
  22404. /**
  22405. * Gets the vector input component
  22406. */
  22407. get vector(): NodeMaterialConnectionPoint;
  22408. protected _buildBlock(state: NodeMaterialBuildState): this;
  22409. }
  22410. }
  22411. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22415. /**
  22416. * Block used to output the final color
  22417. */
  22418. export class FragmentOutputBlock extends NodeMaterialBlock {
  22419. /**
  22420. * Create a new FragmentOutputBlock
  22421. * @param name defines the block name
  22422. */
  22423. constructor(name: string);
  22424. /**
  22425. * Gets the current class name
  22426. * @returns the class name
  22427. */
  22428. getClassName(): string;
  22429. /**
  22430. * Gets the rgba input component
  22431. */
  22432. get rgba(): NodeMaterialConnectionPoint;
  22433. /**
  22434. * Gets the rgb input component
  22435. */
  22436. get rgb(): NodeMaterialConnectionPoint;
  22437. /**
  22438. * Gets the a input component
  22439. */
  22440. get a(): NodeMaterialConnectionPoint;
  22441. protected _buildBlock(state: NodeMaterialBuildState): this;
  22442. }
  22443. }
  22444. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22448. /**
  22449. * Block used for the particle ramp gradient section
  22450. */
  22451. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22452. /**
  22453. * Create a new ParticleRampGradientBlock
  22454. * @param name defines the block name
  22455. */
  22456. constructor(name: string);
  22457. /**
  22458. * Gets the current class name
  22459. * @returns the class name
  22460. */
  22461. getClassName(): string;
  22462. /**
  22463. * Gets the color input component
  22464. */
  22465. get color(): NodeMaterialConnectionPoint;
  22466. /**
  22467. * Gets the rampColor output component
  22468. */
  22469. get rampColor(): NodeMaterialConnectionPoint;
  22470. /**
  22471. * Initialize the block and prepare the context for build
  22472. * @param state defines the state that will be used for the build
  22473. */
  22474. initialize(state: NodeMaterialBuildState): void;
  22475. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22476. }
  22477. }
  22478. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22482. /**
  22483. * Block used for the particle blend multiply section
  22484. */
  22485. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22486. /**
  22487. * Create a new ParticleBlendMultiplyBlock
  22488. * @param name defines the block name
  22489. */
  22490. constructor(name: string);
  22491. /**
  22492. * Gets the current class name
  22493. * @returns the class name
  22494. */
  22495. getClassName(): string;
  22496. /**
  22497. * Gets the color input component
  22498. */
  22499. get color(): NodeMaterialConnectionPoint;
  22500. /**
  22501. * Gets the alphaTexture input component
  22502. */
  22503. get alphaTexture(): NodeMaterialConnectionPoint;
  22504. /**
  22505. * Gets the alphaColor input component
  22506. */
  22507. get alphaColor(): NodeMaterialConnectionPoint;
  22508. /**
  22509. * Gets the blendColor output component
  22510. */
  22511. get blendColor(): NodeMaterialConnectionPoint;
  22512. /**
  22513. * Initialize the block and prepare the context for build
  22514. * @param state defines the state that will be used for the build
  22515. */
  22516. initialize(state: NodeMaterialBuildState): void;
  22517. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22518. }
  22519. }
  22520. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22524. /**
  22525. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22526. */
  22527. export class VectorMergerBlock extends NodeMaterialBlock {
  22528. /**
  22529. * Create a new VectorMergerBlock
  22530. * @param name defines the block name
  22531. */
  22532. constructor(name: string);
  22533. /**
  22534. * Gets the current class name
  22535. * @returns the class name
  22536. */
  22537. getClassName(): string;
  22538. /**
  22539. * Gets the xyz component (input)
  22540. */
  22541. get xyzIn(): NodeMaterialConnectionPoint;
  22542. /**
  22543. * Gets the xy component (input)
  22544. */
  22545. get xyIn(): NodeMaterialConnectionPoint;
  22546. /**
  22547. * Gets the x component (input)
  22548. */
  22549. get x(): NodeMaterialConnectionPoint;
  22550. /**
  22551. * Gets the y component (input)
  22552. */
  22553. get y(): NodeMaterialConnectionPoint;
  22554. /**
  22555. * Gets the z component (input)
  22556. */
  22557. get z(): NodeMaterialConnectionPoint;
  22558. /**
  22559. * Gets the w component (input)
  22560. */
  22561. get w(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the xyzw component (output)
  22564. */
  22565. get xyzw(): NodeMaterialConnectionPoint;
  22566. /**
  22567. * Gets the xyz component (output)
  22568. */
  22569. get xyzOut(): NodeMaterialConnectionPoint;
  22570. /**
  22571. * Gets the xy component (output)
  22572. */
  22573. get xyOut(): NodeMaterialConnectionPoint;
  22574. /**
  22575. * Gets the xy component (output)
  22576. * @deprecated Please use xyOut instead.
  22577. */
  22578. get xy(): NodeMaterialConnectionPoint;
  22579. /**
  22580. * Gets the xyz component (output)
  22581. * @deprecated Please use xyzOut instead.
  22582. */
  22583. get xyz(): NodeMaterialConnectionPoint;
  22584. protected _buildBlock(state: NodeMaterialBuildState): this;
  22585. }
  22586. }
  22587. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22591. import { Vector2 } from "babylonjs/Maths/math.vector";
  22592. import { Scene } from "babylonjs/scene";
  22593. /**
  22594. * Block used to remap a float from a range to a new one
  22595. */
  22596. export class RemapBlock extends NodeMaterialBlock {
  22597. /**
  22598. * Gets or sets the source range
  22599. */
  22600. sourceRange: Vector2;
  22601. /**
  22602. * Gets or sets the target range
  22603. */
  22604. targetRange: Vector2;
  22605. /**
  22606. * Creates a new RemapBlock
  22607. * @param name defines the block name
  22608. */
  22609. constructor(name: string);
  22610. /**
  22611. * Gets the current class name
  22612. * @returns the class name
  22613. */
  22614. getClassName(): string;
  22615. /**
  22616. * Gets the input component
  22617. */
  22618. get input(): NodeMaterialConnectionPoint;
  22619. /**
  22620. * Gets the source min input component
  22621. */
  22622. get sourceMin(): NodeMaterialConnectionPoint;
  22623. /**
  22624. * Gets the source max input component
  22625. */
  22626. get sourceMax(): NodeMaterialConnectionPoint;
  22627. /**
  22628. * Gets the target min input component
  22629. */
  22630. get targetMin(): NodeMaterialConnectionPoint;
  22631. /**
  22632. * Gets the target max input component
  22633. */
  22634. get targetMax(): NodeMaterialConnectionPoint;
  22635. /**
  22636. * Gets the output component
  22637. */
  22638. get output(): NodeMaterialConnectionPoint;
  22639. protected _buildBlock(state: NodeMaterialBuildState): this;
  22640. protected _dumpPropertiesCode(): string;
  22641. serialize(): any;
  22642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22643. }
  22644. }
  22645. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  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 multiply 2 values
  22651. */
  22652. export class MultiplyBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Creates a new MultiplyBlock
  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 left operand input component
  22665. */
  22666. get left(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the right operand input component
  22669. */
  22670. get right(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the output component
  22673. */
  22674. get output(): NodeMaterialConnectionPoint;
  22675. protected _buildBlock(state: NodeMaterialBuildState): this;
  22676. }
  22677. }
  22678. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  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 to expand a Color3/4 into 4 outputs (one for each component)
  22684. */
  22685. export class ColorSplitterBlock extends NodeMaterialBlock {
  22686. /**
  22687. * Create a new ColorSplitterBlock
  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 rgba component (input)
  22698. */
  22699. get rgba(): NodeMaterialConnectionPoint;
  22700. /**
  22701. * Gets the rgb component (input)
  22702. */
  22703. get rgbIn(): NodeMaterialConnectionPoint;
  22704. /**
  22705. * Gets the rgb component (output)
  22706. */
  22707. get rgbOut(): NodeMaterialConnectionPoint;
  22708. /**
  22709. * Gets the r component (output)
  22710. */
  22711. get r(): NodeMaterialConnectionPoint;
  22712. /**
  22713. * Gets the g component (output)
  22714. */
  22715. get g(): NodeMaterialConnectionPoint;
  22716. /**
  22717. * Gets the b component (output)
  22718. */
  22719. get b(): NodeMaterialConnectionPoint;
  22720. /**
  22721. * Gets the a component (output)
  22722. */
  22723. get a(): NodeMaterialConnectionPoint;
  22724. protected _inputRename(name: string): string;
  22725. protected _outputRename(name: string): string;
  22726. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22727. }
  22728. }
  22729. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22731. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22732. import { Scene } from "babylonjs/scene";
  22733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22734. import { Matrix } from "babylonjs/Maths/math.vector";
  22735. import { Mesh } from "babylonjs/Meshes/mesh";
  22736. import { Engine } from "babylonjs/Engines/engine";
  22737. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22738. import { Observable } from "babylonjs/Misc/observable";
  22739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22740. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22741. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22742. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22743. import { Nullable } from "babylonjs/types";
  22744. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22745. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22746. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22747. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22748. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22749. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22750. import { Effect } from "babylonjs/Materials/effect";
  22751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22752. import { Camera } from "babylonjs/Cameras/camera";
  22753. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22755. /**
  22756. * Interface used to configure the node material editor
  22757. */
  22758. export interface INodeMaterialEditorOptions {
  22759. /** Define the URl to load node editor script */
  22760. editorURL?: string;
  22761. }
  22762. /** @hidden */
  22763. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22764. NORMAL: boolean;
  22765. TANGENT: boolean;
  22766. UV1: boolean;
  22767. /** BONES */
  22768. NUM_BONE_INFLUENCERS: number;
  22769. BonesPerMesh: number;
  22770. BONETEXTURE: boolean;
  22771. /** MORPH TARGETS */
  22772. MORPHTARGETS: boolean;
  22773. MORPHTARGETS_NORMAL: boolean;
  22774. MORPHTARGETS_TANGENT: boolean;
  22775. MORPHTARGETS_UV: boolean;
  22776. NUM_MORPH_INFLUENCERS: number;
  22777. /** IMAGE PROCESSING */
  22778. IMAGEPROCESSING: boolean;
  22779. VIGNETTE: boolean;
  22780. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22781. VIGNETTEBLENDMODEOPAQUE: boolean;
  22782. TONEMAPPING: boolean;
  22783. TONEMAPPING_ACES: boolean;
  22784. CONTRAST: boolean;
  22785. EXPOSURE: boolean;
  22786. COLORCURVES: boolean;
  22787. COLORGRADING: boolean;
  22788. COLORGRADING3D: boolean;
  22789. SAMPLER3DGREENDEPTH: boolean;
  22790. SAMPLER3DBGRMAP: boolean;
  22791. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22792. /** MISC. */
  22793. BUMPDIRECTUV: number;
  22794. constructor();
  22795. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22796. }
  22797. /**
  22798. * Class used to configure NodeMaterial
  22799. */
  22800. export interface INodeMaterialOptions {
  22801. /**
  22802. * Defines if blocks should emit comments
  22803. */
  22804. emitComments: boolean;
  22805. }
  22806. /**
  22807. * Class used to create a node based material built by assembling shader blocks
  22808. */
  22809. export class NodeMaterial extends PushMaterial {
  22810. private static _BuildIdGenerator;
  22811. private _options;
  22812. private _vertexCompilationState;
  22813. private _fragmentCompilationState;
  22814. private _sharedData;
  22815. private _buildId;
  22816. private _buildWasSuccessful;
  22817. private _cachedWorldViewMatrix;
  22818. private _cachedWorldViewProjectionMatrix;
  22819. private _optimizers;
  22820. private _animationFrame;
  22821. /** Define the Url to load node editor script */
  22822. static EditorURL: string;
  22823. /** Define the Url to load snippets */
  22824. static SnippetUrl: string;
  22825. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22826. static IgnoreTexturesAtLoadTime: boolean;
  22827. private BJSNODEMATERIALEDITOR;
  22828. /** Get the inspector from bundle or global */
  22829. private _getGlobalNodeMaterialEditor;
  22830. /**
  22831. * Snippet ID if the material was created from the snippet server
  22832. */
  22833. snippetId: string;
  22834. /**
  22835. * Gets or sets data used by visual editor
  22836. * @see https://nme.babylonjs.com
  22837. */
  22838. editorData: any;
  22839. /**
  22840. * 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)
  22841. */
  22842. ignoreAlpha: boolean;
  22843. /**
  22844. * Defines the maximum number of lights that can be used in the material
  22845. */
  22846. maxSimultaneousLights: number;
  22847. /**
  22848. * Observable raised when the material is built
  22849. */
  22850. onBuildObservable: Observable<NodeMaterial>;
  22851. /**
  22852. * Gets or sets the root nodes of the material vertex shader
  22853. */
  22854. _vertexOutputNodes: NodeMaterialBlock[];
  22855. /**
  22856. * Gets or sets the root nodes of the material fragment (pixel) shader
  22857. */
  22858. _fragmentOutputNodes: NodeMaterialBlock[];
  22859. /** Gets or sets options to control the node material overall behavior */
  22860. get options(): INodeMaterialOptions;
  22861. set options(options: INodeMaterialOptions);
  22862. /**
  22863. * Default configuration related to image processing available in the standard Material.
  22864. */
  22865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22866. /**
  22867. * Gets the image processing configuration used either in this material.
  22868. */
  22869. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22870. /**
  22871. * Sets the Default image processing configuration used either in the this material.
  22872. *
  22873. * If sets to null, the scene one is in use.
  22874. */
  22875. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22876. /**
  22877. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22878. */
  22879. attachedBlocks: NodeMaterialBlock[];
  22880. /**
  22881. * Specifies the mode of the node material
  22882. * @hidden
  22883. */
  22884. _mode: NodeMaterialModes;
  22885. /**
  22886. * Gets the mode property
  22887. */
  22888. get mode(): NodeMaterialModes;
  22889. /**
  22890. * Create a new node based material
  22891. * @param name defines the material name
  22892. * @param scene defines the hosting scene
  22893. * @param options defines creation option
  22894. */
  22895. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22896. /**
  22897. * Gets the current class name of the material e.g. "NodeMaterial"
  22898. * @returns the class name
  22899. */
  22900. getClassName(): string;
  22901. /**
  22902. * Keep track of the image processing observer to allow dispose and replace.
  22903. */
  22904. private _imageProcessingObserver;
  22905. /**
  22906. * Attaches a new image processing configuration to the Standard Material.
  22907. * @param configuration
  22908. */
  22909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22910. /**
  22911. * Get a block by its name
  22912. * @param name defines the name of the block to retrieve
  22913. * @returns the required block or null if not found
  22914. */
  22915. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22916. /**
  22917. * Get a block by its name
  22918. * @param predicate defines the predicate used to find the good candidate
  22919. * @returns the required block or null if not found
  22920. */
  22921. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22922. /**
  22923. * Get an input block by its name
  22924. * @param predicate defines the predicate used to find the good candidate
  22925. * @returns the required input block or null if not found
  22926. */
  22927. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22928. /**
  22929. * Gets the list of input blocks attached to this material
  22930. * @returns an array of InputBlocks
  22931. */
  22932. getInputBlocks(): InputBlock[];
  22933. /**
  22934. * Adds a new optimizer to the list of optimizers
  22935. * @param optimizer defines the optimizers to add
  22936. * @returns the current material
  22937. */
  22938. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22939. /**
  22940. * Remove an optimizer from the list of optimizers
  22941. * @param optimizer defines the optimizers to remove
  22942. * @returns the current material
  22943. */
  22944. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22945. /**
  22946. * Add a new block to the list of output nodes
  22947. * @param node defines the node to add
  22948. * @returns the current material
  22949. */
  22950. addOutputNode(node: NodeMaterialBlock): this;
  22951. /**
  22952. * Remove a block from the list of root nodes
  22953. * @param node defines the node to remove
  22954. * @returns the current material
  22955. */
  22956. removeOutputNode(node: NodeMaterialBlock): this;
  22957. private _addVertexOutputNode;
  22958. private _removeVertexOutputNode;
  22959. private _addFragmentOutputNode;
  22960. private _removeFragmentOutputNode;
  22961. /**
  22962. * Specifies if the material will require alpha blending
  22963. * @returns a boolean specifying if alpha blending is needed
  22964. */
  22965. needAlphaBlending(): boolean;
  22966. /**
  22967. * Specifies if this material should be rendered in alpha test mode
  22968. * @returns a boolean specifying if an alpha test is needed.
  22969. */
  22970. needAlphaTesting(): boolean;
  22971. private _initializeBlock;
  22972. private _resetDualBlocks;
  22973. /**
  22974. * Remove a block from the current node material
  22975. * @param block defines the block to remove
  22976. */
  22977. removeBlock(block: NodeMaterialBlock): void;
  22978. /**
  22979. * Build the material and generates the inner effect
  22980. * @param verbose defines if the build should log activity
  22981. */
  22982. build(verbose?: boolean): void;
  22983. /**
  22984. * Runs an otpimization phase to try to improve the shader code
  22985. */
  22986. optimize(): void;
  22987. private _prepareDefinesForAttributes;
  22988. /**
  22989. * Create a post process from the material
  22990. * @param camera The camera to apply the render pass to.
  22991. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22993. * @param engine The engine which the post process will be applied. (default: current engine)
  22994. * @param reusable If the post process can be reused on the same frame. (default: false)
  22995. * @param textureType Type of textures used when performing the post process. (default: 0)
  22996. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22997. * @returns the post process created
  22998. */
  22999. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23000. /**
  23001. * Create the post process effect from the material
  23002. * @param postProcess The post process to create the effect for
  23003. */
  23004. createEffectForPostProcess(postProcess: PostProcess): void;
  23005. private _createEffectOrPostProcess;
  23006. private _createEffectForParticles;
  23007. /**
  23008. * Create the effect to be used as the custom effect for a particle system
  23009. * @param particleSystem Particle system to create the effect for
  23010. * @param onCompiled defines a function to call when the effect creation is successful
  23011. * @param onError defines a function to call when the effect creation has failed
  23012. */
  23013. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23014. private _processDefines;
  23015. /**
  23016. * Get if the submesh is ready to be used and all its information available.
  23017. * Child classes can use it to update shaders
  23018. * @param mesh defines the mesh to check
  23019. * @param subMesh defines which submesh to check
  23020. * @param useInstances specifies that instances should be used
  23021. * @returns a boolean indicating that the submesh is ready or not
  23022. */
  23023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23024. /**
  23025. * Get a string representing the shaders built by the current node graph
  23026. */
  23027. get compiledShaders(): string;
  23028. /**
  23029. * Binds the world matrix to the material
  23030. * @param world defines the world transformation matrix
  23031. */
  23032. bindOnlyWorldMatrix(world: Matrix): void;
  23033. /**
  23034. * Binds the submesh to this material by preparing the effect and shader to draw
  23035. * @param world defines the world transformation matrix
  23036. * @param mesh defines the mesh containing the submesh
  23037. * @param subMesh defines the submesh to bind the material to
  23038. */
  23039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23040. /**
  23041. * Gets the active textures from the material
  23042. * @returns an array of textures
  23043. */
  23044. getActiveTextures(): BaseTexture[];
  23045. /**
  23046. * Gets the list of texture blocks
  23047. * @returns an array of texture blocks
  23048. */
  23049. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23050. /**
  23051. * Specifies if the material uses a texture
  23052. * @param texture defines the texture to check against the material
  23053. * @returns a boolean specifying if the material uses the texture
  23054. */
  23055. hasTexture(texture: BaseTexture): boolean;
  23056. /**
  23057. * Disposes the material
  23058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23061. */
  23062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23063. /** Creates the node editor window. */
  23064. private _createNodeEditor;
  23065. /**
  23066. * Launch the node material editor
  23067. * @param config Define the configuration of the editor
  23068. * @return a promise fulfilled when the node editor is visible
  23069. */
  23070. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23071. /**
  23072. * Clear the current material
  23073. */
  23074. clear(): void;
  23075. /**
  23076. * Clear the current material and set it to a default state
  23077. */
  23078. setToDefault(): void;
  23079. /**
  23080. * Clear the current material and set it to a default state for post process
  23081. */
  23082. setToDefaultPostProcess(): void;
  23083. /**
  23084. * Clear the current material and set it to a default state for particle
  23085. */
  23086. setToDefaultParticle(): void;
  23087. /**
  23088. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23089. * @param url defines the url to load from
  23090. * @returns a promise that will fullfil when the material is fully loaded
  23091. */
  23092. loadAsync(url: string): Promise<void>;
  23093. private _gatherBlocks;
  23094. /**
  23095. * Generate a string containing the code declaration required to create an equivalent of this material
  23096. * @returns a string
  23097. */
  23098. generateCode(): string;
  23099. /**
  23100. * Serializes this material in a JSON representation
  23101. * @returns the serialized material object
  23102. */
  23103. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23104. private _restoreConnections;
  23105. /**
  23106. * Clear the current graph and load a new one from a serialization object
  23107. * @param source defines the JSON representation of the material
  23108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23109. * @param merge defines whether or not the source must be merged or replace the current content
  23110. */
  23111. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23112. /**
  23113. * Makes a duplicate of the current material.
  23114. * @param name - name to use for the new material.
  23115. */
  23116. clone(name: string): NodeMaterial;
  23117. /**
  23118. * Creates a node material from parsed material data
  23119. * @param source defines the JSON representation of the material
  23120. * @param scene defines the hosting scene
  23121. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23122. * @returns a new node material
  23123. */
  23124. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23125. /**
  23126. * Creates a node material from a snippet saved in a remote file
  23127. * @param name defines the name of the material to create
  23128. * @param url defines the url to load from
  23129. * @param scene defines the hosting scene
  23130. * @returns a promise that will resolve to the new node material
  23131. */
  23132. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23133. /**
  23134. * Creates a node material from a snippet saved by the node material editor
  23135. * @param snippetId defines the snippet to load
  23136. * @param scene defines the hosting scene
  23137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23138. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23139. * @returns a promise that will resolve to the new node material
  23140. */
  23141. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23142. /**
  23143. * Creates a new node material set to default basic configuration
  23144. * @param name defines the name of the material
  23145. * @param scene defines the hosting scene
  23146. * @returns a new NodeMaterial
  23147. */
  23148. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23149. }
  23150. }
  23151. declare module "babylonjs/PostProcesses/postProcess" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { SmartArray } from "babylonjs/Misc/smartArray";
  23154. import { Observable } from "babylonjs/Misc/observable";
  23155. import { Vector2 } from "babylonjs/Maths/math.vector";
  23156. import { Camera } from "babylonjs/Cameras/camera";
  23157. import { Effect } from "babylonjs/Materials/effect";
  23158. import "babylonjs/Shaders/postprocess.vertex";
  23159. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23160. import { Engine } from "babylonjs/Engines/engine";
  23161. import { Color4 } from "babylonjs/Maths/math.color";
  23162. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23163. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23164. import { Scene } from "babylonjs/scene";
  23165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23166. /**
  23167. * Size options for a post process
  23168. */
  23169. export type PostProcessOptions = {
  23170. width: number;
  23171. height: number;
  23172. };
  23173. /**
  23174. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23175. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23176. */
  23177. export class PostProcess {
  23178. /** Name of the PostProcess. */
  23179. name: string;
  23180. /**
  23181. * Gets or sets the unique id of the post process
  23182. */
  23183. uniqueId: number;
  23184. /**
  23185. * Width of the texture to apply the post process on
  23186. */
  23187. width: number;
  23188. /**
  23189. * Height of the texture to apply the post process on
  23190. */
  23191. height: number;
  23192. /**
  23193. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23194. */
  23195. nodeMaterialSource: Nullable<NodeMaterial>;
  23196. /**
  23197. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23198. * @hidden
  23199. */
  23200. _outputTexture: Nullable<InternalTexture>;
  23201. /**
  23202. * Sampling mode used by the shader
  23203. * See https://doc.babylonjs.com/classes/3.1/texture
  23204. */
  23205. renderTargetSamplingMode: number;
  23206. /**
  23207. * Clear color to use when screen clearing
  23208. */
  23209. clearColor: Color4;
  23210. /**
  23211. * If the buffer needs to be cleared before applying the post process. (default: true)
  23212. * Should be set to false if shader will overwrite all previous pixels.
  23213. */
  23214. autoClear: boolean;
  23215. /**
  23216. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23217. */
  23218. alphaMode: number;
  23219. /**
  23220. * Sets the setAlphaBlendConstants of the babylon engine
  23221. */
  23222. alphaConstants: Color4;
  23223. /**
  23224. * Animations to be used for the post processing
  23225. */
  23226. animations: import("babylonjs/Animations/animation").Animation[];
  23227. /**
  23228. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23229. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23230. */
  23231. enablePixelPerfectMode: boolean;
  23232. /**
  23233. * Force the postprocess to be applied without taking in account viewport
  23234. */
  23235. forceFullscreenViewport: boolean;
  23236. /**
  23237. * List of inspectable custom properties (used by the Inspector)
  23238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23239. */
  23240. inspectableCustomProperties: IInspectable[];
  23241. /**
  23242. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23243. *
  23244. * | Value | Type | Description |
  23245. * | ----- | ----------------------------------- | ----------- |
  23246. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23247. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23248. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23249. *
  23250. */
  23251. scaleMode: number;
  23252. /**
  23253. * Force textures to be a power of two (default: false)
  23254. */
  23255. alwaysForcePOT: boolean;
  23256. private _samples;
  23257. /**
  23258. * Number of sample textures (default: 1)
  23259. */
  23260. get samples(): number;
  23261. set samples(n: number);
  23262. /**
  23263. * Modify the scale of the post process to be the same as the viewport (default: false)
  23264. */
  23265. adaptScaleToCurrentViewport: boolean;
  23266. private _camera;
  23267. protected _scene: Scene;
  23268. private _engine;
  23269. private _options;
  23270. private _reusable;
  23271. private _textureType;
  23272. private _textureFormat;
  23273. /**
  23274. * Smart array of input and output textures for the post process.
  23275. * @hidden
  23276. */
  23277. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23278. /**
  23279. * The index in _textures that corresponds to the output texture.
  23280. * @hidden
  23281. */
  23282. _currentRenderTextureInd: number;
  23283. private _effect;
  23284. private _samplers;
  23285. private _fragmentUrl;
  23286. private _vertexUrl;
  23287. private _parameters;
  23288. private _scaleRatio;
  23289. protected _indexParameters: any;
  23290. private _shareOutputWithPostProcess;
  23291. private _texelSize;
  23292. private _forcedOutputTexture;
  23293. /**
  23294. * Returns the fragment url or shader name used in the post process.
  23295. * @returns the fragment url or name in the shader store.
  23296. */
  23297. getEffectName(): string;
  23298. /**
  23299. * An event triggered when the postprocess is activated.
  23300. */
  23301. onActivateObservable: Observable<Camera>;
  23302. private _onActivateObserver;
  23303. /**
  23304. * A function that is added to the onActivateObservable
  23305. */
  23306. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23307. /**
  23308. * An event triggered when the postprocess changes its size.
  23309. */
  23310. onSizeChangedObservable: Observable<PostProcess>;
  23311. private _onSizeChangedObserver;
  23312. /**
  23313. * A function that is added to the onSizeChangedObservable
  23314. */
  23315. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23316. /**
  23317. * An event triggered when the postprocess applies its effect.
  23318. */
  23319. onApplyObservable: Observable<Effect>;
  23320. private _onApplyObserver;
  23321. /**
  23322. * A function that is added to the onApplyObservable
  23323. */
  23324. set onApply(callback: (effect: Effect) => void);
  23325. /**
  23326. * An event triggered before rendering the postprocess
  23327. */
  23328. onBeforeRenderObservable: Observable<Effect>;
  23329. private _onBeforeRenderObserver;
  23330. /**
  23331. * A function that is added to the onBeforeRenderObservable
  23332. */
  23333. set onBeforeRender(callback: (effect: Effect) => void);
  23334. /**
  23335. * An event triggered after rendering the postprocess
  23336. */
  23337. onAfterRenderObservable: Observable<Effect>;
  23338. private _onAfterRenderObserver;
  23339. /**
  23340. * A function that is added to the onAfterRenderObservable
  23341. */
  23342. set onAfterRender(callback: (efect: Effect) => void);
  23343. /**
  23344. * 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
  23345. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23346. */
  23347. get inputTexture(): InternalTexture;
  23348. set inputTexture(value: InternalTexture);
  23349. /**
  23350. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23351. * the only way to unset it is to use this function to restore its internal state
  23352. */
  23353. restoreDefaultInputTexture(): void;
  23354. /**
  23355. * Gets the camera which post process is applied to.
  23356. * @returns The camera the post process is applied to.
  23357. */
  23358. getCamera(): Camera;
  23359. /**
  23360. * Gets the texel size of the postprocess.
  23361. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23362. */
  23363. get texelSize(): Vector2;
  23364. /**
  23365. * Creates a new instance PostProcess
  23366. * @param name The name of the PostProcess.
  23367. * @param fragmentUrl The url of the fragment shader to be used.
  23368. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23369. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23370. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23371. * @param camera The camera to apply the render pass to.
  23372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23373. * @param engine The engine which the post process will be applied. (default: current engine)
  23374. * @param reusable If the post process can be reused on the same frame. (default: false)
  23375. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23376. * @param textureType Type of textures used when performing the post process. (default: 0)
  23377. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23378. * @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
  23379. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23380. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23381. */
  23382. constructor(
  23383. /** Name of the PostProcess. */
  23384. 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);
  23385. /**
  23386. * Gets a string idenfifying the name of the class
  23387. * @returns "PostProcess" string
  23388. */
  23389. getClassName(): string;
  23390. /**
  23391. * Gets the engine which this post process belongs to.
  23392. * @returns The engine the post process was enabled with.
  23393. */
  23394. getEngine(): Engine;
  23395. /**
  23396. * The effect that is created when initializing the post process.
  23397. * @returns The created effect corresponding the the postprocess.
  23398. */
  23399. getEffect(): Effect;
  23400. /**
  23401. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23402. * @param postProcess The post process to share the output with.
  23403. * @returns This post process.
  23404. */
  23405. shareOutputWith(postProcess: PostProcess): PostProcess;
  23406. /**
  23407. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23408. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23409. */
  23410. useOwnOutput(): void;
  23411. /**
  23412. * Updates the effect with the current post process compile time values and recompiles the shader.
  23413. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23414. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23415. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23416. * @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
  23417. * @param onCompiled Called when the shader has been compiled.
  23418. * @param onError Called if there is an error when compiling a shader.
  23419. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23420. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23421. */
  23422. 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;
  23423. /**
  23424. * The post process is reusable if it can be used multiple times within one frame.
  23425. * @returns If the post process is reusable
  23426. */
  23427. isReusable(): boolean;
  23428. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23429. markTextureDirty(): void;
  23430. /**
  23431. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23432. * 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.
  23433. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23434. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23435. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23436. * @returns The target texture that was bound to be written to.
  23437. */
  23438. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23439. /**
  23440. * If the post process is supported.
  23441. */
  23442. get isSupported(): boolean;
  23443. /**
  23444. * The aspect ratio of the output texture.
  23445. */
  23446. get aspectRatio(): number;
  23447. /**
  23448. * Get a value indicating if the post-process is ready to be used
  23449. * @returns true if the post-process is ready (shader is compiled)
  23450. */
  23451. isReady(): boolean;
  23452. /**
  23453. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23454. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23455. */
  23456. apply(): Nullable<Effect>;
  23457. private _disposeTextures;
  23458. /**
  23459. * Disposes the post process.
  23460. * @param camera The camera to dispose the post process on.
  23461. */
  23462. dispose(camera?: Camera): void;
  23463. }
  23464. }
  23465. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23466. /** @hidden */
  23467. export var kernelBlurVaryingDeclaration: {
  23468. name: string;
  23469. shader: string;
  23470. };
  23471. }
  23472. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23473. /** @hidden */
  23474. export var kernelBlurFragment: {
  23475. name: string;
  23476. shader: string;
  23477. };
  23478. }
  23479. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23480. /** @hidden */
  23481. export var kernelBlurFragment2: {
  23482. name: string;
  23483. shader: string;
  23484. };
  23485. }
  23486. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23487. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23488. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23489. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23490. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23491. /** @hidden */
  23492. export var kernelBlurPixelShader: {
  23493. name: string;
  23494. shader: string;
  23495. };
  23496. }
  23497. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23498. /** @hidden */
  23499. export var kernelBlurVertex: {
  23500. name: string;
  23501. shader: string;
  23502. };
  23503. }
  23504. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23505. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23506. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23507. /** @hidden */
  23508. export var kernelBlurVertexShader: {
  23509. name: string;
  23510. shader: string;
  23511. };
  23512. }
  23513. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23514. import { Vector2 } from "babylonjs/Maths/math.vector";
  23515. import { Nullable } from "babylonjs/types";
  23516. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23517. import { Camera } from "babylonjs/Cameras/camera";
  23518. import { Effect } from "babylonjs/Materials/effect";
  23519. import { Engine } from "babylonjs/Engines/engine";
  23520. import "babylonjs/Shaders/kernelBlur.fragment";
  23521. import "babylonjs/Shaders/kernelBlur.vertex";
  23522. /**
  23523. * The Blur Post Process which blurs an image based on a kernel and direction.
  23524. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23525. */
  23526. export class BlurPostProcess extends PostProcess {
  23527. /** The direction in which to blur the image. */
  23528. direction: Vector2;
  23529. private blockCompilation;
  23530. protected _kernel: number;
  23531. protected _idealKernel: number;
  23532. protected _packedFloat: boolean;
  23533. private _staticDefines;
  23534. /**
  23535. * Sets the length in pixels of the blur sample region
  23536. */
  23537. set kernel(v: number);
  23538. /**
  23539. * Gets the length in pixels of the blur sample region
  23540. */
  23541. get kernel(): number;
  23542. /**
  23543. * Sets wether or not the blur needs to unpack/repack floats
  23544. */
  23545. set packedFloat(v: boolean);
  23546. /**
  23547. * Gets wether or not the blur is unpacking/repacking floats
  23548. */
  23549. get packedFloat(): boolean;
  23550. /**
  23551. * Creates a new instance BlurPostProcess
  23552. * @param name The name of the effect.
  23553. * @param direction The direction in which to blur the image.
  23554. * @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.
  23555. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23556. * @param camera The camera to apply the render pass to.
  23557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23558. * @param engine The engine which the post process will be applied. (default: current engine)
  23559. * @param reusable If the post process can be reused on the same frame. (default: false)
  23560. * @param textureType Type of textures used when performing the post process. (default: 0)
  23561. * @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)
  23562. */
  23563. constructor(name: string,
  23564. /** The direction in which to blur the image. */
  23565. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23566. /**
  23567. * Updates the effect with the current post process compile time values and recompiles the shader.
  23568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23571. * @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
  23572. * @param onCompiled Called when the shader has been compiled.
  23573. * @param onError Called if there is an error when compiling a shader.
  23574. */
  23575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23576. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23577. /**
  23578. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23579. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23580. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23581. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23582. * The gaps between physical kernels are compensated for in the weighting of the samples
  23583. * @param idealKernel Ideal blur kernel.
  23584. * @return Nearest best kernel.
  23585. */
  23586. protected _nearestBestKernel(idealKernel: number): number;
  23587. /**
  23588. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23589. * @param x The point on the Gaussian distribution to sample.
  23590. * @return the value of the Gaussian function at x.
  23591. */
  23592. protected _gaussianWeight(x: number): number;
  23593. /**
  23594. * Generates a string that can be used as a floating point number in GLSL.
  23595. * @param x Value to print.
  23596. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23597. * @return GLSL float string.
  23598. */
  23599. protected _glslFloat(x: number, decimalFigures?: number): string;
  23600. }
  23601. }
  23602. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23603. import { Scene } from "babylonjs/scene";
  23604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23605. import { Plane } from "babylonjs/Maths/math.plane";
  23606. /**
  23607. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23608. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23609. * You can then easily use it as a reflectionTexture on a flat surface.
  23610. * In case the surface is not a plane, please consider relying on reflection probes.
  23611. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23612. */
  23613. export class MirrorTexture extends RenderTargetTexture {
  23614. private scene;
  23615. /**
  23616. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23617. * 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.
  23618. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23619. */
  23620. mirrorPlane: Plane;
  23621. /**
  23622. * Define the blur ratio used to blur the reflection if needed.
  23623. */
  23624. set blurRatio(value: number);
  23625. get blurRatio(): number;
  23626. /**
  23627. * Define the adaptive blur kernel used to blur the reflection if needed.
  23628. * This will autocompute the closest best match for the `blurKernel`
  23629. */
  23630. set adaptiveBlurKernel(value: number);
  23631. /**
  23632. * Define the blur kernel used to blur the reflection if needed.
  23633. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23634. */
  23635. set blurKernel(value: number);
  23636. /**
  23637. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23638. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23639. */
  23640. set blurKernelX(value: number);
  23641. get blurKernelX(): number;
  23642. /**
  23643. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23644. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23645. */
  23646. set blurKernelY(value: number);
  23647. get blurKernelY(): number;
  23648. private _autoComputeBlurKernel;
  23649. protected _onRatioRescale(): void;
  23650. private _updateGammaSpace;
  23651. private _imageProcessingConfigChangeObserver;
  23652. private _transformMatrix;
  23653. private _mirrorMatrix;
  23654. private _savedViewMatrix;
  23655. private _blurX;
  23656. private _blurY;
  23657. private _adaptiveBlurKernel;
  23658. private _blurKernelX;
  23659. private _blurKernelY;
  23660. private _blurRatio;
  23661. /**
  23662. * Instantiates a Mirror Texture.
  23663. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23664. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23665. * You can then easily use it as a reflectionTexture on a flat surface.
  23666. * In case the surface is not a plane, please consider relying on reflection probes.
  23667. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23668. * @param name
  23669. * @param size
  23670. * @param scene
  23671. * @param generateMipMaps
  23672. * @param type
  23673. * @param samplingMode
  23674. * @param generateDepthBuffer
  23675. */
  23676. constructor(name: string, size: number | {
  23677. width: number;
  23678. height: number;
  23679. } | {
  23680. ratio: number;
  23681. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23682. private _preparePostProcesses;
  23683. /**
  23684. * Clone the mirror texture.
  23685. * @returns the cloned texture
  23686. */
  23687. clone(): MirrorTexture;
  23688. /**
  23689. * Serialize the texture to a JSON representation you could use in Parse later on
  23690. * @returns the serialized JSON representation
  23691. */
  23692. serialize(): any;
  23693. /**
  23694. * Dispose the texture and release its associated resources.
  23695. */
  23696. dispose(): void;
  23697. }
  23698. }
  23699. declare module "babylonjs/Materials/Textures/texture" {
  23700. import { Observable } from "babylonjs/Misc/observable";
  23701. import { Nullable } from "babylonjs/types";
  23702. import { Matrix } from "babylonjs/Maths/math.vector";
  23703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23704. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23705. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23706. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23707. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23709. import { Scene } from "babylonjs/scene";
  23710. /**
  23711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23712. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23713. */
  23714. export class Texture extends BaseTexture {
  23715. /**
  23716. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23717. */
  23718. static SerializeBuffers: boolean;
  23719. /** @hidden */
  23720. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23721. /** @hidden */
  23722. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23723. /** @hidden */
  23724. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23725. /** nearest is mag = nearest and min = nearest and mip = linear */
  23726. static readonly NEAREST_SAMPLINGMODE: number;
  23727. /** nearest is mag = nearest and min = nearest and mip = linear */
  23728. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23729. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23730. static readonly BILINEAR_SAMPLINGMODE: number;
  23731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23732. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23733. /** Trilinear is mag = linear and min = linear and mip = linear */
  23734. static readonly TRILINEAR_SAMPLINGMODE: number;
  23735. /** Trilinear is mag = linear and min = linear and mip = linear */
  23736. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23737. /** mag = nearest and min = nearest and mip = nearest */
  23738. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23739. /** mag = nearest and min = linear and mip = nearest */
  23740. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23741. /** mag = nearest and min = linear and mip = linear */
  23742. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23743. /** mag = nearest and min = linear and mip = none */
  23744. static readonly NEAREST_LINEAR: number;
  23745. /** mag = nearest and min = nearest and mip = none */
  23746. static readonly NEAREST_NEAREST: number;
  23747. /** mag = linear and min = nearest and mip = nearest */
  23748. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23749. /** mag = linear and min = nearest and mip = linear */
  23750. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23751. /** mag = linear and min = linear and mip = none */
  23752. static readonly LINEAR_LINEAR: number;
  23753. /** mag = linear and min = nearest and mip = none */
  23754. static readonly LINEAR_NEAREST: number;
  23755. /** Explicit coordinates mode */
  23756. static readonly EXPLICIT_MODE: number;
  23757. /** Spherical coordinates mode */
  23758. static readonly SPHERICAL_MODE: number;
  23759. /** Planar coordinates mode */
  23760. static readonly PLANAR_MODE: number;
  23761. /** Cubic coordinates mode */
  23762. static readonly CUBIC_MODE: number;
  23763. /** Projection coordinates mode */
  23764. static readonly PROJECTION_MODE: number;
  23765. /** Inverse Cubic coordinates mode */
  23766. static readonly SKYBOX_MODE: number;
  23767. /** Inverse Cubic coordinates mode */
  23768. static readonly INVCUBIC_MODE: number;
  23769. /** Equirectangular coordinates mode */
  23770. static readonly EQUIRECTANGULAR_MODE: number;
  23771. /** Equirectangular Fixed coordinates mode */
  23772. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23773. /** Equirectangular Fixed Mirrored coordinates mode */
  23774. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23775. /** Texture is not repeating outside of 0..1 UVs */
  23776. static readonly CLAMP_ADDRESSMODE: number;
  23777. /** Texture is repeating outside of 0..1 UVs */
  23778. static readonly WRAP_ADDRESSMODE: number;
  23779. /** Texture is repeating and mirrored */
  23780. static readonly MIRROR_ADDRESSMODE: number;
  23781. /**
  23782. * 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
  23783. */
  23784. static UseSerializedUrlIfAny: boolean;
  23785. /**
  23786. * Define the url of the texture.
  23787. */
  23788. url: Nullable<string>;
  23789. /**
  23790. * Define an offset on the texture to offset the u coordinates of the UVs
  23791. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23792. */
  23793. uOffset: number;
  23794. /**
  23795. * Define an offset on the texture to offset the v coordinates of the UVs
  23796. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23797. */
  23798. vOffset: number;
  23799. /**
  23800. * Define an offset on the texture to scale the u coordinates of the UVs
  23801. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23802. */
  23803. uScale: number;
  23804. /**
  23805. * Define an offset on the texture to scale the v coordinates of the UVs
  23806. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23807. */
  23808. vScale: number;
  23809. /**
  23810. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23811. * @see https://doc.babylonjs.com/how_to/more_materials
  23812. */
  23813. uAng: number;
  23814. /**
  23815. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23816. * @see https://doc.babylonjs.com/how_to/more_materials
  23817. */
  23818. vAng: number;
  23819. /**
  23820. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23821. * @see https://doc.babylonjs.com/how_to/more_materials
  23822. */
  23823. wAng: number;
  23824. /**
  23825. * Defines the center of rotation (U)
  23826. */
  23827. uRotationCenter: number;
  23828. /**
  23829. * Defines the center of rotation (V)
  23830. */
  23831. vRotationCenter: number;
  23832. /**
  23833. * Defines the center of rotation (W)
  23834. */
  23835. wRotationCenter: number;
  23836. /**
  23837. * Are mip maps generated for this texture or not.
  23838. */
  23839. get noMipmap(): boolean;
  23840. /**
  23841. * List of inspectable custom properties (used by the Inspector)
  23842. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23843. */
  23844. inspectableCustomProperties: Nullable<IInspectable[]>;
  23845. private _noMipmap;
  23846. /** @hidden */
  23847. _invertY: boolean;
  23848. private _rowGenerationMatrix;
  23849. private _cachedTextureMatrix;
  23850. private _projectionModeMatrix;
  23851. private _t0;
  23852. private _t1;
  23853. private _t2;
  23854. private _cachedUOffset;
  23855. private _cachedVOffset;
  23856. private _cachedUScale;
  23857. private _cachedVScale;
  23858. private _cachedUAng;
  23859. private _cachedVAng;
  23860. private _cachedWAng;
  23861. private _cachedProjectionMatrixId;
  23862. private _cachedCoordinatesMode;
  23863. /** @hidden */
  23864. protected _initialSamplingMode: number;
  23865. /** @hidden */
  23866. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23867. private _deleteBuffer;
  23868. protected _format: Nullable<number>;
  23869. private _delayedOnLoad;
  23870. private _delayedOnError;
  23871. private _mimeType?;
  23872. /**
  23873. * Observable triggered once the texture has been loaded.
  23874. */
  23875. onLoadObservable: Observable<Texture>;
  23876. protected _isBlocking: boolean;
  23877. /**
  23878. * Is the texture preventing material to render while loading.
  23879. * If false, a default texture will be used instead of the loading one during the preparation step.
  23880. */
  23881. set isBlocking(value: boolean);
  23882. get isBlocking(): boolean;
  23883. /**
  23884. * Get the current sampling mode associated with the texture.
  23885. */
  23886. get samplingMode(): number;
  23887. /**
  23888. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23889. */
  23890. get invertY(): boolean;
  23891. /**
  23892. * Instantiates a new texture.
  23893. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23894. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23895. * @param url defines the url of the picture to load as a texture
  23896. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23897. * @param noMipmap defines if the texture will require mip maps or not
  23898. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23899. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23900. * @param onLoad defines a callback triggered when the texture has been loaded
  23901. * @param onError defines a callback triggered when an error occurred during the loading session
  23902. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23903. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23904. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23905. * @param mimeType defines an optional mime type information
  23906. */
  23907. 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);
  23908. /**
  23909. * Update the url (and optional buffer) of this texture if url was null during construction.
  23910. * @param url the url of the texture
  23911. * @param buffer the buffer of the texture (defaults to null)
  23912. * @param onLoad callback called when the texture is loaded (defaults to null)
  23913. */
  23914. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23915. /**
  23916. * Finish the loading sequence of a texture flagged as delayed load.
  23917. * @hidden
  23918. */
  23919. delayLoad(): void;
  23920. private _prepareRowForTextureGeneration;
  23921. /**
  23922. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23923. * @returns the transform matrix of the texture.
  23924. */
  23925. getTextureMatrix(uBase?: number): Matrix;
  23926. /**
  23927. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23928. * @returns The reflection texture transform
  23929. */
  23930. getReflectionTextureMatrix(): Matrix;
  23931. /**
  23932. * Clones the texture.
  23933. * @returns the cloned texture
  23934. */
  23935. clone(): Texture;
  23936. /**
  23937. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23938. * @returns The JSON representation of the texture
  23939. */
  23940. serialize(): any;
  23941. /**
  23942. * Get the current class name of the texture useful for serialization or dynamic coding.
  23943. * @returns "Texture"
  23944. */
  23945. getClassName(): string;
  23946. /**
  23947. * Dispose the texture and release its associated resources.
  23948. */
  23949. dispose(): void;
  23950. /**
  23951. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23952. * @param parsedTexture Define the JSON representation of the texture
  23953. * @param scene Define the scene the parsed texture should be instantiated in
  23954. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23955. * @returns The parsed texture if successful
  23956. */
  23957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23958. /**
  23959. * Creates a texture from its base 64 representation.
  23960. * @param data Define the base64 payload without the data: prefix
  23961. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23962. * @param scene Define the scene the texture should belong to
  23963. * @param noMipmap Forces the texture to not create mip map information if true
  23964. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23965. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23966. * @param onLoad define a callback triggered when the texture has been loaded
  23967. * @param onError define a callback triggered when an error occurred during the loading session
  23968. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23969. * @returns the created texture
  23970. */
  23971. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23972. /**
  23973. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23974. * @param data Define the base64 payload without the data: prefix
  23975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23976. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23977. * @param scene Define the scene the texture should belong to
  23978. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23979. * @param noMipmap Forces the texture to not create mip map information if true
  23980. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23981. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23982. * @param onLoad define a callback triggered when the texture has been loaded
  23983. * @param onError define a callback triggered when an error occurred during the loading session
  23984. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23985. * @returns the created texture
  23986. */
  23987. 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;
  23988. }
  23989. }
  23990. declare module "babylonjs/PostProcesses/postProcessManager" {
  23991. import { Nullable } from "babylonjs/types";
  23992. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23993. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23994. import { Scene } from "babylonjs/scene";
  23995. /**
  23996. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23997. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23998. */
  23999. export class PostProcessManager {
  24000. private _scene;
  24001. private _indexBuffer;
  24002. private _vertexBuffers;
  24003. /**
  24004. * Creates a new instance PostProcess
  24005. * @param scene The scene that the post process is associated with.
  24006. */
  24007. constructor(scene: Scene);
  24008. private _prepareBuffers;
  24009. private _buildIndexBuffer;
  24010. /**
  24011. * Rebuilds the vertex buffers of the manager.
  24012. * @hidden
  24013. */
  24014. _rebuild(): void;
  24015. /**
  24016. * Prepares a frame to be run through a post process.
  24017. * @param sourceTexture The input texture to the post procesess. (default: null)
  24018. * @param postProcesses An array of post processes to be run. (default: null)
  24019. * @returns True if the post processes were able to be run.
  24020. * @hidden
  24021. */
  24022. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24023. /**
  24024. * Manually render a set of post processes to a texture.
  24025. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24026. * @param postProcesses An array of post processes to be run.
  24027. * @param targetTexture The target texture to render to.
  24028. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24029. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24030. * @param lodLevel defines which lod of the texture to render to
  24031. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24032. */
  24033. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24034. /**
  24035. * Finalize the result of the output of the postprocesses.
  24036. * @param doNotPresent If true the result will not be displayed to the screen.
  24037. * @param targetTexture The target texture to render to.
  24038. * @param faceIndex The index of the face to bind the target texture to.
  24039. * @param postProcesses The array of post processes to render.
  24040. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24041. * @hidden
  24042. */
  24043. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24044. /**
  24045. * Disposes of the post process manager.
  24046. */
  24047. dispose(): void;
  24048. }
  24049. }
  24050. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24051. import { Observable } from "babylonjs/Misc/observable";
  24052. import { SmartArray } from "babylonjs/Misc/smartArray";
  24053. import { Nullable, Immutable } from "babylonjs/types";
  24054. import { Camera } from "babylonjs/Cameras/camera";
  24055. import { Scene } from "babylonjs/scene";
  24056. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24057. import { Color4 } from "babylonjs/Maths/math.color";
  24058. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24061. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24062. import { Texture } from "babylonjs/Materials/Textures/texture";
  24063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24064. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24065. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24066. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24067. import { Engine } from "babylonjs/Engines/engine";
  24068. /**
  24069. * This Helps creating a texture that will be created from a camera in your scene.
  24070. * It is basically a dynamic texture that could be used to create special effects for instance.
  24071. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24072. */
  24073. export class RenderTargetTexture extends Texture {
  24074. isCube: boolean;
  24075. /**
  24076. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24077. */
  24078. static readonly REFRESHRATE_RENDER_ONCE: number;
  24079. /**
  24080. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24081. */
  24082. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24083. /**
  24084. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24085. * the central point of your effect and can save a lot of performances.
  24086. */
  24087. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24088. /**
  24089. * Use this predicate to dynamically define the list of mesh you want to render.
  24090. * If set, the renderList property will be overwritten.
  24091. */
  24092. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24093. private _renderList;
  24094. /**
  24095. * Use this list to define the list of mesh you want to render.
  24096. */
  24097. get renderList(): Nullable<Array<AbstractMesh>>;
  24098. set renderList(value: Nullable<Array<AbstractMesh>>);
  24099. /**
  24100. * Use this function to overload the renderList array at rendering time.
  24101. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24102. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24103. * the cube (if the RTT is a cube, else layerOrFace=0).
  24104. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24105. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24106. * hold dummy elements!
  24107. */
  24108. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24109. private _hookArray;
  24110. /**
  24111. * Define if particles should be rendered in your texture.
  24112. */
  24113. renderParticles: boolean;
  24114. /**
  24115. * Define if sprites should be rendered in your texture.
  24116. */
  24117. renderSprites: boolean;
  24118. /**
  24119. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24120. */
  24121. coordinatesMode: number;
  24122. /**
  24123. * Define the camera used to render the texture.
  24124. */
  24125. activeCamera: Nullable<Camera>;
  24126. /**
  24127. * Override the mesh isReady function with your own one.
  24128. */
  24129. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24130. /**
  24131. * Override the render function of the texture with your own one.
  24132. */
  24133. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24134. /**
  24135. * Define if camera post processes should be use while rendering the texture.
  24136. */
  24137. useCameraPostProcesses: boolean;
  24138. /**
  24139. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24140. */
  24141. ignoreCameraViewport: boolean;
  24142. private _postProcessManager;
  24143. private _postProcesses;
  24144. private _resizeObserver;
  24145. /**
  24146. * An event triggered when the texture is unbind.
  24147. */
  24148. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24149. /**
  24150. * An event triggered when the texture is unbind.
  24151. */
  24152. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24153. private _onAfterUnbindObserver;
  24154. /**
  24155. * Set a after unbind callback in the texture.
  24156. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24157. */
  24158. set onAfterUnbind(callback: () => void);
  24159. /**
  24160. * An event triggered before rendering the texture
  24161. */
  24162. onBeforeRenderObservable: Observable<number>;
  24163. private _onBeforeRenderObserver;
  24164. /**
  24165. * Set a before render callback in the texture.
  24166. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24167. */
  24168. set onBeforeRender(callback: (faceIndex: number) => void);
  24169. /**
  24170. * An event triggered after rendering the texture
  24171. */
  24172. onAfterRenderObservable: Observable<number>;
  24173. private _onAfterRenderObserver;
  24174. /**
  24175. * Set a after render callback in the texture.
  24176. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24177. */
  24178. set onAfterRender(callback: (faceIndex: number) => void);
  24179. /**
  24180. * An event triggered after the texture clear
  24181. */
  24182. onClearObservable: Observable<Engine>;
  24183. private _onClearObserver;
  24184. /**
  24185. * Set a clear callback in the texture.
  24186. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24187. */
  24188. set onClear(callback: (Engine: Engine) => void);
  24189. /**
  24190. * An event triggered when the texture is resized.
  24191. */
  24192. onResizeObservable: Observable<RenderTargetTexture>;
  24193. /**
  24194. * Define the clear color of the Render Target if it should be different from the scene.
  24195. */
  24196. clearColor: Color4;
  24197. protected _size: number | {
  24198. width: number;
  24199. height: number;
  24200. layers?: number;
  24201. };
  24202. protected _initialSizeParameter: number | {
  24203. width: number;
  24204. height: number;
  24205. } | {
  24206. ratio: number;
  24207. };
  24208. protected _sizeRatio: Nullable<number>;
  24209. /** @hidden */
  24210. _generateMipMaps: boolean;
  24211. protected _renderingManager: RenderingManager;
  24212. /** @hidden */
  24213. _waitingRenderList: string[];
  24214. protected _doNotChangeAspectRatio: boolean;
  24215. protected _currentRefreshId: number;
  24216. protected _refreshRate: number;
  24217. protected _textureMatrix: Matrix;
  24218. protected _samples: number;
  24219. protected _renderTargetOptions: RenderTargetCreationOptions;
  24220. /**
  24221. * Gets render target creation options that were used.
  24222. */
  24223. get renderTargetOptions(): RenderTargetCreationOptions;
  24224. protected _onRatioRescale(): void;
  24225. /**
  24226. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24227. * It must define where the camera used to render the texture is set
  24228. */
  24229. boundingBoxPosition: Vector3;
  24230. private _boundingBoxSize;
  24231. /**
  24232. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24233. * When defined, the cubemap will switch to local mode
  24234. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24235. * @example https://www.babylonjs-playground.com/#RNASML
  24236. */
  24237. set boundingBoxSize(value: Vector3);
  24238. get boundingBoxSize(): Vector3;
  24239. /**
  24240. * In case the RTT has been created with a depth texture, get the associated
  24241. * depth texture.
  24242. * Otherwise, return null.
  24243. */
  24244. get depthStencilTexture(): Nullable<InternalTexture>;
  24245. /**
  24246. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24247. * or used a shadow, depth texture...
  24248. * @param name The friendly name of the texture
  24249. * @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)
  24250. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24251. * @param generateMipMaps True if mip maps need to be generated after render.
  24252. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24253. * @param type The type of the buffer in the RTT (int, half float, float...)
  24254. * @param isCube True if a cube texture needs to be created
  24255. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24256. * @param generateDepthBuffer True to generate a depth buffer
  24257. * @param generateStencilBuffer True to generate a stencil buffer
  24258. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24259. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24260. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24261. */
  24262. constructor(name: string, size: number | {
  24263. width: number;
  24264. height: number;
  24265. layers?: number;
  24266. } | {
  24267. ratio: number;
  24268. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24269. /**
  24270. * Creates a depth stencil texture.
  24271. * This is only available in WebGL 2 or with the depth texture extension available.
  24272. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24273. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24274. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24275. */
  24276. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24277. private _processSizeParameter;
  24278. /**
  24279. * Define the number of samples to use in case of MSAA.
  24280. * It defaults to one meaning no MSAA has been enabled.
  24281. */
  24282. get samples(): number;
  24283. set samples(value: number);
  24284. /**
  24285. * Resets the refresh counter of the texture and start bak from scratch.
  24286. * Could be useful to regenerate the texture if it is setup to render only once.
  24287. */
  24288. resetRefreshCounter(): void;
  24289. /**
  24290. * Define the refresh rate of the texture or the rendering frequency.
  24291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24292. */
  24293. get refreshRate(): number;
  24294. set refreshRate(value: number);
  24295. /**
  24296. * Adds a post process to the render target rendering passes.
  24297. * @param postProcess define the post process to add
  24298. */
  24299. addPostProcess(postProcess: PostProcess): void;
  24300. /**
  24301. * Clear all the post processes attached to the render target
  24302. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24303. */
  24304. clearPostProcesses(dispose?: boolean): void;
  24305. /**
  24306. * Remove one of the post process from the list of attached post processes to the texture
  24307. * @param postProcess define the post process to remove from the list
  24308. */
  24309. removePostProcess(postProcess: PostProcess): void;
  24310. /** @hidden */
  24311. _shouldRender(): boolean;
  24312. /**
  24313. * Gets the actual render size of the texture.
  24314. * @returns the width of the render size
  24315. */
  24316. getRenderSize(): number;
  24317. /**
  24318. * Gets the actual render width of the texture.
  24319. * @returns the width of the render size
  24320. */
  24321. getRenderWidth(): number;
  24322. /**
  24323. * Gets the actual render height of the texture.
  24324. * @returns the height of the render size
  24325. */
  24326. getRenderHeight(): number;
  24327. /**
  24328. * Gets the actual number of layers of the texture.
  24329. * @returns the number of layers
  24330. */
  24331. getRenderLayers(): number;
  24332. /**
  24333. * Get if the texture can be rescaled or not.
  24334. */
  24335. get canRescale(): boolean;
  24336. /**
  24337. * Resize the texture using a ratio.
  24338. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24339. */
  24340. scale(ratio: number): void;
  24341. /**
  24342. * Get the texture reflection matrix used to rotate/transform the reflection.
  24343. * @returns the reflection matrix
  24344. */
  24345. getReflectionTextureMatrix(): Matrix;
  24346. /**
  24347. * Resize the texture to a new desired size.
  24348. * Be carrefull as it will recreate all the data in the new texture.
  24349. * @param size Define the new size. It can be:
  24350. * - a number for squared texture,
  24351. * - an object containing { width: number, height: number }
  24352. * - or an object containing a ratio { ratio: number }
  24353. */
  24354. resize(size: number | {
  24355. width: number;
  24356. height: number;
  24357. } | {
  24358. ratio: number;
  24359. }): void;
  24360. private _defaultRenderListPrepared;
  24361. /**
  24362. * Renders all the objects from the render list into the texture.
  24363. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24364. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24365. */
  24366. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24367. private _bestReflectionRenderTargetDimension;
  24368. private _prepareRenderingManager;
  24369. /**
  24370. * @hidden
  24371. * @param faceIndex face index to bind to if this is a cubetexture
  24372. * @param layer defines the index of the texture to bind in the array
  24373. */
  24374. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24375. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24376. private renderToTarget;
  24377. /**
  24378. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24379. * This allowed control for front to back rendering or reversly depending of the special needs.
  24380. *
  24381. * @param renderingGroupId The rendering group id corresponding to its index
  24382. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24383. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24384. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24385. */
  24386. 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;
  24387. /**
  24388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24389. *
  24390. * @param renderingGroupId The rendering group id corresponding to its index
  24391. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24392. */
  24393. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24394. /**
  24395. * Clones the texture.
  24396. * @returns the cloned texture
  24397. */
  24398. clone(): RenderTargetTexture;
  24399. /**
  24400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24401. * @returns The JSON representation of the texture
  24402. */
  24403. serialize(): any;
  24404. /**
  24405. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24406. */
  24407. disposeFramebufferObjects(): void;
  24408. /**
  24409. * Dispose the texture and release its associated resources.
  24410. */
  24411. dispose(): void;
  24412. /** @hidden */
  24413. _rebuild(): void;
  24414. /**
  24415. * Clear the info related to rendering groups preventing retention point in material dispose.
  24416. */
  24417. freeRenderingGroups(): void;
  24418. /**
  24419. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24420. * @returns the view count
  24421. */
  24422. getViewCount(): number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Misc/guid" {
  24426. /**
  24427. * Class used to manipulate GUIDs
  24428. */
  24429. export class GUID {
  24430. /**
  24431. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24432. * Be aware Math.random() could cause collisions, but:
  24433. * "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"
  24434. * @returns a pseudo random id
  24435. */
  24436. static RandomId(): string;
  24437. }
  24438. }
  24439. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24440. import { Nullable } from "babylonjs/types";
  24441. import { Scene } from "babylonjs/scene";
  24442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24443. import { Material } from "babylonjs/Materials/material";
  24444. import { Effect } from "babylonjs/Materials/effect";
  24445. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24446. /**
  24447. * Options to be used when creating a shadow depth material
  24448. */
  24449. export interface IIOptionShadowDepthMaterial {
  24450. /** Variables in the vertex shader code that need to have their names remapped.
  24451. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24452. * "var_name" should be either: worldPos or vNormalW
  24453. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24454. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24455. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24456. */
  24457. remappedVariables?: string[];
  24458. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24459. standalone?: boolean;
  24460. }
  24461. /**
  24462. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24463. */
  24464. export class ShadowDepthWrapper {
  24465. private _scene;
  24466. private _options?;
  24467. private _baseMaterial;
  24468. private _onEffectCreatedObserver;
  24469. private _subMeshToEffect;
  24470. private _subMeshToDepthEffect;
  24471. private _meshes;
  24472. /** @hidden */
  24473. _matriceNames: any;
  24474. /** Gets the standalone status of the wrapper */
  24475. get standalone(): boolean;
  24476. /** Gets the base material the wrapper is built upon */
  24477. get baseMaterial(): Material;
  24478. /**
  24479. * Instantiate a new shadow depth wrapper.
  24480. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24481. * generate the shadow depth map. For more information, please refer to the documentation:
  24482. * https://doc.babylonjs.com/babylon101/shadows
  24483. * @param baseMaterial Material to wrap
  24484. * @param scene Define the scene the material belongs to
  24485. * @param options Options used to create the wrapper
  24486. */
  24487. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24488. /**
  24489. * Gets the effect to use to generate the depth map
  24490. * @param subMesh subMesh to get the effect for
  24491. * @param shadowGenerator shadow generator to get the effect for
  24492. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24493. */
  24494. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24495. /**
  24496. * Specifies that the submesh is ready to be used for depth rendering
  24497. * @param subMesh submesh to check
  24498. * @param defines the list of defines to take into account when checking the effect
  24499. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24500. * @param useInstances specifies that instances should be used
  24501. * @returns a boolean indicating that the submesh is ready or not
  24502. */
  24503. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24504. /**
  24505. * Disposes the resources
  24506. */
  24507. dispose(): void;
  24508. private _makeEffect;
  24509. }
  24510. }
  24511. declare module "babylonjs/Materials/material" {
  24512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24513. import { SmartArray } from "babylonjs/Misc/smartArray";
  24514. import { Observable } from "babylonjs/Misc/observable";
  24515. import { Nullable } from "babylonjs/types";
  24516. import { Scene } from "babylonjs/scene";
  24517. import { Matrix } from "babylonjs/Maths/math.vector";
  24518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24520. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24521. import { Effect } from "babylonjs/Materials/effect";
  24522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24523. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24524. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24525. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24526. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24527. import { Mesh } from "babylonjs/Meshes/mesh";
  24528. import { Animation } from "babylonjs/Animations/animation";
  24529. /**
  24530. * Options for compiling materials.
  24531. */
  24532. export interface IMaterialCompilationOptions {
  24533. /**
  24534. * Defines whether clip planes are enabled.
  24535. */
  24536. clipPlane: boolean;
  24537. /**
  24538. * Defines whether instances are enabled.
  24539. */
  24540. useInstances: boolean;
  24541. }
  24542. /**
  24543. * Options passed when calling customShaderNameResolve
  24544. */
  24545. export interface ICustomShaderNameResolveOptions {
  24546. /**
  24547. * 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
  24548. */
  24549. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24550. }
  24551. /**
  24552. * Base class for the main features of a material in Babylon.js
  24553. */
  24554. export class Material implements IAnimatable {
  24555. /**
  24556. * Returns the triangle fill mode
  24557. */
  24558. static readonly TriangleFillMode: number;
  24559. /**
  24560. * Returns the wireframe mode
  24561. */
  24562. static readonly WireFrameFillMode: number;
  24563. /**
  24564. * Returns the point fill mode
  24565. */
  24566. static readonly PointFillMode: number;
  24567. /**
  24568. * Returns the point list draw mode
  24569. */
  24570. static readonly PointListDrawMode: number;
  24571. /**
  24572. * Returns the line list draw mode
  24573. */
  24574. static readonly LineListDrawMode: number;
  24575. /**
  24576. * Returns the line loop draw mode
  24577. */
  24578. static readonly LineLoopDrawMode: number;
  24579. /**
  24580. * Returns the line strip draw mode
  24581. */
  24582. static readonly LineStripDrawMode: number;
  24583. /**
  24584. * Returns the triangle strip draw mode
  24585. */
  24586. static readonly TriangleStripDrawMode: number;
  24587. /**
  24588. * Returns the triangle fan draw mode
  24589. */
  24590. static readonly TriangleFanDrawMode: number;
  24591. /**
  24592. * Stores the clock-wise side orientation
  24593. */
  24594. static readonly ClockWiseSideOrientation: number;
  24595. /**
  24596. * Stores the counter clock-wise side orientation
  24597. */
  24598. static readonly CounterClockWiseSideOrientation: number;
  24599. /**
  24600. * The dirty texture flag value
  24601. */
  24602. static readonly TextureDirtyFlag: number;
  24603. /**
  24604. * The dirty light flag value
  24605. */
  24606. static readonly LightDirtyFlag: number;
  24607. /**
  24608. * The dirty fresnel flag value
  24609. */
  24610. static readonly FresnelDirtyFlag: number;
  24611. /**
  24612. * The dirty attribute flag value
  24613. */
  24614. static readonly AttributesDirtyFlag: number;
  24615. /**
  24616. * The dirty misc flag value
  24617. */
  24618. static readonly MiscDirtyFlag: number;
  24619. /**
  24620. * The all dirty flag value
  24621. */
  24622. static readonly AllDirtyFlag: number;
  24623. /**
  24624. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24625. */
  24626. static readonly MATERIAL_OPAQUE: number;
  24627. /**
  24628. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24629. */
  24630. static readonly MATERIAL_ALPHATEST: number;
  24631. /**
  24632. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24633. */
  24634. static readonly MATERIAL_ALPHABLEND: number;
  24635. /**
  24636. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24637. * They are also discarded below the alpha cutoff threshold to improve performances.
  24638. */
  24639. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24640. /**
  24641. * The Whiteout method is used to blend normals.
  24642. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24643. */
  24644. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24645. /**
  24646. * The Reoriented Normal Mapping method is used to blend normals.
  24647. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24648. */
  24649. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24650. /**
  24651. * Custom callback helping to override the default shader used in the material.
  24652. */
  24653. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24654. /**
  24655. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24656. */
  24657. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24658. /**
  24659. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24660. * This means that the material can keep using a previous shader while a new one is being compiled.
  24661. * This is mostly used when shader parallel compilation is supported (true by default)
  24662. */
  24663. allowShaderHotSwapping: boolean;
  24664. /**
  24665. * The ID of the material
  24666. */
  24667. id: string;
  24668. /**
  24669. * Gets or sets the unique id of the material
  24670. */
  24671. uniqueId: number;
  24672. /**
  24673. * The name of the material
  24674. */
  24675. name: string;
  24676. /**
  24677. * Gets or sets user defined metadata
  24678. */
  24679. metadata: any;
  24680. /**
  24681. * For internal use only. Please do not use.
  24682. */
  24683. reservedDataStore: any;
  24684. /**
  24685. * Specifies if the ready state should be checked on each call
  24686. */
  24687. checkReadyOnEveryCall: boolean;
  24688. /**
  24689. * Specifies if the ready state should be checked once
  24690. */
  24691. checkReadyOnlyOnce: boolean;
  24692. /**
  24693. * The state of the material
  24694. */
  24695. state: string;
  24696. /**
  24697. * If the material should be rendered to several textures with MRT extension
  24698. */
  24699. get shouldRenderToMRT(): boolean;
  24700. /**
  24701. * The alpha value of the material
  24702. */
  24703. protected _alpha: number;
  24704. /**
  24705. * List of inspectable custom properties (used by the Inspector)
  24706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24707. */
  24708. inspectableCustomProperties: IInspectable[];
  24709. /**
  24710. * Sets the alpha value of the material
  24711. */
  24712. set alpha(value: number);
  24713. /**
  24714. * Gets the alpha value of the material
  24715. */
  24716. get alpha(): number;
  24717. /**
  24718. * Specifies if back face culling is enabled
  24719. */
  24720. protected _backFaceCulling: boolean;
  24721. /**
  24722. * Sets the back-face culling state
  24723. */
  24724. set backFaceCulling(value: boolean);
  24725. /**
  24726. * Gets the back-face culling state
  24727. */
  24728. get backFaceCulling(): boolean;
  24729. /**
  24730. * Stores the value for side orientation
  24731. */
  24732. sideOrientation: number;
  24733. /**
  24734. * Callback triggered when the material is compiled
  24735. */
  24736. onCompiled: Nullable<(effect: Effect) => void>;
  24737. /**
  24738. * Callback triggered when an error occurs
  24739. */
  24740. onError: Nullable<(effect: Effect, errors: string) => void>;
  24741. /**
  24742. * Callback triggered to get the render target textures
  24743. */
  24744. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24745. /**
  24746. * Gets a boolean indicating that current material needs to register RTT
  24747. */
  24748. get hasRenderTargetTextures(): boolean;
  24749. /**
  24750. * Specifies if the material should be serialized
  24751. */
  24752. doNotSerialize: boolean;
  24753. /**
  24754. * @hidden
  24755. */
  24756. _storeEffectOnSubMeshes: boolean;
  24757. /**
  24758. * Stores the animations for the material
  24759. */
  24760. animations: Nullable<Array<Animation>>;
  24761. /**
  24762. * An event triggered when the material is disposed
  24763. */
  24764. onDisposeObservable: Observable<Material>;
  24765. /**
  24766. * An observer which watches for dispose events
  24767. */
  24768. private _onDisposeObserver;
  24769. private _onUnBindObservable;
  24770. /**
  24771. * Called during a dispose event
  24772. */
  24773. set onDispose(callback: () => void);
  24774. private _onBindObservable;
  24775. /**
  24776. * An event triggered when the material is bound
  24777. */
  24778. get onBindObservable(): Observable<AbstractMesh>;
  24779. /**
  24780. * An observer which watches for bind events
  24781. */
  24782. private _onBindObserver;
  24783. /**
  24784. * Called during a bind event
  24785. */
  24786. set onBind(callback: (Mesh: AbstractMesh) => void);
  24787. /**
  24788. * An event triggered when the material is unbound
  24789. */
  24790. get onUnBindObservable(): Observable<Material>;
  24791. protected _onEffectCreatedObservable: Nullable<Observable<{
  24792. effect: Effect;
  24793. subMesh: Nullable<SubMesh>;
  24794. }>>;
  24795. /**
  24796. * An event triggered when the effect is (re)created
  24797. */
  24798. get onEffectCreatedObservable(): Observable<{
  24799. effect: Effect;
  24800. subMesh: Nullable<SubMesh>;
  24801. }>;
  24802. /**
  24803. * Stores the value of the alpha mode
  24804. */
  24805. private _alphaMode;
  24806. /**
  24807. * Sets the value of the alpha mode.
  24808. *
  24809. * | Value | Type | Description |
  24810. * | --- | --- | --- |
  24811. * | 0 | ALPHA_DISABLE | |
  24812. * | 1 | ALPHA_ADD | |
  24813. * | 2 | ALPHA_COMBINE | |
  24814. * | 3 | ALPHA_SUBTRACT | |
  24815. * | 4 | ALPHA_MULTIPLY | |
  24816. * | 5 | ALPHA_MAXIMIZED | |
  24817. * | 6 | ALPHA_ONEONE | |
  24818. * | 7 | ALPHA_PREMULTIPLIED | |
  24819. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24820. * | 9 | ALPHA_INTERPOLATE | |
  24821. * | 10 | ALPHA_SCREENMODE | |
  24822. *
  24823. */
  24824. set alphaMode(value: number);
  24825. /**
  24826. * Gets the value of the alpha mode
  24827. */
  24828. get alphaMode(): number;
  24829. /**
  24830. * Stores the state of the need depth pre-pass value
  24831. */
  24832. private _needDepthPrePass;
  24833. /**
  24834. * Sets the need depth pre-pass value
  24835. */
  24836. set needDepthPrePass(value: boolean);
  24837. /**
  24838. * Gets the depth pre-pass value
  24839. */
  24840. get needDepthPrePass(): boolean;
  24841. /**
  24842. * Specifies if depth writing should be disabled
  24843. */
  24844. disableDepthWrite: boolean;
  24845. /**
  24846. * Specifies if color writing should be disabled
  24847. */
  24848. disableColorWrite: boolean;
  24849. /**
  24850. * Specifies if depth writing should be forced
  24851. */
  24852. forceDepthWrite: boolean;
  24853. /**
  24854. * Specifies the depth function that should be used. 0 means the default engine function
  24855. */
  24856. depthFunction: number;
  24857. /**
  24858. * Specifies if there should be a separate pass for culling
  24859. */
  24860. separateCullingPass: boolean;
  24861. /**
  24862. * Stores the state specifing if fog should be enabled
  24863. */
  24864. private _fogEnabled;
  24865. /**
  24866. * Sets the state for enabling fog
  24867. */
  24868. set fogEnabled(value: boolean);
  24869. /**
  24870. * Gets the value of the fog enabled state
  24871. */
  24872. get fogEnabled(): boolean;
  24873. /**
  24874. * Stores the size of points
  24875. */
  24876. pointSize: number;
  24877. /**
  24878. * Stores the z offset value
  24879. */
  24880. zOffset: number;
  24881. get wireframe(): boolean;
  24882. /**
  24883. * Sets the state of wireframe mode
  24884. */
  24885. set wireframe(value: boolean);
  24886. /**
  24887. * Gets the value specifying if point clouds are enabled
  24888. */
  24889. get pointsCloud(): boolean;
  24890. /**
  24891. * Sets the state of point cloud mode
  24892. */
  24893. set pointsCloud(value: boolean);
  24894. /**
  24895. * Gets the material fill mode
  24896. */
  24897. get fillMode(): number;
  24898. /**
  24899. * Sets the material fill mode
  24900. */
  24901. set fillMode(value: number);
  24902. /**
  24903. * @hidden
  24904. * Stores the effects for the material
  24905. */
  24906. _effect: Nullable<Effect>;
  24907. /**
  24908. * Specifies if uniform buffers should be used
  24909. */
  24910. private _useUBO;
  24911. /**
  24912. * Stores a reference to the scene
  24913. */
  24914. private _scene;
  24915. /**
  24916. * Stores the fill mode state
  24917. */
  24918. private _fillMode;
  24919. /**
  24920. * Specifies if the depth write state should be cached
  24921. */
  24922. private _cachedDepthWriteState;
  24923. /**
  24924. * Specifies if the color write state should be cached
  24925. */
  24926. private _cachedColorWriteState;
  24927. /**
  24928. * Specifies if the depth function state should be cached
  24929. */
  24930. private _cachedDepthFunctionState;
  24931. /**
  24932. * Stores the uniform buffer
  24933. */
  24934. protected _uniformBuffer: UniformBuffer;
  24935. /** @hidden */
  24936. _indexInSceneMaterialArray: number;
  24937. /** @hidden */
  24938. meshMap: Nullable<{
  24939. [id: string]: AbstractMesh | undefined;
  24940. }>;
  24941. /**
  24942. * Creates a material instance
  24943. * @param name defines the name of the material
  24944. * @param scene defines the scene to reference
  24945. * @param doNotAdd specifies if the material should be added to the scene
  24946. */
  24947. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24948. /**
  24949. * Returns a string representation of the current material
  24950. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24951. * @returns a string with material information
  24952. */
  24953. toString(fullDetails?: boolean): string;
  24954. /**
  24955. * Gets the class name of the material
  24956. * @returns a string with the class name of the material
  24957. */
  24958. getClassName(): string;
  24959. /**
  24960. * Specifies if updates for the material been locked
  24961. */
  24962. get isFrozen(): boolean;
  24963. /**
  24964. * Locks updates for the material
  24965. */
  24966. freeze(): void;
  24967. /**
  24968. * Unlocks updates for the material
  24969. */
  24970. unfreeze(): void;
  24971. /**
  24972. * Specifies if the material is ready to be used
  24973. * @param mesh defines the mesh to check
  24974. * @param useInstances specifies if instances should be used
  24975. * @returns a boolean indicating if the material is ready to be used
  24976. */
  24977. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24978. /**
  24979. * Specifies that the submesh is ready to be used
  24980. * @param mesh defines the mesh to check
  24981. * @param subMesh defines which submesh to check
  24982. * @param useInstances specifies that instances should be used
  24983. * @returns a boolean indicating that the submesh is ready or not
  24984. */
  24985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24986. /**
  24987. * Returns the material effect
  24988. * @returns the effect associated with the material
  24989. */
  24990. getEffect(): Nullable<Effect>;
  24991. /**
  24992. * Returns the current scene
  24993. * @returns a Scene
  24994. */
  24995. getScene(): Scene;
  24996. /**
  24997. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24998. */
  24999. protected _forceAlphaTest: boolean;
  25000. /**
  25001. * The transparency mode of the material.
  25002. */
  25003. protected _transparencyMode: Nullable<number>;
  25004. /**
  25005. * Gets the current transparency mode.
  25006. */
  25007. get transparencyMode(): Nullable<number>;
  25008. /**
  25009. * Sets the transparency mode of the material.
  25010. *
  25011. * | Value | Type | Description |
  25012. * | ----- | ----------------------------------- | ----------- |
  25013. * | 0 | OPAQUE | |
  25014. * | 1 | ALPHATEST | |
  25015. * | 2 | ALPHABLEND | |
  25016. * | 3 | ALPHATESTANDBLEND | |
  25017. *
  25018. */
  25019. set transparencyMode(value: Nullable<number>);
  25020. /**
  25021. * Returns true if alpha blending should be disabled.
  25022. */
  25023. protected get _disableAlphaBlending(): boolean;
  25024. /**
  25025. * Specifies whether or not this material should be rendered in alpha blend mode.
  25026. * @returns a boolean specifying if alpha blending is needed
  25027. */
  25028. needAlphaBlending(): boolean;
  25029. /**
  25030. * Specifies if the mesh will require alpha blending
  25031. * @param mesh defines the mesh to check
  25032. * @returns a boolean specifying if alpha blending is needed for the mesh
  25033. */
  25034. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25035. /**
  25036. * Specifies whether or not this material should be rendered in alpha test mode.
  25037. * @returns a boolean specifying if an alpha test is needed.
  25038. */
  25039. needAlphaTesting(): boolean;
  25040. /**
  25041. * Specifies if material alpha testing should be turned on for the mesh
  25042. * @param mesh defines the mesh to check
  25043. */
  25044. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25045. /**
  25046. * Gets the texture used for the alpha test
  25047. * @returns the texture to use for alpha testing
  25048. */
  25049. getAlphaTestTexture(): Nullable<BaseTexture>;
  25050. /**
  25051. * Marks the material to indicate that it needs to be re-calculated
  25052. */
  25053. markDirty(): void;
  25054. /** @hidden */
  25055. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25056. /**
  25057. * Binds the material to the mesh
  25058. * @param world defines the world transformation matrix
  25059. * @param mesh defines the mesh to bind the material to
  25060. */
  25061. bind(world: Matrix, mesh?: Mesh): void;
  25062. /**
  25063. * Binds the submesh to the material
  25064. * @param world defines the world transformation matrix
  25065. * @param mesh defines the mesh containing the submesh
  25066. * @param subMesh defines the submesh to bind the material to
  25067. */
  25068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25069. /**
  25070. * Binds the world matrix to the material
  25071. * @param world defines the world transformation matrix
  25072. */
  25073. bindOnlyWorldMatrix(world: Matrix): void;
  25074. /**
  25075. * Binds the scene's uniform buffer to the effect.
  25076. * @param effect defines the effect to bind to the scene uniform buffer
  25077. * @param sceneUbo defines the uniform buffer storing scene data
  25078. */
  25079. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25080. /**
  25081. * Binds the view matrix to the effect
  25082. * @param effect defines the effect to bind the view matrix to
  25083. */
  25084. bindView(effect: Effect): void;
  25085. /**
  25086. * Binds the view projection matrix to the effect
  25087. * @param effect defines the effect to bind the view projection matrix to
  25088. */
  25089. bindViewProjection(effect: Effect): void;
  25090. /**
  25091. * Processes to execute after binding the material to a mesh
  25092. * @param mesh defines the rendered mesh
  25093. */
  25094. protected _afterBind(mesh?: Mesh): void;
  25095. /**
  25096. * Unbinds the material from the mesh
  25097. */
  25098. unbind(): void;
  25099. /**
  25100. * Gets the active textures from the material
  25101. * @returns an array of textures
  25102. */
  25103. getActiveTextures(): BaseTexture[];
  25104. /**
  25105. * Specifies if the material uses a texture
  25106. * @param texture defines the texture to check against the material
  25107. * @returns a boolean specifying if the material uses the texture
  25108. */
  25109. hasTexture(texture: BaseTexture): boolean;
  25110. /**
  25111. * Makes a duplicate of the material, and gives it a new name
  25112. * @param name defines the new name for the duplicated material
  25113. * @returns the cloned material
  25114. */
  25115. clone(name: string): Nullable<Material>;
  25116. /**
  25117. * Gets the meshes bound to the material
  25118. * @returns an array of meshes bound to the material
  25119. */
  25120. getBindedMeshes(): AbstractMesh[];
  25121. /**
  25122. * Force shader compilation
  25123. * @param mesh defines the mesh associated with this material
  25124. * @param onCompiled defines a function to execute once the material is compiled
  25125. * @param options defines the options to configure the compilation
  25126. * @param onError defines a function to execute if the material fails compiling
  25127. */
  25128. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25129. /**
  25130. * Force shader compilation
  25131. * @param mesh defines the mesh that will use this material
  25132. * @param options defines additional options for compiling the shaders
  25133. * @returns a promise that resolves when the compilation completes
  25134. */
  25135. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25136. private static readonly _AllDirtyCallBack;
  25137. private static readonly _ImageProcessingDirtyCallBack;
  25138. private static readonly _TextureDirtyCallBack;
  25139. private static readonly _FresnelDirtyCallBack;
  25140. private static readonly _MiscDirtyCallBack;
  25141. private static readonly _LightsDirtyCallBack;
  25142. private static readonly _AttributeDirtyCallBack;
  25143. private static _FresnelAndMiscDirtyCallBack;
  25144. private static _TextureAndMiscDirtyCallBack;
  25145. private static readonly _DirtyCallbackArray;
  25146. private static readonly _RunDirtyCallBacks;
  25147. /**
  25148. * Marks a define in the material to indicate that it needs to be re-computed
  25149. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25150. */
  25151. markAsDirty(flag: number): void;
  25152. /**
  25153. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25154. * @param func defines a function which checks material defines against the submeshes
  25155. */
  25156. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25157. /**
  25158. * Indicates that the scene should check if the rendering now needs a prepass
  25159. */
  25160. protected _markScenePrePassDirty(): void;
  25161. /**
  25162. * Indicates that we need to re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsAllDirty(): void;
  25165. /**
  25166. * Indicates that image processing needs to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25169. /**
  25170. * Indicates that textures need to be re-calculated for all submeshes
  25171. */
  25172. protected _markAllSubMeshesAsTexturesDirty(): void;
  25173. /**
  25174. * Indicates that fresnel needs to be re-calculated for all submeshes
  25175. */
  25176. protected _markAllSubMeshesAsFresnelDirty(): void;
  25177. /**
  25178. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25179. */
  25180. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25181. /**
  25182. * Indicates that lights need to be re-calculated for all submeshes
  25183. */
  25184. protected _markAllSubMeshesAsLightsDirty(): void;
  25185. /**
  25186. * Indicates that attributes need to be re-calculated for all submeshes
  25187. */
  25188. protected _markAllSubMeshesAsAttributesDirty(): void;
  25189. /**
  25190. * Indicates that misc needs to be re-calculated for all submeshes
  25191. */
  25192. protected _markAllSubMeshesAsMiscDirty(): void;
  25193. /**
  25194. * Indicates that textures and misc need to be re-calculated for all submeshes
  25195. */
  25196. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25197. /**
  25198. * Disposes the material
  25199. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25200. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25201. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25202. */
  25203. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25204. /** @hidden */
  25205. private releaseVertexArrayObject;
  25206. /**
  25207. * Serializes this material
  25208. * @returns the serialized material object
  25209. */
  25210. serialize(): any;
  25211. /**
  25212. * Creates a material from parsed material data
  25213. * @param parsedMaterial defines parsed material data
  25214. * @param scene defines the hosting scene
  25215. * @param rootUrl defines the root URL to use to load textures
  25216. * @returns a new material
  25217. */
  25218. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25219. }
  25220. }
  25221. declare module "babylonjs/Materials/multiMaterial" {
  25222. import { Nullable } from "babylonjs/types";
  25223. import { Scene } from "babylonjs/scene";
  25224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25227. import { Material } from "babylonjs/Materials/material";
  25228. /**
  25229. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25230. * separate meshes. This can be use to improve performances.
  25231. * @see https://doc.babylonjs.com/how_to/multi_materials
  25232. */
  25233. export class MultiMaterial extends Material {
  25234. private _subMaterials;
  25235. /**
  25236. * Gets or Sets the list of Materials used within the multi material.
  25237. * They need to be ordered according to the submeshes order in the associated mesh
  25238. */
  25239. get subMaterials(): Nullable<Material>[];
  25240. set subMaterials(value: Nullable<Material>[]);
  25241. /**
  25242. * Function used to align with Node.getChildren()
  25243. * @returns the list of Materials used within the multi material
  25244. */
  25245. getChildren(): Nullable<Material>[];
  25246. /**
  25247. * Instantiates a new Multi Material
  25248. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25249. * separate meshes. This can be use to improve performances.
  25250. * @see https://doc.babylonjs.com/how_to/multi_materials
  25251. * @param name Define the name in the scene
  25252. * @param scene Define the scene the material belongs to
  25253. */
  25254. constructor(name: string, scene: Scene);
  25255. private _hookArray;
  25256. /**
  25257. * Get one of the submaterial by its index in the submaterials array
  25258. * @param index The index to look the sub material at
  25259. * @returns The Material if the index has been defined
  25260. */
  25261. getSubMaterial(index: number): Nullable<Material>;
  25262. /**
  25263. * Get the list of active textures for the whole sub materials list.
  25264. * @returns All the textures that will be used during the rendering
  25265. */
  25266. getActiveTextures(): BaseTexture[];
  25267. /**
  25268. * Gets the current class name of the material e.g. "MultiMaterial"
  25269. * Mainly use in serialization.
  25270. * @returns the class name
  25271. */
  25272. getClassName(): string;
  25273. /**
  25274. * Checks if the material is ready to render the requested sub mesh
  25275. * @param mesh Define the mesh the submesh belongs to
  25276. * @param subMesh Define the sub mesh to look readyness for
  25277. * @param useInstances Define whether or not the material is used with instances
  25278. * @returns true if ready, otherwise false
  25279. */
  25280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25281. /**
  25282. * Clones the current material and its related sub materials
  25283. * @param name Define the name of the newly cloned material
  25284. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25285. * @returns the cloned material
  25286. */
  25287. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25288. /**
  25289. * Serializes the materials into a JSON representation.
  25290. * @returns the JSON representation
  25291. */
  25292. serialize(): any;
  25293. /**
  25294. * Dispose the material and release its associated resources
  25295. * @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)
  25296. * @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)
  25297. * @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)
  25298. */
  25299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25300. /**
  25301. * Creates a MultiMaterial from parsed MultiMaterial data.
  25302. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25303. * @param scene defines the hosting scene
  25304. * @returns a new MultiMaterial
  25305. */
  25306. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25307. }
  25308. }
  25309. declare module "babylonjs/Meshes/subMesh" {
  25310. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25311. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25312. import { Engine } from "babylonjs/Engines/engine";
  25313. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25314. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25315. import { Effect } from "babylonjs/Materials/effect";
  25316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25317. import { Plane } from "babylonjs/Maths/math.plane";
  25318. import { Collider } from "babylonjs/Collisions/collider";
  25319. import { Material } from "babylonjs/Materials/material";
  25320. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25322. import { Mesh } from "babylonjs/Meshes/mesh";
  25323. import { Ray } from "babylonjs/Culling/ray";
  25324. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25325. /**
  25326. * Defines a subdivision inside a mesh
  25327. */
  25328. export class SubMesh implements ICullable {
  25329. /** the material index to use */
  25330. materialIndex: number;
  25331. /** vertex index start */
  25332. verticesStart: number;
  25333. /** vertices count */
  25334. verticesCount: number;
  25335. /** index start */
  25336. indexStart: number;
  25337. /** indices count */
  25338. indexCount: number;
  25339. /** @hidden */
  25340. _materialDefines: Nullable<MaterialDefines>;
  25341. /** @hidden */
  25342. _materialEffect: Nullable<Effect>;
  25343. /** @hidden */
  25344. _effectOverride: Nullable<Effect>;
  25345. /**
  25346. * Gets material defines used by the effect associated to the sub mesh
  25347. */
  25348. get materialDefines(): Nullable<MaterialDefines>;
  25349. /**
  25350. * Sets material defines used by the effect associated to the sub mesh
  25351. */
  25352. set materialDefines(defines: Nullable<MaterialDefines>);
  25353. /**
  25354. * Gets associated effect
  25355. */
  25356. get effect(): Nullable<Effect>;
  25357. /**
  25358. * Sets associated effect (effect used to render this submesh)
  25359. * @param effect defines the effect to associate with
  25360. * @param defines defines the set of defines used to compile this effect
  25361. */
  25362. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25363. /** @hidden */
  25364. _linesIndexCount: number;
  25365. private _mesh;
  25366. private _renderingMesh;
  25367. private _boundingInfo;
  25368. private _linesIndexBuffer;
  25369. /** @hidden */
  25370. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25371. /** @hidden */
  25372. _trianglePlanes: Plane[];
  25373. /** @hidden */
  25374. _lastColliderTransformMatrix: Nullable<Matrix>;
  25375. /** @hidden */
  25376. _renderId: number;
  25377. /** @hidden */
  25378. _alphaIndex: number;
  25379. /** @hidden */
  25380. _distanceToCamera: number;
  25381. /** @hidden */
  25382. _id: number;
  25383. private _currentMaterial;
  25384. /**
  25385. * Add a new submesh to a mesh
  25386. * @param materialIndex defines the material index to use
  25387. * @param verticesStart defines vertex index start
  25388. * @param verticesCount defines vertices count
  25389. * @param indexStart defines index start
  25390. * @param indexCount defines indices count
  25391. * @param mesh defines the parent mesh
  25392. * @param renderingMesh defines an optional rendering mesh
  25393. * @param createBoundingBox defines if bounding box should be created for this submesh
  25394. * @returns the new submesh
  25395. */
  25396. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25397. /**
  25398. * Creates a new submesh
  25399. * @param materialIndex defines the material index to use
  25400. * @param verticesStart defines vertex index start
  25401. * @param verticesCount defines vertices count
  25402. * @param indexStart defines index start
  25403. * @param indexCount defines indices count
  25404. * @param mesh defines the parent mesh
  25405. * @param renderingMesh defines an optional rendering mesh
  25406. * @param createBoundingBox defines if bounding box should be created for this submesh
  25407. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25408. */
  25409. constructor(
  25410. /** the material index to use */
  25411. materialIndex: number,
  25412. /** vertex index start */
  25413. verticesStart: number,
  25414. /** vertices count */
  25415. verticesCount: number,
  25416. /** index start */
  25417. indexStart: number,
  25418. /** indices count */
  25419. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25420. /**
  25421. * Returns true if this submesh covers the entire parent mesh
  25422. * @ignorenaming
  25423. */
  25424. get IsGlobal(): boolean;
  25425. /**
  25426. * Returns the submesh BoudingInfo object
  25427. * @returns current bounding info (or mesh's one if the submesh is global)
  25428. */
  25429. getBoundingInfo(): BoundingInfo;
  25430. /**
  25431. * Sets the submesh BoundingInfo
  25432. * @param boundingInfo defines the new bounding info to use
  25433. * @returns the SubMesh
  25434. */
  25435. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25436. /**
  25437. * Returns the mesh of the current submesh
  25438. * @return the parent mesh
  25439. */
  25440. getMesh(): AbstractMesh;
  25441. /**
  25442. * Returns the rendering mesh of the submesh
  25443. * @returns the rendering mesh (could be different from parent mesh)
  25444. */
  25445. getRenderingMesh(): Mesh;
  25446. /**
  25447. * Returns the replacement mesh of the submesh
  25448. * @returns the replacement mesh (could be different from parent mesh)
  25449. */
  25450. getReplacementMesh(): Nullable<AbstractMesh>;
  25451. /**
  25452. * Returns the effective mesh of the submesh
  25453. * @returns the effective mesh (could be different from parent mesh)
  25454. */
  25455. getEffectiveMesh(): AbstractMesh;
  25456. /**
  25457. * Returns the submesh material
  25458. * @returns null or the current material
  25459. */
  25460. getMaterial(): Nullable<Material>;
  25461. private _IsMultiMaterial;
  25462. /**
  25463. * Sets a new updated BoundingInfo object to the submesh
  25464. * @param data defines an optional position array to use to determine the bounding info
  25465. * @returns the SubMesh
  25466. */
  25467. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25468. /** @hidden */
  25469. _checkCollision(collider: Collider): boolean;
  25470. /**
  25471. * Updates the submesh BoundingInfo
  25472. * @param world defines the world matrix to use to update the bounding info
  25473. * @returns the submesh
  25474. */
  25475. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25476. /**
  25477. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25478. * @param frustumPlanes defines the frustum planes
  25479. * @returns true if the submesh is intersecting with the frustum
  25480. */
  25481. isInFrustum(frustumPlanes: Plane[]): boolean;
  25482. /**
  25483. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25484. * @param frustumPlanes defines the frustum planes
  25485. * @returns true if the submesh is inside the frustum
  25486. */
  25487. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25488. /**
  25489. * Renders the submesh
  25490. * @param enableAlphaMode defines if alpha needs to be used
  25491. * @returns the submesh
  25492. */
  25493. render(enableAlphaMode: boolean): SubMesh;
  25494. /**
  25495. * @hidden
  25496. */
  25497. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25498. /**
  25499. * Checks if the submesh intersects with a ray
  25500. * @param ray defines the ray to test
  25501. * @returns true is the passed ray intersects the submesh bounding box
  25502. */
  25503. canIntersects(ray: Ray): boolean;
  25504. /**
  25505. * Intersects current submesh with a ray
  25506. * @param ray defines the ray to test
  25507. * @param positions defines mesh's positions array
  25508. * @param indices defines mesh's indices array
  25509. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25511. * @returns intersection info or null if no intersection
  25512. */
  25513. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25514. /** @hidden */
  25515. private _intersectLines;
  25516. /** @hidden */
  25517. private _intersectUnIndexedLines;
  25518. /** @hidden */
  25519. private _intersectTriangles;
  25520. /** @hidden */
  25521. private _intersectUnIndexedTriangles;
  25522. /** @hidden */
  25523. _rebuild(): void;
  25524. /**
  25525. * Creates a new submesh from the passed mesh
  25526. * @param newMesh defines the new hosting mesh
  25527. * @param newRenderingMesh defines an optional rendering mesh
  25528. * @returns the new submesh
  25529. */
  25530. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25531. /**
  25532. * Release associated resources
  25533. */
  25534. dispose(): void;
  25535. /**
  25536. * Gets the class name
  25537. * @returns the string "SubMesh".
  25538. */
  25539. getClassName(): string;
  25540. /**
  25541. * Creates a new submesh from indices data
  25542. * @param materialIndex the index of the main mesh material
  25543. * @param startIndex the index where to start the copy in the mesh indices array
  25544. * @param indexCount the number of indices to copy then from the startIndex
  25545. * @param mesh the main mesh to create the submesh from
  25546. * @param renderingMesh the optional rendering mesh
  25547. * @returns a new submesh
  25548. */
  25549. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25550. }
  25551. }
  25552. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25553. /**
  25554. * Class used to represent data loading progression
  25555. */
  25556. export class SceneLoaderFlags {
  25557. private static _ForceFullSceneLoadingForIncremental;
  25558. private static _ShowLoadingScreen;
  25559. private static _CleanBoneMatrixWeights;
  25560. private static _loggingLevel;
  25561. /**
  25562. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25563. */
  25564. static get ForceFullSceneLoadingForIncremental(): boolean;
  25565. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25566. /**
  25567. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25568. */
  25569. static get ShowLoadingScreen(): boolean;
  25570. static set ShowLoadingScreen(value: boolean);
  25571. /**
  25572. * Defines the current logging level (while loading the scene)
  25573. * @ignorenaming
  25574. */
  25575. static get loggingLevel(): number;
  25576. static set loggingLevel(value: number);
  25577. /**
  25578. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25579. */
  25580. static get CleanBoneMatrixWeights(): boolean;
  25581. static set CleanBoneMatrixWeights(value: boolean);
  25582. }
  25583. }
  25584. declare module "babylonjs/Meshes/geometry" {
  25585. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25586. import { Scene } from "babylonjs/scene";
  25587. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25588. import { Engine } from "babylonjs/Engines/engine";
  25589. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25590. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25591. import { Effect } from "babylonjs/Materials/effect";
  25592. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25593. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25594. import { Mesh } from "babylonjs/Meshes/mesh";
  25595. /**
  25596. * Class used to store geometry data (vertex buffers + index buffer)
  25597. */
  25598. export class Geometry implements IGetSetVerticesData {
  25599. /**
  25600. * Gets or sets the ID of the geometry
  25601. */
  25602. id: string;
  25603. /**
  25604. * Gets or sets the unique ID of the geometry
  25605. */
  25606. uniqueId: number;
  25607. /**
  25608. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25609. */
  25610. delayLoadState: number;
  25611. /**
  25612. * Gets the file containing the data to load when running in delay load state
  25613. */
  25614. delayLoadingFile: Nullable<string>;
  25615. /**
  25616. * Callback called when the geometry is updated
  25617. */
  25618. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25619. private _scene;
  25620. private _engine;
  25621. private _meshes;
  25622. private _totalVertices;
  25623. /** @hidden */
  25624. _indices: IndicesArray;
  25625. /** @hidden */
  25626. _vertexBuffers: {
  25627. [key: string]: VertexBuffer;
  25628. };
  25629. private _isDisposed;
  25630. private _extend;
  25631. private _boundingBias;
  25632. /** @hidden */
  25633. _delayInfo: Array<string>;
  25634. private _indexBuffer;
  25635. private _indexBufferIsUpdatable;
  25636. /** @hidden */
  25637. _boundingInfo: Nullable<BoundingInfo>;
  25638. /** @hidden */
  25639. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25640. /** @hidden */
  25641. _softwareSkinningFrameId: number;
  25642. private _vertexArrayObjects;
  25643. private _updatable;
  25644. /** @hidden */
  25645. _positions: Nullable<Vector3[]>;
  25646. /**
  25647. * 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
  25648. */
  25649. get boundingBias(): Vector2;
  25650. /**
  25651. * 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
  25652. */
  25653. set boundingBias(value: Vector2);
  25654. /**
  25655. * Static function used to attach a new empty geometry to a mesh
  25656. * @param mesh defines the mesh to attach the geometry to
  25657. * @returns the new Geometry
  25658. */
  25659. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25660. /** Get the list of meshes using this geometry */
  25661. get meshes(): Mesh[];
  25662. /**
  25663. * 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
  25664. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25665. */
  25666. useBoundingInfoFromGeometry: boolean;
  25667. /**
  25668. * Creates a new geometry
  25669. * @param id defines the unique ID
  25670. * @param scene defines the hosting scene
  25671. * @param vertexData defines the VertexData used to get geometry data
  25672. * @param updatable defines if geometry must be updatable (false by default)
  25673. * @param mesh defines the mesh that will be associated with the geometry
  25674. */
  25675. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25676. /**
  25677. * Gets the current extend of the geometry
  25678. */
  25679. get extend(): {
  25680. minimum: Vector3;
  25681. maximum: Vector3;
  25682. };
  25683. /**
  25684. * Gets the hosting scene
  25685. * @returns the hosting Scene
  25686. */
  25687. getScene(): Scene;
  25688. /**
  25689. * Gets the hosting engine
  25690. * @returns the hosting Engine
  25691. */
  25692. getEngine(): Engine;
  25693. /**
  25694. * Defines if the geometry is ready to use
  25695. * @returns true if the geometry is ready to be used
  25696. */
  25697. isReady(): boolean;
  25698. /**
  25699. * Gets a value indicating that the geometry should not be serialized
  25700. */
  25701. get doNotSerialize(): boolean;
  25702. /** @hidden */
  25703. _rebuild(): void;
  25704. /**
  25705. * Affects all geometry data in one call
  25706. * @param vertexData defines the geometry data
  25707. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25708. */
  25709. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25710. /**
  25711. * Set specific vertex data
  25712. * @param kind defines the data kind (Position, normal, etc...)
  25713. * @param data defines the vertex data to use
  25714. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25715. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25716. */
  25717. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25718. /**
  25719. * Removes a specific vertex data
  25720. * @param kind defines the data kind (Position, normal, etc...)
  25721. */
  25722. removeVerticesData(kind: string): void;
  25723. /**
  25724. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25725. * @param buffer defines the vertex buffer to use
  25726. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25727. */
  25728. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25729. /**
  25730. * Update a specific vertex buffer
  25731. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25732. * It will do nothing if the buffer is not updatable
  25733. * @param kind defines the data kind (Position, normal, etc...)
  25734. * @param data defines the data to use
  25735. * @param offset defines the offset in the target buffer where to store the data
  25736. * @param useBytes set to true if the offset is in bytes
  25737. */
  25738. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25739. /**
  25740. * Update a specific vertex buffer
  25741. * This function will create a new buffer if the current one is not updatable
  25742. * @param kind defines the data kind (Position, normal, etc...)
  25743. * @param data defines the data to use
  25744. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25745. */
  25746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25747. private _updateBoundingInfo;
  25748. /** @hidden */
  25749. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25750. /**
  25751. * Gets total number of vertices
  25752. * @returns the total number of vertices
  25753. */
  25754. getTotalVertices(): number;
  25755. /**
  25756. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25757. * @param kind defines the data kind (Position, normal, etc...)
  25758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25760. * @returns a float array containing vertex data
  25761. */
  25762. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25763. /**
  25764. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25765. * @param kind defines the data kind (Position, normal, etc...)
  25766. * @returns true if the vertex buffer with the specified kind is updatable
  25767. */
  25768. isVertexBufferUpdatable(kind: string): boolean;
  25769. /**
  25770. * Gets a specific vertex buffer
  25771. * @param kind defines the data kind (Position, normal, etc...)
  25772. * @returns a VertexBuffer
  25773. */
  25774. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25775. /**
  25776. * Returns all vertex buffers
  25777. * @return an object holding all vertex buffers indexed by kind
  25778. */
  25779. getVertexBuffers(): Nullable<{
  25780. [key: string]: VertexBuffer;
  25781. }>;
  25782. /**
  25783. * Gets a boolean indicating if specific vertex buffer is present
  25784. * @param kind defines the data kind (Position, normal, etc...)
  25785. * @returns true if data is present
  25786. */
  25787. isVerticesDataPresent(kind: string): boolean;
  25788. /**
  25789. * Gets a list of all attached data kinds (Position, normal, etc...)
  25790. * @returns a list of string containing all kinds
  25791. */
  25792. getVerticesDataKinds(): string[];
  25793. /**
  25794. * Update index buffer
  25795. * @param indices defines the indices to store in the index buffer
  25796. * @param offset defines the offset in the target buffer where to store the data
  25797. * @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)
  25798. */
  25799. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25800. /**
  25801. * Creates a new index buffer
  25802. * @param indices defines the indices to store in the index buffer
  25803. * @param totalVertices defines the total number of vertices (could be null)
  25804. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25805. */
  25806. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25807. /**
  25808. * Return the total number of indices
  25809. * @returns the total number of indices
  25810. */
  25811. getTotalIndices(): number;
  25812. /**
  25813. * Gets the index buffer array
  25814. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25815. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25816. * @returns the index buffer array
  25817. */
  25818. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25819. /**
  25820. * Gets the index buffer
  25821. * @return the index buffer
  25822. */
  25823. getIndexBuffer(): Nullable<DataBuffer>;
  25824. /** @hidden */
  25825. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25826. /**
  25827. * Release the associated resources for a specific mesh
  25828. * @param mesh defines the source mesh
  25829. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25830. */
  25831. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25832. /**
  25833. * Apply current geometry to a given mesh
  25834. * @param mesh defines the mesh to apply geometry to
  25835. */
  25836. applyToMesh(mesh: Mesh): void;
  25837. private _updateExtend;
  25838. private _applyToMesh;
  25839. private notifyUpdate;
  25840. /**
  25841. * Load the geometry if it was flagged as delay loaded
  25842. * @param scene defines the hosting scene
  25843. * @param onLoaded defines a callback called when the geometry is loaded
  25844. */
  25845. load(scene: Scene, onLoaded?: () => void): void;
  25846. private _queueLoad;
  25847. /**
  25848. * Invert the geometry to move from a right handed system to a left handed one.
  25849. */
  25850. toLeftHanded(): void;
  25851. /** @hidden */
  25852. _resetPointsArrayCache(): void;
  25853. /** @hidden */
  25854. _generatePointsArray(): boolean;
  25855. /**
  25856. * Gets a value indicating if the geometry is disposed
  25857. * @returns true if the geometry was disposed
  25858. */
  25859. isDisposed(): boolean;
  25860. private _disposeVertexArrayObjects;
  25861. /**
  25862. * Free all associated resources
  25863. */
  25864. dispose(): void;
  25865. /**
  25866. * Clone the current geometry into a new geometry
  25867. * @param id defines the unique ID of the new geometry
  25868. * @returns a new geometry object
  25869. */
  25870. copy(id: string): Geometry;
  25871. /**
  25872. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25873. * @return a JSON representation of the current geometry data (without the vertices data)
  25874. */
  25875. serialize(): any;
  25876. private toNumberArray;
  25877. /**
  25878. * Serialize all vertices data into a JSON oject
  25879. * @returns a JSON representation of the current geometry data
  25880. */
  25881. serializeVerticeData(): any;
  25882. /**
  25883. * Extracts a clone of a mesh geometry
  25884. * @param mesh defines the source mesh
  25885. * @param id defines the unique ID of the new geometry object
  25886. * @returns the new geometry object
  25887. */
  25888. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25889. /**
  25890. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25891. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25892. * Be aware Math.random() could cause collisions, but:
  25893. * "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"
  25894. * @returns a string containing a new GUID
  25895. */
  25896. static RandomId(): string;
  25897. /** @hidden */
  25898. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25899. private static _CleanMatricesWeights;
  25900. /**
  25901. * Create a new geometry from persisted data (Using .babylon file format)
  25902. * @param parsedVertexData defines the persisted data
  25903. * @param scene defines the hosting scene
  25904. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25905. * @returns the new geometry object
  25906. */
  25907. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25908. }
  25909. }
  25910. declare module "babylonjs/Meshes/mesh.vertexData" {
  25911. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25912. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25913. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25914. import { Geometry } from "babylonjs/Meshes/geometry";
  25915. import { Mesh } from "babylonjs/Meshes/mesh";
  25916. /**
  25917. * Define an interface for all classes that will get and set the data on vertices
  25918. */
  25919. export interface IGetSetVerticesData {
  25920. /**
  25921. * Gets a boolean indicating if specific vertex data is present
  25922. * @param kind defines the vertex data kind to use
  25923. * @returns true is data kind is present
  25924. */
  25925. isVerticesDataPresent(kind: string): boolean;
  25926. /**
  25927. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25928. * @param kind defines the data kind (Position, normal, etc...)
  25929. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25931. * @returns a float array containing vertex data
  25932. */
  25933. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25934. /**
  25935. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25936. * @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.
  25937. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25938. * @returns the indices array or an empty array if the mesh has no geometry
  25939. */
  25940. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25941. /**
  25942. * Set specific vertex data
  25943. * @param kind defines the data kind (Position, normal, etc...)
  25944. * @param data defines the vertex data to use
  25945. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25946. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25947. */
  25948. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25949. /**
  25950. * Update a specific associated vertex buffer
  25951. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25952. * - VertexBuffer.PositionKind
  25953. * - VertexBuffer.UVKind
  25954. * - VertexBuffer.UV2Kind
  25955. * - VertexBuffer.UV3Kind
  25956. * - VertexBuffer.UV4Kind
  25957. * - VertexBuffer.UV5Kind
  25958. * - VertexBuffer.UV6Kind
  25959. * - VertexBuffer.ColorKind
  25960. * - VertexBuffer.MatricesIndicesKind
  25961. * - VertexBuffer.MatricesIndicesExtraKind
  25962. * - VertexBuffer.MatricesWeightsKind
  25963. * - VertexBuffer.MatricesWeightsExtraKind
  25964. * @param data defines the data source
  25965. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25966. * @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)
  25967. */
  25968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25969. /**
  25970. * Creates a new index buffer
  25971. * @param indices defines the indices to store in the index buffer
  25972. * @param totalVertices defines the total number of vertices (could be null)
  25973. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25974. */
  25975. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25976. }
  25977. /**
  25978. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25979. */
  25980. export class VertexData {
  25981. /**
  25982. * Mesh side orientation : usually the external or front surface
  25983. */
  25984. static readonly FRONTSIDE: number;
  25985. /**
  25986. * Mesh side orientation : usually the internal or back surface
  25987. */
  25988. static readonly BACKSIDE: number;
  25989. /**
  25990. * Mesh side orientation : both internal and external or front and back surfaces
  25991. */
  25992. static readonly DOUBLESIDE: number;
  25993. /**
  25994. * Mesh side orientation : by default, `FRONTSIDE`
  25995. */
  25996. static readonly DEFAULTSIDE: number;
  25997. /**
  25998. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25999. */
  26000. positions: Nullable<FloatArray>;
  26001. /**
  26002. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26003. */
  26004. normals: Nullable<FloatArray>;
  26005. /**
  26006. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26007. */
  26008. tangents: Nullable<FloatArray>;
  26009. /**
  26010. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26011. */
  26012. uvs: Nullable<FloatArray>;
  26013. /**
  26014. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26015. */
  26016. uvs2: Nullable<FloatArray>;
  26017. /**
  26018. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26019. */
  26020. uvs3: Nullable<FloatArray>;
  26021. /**
  26022. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26023. */
  26024. uvs4: Nullable<FloatArray>;
  26025. /**
  26026. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26027. */
  26028. uvs5: Nullable<FloatArray>;
  26029. /**
  26030. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26031. */
  26032. uvs6: Nullable<FloatArray>;
  26033. /**
  26034. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26035. */
  26036. colors: Nullable<FloatArray>;
  26037. /**
  26038. * 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).
  26039. */
  26040. matricesIndices: Nullable<FloatArray>;
  26041. /**
  26042. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26043. */
  26044. matricesWeights: Nullable<FloatArray>;
  26045. /**
  26046. * An array extending the number of possible indices
  26047. */
  26048. matricesIndicesExtra: Nullable<FloatArray>;
  26049. /**
  26050. * An array extending the number of possible weights when the number of indices is extended
  26051. */
  26052. matricesWeightsExtra: Nullable<FloatArray>;
  26053. /**
  26054. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26055. */
  26056. indices: Nullable<IndicesArray>;
  26057. /**
  26058. * Uses the passed data array to set the set the values for the specified kind of data
  26059. * @param data a linear array of floating numbers
  26060. * @param kind the type of data that is being set, eg positions, colors etc
  26061. */
  26062. set(data: FloatArray, kind: string): void;
  26063. /**
  26064. * Associates the vertexData to the passed Mesh.
  26065. * Sets it as updatable or not (default `false`)
  26066. * @param mesh the mesh the vertexData is applied to
  26067. * @param updatable when used and having the value true allows new data to update the vertexData
  26068. * @returns the VertexData
  26069. */
  26070. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26071. /**
  26072. * Associates the vertexData to the passed Geometry.
  26073. * Sets it as updatable or not (default `false`)
  26074. * @param geometry the geometry the vertexData is applied to
  26075. * @param updatable when used and having the value true allows new data to update the vertexData
  26076. * @returns VertexData
  26077. */
  26078. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26079. /**
  26080. * Updates the associated mesh
  26081. * @param mesh the mesh to be updated
  26082. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26083. * @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
  26084. * @returns VertexData
  26085. */
  26086. updateMesh(mesh: Mesh): VertexData;
  26087. /**
  26088. * Updates the associated geometry
  26089. * @param geometry the geometry to be updated
  26090. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26091. * @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
  26092. * @returns VertexData.
  26093. */
  26094. updateGeometry(geometry: Geometry): VertexData;
  26095. private _applyTo;
  26096. private _update;
  26097. /**
  26098. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26099. * @param matrix the transforming matrix
  26100. * @returns the VertexData
  26101. */
  26102. transform(matrix: Matrix): VertexData;
  26103. /**
  26104. * Merges the passed VertexData into the current one
  26105. * @param other the VertexData to be merged into the current one
  26106. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26107. * @returns the modified VertexData
  26108. */
  26109. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26110. private _mergeElement;
  26111. private _validate;
  26112. /**
  26113. * Serializes the VertexData
  26114. * @returns a serialized object
  26115. */
  26116. serialize(): any;
  26117. /**
  26118. * Extracts the vertexData from a mesh
  26119. * @param mesh the mesh from which to extract the VertexData
  26120. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26121. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26122. * @returns the object VertexData associated to the passed mesh
  26123. */
  26124. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26125. /**
  26126. * Extracts the vertexData from the geometry
  26127. * @param geometry the geometry from which to extract the VertexData
  26128. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26129. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26130. * @returns the object VertexData associated to the passed mesh
  26131. */
  26132. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26133. private static _ExtractFrom;
  26134. /**
  26135. * Creates the VertexData for a Ribbon
  26136. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26137. * * pathArray array of paths, each of which an array of successive Vector3
  26138. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26139. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26140. * * 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
  26141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26142. * * 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)
  26143. * * 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)
  26144. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26145. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26146. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26147. * @returns the VertexData of the ribbon
  26148. */
  26149. static CreateRibbon(options: {
  26150. pathArray: Vector3[][];
  26151. closeArray?: boolean;
  26152. closePath?: boolean;
  26153. offset?: number;
  26154. sideOrientation?: number;
  26155. frontUVs?: Vector4;
  26156. backUVs?: Vector4;
  26157. invertUV?: boolean;
  26158. uvs?: Vector2[];
  26159. colors?: Color4[];
  26160. }): VertexData;
  26161. /**
  26162. * Creates the VertexData for a box
  26163. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26164. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26165. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26166. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26167. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26168. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26169. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26171. * * 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)
  26172. * * 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)
  26173. * @returns the VertexData of the box
  26174. */
  26175. static CreateBox(options: {
  26176. size?: number;
  26177. width?: number;
  26178. height?: number;
  26179. depth?: number;
  26180. faceUV?: Vector4[];
  26181. faceColors?: Color4[];
  26182. sideOrientation?: number;
  26183. frontUVs?: Vector4;
  26184. backUVs?: Vector4;
  26185. }): VertexData;
  26186. /**
  26187. * Creates the VertexData for a tiled box
  26188. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26189. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26193. * @returns the VertexData of the box
  26194. */
  26195. static CreateTiledBox(options: {
  26196. pattern?: number;
  26197. width?: number;
  26198. height?: number;
  26199. depth?: number;
  26200. tileSize?: number;
  26201. tileWidth?: number;
  26202. tileHeight?: number;
  26203. alignHorizontal?: number;
  26204. alignVertical?: number;
  26205. faceUV?: Vector4[];
  26206. faceColors?: Color4[];
  26207. sideOrientation?: number;
  26208. }): VertexData;
  26209. /**
  26210. * Creates the VertexData for a tiled plane
  26211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26212. * * pattern a limited pattern arrangement depending on the number
  26213. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26214. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26215. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26216. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26217. * * 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)
  26218. * * 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)
  26219. * @returns the VertexData of the tiled plane
  26220. */
  26221. static CreateTiledPlane(options: {
  26222. pattern?: number;
  26223. tileSize?: number;
  26224. tileWidth?: number;
  26225. tileHeight?: number;
  26226. size?: number;
  26227. width?: number;
  26228. height?: number;
  26229. alignHorizontal?: number;
  26230. alignVertical?: number;
  26231. sideOrientation?: number;
  26232. frontUVs?: Vector4;
  26233. backUVs?: Vector4;
  26234. }): VertexData;
  26235. /**
  26236. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26238. * * segments sets the number of horizontal strips optional, default 32
  26239. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26240. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26241. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26242. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26243. * * 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
  26244. * * 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
  26245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26246. * * 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)
  26247. * * 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)
  26248. * @returns the VertexData of the ellipsoid
  26249. */
  26250. static CreateSphere(options: {
  26251. segments?: number;
  26252. diameter?: number;
  26253. diameterX?: number;
  26254. diameterY?: number;
  26255. diameterZ?: number;
  26256. arc?: number;
  26257. slice?: number;
  26258. sideOrientation?: number;
  26259. frontUVs?: Vector4;
  26260. backUVs?: Vector4;
  26261. }): VertexData;
  26262. /**
  26263. * Creates the VertexData for a cylinder, cone or prism
  26264. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26265. * * height sets the height (y direction) of the cylinder, optional, default 2
  26266. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26267. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26268. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26269. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26270. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26271. * * 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
  26272. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26273. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26274. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26275. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26277. * * 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)
  26278. * * 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)
  26279. * @returns the VertexData of the cylinder, cone or prism
  26280. */
  26281. static CreateCylinder(options: {
  26282. height?: number;
  26283. diameterTop?: number;
  26284. diameterBottom?: number;
  26285. diameter?: number;
  26286. tessellation?: number;
  26287. subdivisions?: number;
  26288. arc?: number;
  26289. faceColors?: Color4[];
  26290. faceUV?: Vector4[];
  26291. hasRings?: boolean;
  26292. enclose?: boolean;
  26293. sideOrientation?: number;
  26294. frontUVs?: Vector4;
  26295. backUVs?: Vector4;
  26296. }): VertexData;
  26297. /**
  26298. * Creates the VertexData for a torus
  26299. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26300. * * diameter the diameter of the torus, optional default 1
  26301. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26304. * * 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)
  26305. * * 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)
  26306. * @returns the VertexData of the torus
  26307. */
  26308. static CreateTorus(options: {
  26309. diameter?: number;
  26310. thickness?: number;
  26311. tessellation?: number;
  26312. sideOrientation?: number;
  26313. frontUVs?: Vector4;
  26314. backUVs?: Vector4;
  26315. }): VertexData;
  26316. /**
  26317. * Creates the VertexData of the LineSystem
  26318. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26319. * - lines an array of lines, each line being an array of successive Vector3
  26320. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26321. * @returns the VertexData of the LineSystem
  26322. */
  26323. static CreateLineSystem(options: {
  26324. lines: Vector3[][];
  26325. colors?: Nullable<Color4[][]>;
  26326. }): VertexData;
  26327. /**
  26328. * Create the VertexData for a DashedLines
  26329. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26330. * - points an array successive Vector3
  26331. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26332. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26333. * - dashNb the intended total number of dashes, optional, default 200
  26334. * @returns the VertexData for the DashedLines
  26335. */
  26336. static CreateDashedLines(options: {
  26337. points: Vector3[];
  26338. dashSize?: number;
  26339. gapSize?: number;
  26340. dashNb?: number;
  26341. }): VertexData;
  26342. /**
  26343. * Creates the VertexData for a Ground
  26344. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26345. * - width the width (x direction) of the ground, optional, default 1
  26346. * - height the height (z direction) of the ground, optional, default 1
  26347. * - subdivisions the number of subdivisions per side, optional, default 1
  26348. * @returns the VertexData of the Ground
  26349. */
  26350. static CreateGround(options: {
  26351. width?: number;
  26352. height?: number;
  26353. subdivisions?: number;
  26354. subdivisionsX?: number;
  26355. subdivisionsY?: number;
  26356. }): VertexData;
  26357. /**
  26358. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26359. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26360. * * xmin the ground minimum X coordinate, optional, default -1
  26361. * * zmin the ground minimum Z coordinate, optional, default -1
  26362. * * xmax the ground maximum X coordinate, optional, default 1
  26363. * * zmax the ground maximum Z coordinate, optional, default 1
  26364. * * 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}
  26365. * * 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}
  26366. * @returns the VertexData of the TiledGround
  26367. */
  26368. static CreateTiledGround(options: {
  26369. xmin: number;
  26370. zmin: number;
  26371. xmax: number;
  26372. zmax: number;
  26373. subdivisions?: {
  26374. w: number;
  26375. h: number;
  26376. };
  26377. precision?: {
  26378. w: number;
  26379. h: number;
  26380. };
  26381. }): VertexData;
  26382. /**
  26383. * Creates the VertexData of the Ground designed from a heightmap
  26384. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26385. * * width the width (x direction) of the ground
  26386. * * height the height (z direction) of the ground
  26387. * * subdivisions the number of subdivisions per side
  26388. * * minHeight the minimum altitude on the ground, optional, default 0
  26389. * * maxHeight the maximum altitude on the ground, optional default 1
  26390. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26391. * * buffer the array holding the image color data
  26392. * * bufferWidth the width of image
  26393. * * bufferHeight the height of image
  26394. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26395. * @returns the VertexData of the Ground designed from a heightmap
  26396. */
  26397. static CreateGroundFromHeightMap(options: {
  26398. width: number;
  26399. height: number;
  26400. subdivisions: number;
  26401. minHeight: number;
  26402. maxHeight: number;
  26403. colorFilter: Color3;
  26404. buffer: Uint8Array;
  26405. bufferWidth: number;
  26406. bufferHeight: number;
  26407. alphaFilter: number;
  26408. }): VertexData;
  26409. /**
  26410. * Creates the VertexData for a Plane
  26411. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26412. * * size sets the width and height of the plane to the value of size, optional default 1
  26413. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26414. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26416. * * 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)
  26417. * * 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)
  26418. * @returns the VertexData of the box
  26419. */
  26420. static CreatePlane(options: {
  26421. size?: number;
  26422. width?: number;
  26423. height?: number;
  26424. sideOrientation?: number;
  26425. frontUVs?: Vector4;
  26426. backUVs?: Vector4;
  26427. }): VertexData;
  26428. /**
  26429. * Creates the VertexData of the Disc or regular Polygon
  26430. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26431. * * radius the radius of the disc, optional default 0.5
  26432. * * tessellation the number of polygon sides, optional, default 64
  26433. * * 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
  26434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26435. * * 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)
  26436. * * 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)
  26437. * @returns the VertexData of the box
  26438. */
  26439. static CreateDisc(options: {
  26440. radius?: number;
  26441. tessellation?: number;
  26442. arc?: number;
  26443. sideOrientation?: number;
  26444. frontUVs?: Vector4;
  26445. backUVs?: Vector4;
  26446. }): VertexData;
  26447. /**
  26448. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26449. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26450. * @param polygon a mesh built from polygonTriangulation.build()
  26451. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26452. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26453. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26454. * @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)
  26455. * @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)
  26456. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26457. * @returns the VertexData of the Polygon
  26458. */
  26459. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26460. /**
  26461. * Creates the VertexData of the IcoSphere
  26462. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26463. * * radius the radius of the IcoSphere, optional default 1
  26464. * * radiusX allows stretching in the x direction, optional, default radius
  26465. * * radiusY allows stretching in the y direction, optional, default radius
  26466. * * radiusZ allows stretching in the z direction, optional, default radius
  26467. * * flat when true creates a flat shaded mesh, optional, default true
  26468. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26470. * * 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)
  26471. * * 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)
  26472. * @returns the VertexData of the IcoSphere
  26473. */
  26474. static CreateIcoSphere(options: {
  26475. radius?: number;
  26476. radiusX?: number;
  26477. radiusY?: number;
  26478. radiusZ?: number;
  26479. flat?: boolean;
  26480. subdivisions?: number;
  26481. sideOrientation?: number;
  26482. frontUVs?: Vector4;
  26483. backUVs?: Vector4;
  26484. }): VertexData;
  26485. /**
  26486. * Creates the VertexData for a Polyhedron
  26487. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26488. * * type provided types are:
  26489. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26490. * * 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)
  26491. * * size the size of the IcoSphere, optional default 1
  26492. * * sizeX allows stretching in the x direction, optional, default size
  26493. * * sizeY allows stretching in the y direction, optional, default size
  26494. * * sizeZ allows stretching in the z direction, optional, default size
  26495. * * 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
  26496. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26497. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26498. * * flat when true creates a flat shaded mesh, optional, default true
  26499. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26501. * * 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)
  26502. * * 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)
  26503. * @returns the VertexData of the Polyhedron
  26504. */
  26505. static CreatePolyhedron(options: {
  26506. type?: number;
  26507. size?: number;
  26508. sizeX?: number;
  26509. sizeY?: number;
  26510. sizeZ?: number;
  26511. custom?: any;
  26512. faceUV?: Vector4[];
  26513. faceColors?: Color4[];
  26514. flat?: boolean;
  26515. sideOrientation?: number;
  26516. frontUVs?: Vector4;
  26517. backUVs?: Vector4;
  26518. }): VertexData;
  26519. /**
  26520. * Creates the VertexData for a TorusKnot
  26521. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26522. * * radius the radius of the torus knot, optional, default 2
  26523. * * tube the thickness of the tube, optional, default 0.5
  26524. * * radialSegments the number of sides on each tube segments, optional, default 32
  26525. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26526. * * p the number of windings around the z axis, optional, default 2
  26527. * * q the number of windings around the x axis, optional, default 3
  26528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26529. * * 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)
  26530. * * 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)
  26531. * @returns the VertexData of the Torus Knot
  26532. */
  26533. static CreateTorusKnot(options: {
  26534. radius?: number;
  26535. tube?: number;
  26536. radialSegments?: number;
  26537. tubularSegments?: number;
  26538. p?: number;
  26539. q?: number;
  26540. sideOrientation?: number;
  26541. frontUVs?: Vector4;
  26542. backUVs?: Vector4;
  26543. }): VertexData;
  26544. /**
  26545. * Compute normals for given positions and indices
  26546. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26547. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26548. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26549. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26550. * * facetNormals : optional array of facet normals (vector3)
  26551. * * facetPositions : optional array of facet positions (vector3)
  26552. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26553. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26554. * * bInfo : optional bounding info, required for facetPartitioning computation
  26555. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26556. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26557. * * useRightHandedSystem: optional boolean to for right handed system computation
  26558. * * depthSort : optional boolean to enable the facet depth sort computation
  26559. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26560. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26561. */
  26562. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26563. facetNormals?: any;
  26564. facetPositions?: any;
  26565. facetPartitioning?: any;
  26566. ratio?: number;
  26567. bInfo?: any;
  26568. bbSize?: Vector3;
  26569. subDiv?: any;
  26570. useRightHandedSystem?: boolean;
  26571. depthSort?: boolean;
  26572. distanceTo?: Vector3;
  26573. depthSortedFacets?: any;
  26574. }): void;
  26575. /** @hidden */
  26576. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26577. /**
  26578. * Applies VertexData created from the imported parameters to the geometry
  26579. * @param parsedVertexData the parsed data from an imported file
  26580. * @param geometry the geometry to apply the VertexData to
  26581. */
  26582. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26583. }
  26584. }
  26585. declare module "babylonjs/Morph/morphTarget" {
  26586. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26587. import { Observable } from "babylonjs/Misc/observable";
  26588. import { Nullable, FloatArray } from "babylonjs/types";
  26589. import { Scene } from "babylonjs/scene";
  26590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26591. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26592. /**
  26593. * Defines a target to use with MorphTargetManager
  26594. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26595. */
  26596. export class MorphTarget implements IAnimatable {
  26597. /** defines the name of the target */
  26598. name: string;
  26599. /**
  26600. * Gets or sets the list of animations
  26601. */
  26602. animations: import("babylonjs/Animations/animation").Animation[];
  26603. private _scene;
  26604. private _positions;
  26605. private _normals;
  26606. private _tangents;
  26607. private _uvs;
  26608. private _influence;
  26609. private _uniqueId;
  26610. /**
  26611. * Observable raised when the influence changes
  26612. */
  26613. onInfluenceChanged: Observable<boolean>;
  26614. /** @hidden */
  26615. _onDataLayoutChanged: Observable<void>;
  26616. /**
  26617. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26618. */
  26619. get influence(): number;
  26620. set influence(influence: number);
  26621. /**
  26622. * Gets or sets the id of the morph Target
  26623. */
  26624. id: string;
  26625. private _animationPropertiesOverride;
  26626. /**
  26627. * Gets or sets the animation properties override
  26628. */
  26629. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26630. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26631. /**
  26632. * Creates a new MorphTarget
  26633. * @param name defines the name of the target
  26634. * @param influence defines the influence to use
  26635. * @param scene defines the scene the morphtarget belongs to
  26636. */
  26637. constructor(
  26638. /** defines the name of the target */
  26639. name: string, influence?: number, scene?: Nullable<Scene>);
  26640. /**
  26641. * Gets the unique ID of this manager
  26642. */
  26643. get uniqueId(): number;
  26644. /**
  26645. * Gets a boolean defining if the target contains position data
  26646. */
  26647. get hasPositions(): boolean;
  26648. /**
  26649. * Gets a boolean defining if the target contains normal data
  26650. */
  26651. get hasNormals(): boolean;
  26652. /**
  26653. * Gets a boolean defining if the target contains tangent data
  26654. */
  26655. get hasTangents(): boolean;
  26656. /**
  26657. * Gets a boolean defining if the target contains texture coordinates data
  26658. */
  26659. get hasUVs(): boolean;
  26660. /**
  26661. * Affects position data to this target
  26662. * @param data defines the position data to use
  26663. */
  26664. setPositions(data: Nullable<FloatArray>): void;
  26665. /**
  26666. * Gets the position data stored in this target
  26667. * @returns a FloatArray containing the position data (or null if not present)
  26668. */
  26669. getPositions(): Nullable<FloatArray>;
  26670. /**
  26671. * Affects normal data to this target
  26672. * @param data defines the normal data to use
  26673. */
  26674. setNormals(data: Nullable<FloatArray>): void;
  26675. /**
  26676. * Gets the normal data stored in this target
  26677. * @returns a FloatArray containing the normal data (or null if not present)
  26678. */
  26679. getNormals(): Nullable<FloatArray>;
  26680. /**
  26681. * Affects tangent data to this target
  26682. * @param data defines the tangent data to use
  26683. */
  26684. setTangents(data: Nullable<FloatArray>): void;
  26685. /**
  26686. * Gets the tangent data stored in this target
  26687. * @returns a FloatArray containing the tangent data (or null if not present)
  26688. */
  26689. getTangents(): Nullable<FloatArray>;
  26690. /**
  26691. * Affects texture coordinates data to this target
  26692. * @param data defines the texture coordinates data to use
  26693. */
  26694. setUVs(data: Nullable<FloatArray>): void;
  26695. /**
  26696. * Gets the texture coordinates data stored in this target
  26697. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26698. */
  26699. getUVs(): Nullable<FloatArray>;
  26700. /**
  26701. * Clone the current target
  26702. * @returns a new MorphTarget
  26703. */
  26704. clone(): MorphTarget;
  26705. /**
  26706. * Serializes the current target into a Serialization object
  26707. * @returns the serialized object
  26708. */
  26709. serialize(): any;
  26710. /**
  26711. * Returns the string "MorphTarget"
  26712. * @returns "MorphTarget"
  26713. */
  26714. getClassName(): string;
  26715. /**
  26716. * Creates a new target from serialized data
  26717. * @param serializationObject defines the serialized data to use
  26718. * @returns a new MorphTarget
  26719. */
  26720. static Parse(serializationObject: any): MorphTarget;
  26721. /**
  26722. * Creates a MorphTarget from mesh data
  26723. * @param mesh defines the source mesh
  26724. * @param name defines the name to use for the new target
  26725. * @param influence defines the influence to attach to the target
  26726. * @returns a new MorphTarget
  26727. */
  26728. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26729. }
  26730. }
  26731. declare module "babylonjs/Morph/morphTargetManager" {
  26732. import { Nullable } from "babylonjs/types";
  26733. import { Scene } from "babylonjs/scene";
  26734. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26735. /**
  26736. * This class is used to deform meshes using morphing between different targets
  26737. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26738. */
  26739. export class MorphTargetManager {
  26740. private _targets;
  26741. private _targetInfluenceChangedObservers;
  26742. private _targetDataLayoutChangedObservers;
  26743. private _activeTargets;
  26744. private _scene;
  26745. private _influences;
  26746. private _supportsNormals;
  26747. private _supportsTangents;
  26748. private _supportsUVs;
  26749. private _vertexCount;
  26750. private _uniqueId;
  26751. private _tempInfluences;
  26752. /**
  26753. * Gets or sets a boolean indicating if normals must be morphed
  26754. */
  26755. enableNormalMorphing: boolean;
  26756. /**
  26757. * Gets or sets a boolean indicating if tangents must be morphed
  26758. */
  26759. enableTangentMorphing: boolean;
  26760. /**
  26761. * Gets or sets a boolean indicating if UV must be morphed
  26762. */
  26763. enableUVMorphing: boolean;
  26764. /**
  26765. * Creates a new MorphTargetManager
  26766. * @param scene defines the current scene
  26767. */
  26768. constructor(scene?: Nullable<Scene>);
  26769. /**
  26770. * Gets the unique ID of this manager
  26771. */
  26772. get uniqueId(): number;
  26773. /**
  26774. * Gets the number of vertices handled by this manager
  26775. */
  26776. get vertexCount(): number;
  26777. /**
  26778. * Gets a boolean indicating if this manager supports morphing of normals
  26779. */
  26780. get supportsNormals(): boolean;
  26781. /**
  26782. * Gets a boolean indicating if this manager supports morphing of tangents
  26783. */
  26784. get supportsTangents(): boolean;
  26785. /**
  26786. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26787. */
  26788. get supportsUVs(): boolean;
  26789. /**
  26790. * Gets the number of targets stored in this manager
  26791. */
  26792. get numTargets(): number;
  26793. /**
  26794. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26795. */
  26796. get numInfluencers(): number;
  26797. /**
  26798. * Gets the list of influences (one per target)
  26799. */
  26800. get influences(): Float32Array;
  26801. /**
  26802. * Gets the active target at specified index. An active target is a target with an influence > 0
  26803. * @param index defines the index to check
  26804. * @returns the requested target
  26805. */
  26806. getActiveTarget(index: number): MorphTarget;
  26807. /**
  26808. * Gets the target at specified index
  26809. * @param index defines the index to check
  26810. * @returns the requested target
  26811. */
  26812. getTarget(index: number): MorphTarget;
  26813. /**
  26814. * Add a new target to this manager
  26815. * @param target defines the target to add
  26816. */
  26817. addTarget(target: MorphTarget): void;
  26818. /**
  26819. * Removes a target from the manager
  26820. * @param target defines the target to remove
  26821. */
  26822. removeTarget(target: MorphTarget): void;
  26823. /**
  26824. * Clone the current manager
  26825. * @returns a new MorphTargetManager
  26826. */
  26827. clone(): MorphTargetManager;
  26828. /**
  26829. * Serializes the current manager into a Serialization object
  26830. * @returns the serialized object
  26831. */
  26832. serialize(): any;
  26833. private _syncActiveTargets;
  26834. /**
  26835. * Syncrhonize the targets with all the meshes using this morph target manager
  26836. */
  26837. synchronize(): void;
  26838. /**
  26839. * Creates a new MorphTargetManager from serialized data
  26840. * @param serializationObject defines the serialized data
  26841. * @param scene defines the hosting scene
  26842. * @returns the new MorphTargetManager
  26843. */
  26844. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26845. }
  26846. }
  26847. declare module "babylonjs/Meshes/meshLODLevel" {
  26848. import { Mesh } from "babylonjs/Meshes/mesh";
  26849. import { Nullable } from "babylonjs/types";
  26850. /**
  26851. * Class used to represent a specific level of detail of a mesh
  26852. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26853. */
  26854. export class MeshLODLevel {
  26855. /** Defines the distance where this level should start being displayed */
  26856. distance: number;
  26857. /** Defines the mesh to use to render this level */
  26858. mesh: Nullable<Mesh>;
  26859. /**
  26860. * Creates a new LOD level
  26861. * @param distance defines the distance where this level should star being displayed
  26862. * @param mesh defines the mesh to use to render this level
  26863. */
  26864. constructor(
  26865. /** Defines the distance where this level should start being displayed */
  26866. distance: number,
  26867. /** Defines the mesh to use to render this level */
  26868. mesh: Nullable<Mesh>);
  26869. }
  26870. }
  26871. declare module "babylonjs/Misc/canvasGenerator" {
  26872. /**
  26873. * Helper class used to generate a canvas to manipulate images
  26874. */
  26875. export class CanvasGenerator {
  26876. /**
  26877. * Create a new canvas (or offscreen canvas depending on the context)
  26878. * @param width defines the expected width
  26879. * @param height defines the expected height
  26880. * @return a new canvas or offscreen canvas
  26881. */
  26882. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26883. }
  26884. }
  26885. declare module "babylonjs/Meshes/groundMesh" {
  26886. import { Scene } from "babylonjs/scene";
  26887. import { Vector3 } from "babylonjs/Maths/math.vector";
  26888. import { Mesh } from "babylonjs/Meshes/mesh";
  26889. /**
  26890. * Mesh representing the gorund
  26891. */
  26892. export class GroundMesh extends Mesh {
  26893. /** If octree should be generated */
  26894. generateOctree: boolean;
  26895. private _heightQuads;
  26896. /** @hidden */
  26897. _subdivisionsX: number;
  26898. /** @hidden */
  26899. _subdivisionsY: number;
  26900. /** @hidden */
  26901. _width: number;
  26902. /** @hidden */
  26903. _height: number;
  26904. /** @hidden */
  26905. _minX: number;
  26906. /** @hidden */
  26907. _maxX: number;
  26908. /** @hidden */
  26909. _minZ: number;
  26910. /** @hidden */
  26911. _maxZ: number;
  26912. constructor(name: string, scene: Scene);
  26913. /**
  26914. * "GroundMesh"
  26915. * @returns "GroundMesh"
  26916. */
  26917. getClassName(): string;
  26918. /**
  26919. * The minimum of x and y subdivisions
  26920. */
  26921. get subdivisions(): number;
  26922. /**
  26923. * X subdivisions
  26924. */
  26925. get subdivisionsX(): number;
  26926. /**
  26927. * Y subdivisions
  26928. */
  26929. get subdivisionsY(): number;
  26930. /**
  26931. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26932. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26933. * @param chunksCount the number of subdivisions for x and y
  26934. * @param octreeBlocksSize (Default: 32)
  26935. */
  26936. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26937. /**
  26938. * Returns a height (y) value in the Worl system :
  26939. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26940. * @param x x coordinate
  26941. * @param z z coordinate
  26942. * @returns the ground y position if (x, z) are outside the ground surface.
  26943. */
  26944. getHeightAtCoordinates(x: number, z: number): number;
  26945. /**
  26946. * Returns a normalized vector (Vector3) orthogonal to the ground
  26947. * at the ground coordinates (x, z) expressed in the World system.
  26948. * @param x x coordinate
  26949. * @param z z coordinate
  26950. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26951. */
  26952. getNormalAtCoordinates(x: number, z: number): Vector3;
  26953. /**
  26954. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26955. * at the ground coordinates (x, z) expressed in the World system.
  26956. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26957. * @param x x coordinate
  26958. * @param z z coordinate
  26959. * @param ref vector to store the result
  26960. * @returns the GroundMesh.
  26961. */
  26962. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26963. /**
  26964. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26965. * if the ground has been updated.
  26966. * This can be used in the render loop.
  26967. * @returns the GroundMesh.
  26968. */
  26969. updateCoordinateHeights(): GroundMesh;
  26970. private _getFacetAt;
  26971. private _initHeightQuads;
  26972. private _computeHeightQuads;
  26973. /**
  26974. * Serializes this ground mesh
  26975. * @param serializationObject object to write serialization to
  26976. */
  26977. serialize(serializationObject: any): void;
  26978. /**
  26979. * Parses a serialized ground mesh
  26980. * @param parsedMesh the serialized mesh
  26981. * @param scene the scene to create the ground mesh in
  26982. * @returns the created ground mesh
  26983. */
  26984. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26985. }
  26986. }
  26987. declare module "babylonjs/Physics/physicsJoint" {
  26988. import { Vector3 } from "babylonjs/Maths/math.vector";
  26989. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26990. /**
  26991. * Interface for Physics-Joint data
  26992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26993. */
  26994. export interface PhysicsJointData {
  26995. /**
  26996. * The main pivot of the joint
  26997. */
  26998. mainPivot?: Vector3;
  26999. /**
  27000. * The connected pivot of the joint
  27001. */
  27002. connectedPivot?: Vector3;
  27003. /**
  27004. * The main axis of the joint
  27005. */
  27006. mainAxis?: Vector3;
  27007. /**
  27008. * The connected axis of the joint
  27009. */
  27010. connectedAxis?: Vector3;
  27011. /**
  27012. * The collision of the joint
  27013. */
  27014. collision?: boolean;
  27015. /**
  27016. * Native Oimo/Cannon/Energy data
  27017. */
  27018. nativeParams?: any;
  27019. }
  27020. /**
  27021. * This is a holder class for the physics joint created by the physics plugin
  27022. * It holds a set of functions to control the underlying joint
  27023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27024. */
  27025. export class PhysicsJoint {
  27026. /**
  27027. * The type of the physics joint
  27028. */
  27029. type: number;
  27030. /**
  27031. * The data for the physics joint
  27032. */
  27033. jointData: PhysicsJointData;
  27034. private _physicsJoint;
  27035. protected _physicsPlugin: IPhysicsEnginePlugin;
  27036. /**
  27037. * Initializes the physics joint
  27038. * @param type The type of the physics joint
  27039. * @param jointData The data for the physics joint
  27040. */
  27041. constructor(
  27042. /**
  27043. * The type of the physics joint
  27044. */
  27045. type: number,
  27046. /**
  27047. * The data for the physics joint
  27048. */
  27049. jointData: PhysicsJointData);
  27050. /**
  27051. * Gets the physics joint
  27052. */
  27053. get physicsJoint(): any;
  27054. /**
  27055. * Sets the physics joint
  27056. */
  27057. set physicsJoint(newJoint: any);
  27058. /**
  27059. * Sets the physics plugin
  27060. */
  27061. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27062. /**
  27063. * Execute a function that is physics-plugin specific.
  27064. * @param {Function} func the function that will be executed.
  27065. * It accepts two parameters: the physics world and the physics joint
  27066. */
  27067. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27068. /**
  27069. * Distance-Joint type
  27070. */
  27071. static DistanceJoint: number;
  27072. /**
  27073. * Hinge-Joint type
  27074. */
  27075. static HingeJoint: number;
  27076. /**
  27077. * Ball-and-Socket joint type
  27078. */
  27079. static BallAndSocketJoint: number;
  27080. /**
  27081. * Wheel-Joint type
  27082. */
  27083. static WheelJoint: number;
  27084. /**
  27085. * Slider-Joint type
  27086. */
  27087. static SliderJoint: number;
  27088. /**
  27089. * Prismatic-Joint type
  27090. */
  27091. static PrismaticJoint: number;
  27092. /**
  27093. * Universal-Joint type
  27094. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27095. */
  27096. static UniversalJoint: number;
  27097. /**
  27098. * Hinge-Joint 2 type
  27099. */
  27100. static Hinge2Joint: number;
  27101. /**
  27102. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27103. */
  27104. static PointToPointJoint: number;
  27105. /**
  27106. * Spring-Joint type
  27107. */
  27108. static SpringJoint: number;
  27109. /**
  27110. * Lock-Joint type
  27111. */
  27112. static LockJoint: number;
  27113. }
  27114. /**
  27115. * A class representing a physics distance joint
  27116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27117. */
  27118. export class DistanceJoint extends PhysicsJoint {
  27119. /**
  27120. *
  27121. * @param jointData The data for the Distance-Joint
  27122. */
  27123. constructor(jointData: DistanceJointData);
  27124. /**
  27125. * Update the predefined distance.
  27126. * @param maxDistance The maximum preferred distance
  27127. * @param minDistance The minimum preferred distance
  27128. */
  27129. updateDistance(maxDistance: number, minDistance?: number): void;
  27130. }
  27131. /**
  27132. * Represents a Motor-Enabled Joint
  27133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27134. */
  27135. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27136. /**
  27137. * Initializes the Motor-Enabled Joint
  27138. * @param type The type of the joint
  27139. * @param jointData The physica joint data for the joint
  27140. */
  27141. constructor(type: number, jointData: PhysicsJointData);
  27142. /**
  27143. * Set the motor values.
  27144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27145. * @param force the force to apply
  27146. * @param maxForce max force for this motor.
  27147. */
  27148. setMotor(force?: number, maxForce?: number): void;
  27149. /**
  27150. * Set the motor's limits.
  27151. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27152. * @param upperLimit The upper limit of the motor
  27153. * @param lowerLimit The lower limit of the motor
  27154. */
  27155. setLimit(upperLimit: number, lowerLimit?: number): void;
  27156. }
  27157. /**
  27158. * This class represents a single physics Hinge-Joint
  27159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27160. */
  27161. export class HingeJoint extends MotorEnabledJoint {
  27162. /**
  27163. * Initializes the Hinge-Joint
  27164. * @param jointData The joint data for the Hinge-Joint
  27165. */
  27166. constructor(jointData: PhysicsJointData);
  27167. /**
  27168. * Set the motor values.
  27169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27170. * @param {number} force the force to apply
  27171. * @param {number} maxForce max force for this motor.
  27172. */
  27173. setMotor(force?: number, maxForce?: number): void;
  27174. /**
  27175. * Set the motor's limits.
  27176. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27177. * @param upperLimit The upper limit of the motor
  27178. * @param lowerLimit The lower limit of the motor
  27179. */
  27180. setLimit(upperLimit: number, lowerLimit?: number): void;
  27181. }
  27182. /**
  27183. * This class represents a dual hinge physics joint (same as wheel joint)
  27184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27185. */
  27186. export class Hinge2Joint extends MotorEnabledJoint {
  27187. /**
  27188. * Initializes the Hinge2-Joint
  27189. * @param jointData The joint data for the Hinge2-Joint
  27190. */
  27191. constructor(jointData: PhysicsJointData);
  27192. /**
  27193. * Set the motor values.
  27194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27195. * @param {number} targetSpeed the speed the motor is to reach
  27196. * @param {number} maxForce max force for this motor.
  27197. * @param {motorIndex} the motor's index, 0 or 1.
  27198. */
  27199. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27200. /**
  27201. * Set the motor limits.
  27202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27203. * @param {number} upperLimit the upper limit
  27204. * @param {number} lowerLimit lower limit
  27205. * @param {motorIndex} the motor's index, 0 or 1.
  27206. */
  27207. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27208. }
  27209. /**
  27210. * Interface for a motor enabled joint
  27211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27212. */
  27213. export interface IMotorEnabledJoint {
  27214. /**
  27215. * Physics joint
  27216. */
  27217. physicsJoint: any;
  27218. /**
  27219. * Sets the motor of the motor-enabled joint
  27220. * @param force The force of the motor
  27221. * @param maxForce The maximum force of the motor
  27222. * @param motorIndex The index of the motor
  27223. */
  27224. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27225. /**
  27226. * Sets the limit of the motor
  27227. * @param upperLimit The upper limit of the motor
  27228. * @param lowerLimit The lower limit of the motor
  27229. * @param motorIndex The index of the motor
  27230. */
  27231. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27232. }
  27233. /**
  27234. * Joint data for a Distance-Joint
  27235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27236. */
  27237. export interface DistanceJointData extends PhysicsJointData {
  27238. /**
  27239. * Max distance the 2 joint objects can be apart
  27240. */
  27241. maxDistance: number;
  27242. }
  27243. /**
  27244. * Joint data from a spring joint
  27245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27246. */
  27247. export interface SpringJointData extends PhysicsJointData {
  27248. /**
  27249. * Length of the spring
  27250. */
  27251. length: number;
  27252. /**
  27253. * Stiffness of the spring
  27254. */
  27255. stiffness: number;
  27256. /**
  27257. * Damping of the spring
  27258. */
  27259. damping: number;
  27260. /** this callback will be called when applying the force to the impostors. */
  27261. forceApplicationCallback: () => void;
  27262. }
  27263. }
  27264. declare module "babylonjs/Physics/physicsRaycastResult" {
  27265. import { Vector3 } from "babylonjs/Maths/math.vector";
  27266. /**
  27267. * Holds the data for the raycast result
  27268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27269. */
  27270. export class PhysicsRaycastResult {
  27271. private _hasHit;
  27272. private _hitDistance;
  27273. private _hitNormalWorld;
  27274. private _hitPointWorld;
  27275. private _rayFromWorld;
  27276. private _rayToWorld;
  27277. /**
  27278. * Gets if there was a hit
  27279. */
  27280. get hasHit(): boolean;
  27281. /**
  27282. * Gets the distance from the hit
  27283. */
  27284. get hitDistance(): number;
  27285. /**
  27286. * Gets the hit normal/direction in the world
  27287. */
  27288. get hitNormalWorld(): Vector3;
  27289. /**
  27290. * Gets the hit point in the world
  27291. */
  27292. get hitPointWorld(): Vector3;
  27293. /**
  27294. * Gets the ray "start point" of the ray in the world
  27295. */
  27296. get rayFromWorld(): Vector3;
  27297. /**
  27298. * Gets the ray "end point" of the ray in the world
  27299. */
  27300. get rayToWorld(): Vector3;
  27301. /**
  27302. * Sets the hit data (normal & point in world space)
  27303. * @param hitNormalWorld defines the normal in world space
  27304. * @param hitPointWorld defines the point in world space
  27305. */
  27306. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27307. /**
  27308. * Sets the distance from the start point to the hit point
  27309. * @param distance
  27310. */
  27311. setHitDistance(distance: number): void;
  27312. /**
  27313. * Calculates the distance manually
  27314. */
  27315. calculateHitDistance(): void;
  27316. /**
  27317. * Resets all the values to default
  27318. * @param from The from point on world space
  27319. * @param to The to point on world space
  27320. */
  27321. reset(from?: Vector3, to?: Vector3): void;
  27322. }
  27323. /**
  27324. * Interface for the size containing width and height
  27325. */
  27326. interface IXYZ {
  27327. /**
  27328. * X
  27329. */
  27330. x: number;
  27331. /**
  27332. * Y
  27333. */
  27334. y: number;
  27335. /**
  27336. * Z
  27337. */
  27338. z: number;
  27339. }
  27340. }
  27341. declare module "babylonjs/Physics/IPhysicsEngine" {
  27342. import { Nullable } from "babylonjs/types";
  27343. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27345. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27346. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27347. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27348. /**
  27349. * Interface used to describe a physics joint
  27350. */
  27351. export interface PhysicsImpostorJoint {
  27352. /** Defines the main impostor to which the joint is linked */
  27353. mainImpostor: PhysicsImpostor;
  27354. /** Defines the impostor that is connected to the main impostor using this joint */
  27355. connectedImpostor: PhysicsImpostor;
  27356. /** Defines the joint itself */
  27357. joint: PhysicsJoint;
  27358. }
  27359. /** @hidden */
  27360. export interface IPhysicsEnginePlugin {
  27361. world: any;
  27362. name: string;
  27363. setGravity(gravity: Vector3): void;
  27364. setTimeStep(timeStep: number): void;
  27365. getTimeStep(): number;
  27366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27370. removePhysicsBody(impostor: PhysicsImpostor): void;
  27371. generateJoint(joint: PhysicsImpostorJoint): void;
  27372. removeJoint(joint: PhysicsImpostorJoint): void;
  27373. isSupported(): boolean;
  27374. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27375. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27376. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27377. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27378. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27379. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27381. getBodyMass(impostor: PhysicsImpostor): number;
  27382. getBodyFriction(impostor: PhysicsImpostor): number;
  27383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27384. getBodyRestitution(impostor: PhysicsImpostor): number;
  27385. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27386. getBodyPressure?(impostor: PhysicsImpostor): number;
  27387. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27388. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27389. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27390. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27391. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27392. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27393. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27394. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27395. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27396. sleepBody(impostor: PhysicsImpostor): void;
  27397. wakeUpBody(impostor: PhysicsImpostor): void;
  27398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27400. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27401. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27402. getRadius(impostor: PhysicsImpostor): number;
  27403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27404. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27405. dispose(): void;
  27406. }
  27407. /**
  27408. * Interface used to define a physics engine
  27409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27410. */
  27411. export interface IPhysicsEngine {
  27412. /**
  27413. * Gets the gravity vector used by the simulation
  27414. */
  27415. gravity: Vector3;
  27416. /**
  27417. * Sets the gravity vector used by the simulation
  27418. * @param gravity defines the gravity vector to use
  27419. */
  27420. setGravity(gravity: Vector3): void;
  27421. /**
  27422. * Set the time step of the physics engine.
  27423. * Default is 1/60.
  27424. * To slow it down, enter 1/600 for example.
  27425. * To speed it up, 1/30
  27426. * @param newTimeStep the new timestep to apply to this world.
  27427. */
  27428. setTimeStep(newTimeStep: number): void;
  27429. /**
  27430. * Get the time step of the physics engine.
  27431. * @returns the current time step
  27432. */
  27433. getTimeStep(): number;
  27434. /**
  27435. * Set the sub time step of the physics engine.
  27436. * Default is 0 meaning there is no sub steps
  27437. * To increase physics resolution precision, set a small value (like 1 ms)
  27438. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27439. */
  27440. setSubTimeStep(subTimeStep: number): void;
  27441. /**
  27442. * Get the sub time step of the physics engine.
  27443. * @returns the current sub time step
  27444. */
  27445. getSubTimeStep(): number;
  27446. /**
  27447. * Release all resources
  27448. */
  27449. dispose(): void;
  27450. /**
  27451. * Gets the name of the current physics plugin
  27452. * @returns the name of the plugin
  27453. */
  27454. getPhysicsPluginName(): string;
  27455. /**
  27456. * Adding a new impostor for the impostor tracking.
  27457. * This will be done by the impostor itself.
  27458. * @param impostor the impostor to add
  27459. */
  27460. addImpostor(impostor: PhysicsImpostor): void;
  27461. /**
  27462. * Remove an impostor from the engine.
  27463. * This impostor and its mesh will not longer be updated by the physics engine.
  27464. * @param impostor the impostor to remove
  27465. */
  27466. removeImpostor(impostor: PhysicsImpostor): void;
  27467. /**
  27468. * Add a joint to the physics engine
  27469. * @param mainImpostor defines the main impostor to which the joint is added.
  27470. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27471. * @param joint defines the joint that will connect both impostors.
  27472. */
  27473. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27474. /**
  27475. * Removes a joint from the simulation
  27476. * @param mainImpostor defines the impostor used with the joint
  27477. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27478. * @param joint defines the joint to remove
  27479. */
  27480. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27481. /**
  27482. * Gets the current plugin used to run the simulation
  27483. * @returns current plugin
  27484. */
  27485. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27486. /**
  27487. * Gets the list of physic impostors
  27488. * @returns an array of PhysicsImpostor
  27489. */
  27490. getImpostors(): Array<PhysicsImpostor>;
  27491. /**
  27492. * Gets the impostor for a physics enabled object
  27493. * @param object defines the object impersonated by the impostor
  27494. * @returns the PhysicsImpostor or null if not found
  27495. */
  27496. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27497. /**
  27498. * Gets the impostor for a physics body object
  27499. * @param body defines physics body used by the impostor
  27500. * @returns the PhysicsImpostor or null if not found
  27501. */
  27502. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27503. /**
  27504. * Does a raycast in the physics world
  27505. * @param from when should the ray start?
  27506. * @param to when should the ray end?
  27507. * @returns PhysicsRaycastResult
  27508. */
  27509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27510. /**
  27511. * Called by the scene. No need to call it.
  27512. * @param delta defines the timespam between frames
  27513. */
  27514. _step(delta: number): void;
  27515. }
  27516. }
  27517. declare module "babylonjs/Physics/physicsImpostor" {
  27518. import { Nullable, IndicesArray } from "babylonjs/types";
  27519. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27522. import { Scene } from "babylonjs/scene";
  27523. import { Bone } from "babylonjs/Bones/bone";
  27524. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27525. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27526. import { Space } from "babylonjs/Maths/math.axis";
  27527. /**
  27528. * The interface for the physics imposter parameters
  27529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27530. */
  27531. export interface PhysicsImpostorParameters {
  27532. /**
  27533. * The mass of the physics imposter
  27534. */
  27535. mass: number;
  27536. /**
  27537. * The friction of the physics imposter
  27538. */
  27539. friction?: number;
  27540. /**
  27541. * The coefficient of restitution of the physics imposter
  27542. */
  27543. restitution?: number;
  27544. /**
  27545. * The native options of the physics imposter
  27546. */
  27547. nativeOptions?: any;
  27548. /**
  27549. * Specifies if the parent should be ignored
  27550. */
  27551. ignoreParent?: boolean;
  27552. /**
  27553. * Specifies if bi-directional transformations should be disabled
  27554. */
  27555. disableBidirectionalTransformation?: boolean;
  27556. /**
  27557. * The pressure inside the physics imposter, soft object only
  27558. */
  27559. pressure?: number;
  27560. /**
  27561. * The stiffness the physics imposter, soft object only
  27562. */
  27563. stiffness?: number;
  27564. /**
  27565. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27566. */
  27567. velocityIterations?: number;
  27568. /**
  27569. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27570. */
  27571. positionIterations?: number;
  27572. /**
  27573. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27574. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27575. * Add to fix multiple points
  27576. */
  27577. fixedPoints?: number;
  27578. /**
  27579. * The collision margin around a soft object
  27580. */
  27581. margin?: number;
  27582. /**
  27583. * The collision margin around a soft object
  27584. */
  27585. damping?: number;
  27586. /**
  27587. * The path for a rope based on an extrusion
  27588. */
  27589. path?: any;
  27590. /**
  27591. * The shape of an extrusion used for a rope based on an extrusion
  27592. */
  27593. shape?: any;
  27594. }
  27595. /**
  27596. * Interface for a physics-enabled object
  27597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27598. */
  27599. export interface IPhysicsEnabledObject {
  27600. /**
  27601. * The position of the physics-enabled object
  27602. */
  27603. position: Vector3;
  27604. /**
  27605. * The rotation of the physics-enabled object
  27606. */
  27607. rotationQuaternion: Nullable<Quaternion>;
  27608. /**
  27609. * The scale of the physics-enabled object
  27610. */
  27611. scaling: Vector3;
  27612. /**
  27613. * The rotation of the physics-enabled object
  27614. */
  27615. rotation?: Vector3;
  27616. /**
  27617. * The parent of the physics-enabled object
  27618. */
  27619. parent?: any;
  27620. /**
  27621. * The bounding info of the physics-enabled object
  27622. * @returns The bounding info of the physics-enabled object
  27623. */
  27624. getBoundingInfo(): BoundingInfo;
  27625. /**
  27626. * Computes the world matrix
  27627. * @param force Specifies if the world matrix should be computed by force
  27628. * @returns A world matrix
  27629. */
  27630. computeWorldMatrix(force: boolean): Matrix;
  27631. /**
  27632. * Gets the world matrix
  27633. * @returns A world matrix
  27634. */
  27635. getWorldMatrix?(): Matrix;
  27636. /**
  27637. * Gets the child meshes
  27638. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27639. * @returns An array of abstract meshes
  27640. */
  27641. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27642. /**
  27643. * Gets the vertex data
  27644. * @param kind The type of vertex data
  27645. * @returns A nullable array of numbers, or a float32 array
  27646. */
  27647. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27648. /**
  27649. * Gets the indices from the mesh
  27650. * @returns A nullable array of index arrays
  27651. */
  27652. getIndices?(): Nullable<IndicesArray>;
  27653. /**
  27654. * Gets the scene from the mesh
  27655. * @returns the indices array or null
  27656. */
  27657. getScene?(): Scene;
  27658. /**
  27659. * Gets the absolute position from the mesh
  27660. * @returns the absolute position
  27661. */
  27662. getAbsolutePosition(): Vector3;
  27663. /**
  27664. * Gets the absolute pivot point from the mesh
  27665. * @returns the absolute pivot point
  27666. */
  27667. getAbsolutePivotPoint(): Vector3;
  27668. /**
  27669. * Rotates the mesh
  27670. * @param axis The axis of rotation
  27671. * @param amount The amount of rotation
  27672. * @param space The space of the rotation
  27673. * @returns The rotation transform node
  27674. */
  27675. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27676. /**
  27677. * Translates the mesh
  27678. * @param axis The axis of translation
  27679. * @param distance The distance of translation
  27680. * @param space The space of the translation
  27681. * @returns The transform node
  27682. */
  27683. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27684. /**
  27685. * Sets the absolute position of the mesh
  27686. * @param absolutePosition The absolute position of the mesh
  27687. * @returns The transform node
  27688. */
  27689. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27690. /**
  27691. * Gets the class name of the mesh
  27692. * @returns The class name
  27693. */
  27694. getClassName(): string;
  27695. }
  27696. /**
  27697. * Represents a physics imposter
  27698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27699. */
  27700. export class PhysicsImpostor {
  27701. /**
  27702. * The physics-enabled object used as the physics imposter
  27703. */
  27704. object: IPhysicsEnabledObject;
  27705. /**
  27706. * The type of the physics imposter
  27707. */
  27708. type: number;
  27709. private _options;
  27710. private _scene?;
  27711. /**
  27712. * The default object size of the imposter
  27713. */
  27714. static DEFAULT_OBJECT_SIZE: Vector3;
  27715. /**
  27716. * The identity quaternion of the imposter
  27717. */
  27718. static IDENTITY_QUATERNION: Quaternion;
  27719. /** @hidden */
  27720. _pluginData: any;
  27721. private _physicsEngine;
  27722. private _physicsBody;
  27723. private _bodyUpdateRequired;
  27724. private _onBeforePhysicsStepCallbacks;
  27725. private _onAfterPhysicsStepCallbacks;
  27726. /** @hidden */
  27727. _onPhysicsCollideCallbacks: Array<{
  27728. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27729. otherImpostors: Array<PhysicsImpostor>;
  27730. }>;
  27731. private _deltaPosition;
  27732. private _deltaRotation;
  27733. private _deltaRotationConjugated;
  27734. /** @hidden */
  27735. _isFromLine: boolean;
  27736. private _parent;
  27737. private _isDisposed;
  27738. private static _tmpVecs;
  27739. private static _tmpQuat;
  27740. /**
  27741. * Specifies if the physics imposter is disposed
  27742. */
  27743. get isDisposed(): boolean;
  27744. /**
  27745. * Gets the mass of the physics imposter
  27746. */
  27747. get mass(): number;
  27748. set mass(value: number);
  27749. /**
  27750. * Gets the coefficient of friction
  27751. */
  27752. get friction(): number;
  27753. /**
  27754. * Sets the coefficient of friction
  27755. */
  27756. set friction(value: number);
  27757. /**
  27758. * Gets the coefficient of restitution
  27759. */
  27760. get restitution(): number;
  27761. /**
  27762. * Sets the coefficient of restitution
  27763. */
  27764. set restitution(value: number);
  27765. /**
  27766. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27767. */
  27768. get pressure(): number;
  27769. /**
  27770. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27771. */
  27772. set pressure(value: number);
  27773. /**
  27774. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27775. */
  27776. get stiffness(): number;
  27777. /**
  27778. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27779. */
  27780. set stiffness(value: number);
  27781. /**
  27782. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27783. */
  27784. get velocityIterations(): number;
  27785. /**
  27786. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27787. */
  27788. set velocityIterations(value: number);
  27789. /**
  27790. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27791. */
  27792. get positionIterations(): number;
  27793. /**
  27794. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27795. */
  27796. set positionIterations(value: number);
  27797. /**
  27798. * The unique id of the physics imposter
  27799. * set by the physics engine when adding this impostor to the array
  27800. */
  27801. uniqueId: number;
  27802. /**
  27803. * @hidden
  27804. */
  27805. soft: boolean;
  27806. /**
  27807. * @hidden
  27808. */
  27809. segments: number;
  27810. private _joints;
  27811. /**
  27812. * Initializes the physics imposter
  27813. * @param object The physics-enabled object used as the physics imposter
  27814. * @param type The type of the physics imposter
  27815. * @param _options The options for the physics imposter
  27816. * @param _scene The Babylon scene
  27817. */
  27818. constructor(
  27819. /**
  27820. * The physics-enabled object used as the physics imposter
  27821. */
  27822. object: IPhysicsEnabledObject,
  27823. /**
  27824. * The type of the physics imposter
  27825. */
  27826. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27827. /**
  27828. * This function will completly initialize this impostor.
  27829. * It will create a new body - but only if this mesh has no parent.
  27830. * If it has, this impostor will not be used other than to define the impostor
  27831. * of the child mesh.
  27832. * @hidden
  27833. */
  27834. _init(): void;
  27835. private _getPhysicsParent;
  27836. /**
  27837. * Should a new body be generated.
  27838. * @returns boolean specifying if body initialization is required
  27839. */
  27840. isBodyInitRequired(): boolean;
  27841. /**
  27842. * Sets the updated scaling
  27843. * @param updated Specifies if the scaling is updated
  27844. */
  27845. setScalingUpdated(): void;
  27846. /**
  27847. * Force a regeneration of this or the parent's impostor's body.
  27848. * Use under cautious - This will remove all joints already implemented.
  27849. */
  27850. forceUpdate(): void;
  27851. /**
  27852. * Gets the body that holds this impostor. Either its own, or its parent.
  27853. */
  27854. get physicsBody(): any;
  27855. /**
  27856. * Get the parent of the physics imposter
  27857. * @returns Physics imposter or null
  27858. */
  27859. get parent(): Nullable<PhysicsImpostor>;
  27860. /**
  27861. * Sets the parent of the physics imposter
  27862. */
  27863. set parent(value: Nullable<PhysicsImpostor>);
  27864. /**
  27865. * Set the physics body. Used mainly by the physics engine/plugin
  27866. */
  27867. set physicsBody(physicsBody: any);
  27868. /**
  27869. * Resets the update flags
  27870. */
  27871. resetUpdateFlags(): void;
  27872. /**
  27873. * Gets the object extend size
  27874. * @returns the object extend size
  27875. */
  27876. getObjectExtendSize(): Vector3;
  27877. /**
  27878. * Gets the object center
  27879. * @returns The object center
  27880. */
  27881. getObjectCenter(): Vector3;
  27882. /**
  27883. * Get a specific parameter from the options parameters
  27884. * @param paramName The object parameter name
  27885. * @returns The object parameter
  27886. */
  27887. getParam(paramName: string): any;
  27888. /**
  27889. * Sets a specific parameter in the options given to the physics plugin
  27890. * @param paramName The parameter name
  27891. * @param value The value of the parameter
  27892. */
  27893. setParam(paramName: string, value: number): void;
  27894. /**
  27895. * Specifically change the body's mass option. Won't recreate the physics body object
  27896. * @param mass The mass of the physics imposter
  27897. */
  27898. setMass(mass: number): void;
  27899. /**
  27900. * Gets the linear velocity
  27901. * @returns linear velocity or null
  27902. */
  27903. getLinearVelocity(): Nullable<Vector3>;
  27904. /**
  27905. * Sets the linear velocity
  27906. * @param velocity linear velocity or null
  27907. */
  27908. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27909. /**
  27910. * Gets the angular velocity
  27911. * @returns angular velocity or null
  27912. */
  27913. getAngularVelocity(): Nullable<Vector3>;
  27914. /**
  27915. * Sets the angular velocity
  27916. * @param velocity The velocity or null
  27917. */
  27918. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27919. /**
  27920. * Execute a function with the physics plugin native code
  27921. * Provide a function the will have two variables - the world object and the physics body object
  27922. * @param func The function to execute with the physics plugin native code
  27923. */
  27924. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27925. /**
  27926. * Register a function that will be executed before the physics world is stepping forward
  27927. * @param func The function to execute before the physics world is stepped forward
  27928. */
  27929. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27930. /**
  27931. * Unregister a function that will be executed before the physics world is stepping forward
  27932. * @param func The function to execute before the physics world is stepped forward
  27933. */
  27934. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27935. /**
  27936. * Register a function that will be executed after the physics step
  27937. * @param func The function to execute after physics step
  27938. */
  27939. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27940. /**
  27941. * Unregisters a function that will be executed after the physics step
  27942. * @param func The function to execute after physics step
  27943. */
  27944. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27945. /**
  27946. * register a function that will be executed when this impostor collides against a different body
  27947. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27948. * @param func Callback that is executed on collision
  27949. */
  27950. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27951. /**
  27952. * Unregisters the physics imposter on contact
  27953. * @param collideAgainst The physics object to collide against
  27954. * @param func Callback to execute on collision
  27955. */
  27956. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27957. private _tmpQuat;
  27958. private _tmpQuat2;
  27959. /**
  27960. * Get the parent rotation
  27961. * @returns The parent rotation
  27962. */
  27963. getParentsRotation(): Quaternion;
  27964. /**
  27965. * this function is executed by the physics engine.
  27966. */
  27967. beforeStep: () => void;
  27968. /**
  27969. * this function is executed by the physics engine
  27970. */
  27971. afterStep: () => void;
  27972. /**
  27973. * Legacy collision detection event support
  27974. */
  27975. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27976. /**
  27977. * event and body object due to cannon's event-based architecture.
  27978. */
  27979. onCollide: (e: {
  27980. body: any;
  27981. }) => void;
  27982. /**
  27983. * Apply a force
  27984. * @param force The force to apply
  27985. * @param contactPoint The contact point for the force
  27986. * @returns The physics imposter
  27987. */
  27988. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27989. /**
  27990. * Apply an impulse
  27991. * @param force The impulse force
  27992. * @param contactPoint The contact point for the impulse force
  27993. * @returns The physics imposter
  27994. */
  27995. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27996. /**
  27997. * A help function to create a joint
  27998. * @param otherImpostor A physics imposter used to create a joint
  27999. * @param jointType The type of joint
  28000. * @param jointData The data for the joint
  28001. * @returns The physics imposter
  28002. */
  28003. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28004. /**
  28005. * Add a joint to this impostor with a different impostor
  28006. * @param otherImpostor A physics imposter used to add a joint
  28007. * @param joint The joint to add
  28008. * @returns The physics imposter
  28009. */
  28010. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28011. /**
  28012. * Add an anchor to a cloth impostor
  28013. * @param otherImpostor rigid impostor to anchor to
  28014. * @param width ratio across width from 0 to 1
  28015. * @param height ratio up height from 0 to 1
  28016. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28017. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28018. * @returns impostor the soft imposter
  28019. */
  28020. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28021. /**
  28022. * Add a hook to a rope impostor
  28023. * @param otherImpostor rigid impostor to anchor to
  28024. * @param length ratio across rope from 0 to 1
  28025. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28026. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28027. * @returns impostor the rope imposter
  28028. */
  28029. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28030. /**
  28031. * Will keep this body still, in a sleep mode.
  28032. * @returns the physics imposter
  28033. */
  28034. sleep(): PhysicsImpostor;
  28035. /**
  28036. * Wake the body up.
  28037. * @returns The physics imposter
  28038. */
  28039. wakeUp(): PhysicsImpostor;
  28040. /**
  28041. * Clones the physics imposter
  28042. * @param newObject The physics imposter clones to this physics-enabled object
  28043. * @returns A nullable physics imposter
  28044. */
  28045. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28046. /**
  28047. * Disposes the physics imposter
  28048. */
  28049. dispose(): void;
  28050. /**
  28051. * Sets the delta position
  28052. * @param position The delta position amount
  28053. */
  28054. setDeltaPosition(position: Vector3): void;
  28055. /**
  28056. * Sets the delta rotation
  28057. * @param rotation The delta rotation amount
  28058. */
  28059. setDeltaRotation(rotation: Quaternion): void;
  28060. /**
  28061. * Gets the box size of the physics imposter and stores the result in the input parameter
  28062. * @param result Stores the box size
  28063. * @returns The physics imposter
  28064. */
  28065. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28066. /**
  28067. * Gets the radius of the physics imposter
  28068. * @returns Radius of the physics imposter
  28069. */
  28070. getRadius(): number;
  28071. /**
  28072. * Sync a bone with this impostor
  28073. * @param bone The bone to sync to the impostor.
  28074. * @param boneMesh The mesh that the bone is influencing.
  28075. * @param jointPivot The pivot of the joint / bone in local space.
  28076. * @param distToJoint Optional distance from the impostor to the joint.
  28077. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28078. */
  28079. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28080. /**
  28081. * Sync impostor to a bone
  28082. * @param bone The bone that the impostor will be synced to.
  28083. * @param boneMesh The mesh that the bone is influencing.
  28084. * @param jointPivot The pivot of the joint / bone in local space.
  28085. * @param distToJoint Optional distance from the impostor to the joint.
  28086. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28087. * @param boneAxis Optional vector3 axis the bone is aligned with
  28088. */
  28089. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28090. /**
  28091. * No-Imposter type
  28092. */
  28093. static NoImpostor: number;
  28094. /**
  28095. * Sphere-Imposter type
  28096. */
  28097. static SphereImpostor: number;
  28098. /**
  28099. * Box-Imposter type
  28100. */
  28101. static BoxImpostor: number;
  28102. /**
  28103. * Plane-Imposter type
  28104. */
  28105. static PlaneImpostor: number;
  28106. /**
  28107. * Mesh-imposter type
  28108. */
  28109. static MeshImpostor: number;
  28110. /**
  28111. * Capsule-Impostor type (Ammo.js plugin only)
  28112. */
  28113. static CapsuleImpostor: number;
  28114. /**
  28115. * Cylinder-Imposter type
  28116. */
  28117. static CylinderImpostor: number;
  28118. /**
  28119. * Particle-Imposter type
  28120. */
  28121. static ParticleImpostor: number;
  28122. /**
  28123. * Heightmap-Imposter type
  28124. */
  28125. static HeightmapImpostor: number;
  28126. /**
  28127. * ConvexHull-Impostor type (Ammo.js plugin only)
  28128. */
  28129. static ConvexHullImpostor: number;
  28130. /**
  28131. * Custom-Imposter type (Ammo.js plugin only)
  28132. */
  28133. static CustomImpostor: number;
  28134. /**
  28135. * Rope-Imposter type
  28136. */
  28137. static RopeImpostor: number;
  28138. /**
  28139. * Cloth-Imposter type
  28140. */
  28141. static ClothImpostor: number;
  28142. /**
  28143. * Softbody-Imposter type
  28144. */
  28145. static SoftbodyImpostor: number;
  28146. }
  28147. }
  28148. declare module "babylonjs/Meshes/mesh" {
  28149. import { Observable } from "babylonjs/Misc/observable";
  28150. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28151. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28152. import { Camera } from "babylonjs/Cameras/camera";
  28153. import { Scene } from "babylonjs/scene";
  28154. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28155. import { Color4 } from "babylonjs/Maths/math.color";
  28156. import { Engine } from "babylonjs/Engines/engine";
  28157. import { Node } from "babylonjs/node";
  28158. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28159. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28160. import { Buffer } from "babylonjs/Meshes/buffer";
  28161. import { Geometry } from "babylonjs/Meshes/geometry";
  28162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28164. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28165. import { Effect } from "babylonjs/Materials/effect";
  28166. import { Material } from "babylonjs/Materials/material";
  28167. import { Skeleton } from "babylonjs/Bones/skeleton";
  28168. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28169. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28170. import { Path3D } from "babylonjs/Maths/math.path";
  28171. import { Plane } from "babylonjs/Maths/math.plane";
  28172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28173. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28174. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28175. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28176. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28177. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28178. /**
  28179. * @hidden
  28180. **/
  28181. export class _CreationDataStorage {
  28182. closePath?: boolean;
  28183. closeArray?: boolean;
  28184. idx: number[];
  28185. dashSize: number;
  28186. gapSize: number;
  28187. path3D: Path3D;
  28188. pathArray: Vector3[][];
  28189. arc: number;
  28190. radius: number;
  28191. cap: number;
  28192. tessellation: number;
  28193. }
  28194. /**
  28195. * @hidden
  28196. **/
  28197. class _InstanceDataStorage {
  28198. visibleInstances: any;
  28199. batchCache: _InstancesBatch;
  28200. instancesBufferSize: number;
  28201. instancesBuffer: Nullable<Buffer>;
  28202. instancesData: Float32Array;
  28203. overridenInstanceCount: number;
  28204. isFrozen: boolean;
  28205. previousBatch: Nullable<_InstancesBatch>;
  28206. hardwareInstancedRendering: boolean;
  28207. sideOrientation: number;
  28208. manualUpdate: boolean;
  28209. }
  28210. /**
  28211. * @hidden
  28212. **/
  28213. export class _InstancesBatch {
  28214. mustReturn: boolean;
  28215. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28216. renderSelf: boolean[];
  28217. hardwareInstancedRendering: boolean[];
  28218. }
  28219. /**
  28220. * @hidden
  28221. **/
  28222. class _ThinInstanceDataStorage {
  28223. instancesCount: number;
  28224. matrixBuffer: Nullable<Buffer>;
  28225. matrixBufferSize: number;
  28226. matrixData: Nullable<Float32Array>;
  28227. boundingVectors: Array<Vector3>;
  28228. }
  28229. /**
  28230. * Class used to represent renderable models
  28231. */
  28232. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28233. /**
  28234. * Mesh side orientation : usually the external or front surface
  28235. */
  28236. static readonly FRONTSIDE: number;
  28237. /**
  28238. * Mesh side orientation : usually the internal or back surface
  28239. */
  28240. static readonly BACKSIDE: number;
  28241. /**
  28242. * Mesh side orientation : both internal and external or front and back surfaces
  28243. */
  28244. static readonly DOUBLESIDE: number;
  28245. /**
  28246. * Mesh side orientation : by default, `FRONTSIDE`
  28247. */
  28248. static readonly DEFAULTSIDE: number;
  28249. /**
  28250. * Mesh cap setting : no cap
  28251. */
  28252. static readonly NO_CAP: number;
  28253. /**
  28254. * Mesh cap setting : one cap at the beginning of the mesh
  28255. */
  28256. static readonly CAP_START: number;
  28257. /**
  28258. * Mesh cap setting : one cap at the end of the mesh
  28259. */
  28260. static readonly CAP_END: number;
  28261. /**
  28262. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28263. */
  28264. static readonly CAP_ALL: number;
  28265. /**
  28266. * Mesh pattern setting : no flip or rotate
  28267. */
  28268. static readonly NO_FLIP: number;
  28269. /**
  28270. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28271. */
  28272. static readonly FLIP_TILE: number;
  28273. /**
  28274. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28275. */
  28276. static readonly ROTATE_TILE: number;
  28277. /**
  28278. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28279. */
  28280. static readonly FLIP_ROW: number;
  28281. /**
  28282. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28283. */
  28284. static readonly ROTATE_ROW: number;
  28285. /**
  28286. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28287. */
  28288. static readonly FLIP_N_ROTATE_TILE: number;
  28289. /**
  28290. * Mesh pattern setting : rotate pattern and rotate
  28291. */
  28292. static readonly FLIP_N_ROTATE_ROW: number;
  28293. /**
  28294. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28295. */
  28296. static readonly CENTER: number;
  28297. /**
  28298. * Mesh tile positioning : part tiles on left
  28299. */
  28300. static readonly LEFT: number;
  28301. /**
  28302. * Mesh tile positioning : part tiles on right
  28303. */
  28304. static readonly RIGHT: number;
  28305. /**
  28306. * Mesh tile positioning : part tiles on top
  28307. */
  28308. static readonly TOP: number;
  28309. /**
  28310. * Mesh tile positioning : part tiles on bottom
  28311. */
  28312. static readonly BOTTOM: number;
  28313. /**
  28314. * Gets the default side orientation.
  28315. * @param orientation the orientation to value to attempt to get
  28316. * @returns the default orientation
  28317. * @hidden
  28318. */
  28319. static _GetDefaultSideOrientation(orientation?: number): number;
  28320. private _internalMeshDataInfo;
  28321. /**
  28322. * An event triggered before rendering the mesh
  28323. */
  28324. get onBeforeRenderObservable(): Observable<Mesh>;
  28325. /**
  28326. * An event triggered before binding the mesh
  28327. */
  28328. get onBeforeBindObservable(): Observable<Mesh>;
  28329. /**
  28330. * An event triggered after rendering the mesh
  28331. */
  28332. get onAfterRenderObservable(): Observable<Mesh>;
  28333. /**
  28334. * An event triggered before drawing the mesh
  28335. */
  28336. get onBeforeDrawObservable(): Observable<Mesh>;
  28337. private _onBeforeDrawObserver;
  28338. /**
  28339. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28340. */
  28341. set onBeforeDraw(callback: () => void);
  28342. get hasInstances(): boolean;
  28343. get hasThinInstances(): boolean;
  28344. /**
  28345. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28346. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28347. */
  28348. delayLoadState: number;
  28349. /**
  28350. * Gets the list of instances created from this mesh
  28351. * it is not supposed to be modified manually.
  28352. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28353. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28354. */
  28355. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28356. /**
  28357. * Gets the file containing delay loading data for this mesh
  28358. */
  28359. delayLoadingFile: string;
  28360. /** @hidden */
  28361. _binaryInfo: any;
  28362. /**
  28363. * User defined function used to change how LOD level selection is done
  28364. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28365. */
  28366. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28367. /**
  28368. * Gets or sets the morph target manager
  28369. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28370. */
  28371. get morphTargetManager(): Nullable<MorphTargetManager>;
  28372. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28373. /** @hidden */
  28374. _creationDataStorage: Nullable<_CreationDataStorage>;
  28375. /** @hidden */
  28376. _geometry: Nullable<Geometry>;
  28377. /** @hidden */
  28378. _delayInfo: Array<string>;
  28379. /** @hidden */
  28380. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28381. /** @hidden */
  28382. _instanceDataStorage: _InstanceDataStorage;
  28383. /** @hidden */
  28384. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28385. private _effectiveMaterial;
  28386. /** @hidden */
  28387. _shouldGenerateFlatShading: boolean;
  28388. /** @hidden */
  28389. _originalBuilderSideOrientation: number;
  28390. /**
  28391. * Use this property to change the original side orientation defined at construction time
  28392. */
  28393. overrideMaterialSideOrientation: Nullable<number>;
  28394. /**
  28395. * Gets the source mesh (the one used to clone this one from)
  28396. */
  28397. get source(): Nullable<Mesh>;
  28398. /**
  28399. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28400. */
  28401. get isUnIndexed(): boolean;
  28402. set isUnIndexed(value: boolean);
  28403. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28404. get worldMatrixInstancedBuffer(): Float32Array;
  28405. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28406. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28407. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28408. /**
  28409. * @constructor
  28410. * @param name The value used by scene.getMeshByName() to do a lookup.
  28411. * @param scene The scene to add this mesh to.
  28412. * @param parent The parent of this mesh, if it has one
  28413. * @param source An optional Mesh from which geometry is shared, cloned.
  28414. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28415. * When false, achieved by calling a clone(), also passing False.
  28416. * This will make creation of children, recursive.
  28417. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28418. */
  28419. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28420. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28421. doNotInstantiate: boolean;
  28422. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28423. /**
  28424. * Gets the class name
  28425. * @returns the string "Mesh".
  28426. */
  28427. getClassName(): string;
  28428. /** @hidden */
  28429. get _isMesh(): boolean;
  28430. /**
  28431. * Returns a description of this mesh
  28432. * @param fullDetails define if full details about this mesh must be used
  28433. * @returns a descriptive string representing this mesh
  28434. */
  28435. toString(fullDetails?: boolean): string;
  28436. /** @hidden */
  28437. _unBindEffect(): void;
  28438. /**
  28439. * Gets a boolean indicating if this mesh has LOD
  28440. */
  28441. get hasLODLevels(): boolean;
  28442. /**
  28443. * Gets the list of MeshLODLevel associated with the current mesh
  28444. * @returns an array of MeshLODLevel
  28445. */
  28446. getLODLevels(): MeshLODLevel[];
  28447. private _sortLODLevels;
  28448. /**
  28449. * Add a mesh as LOD level triggered at the given distance.
  28450. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28451. * @param distance The distance from the center of the object to show this level
  28452. * @param mesh The mesh to be added as LOD level (can be null)
  28453. * @return This mesh (for chaining)
  28454. */
  28455. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28456. /**
  28457. * Returns the LOD level mesh at the passed distance or null if not found.
  28458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28459. * @param distance The distance from the center of the object to show this level
  28460. * @returns a Mesh or `null`
  28461. */
  28462. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28463. /**
  28464. * Remove a mesh from the LOD array
  28465. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28466. * @param mesh defines the mesh to be removed
  28467. * @return This mesh (for chaining)
  28468. */
  28469. removeLODLevel(mesh: Mesh): Mesh;
  28470. /**
  28471. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28472. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28473. * @param camera defines the camera to use to compute distance
  28474. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28475. * @return This mesh (for chaining)
  28476. */
  28477. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28478. /**
  28479. * Gets the mesh internal Geometry object
  28480. */
  28481. get geometry(): Nullable<Geometry>;
  28482. /**
  28483. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28484. * @returns the total number of vertices
  28485. */
  28486. getTotalVertices(): number;
  28487. /**
  28488. * Returns the content of an associated vertex buffer
  28489. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28490. * - VertexBuffer.PositionKind
  28491. * - VertexBuffer.UVKind
  28492. * - VertexBuffer.UV2Kind
  28493. * - VertexBuffer.UV3Kind
  28494. * - VertexBuffer.UV4Kind
  28495. * - VertexBuffer.UV5Kind
  28496. * - VertexBuffer.UV6Kind
  28497. * - VertexBuffer.ColorKind
  28498. * - VertexBuffer.MatricesIndicesKind
  28499. * - VertexBuffer.MatricesIndicesExtraKind
  28500. * - VertexBuffer.MatricesWeightsKind
  28501. * - VertexBuffer.MatricesWeightsExtraKind
  28502. * @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
  28503. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28504. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28505. */
  28506. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28507. /**
  28508. * Returns the mesh VertexBuffer object from the requested `kind`
  28509. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28510. * - VertexBuffer.PositionKind
  28511. * - VertexBuffer.NormalKind
  28512. * - VertexBuffer.UVKind
  28513. * - VertexBuffer.UV2Kind
  28514. * - VertexBuffer.UV3Kind
  28515. * - VertexBuffer.UV4Kind
  28516. * - VertexBuffer.UV5Kind
  28517. * - VertexBuffer.UV6Kind
  28518. * - VertexBuffer.ColorKind
  28519. * - VertexBuffer.MatricesIndicesKind
  28520. * - VertexBuffer.MatricesIndicesExtraKind
  28521. * - VertexBuffer.MatricesWeightsKind
  28522. * - VertexBuffer.MatricesWeightsExtraKind
  28523. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28524. */
  28525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28526. /**
  28527. * Tests if a specific vertex buffer is associated with this mesh
  28528. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28529. * - VertexBuffer.PositionKind
  28530. * - VertexBuffer.NormalKind
  28531. * - VertexBuffer.UVKind
  28532. * - VertexBuffer.UV2Kind
  28533. * - VertexBuffer.UV3Kind
  28534. * - VertexBuffer.UV4Kind
  28535. * - VertexBuffer.UV5Kind
  28536. * - VertexBuffer.UV6Kind
  28537. * - VertexBuffer.ColorKind
  28538. * - VertexBuffer.MatricesIndicesKind
  28539. * - VertexBuffer.MatricesIndicesExtraKind
  28540. * - VertexBuffer.MatricesWeightsKind
  28541. * - VertexBuffer.MatricesWeightsExtraKind
  28542. * @returns a boolean
  28543. */
  28544. isVerticesDataPresent(kind: string): boolean;
  28545. /**
  28546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28547. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28548. * - VertexBuffer.PositionKind
  28549. * - VertexBuffer.UVKind
  28550. * - VertexBuffer.UV2Kind
  28551. * - VertexBuffer.UV3Kind
  28552. * - VertexBuffer.UV4Kind
  28553. * - VertexBuffer.UV5Kind
  28554. * - VertexBuffer.UV6Kind
  28555. * - VertexBuffer.ColorKind
  28556. * - VertexBuffer.MatricesIndicesKind
  28557. * - VertexBuffer.MatricesIndicesExtraKind
  28558. * - VertexBuffer.MatricesWeightsKind
  28559. * - VertexBuffer.MatricesWeightsExtraKind
  28560. * @returns a boolean
  28561. */
  28562. isVertexBufferUpdatable(kind: string): boolean;
  28563. /**
  28564. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28565. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28566. * - VertexBuffer.PositionKind
  28567. * - VertexBuffer.NormalKind
  28568. * - VertexBuffer.UVKind
  28569. * - VertexBuffer.UV2Kind
  28570. * - VertexBuffer.UV3Kind
  28571. * - VertexBuffer.UV4Kind
  28572. * - VertexBuffer.UV5Kind
  28573. * - VertexBuffer.UV6Kind
  28574. * - VertexBuffer.ColorKind
  28575. * - VertexBuffer.MatricesIndicesKind
  28576. * - VertexBuffer.MatricesIndicesExtraKind
  28577. * - VertexBuffer.MatricesWeightsKind
  28578. * - VertexBuffer.MatricesWeightsExtraKind
  28579. * @returns an array of strings
  28580. */
  28581. getVerticesDataKinds(): string[];
  28582. /**
  28583. * Returns a positive integer : the total number of indices in this mesh geometry.
  28584. * @returns the numner of indices or zero if the mesh has no geometry.
  28585. */
  28586. getTotalIndices(): number;
  28587. /**
  28588. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28589. * @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.
  28590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28591. * @returns the indices array or an empty array if the mesh has no geometry
  28592. */
  28593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28594. get isBlocked(): boolean;
  28595. /**
  28596. * Determine if the current mesh is ready to be rendered
  28597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28598. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28599. * @returns true if all associated assets are ready (material, textures, shaders)
  28600. */
  28601. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28602. /**
  28603. * 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.
  28604. */
  28605. get areNormalsFrozen(): boolean;
  28606. /**
  28607. * 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.
  28608. * @returns the current mesh
  28609. */
  28610. freezeNormals(): Mesh;
  28611. /**
  28612. * 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
  28613. * @returns the current mesh
  28614. */
  28615. unfreezeNormals(): Mesh;
  28616. /**
  28617. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28618. */
  28619. set overridenInstanceCount(count: number);
  28620. /** @hidden */
  28621. _preActivate(): Mesh;
  28622. /** @hidden */
  28623. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28624. /** @hidden */
  28625. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28626. protected _afterComputeWorldMatrix(): void;
  28627. /** @hidden */
  28628. _postActivate(): void;
  28629. /**
  28630. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28631. * This means the mesh underlying bounding box and sphere are recomputed.
  28632. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28633. * @returns the current mesh
  28634. */
  28635. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28636. /** @hidden */
  28637. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28638. /**
  28639. * This function will subdivide the mesh into multiple submeshes
  28640. * @param count defines the expected number of submeshes
  28641. */
  28642. subdivide(count: number): void;
  28643. /**
  28644. * Copy a FloatArray into a specific associated vertex buffer
  28645. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28646. * - VertexBuffer.PositionKind
  28647. * - VertexBuffer.UVKind
  28648. * - VertexBuffer.UV2Kind
  28649. * - VertexBuffer.UV3Kind
  28650. * - VertexBuffer.UV4Kind
  28651. * - VertexBuffer.UV5Kind
  28652. * - VertexBuffer.UV6Kind
  28653. * - VertexBuffer.ColorKind
  28654. * - VertexBuffer.MatricesIndicesKind
  28655. * - VertexBuffer.MatricesIndicesExtraKind
  28656. * - VertexBuffer.MatricesWeightsKind
  28657. * - VertexBuffer.MatricesWeightsExtraKind
  28658. * @param data defines the data source
  28659. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28660. * @param stride defines the data stride size (can be null)
  28661. * @returns the current mesh
  28662. */
  28663. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28664. /**
  28665. * Delete a vertex buffer associated with this mesh
  28666. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28667. * - VertexBuffer.PositionKind
  28668. * - VertexBuffer.UVKind
  28669. * - VertexBuffer.UV2Kind
  28670. * - VertexBuffer.UV3Kind
  28671. * - VertexBuffer.UV4Kind
  28672. * - VertexBuffer.UV5Kind
  28673. * - VertexBuffer.UV6Kind
  28674. * - VertexBuffer.ColorKind
  28675. * - VertexBuffer.MatricesIndicesKind
  28676. * - VertexBuffer.MatricesIndicesExtraKind
  28677. * - VertexBuffer.MatricesWeightsKind
  28678. * - VertexBuffer.MatricesWeightsExtraKind
  28679. */
  28680. removeVerticesData(kind: string): void;
  28681. /**
  28682. * Flags an associated vertex buffer as updatable
  28683. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28684. * - VertexBuffer.PositionKind
  28685. * - VertexBuffer.UVKind
  28686. * - VertexBuffer.UV2Kind
  28687. * - VertexBuffer.UV3Kind
  28688. * - VertexBuffer.UV4Kind
  28689. * - VertexBuffer.UV5Kind
  28690. * - VertexBuffer.UV6Kind
  28691. * - VertexBuffer.ColorKind
  28692. * - VertexBuffer.MatricesIndicesKind
  28693. * - VertexBuffer.MatricesIndicesExtraKind
  28694. * - VertexBuffer.MatricesWeightsKind
  28695. * - VertexBuffer.MatricesWeightsExtraKind
  28696. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28697. */
  28698. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28699. /**
  28700. * Sets the mesh global Vertex Buffer
  28701. * @param buffer defines the buffer to use
  28702. * @returns the current mesh
  28703. */
  28704. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28705. /**
  28706. * Update a specific associated vertex buffer
  28707. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28708. * - VertexBuffer.PositionKind
  28709. * - VertexBuffer.UVKind
  28710. * - VertexBuffer.UV2Kind
  28711. * - VertexBuffer.UV3Kind
  28712. * - VertexBuffer.UV4Kind
  28713. * - VertexBuffer.UV5Kind
  28714. * - VertexBuffer.UV6Kind
  28715. * - VertexBuffer.ColorKind
  28716. * - VertexBuffer.MatricesIndicesKind
  28717. * - VertexBuffer.MatricesIndicesExtraKind
  28718. * - VertexBuffer.MatricesWeightsKind
  28719. * - VertexBuffer.MatricesWeightsExtraKind
  28720. * @param data defines the data source
  28721. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28722. * @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)
  28723. * @returns the current mesh
  28724. */
  28725. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28726. /**
  28727. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28728. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28729. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28730. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28731. * @returns the current mesh
  28732. */
  28733. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28734. /**
  28735. * Creates a un-shared specific occurence of the geometry for the mesh.
  28736. * @returns the current mesh
  28737. */
  28738. makeGeometryUnique(): Mesh;
  28739. /**
  28740. * Set the index buffer of this mesh
  28741. * @param indices defines the source data
  28742. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28743. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28744. * @returns the current mesh
  28745. */
  28746. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28747. /**
  28748. * Update the current index buffer
  28749. * @param indices defines the source data
  28750. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28751. * @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)
  28752. * @returns the current mesh
  28753. */
  28754. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28755. /**
  28756. * Invert the geometry to move from a right handed system to a left handed one.
  28757. * @returns the current mesh
  28758. */
  28759. toLeftHanded(): Mesh;
  28760. /** @hidden */
  28761. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28762. /** @hidden */
  28763. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28764. /**
  28765. * Registers for this mesh a javascript function called just before the rendering process
  28766. * @param func defines the function to call before rendering this mesh
  28767. * @returns the current mesh
  28768. */
  28769. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28770. /**
  28771. * Disposes a previously registered javascript function called before the rendering
  28772. * @param func defines the function to remove
  28773. * @returns the current mesh
  28774. */
  28775. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28776. /**
  28777. * Registers for this mesh a javascript function called just after the rendering is complete
  28778. * @param func defines the function to call after rendering this mesh
  28779. * @returns the current mesh
  28780. */
  28781. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28782. /**
  28783. * Disposes a previously registered javascript function called after the rendering.
  28784. * @param func defines the function to remove
  28785. * @returns the current mesh
  28786. */
  28787. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28788. /** @hidden */
  28789. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28790. /** @hidden */
  28791. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28792. /** @hidden */
  28793. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28794. /** @hidden */
  28795. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28796. /** @hidden */
  28797. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28798. /** @hidden */
  28799. _rebuild(): void;
  28800. /** @hidden */
  28801. _freeze(): void;
  28802. /** @hidden */
  28803. _unFreeze(): void;
  28804. /**
  28805. * 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
  28806. * @param subMesh defines the subMesh to render
  28807. * @param enableAlphaMode defines if alpha mode can be changed
  28808. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28809. * @returns the current mesh
  28810. */
  28811. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28812. private _onBeforeDraw;
  28813. /**
  28814. * Renormalize the mesh and patch it up if there are no weights
  28815. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28816. * However in the case of zero weights then we set just a single influence to 1.
  28817. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28818. */
  28819. cleanMatrixWeights(): void;
  28820. private normalizeSkinFourWeights;
  28821. private normalizeSkinWeightsAndExtra;
  28822. /**
  28823. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28824. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28825. * the user know there was an issue with importing the mesh
  28826. * @returns a validation object with skinned, valid and report string
  28827. */
  28828. validateSkinning(): {
  28829. skinned: boolean;
  28830. valid: boolean;
  28831. report: string;
  28832. };
  28833. /** @hidden */
  28834. _checkDelayState(): Mesh;
  28835. private _queueLoad;
  28836. /**
  28837. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28838. * A mesh is in the frustum if its bounding box intersects the frustum
  28839. * @param frustumPlanes defines the frustum to test
  28840. * @returns true if the mesh is in the frustum planes
  28841. */
  28842. isInFrustum(frustumPlanes: Plane[]): boolean;
  28843. /**
  28844. * Sets the mesh material by the material or multiMaterial `id` property
  28845. * @param id is a string identifying the material or the multiMaterial
  28846. * @returns the current mesh
  28847. */
  28848. setMaterialByID(id: string): Mesh;
  28849. /**
  28850. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28851. * @returns an array of IAnimatable
  28852. */
  28853. getAnimatables(): IAnimatable[];
  28854. /**
  28855. * Modifies the mesh geometry according to the passed transformation matrix.
  28856. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28857. * The mesh normals are modified using the same transformation.
  28858. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28859. * @param transform defines the transform matrix to use
  28860. * @see https://doc.babylonjs.com/resources/baking_transformations
  28861. * @returns the current mesh
  28862. */
  28863. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28864. /**
  28865. * Modifies the mesh geometry according to its own current World Matrix.
  28866. * The mesh World Matrix is then reset.
  28867. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28868. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28869. * @see https://doc.babylonjs.com/resources/baking_transformations
  28870. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28871. * @returns the current mesh
  28872. */
  28873. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28874. /** @hidden */
  28875. get _positions(): Nullable<Vector3[]>;
  28876. /** @hidden */
  28877. _resetPointsArrayCache(): Mesh;
  28878. /** @hidden */
  28879. _generatePointsArray(): boolean;
  28880. /**
  28881. * Returns a new Mesh object generated from the current mesh properties.
  28882. * This method must not get confused with createInstance()
  28883. * @param name is a string, the name given to the new mesh
  28884. * @param newParent can be any Node object (default `null`)
  28885. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28886. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28887. * @returns a new mesh
  28888. */
  28889. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28890. /**
  28891. * Releases resources associated with this mesh.
  28892. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28893. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28894. */
  28895. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28896. /** @hidden */
  28897. _disposeInstanceSpecificData(): void;
  28898. /** @hidden */
  28899. _disposeThinInstanceSpecificData(): void;
  28900. /**
  28901. * Modifies the mesh geometry according to a displacement map.
  28902. * 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.
  28903. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28904. * @param url is a string, the URL from the image file is to be downloaded.
  28905. * @param minHeight is the lower limit of the displacement.
  28906. * @param maxHeight is the upper limit of the displacement.
  28907. * @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.
  28908. * @param uvOffset is an optional vector2 used to offset UV.
  28909. * @param uvScale is an optional vector2 used to scale UV.
  28910. * @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.
  28911. * @returns the Mesh.
  28912. */
  28913. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28914. /**
  28915. * Modifies the mesh geometry according to a displacementMap buffer.
  28916. * 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.
  28917. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28918. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28919. * @param heightMapWidth is the width of the buffer image.
  28920. * @param heightMapHeight is the height of the buffer image.
  28921. * @param minHeight is the lower limit of the displacement.
  28922. * @param maxHeight is the upper limit of the displacement.
  28923. * @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.
  28924. * @param uvOffset is an optional vector2 used to offset UV.
  28925. * @param uvScale is an optional vector2 used to scale UV.
  28926. * @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.
  28927. * @returns the Mesh.
  28928. */
  28929. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28930. /**
  28931. * Modify the mesh to get a flat shading rendering.
  28932. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28933. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28934. * @returns current mesh
  28935. */
  28936. convertToFlatShadedMesh(): Mesh;
  28937. /**
  28938. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28939. * In other words, more vertices, no more indices and a single bigger VBO.
  28940. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28941. * @returns current mesh
  28942. */
  28943. convertToUnIndexedMesh(): Mesh;
  28944. /**
  28945. * Inverses facet orientations.
  28946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28947. * @param flipNormals will also inverts the normals
  28948. * @returns current mesh
  28949. */
  28950. flipFaces(flipNormals?: boolean): Mesh;
  28951. /**
  28952. * Increase the number of facets and hence vertices in a mesh
  28953. * Vertex normals are interpolated from existing vertex normals
  28954. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28955. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28956. */
  28957. increaseVertices(numberPerEdge: number): void;
  28958. /**
  28959. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28960. * This will undo any application of covertToFlatShadedMesh
  28961. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28962. */
  28963. forceSharedVertices(): void;
  28964. /** @hidden */
  28965. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28966. /** @hidden */
  28967. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28968. /**
  28969. * Creates a new InstancedMesh object from the mesh model.
  28970. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28971. * @param name defines the name of the new instance
  28972. * @returns a new InstancedMesh
  28973. */
  28974. createInstance(name: string): InstancedMesh;
  28975. /**
  28976. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28977. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28978. * @returns the current mesh
  28979. */
  28980. synchronizeInstances(): Mesh;
  28981. /**
  28982. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28983. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28984. * This should be used together with the simplification to avoid disappearing triangles.
  28985. * @param successCallback an optional success callback to be called after the optimization finished.
  28986. * @returns the current mesh
  28987. */
  28988. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28989. /**
  28990. * Serialize current mesh
  28991. * @param serializationObject defines the object which will receive the serialization data
  28992. */
  28993. serialize(serializationObject: any): void;
  28994. /** @hidden */
  28995. _syncGeometryWithMorphTargetManager(): void;
  28996. /** @hidden */
  28997. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28998. /**
  28999. * Returns a new Mesh object parsed from the source provided.
  29000. * @param parsedMesh is the source
  29001. * @param scene defines the hosting scene
  29002. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29003. * @returns a new Mesh
  29004. */
  29005. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29006. /**
  29007. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29009. * @param name defines the name of the mesh to create
  29010. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29011. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29012. * @param closePath creates a seam between the first and the last points of each path of the path array
  29013. * @param offset is taken in account only if the `pathArray` is containing a single path
  29014. * @param scene defines the hosting scene
  29015. * @param updatable defines if the mesh must be flagged as updatable
  29016. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29017. * @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)
  29018. * @returns a new Mesh
  29019. */
  29020. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29021. /**
  29022. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29023. * @param name defines the name of the mesh to create
  29024. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29025. * @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
  29026. * @param scene defines the hosting scene
  29027. * @param updatable defines if the mesh must be flagged as updatable
  29028. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29029. * @returns a new Mesh
  29030. */
  29031. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29032. /**
  29033. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29034. * @param name defines the name of the mesh to create
  29035. * @param size sets the size (float) of each box side (default 1)
  29036. * @param scene defines the hosting scene
  29037. * @param updatable defines if the mesh must be flagged as updatable
  29038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29039. * @returns a new Mesh
  29040. */
  29041. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29042. /**
  29043. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29044. * @param name defines the name of the mesh to create
  29045. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29046. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29047. * @param scene defines the hosting scene
  29048. * @param updatable defines if the mesh must be flagged as updatable
  29049. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29050. * @returns a new Mesh
  29051. */
  29052. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29053. /**
  29054. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29055. * @param name defines the name of the mesh to create
  29056. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29057. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29058. * @param scene defines the hosting scene
  29059. * @returns a new Mesh
  29060. */
  29061. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29062. /**
  29063. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29064. * @param name defines the name of the mesh to create
  29065. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29066. * @param diameterTop set the top cap diameter (floats, default 1)
  29067. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29068. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29069. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @returns a new Mesh
  29074. */
  29075. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29076. /**
  29077. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29078. * @param name defines the name of the mesh to create
  29079. * @param diameter sets the diameter size (float) of the torus (default 1)
  29080. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29081. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29082. * @param scene defines the hosting scene
  29083. * @param updatable defines if the mesh must be flagged as updatable
  29084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29085. * @returns a new Mesh
  29086. */
  29087. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29088. /**
  29089. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29090. * @param name defines the name of the mesh to create
  29091. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29092. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29093. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29094. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29095. * @param p the number of windings on X axis (positive integers, default 2)
  29096. * @param q the number of windings on Y axis (positive integers, default 3)
  29097. * @param scene defines the hosting scene
  29098. * @param updatable defines if the mesh must be flagged as updatable
  29099. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29100. * @returns a new Mesh
  29101. */
  29102. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29103. /**
  29104. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29105. * @param name defines the name of the mesh to create
  29106. * @param points is an array successive Vector3
  29107. * @param scene defines the hosting scene
  29108. * @param updatable defines if the mesh must be flagged as updatable
  29109. * @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).
  29110. * @returns a new Mesh
  29111. */
  29112. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29113. /**
  29114. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29115. * @param name defines the name of the mesh to create
  29116. * @param points is an array successive Vector3
  29117. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29118. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29119. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29120. * @param scene defines the hosting scene
  29121. * @param updatable defines if the mesh must be flagged as updatable
  29122. * @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)
  29123. * @returns a new Mesh
  29124. */
  29125. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29126. /**
  29127. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29128. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29129. * 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.
  29130. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29131. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29132. * Remember you can only change the shape positions, not their number when updating a polygon.
  29133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29134. * @param name defines the name of the mesh to create
  29135. * @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
  29136. * @param scene defines the hosting scene
  29137. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29138. * @param updatable defines if the mesh must be flagged as updatable
  29139. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29140. * @param earcutInjection can be used to inject your own earcut reference
  29141. * @returns a new Mesh
  29142. */
  29143. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29144. /**
  29145. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29147. * @param name defines the name of the mesh to create
  29148. * @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
  29149. * @param depth defines the height of extrusion
  29150. * @param scene defines the hosting scene
  29151. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29152. * @param updatable defines if the mesh must be flagged as updatable
  29153. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29154. * @param earcutInjection can be used to inject your own earcut reference
  29155. * @returns a new Mesh
  29156. */
  29157. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29158. /**
  29159. * Creates an extruded shape mesh.
  29160. * 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
  29161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29163. * @param name defines the name of the mesh to create
  29164. * @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
  29165. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29166. * @param scale is the value to scale the shape
  29167. * @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
  29168. * @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
  29169. * @param scene defines the hosting scene
  29170. * @param updatable defines if the mesh must be flagged as updatable
  29171. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29172. * @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)
  29173. * @returns a new Mesh
  29174. */
  29175. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29176. /**
  29177. * Creates an custom extruded shape mesh.
  29178. * The custom extrusion is a parametric shape.
  29179. * It has no predefined shape. Its final shape will depend on the input parameters.
  29180. * Please consider using the same method from the MeshBuilder class instead
  29181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29182. * @param name defines the name of the mesh to create
  29183. * @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
  29184. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29185. * @param scaleFunction is a custom Javascript function called on each path point
  29186. * @param rotationFunction is a custom Javascript function called on each path point
  29187. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29188. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29189. * @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
  29190. * @param scene defines the hosting scene
  29191. * @param updatable defines if the mesh must be flagged as updatable
  29192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29193. * @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)
  29194. * @returns a new Mesh
  29195. */
  29196. 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;
  29197. /**
  29198. * Creates lathe mesh.
  29199. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29200. * Please consider using the same method from the MeshBuilder class instead
  29201. * @param name defines the name of the mesh to create
  29202. * @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
  29203. * @param radius is the radius value of the lathe
  29204. * @param tessellation is the side number of the lathe.
  29205. * @param scene defines the hosting scene
  29206. * @param updatable defines if the mesh must be flagged as updatable
  29207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29208. * @returns a new Mesh
  29209. */
  29210. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29211. /**
  29212. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29213. * @param name defines the name of the mesh to create
  29214. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29215. * @param scene defines the hosting scene
  29216. * @param updatable defines if the mesh must be flagged as updatable
  29217. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29218. * @returns a new Mesh
  29219. */
  29220. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29221. /**
  29222. * Creates a ground mesh.
  29223. * Please consider using the same method from the MeshBuilder class instead
  29224. * @param name defines the name of the mesh to create
  29225. * @param width set the width of the ground
  29226. * @param height set the height of the ground
  29227. * @param subdivisions sets the number of subdivisions per side
  29228. * @param scene defines the hosting scene
  29229. * @param updatable defines if the mesh must be flagged as updatable
  29230. * @returns a new Mesh
  29231. */
  29232. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29233. /**
  29234. * Creates a tiled ground mesh.
  29235. * Please consider using the same method from the MeshBuilder class instead
  29236. * @param name defines the name of the mesh to create
  29237. * @param xmin set the ground minimum X coordinate
  29238. * @param zmin set the ground minimum Y coordinate
  29239. * @param xmax set the ground maximum X coordinate
  29240. * @param zmax set the ground maximum Z coordinate
  29241. * @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
  29242. * @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
  29243. * @param scene defines the hosting scene
  29244. * @param updatable defines if the mesh must be flagged as updatable
  29245. * @returns a new Mesh
  29246. */
  29247. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29248. w: number;
  29249. h: number;
  29250. }, precision: {
  29251. w: number;
  29252. h: number;
  29253. }, scene: Scene, updatable?: boolean): Mesh;
  29254. /**
  29255. * Creates a ground mesh from a height map.
  29256. * Please consider using the same method from the MeshBuilder class instead
  29257. * @see https://doc.babylonjs.com/babylon101/height_map
  29258. * @param name defines the name of the mesh to create
  29259. * @param url sets the URL of the height map image resource
  29260. * @param width set the ground width size
  29261. * @param height set the ground height size
  29262. * @param subdivisions sets the number of subdivision per side
  29263. * @param minHeight is the minimum altitude on the ground
  29264. * @param maxHeight is the maximum altitude on the ground
  29265. * @param scene defines the hosting scene
  29266. * @param updatable defines if the mesh must be flagged as updatable
  29267. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29268. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29269. * @returns a new Mesh
  29270. */
  29271. 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;
  29272. /**
  29273. * Creates a tube mesh.
  29274. * The tube is a parametric shape.
  29275. * It has no predefined shape. Its final shape will depend on the input parameters.
  29276. * Please consider using the same method from the MeshBuilder class instead
  29277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29278. * @param name defines the name of the mesh to create
  29279. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29280. * @param radius sets the tube radius size
  29281. * @param tessellation is the number of sides on the tubular surface
  29282. * @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
  29283. * @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
  29284. * @param scene defines the hosting scene
  29285. * @param updatable defines if the mesh must be flagged as updatable
  29286. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29287. * @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)
  29288. * @returns a new Mesh
  29289. */
  29290. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29291. (i: number, distance: number): number;
  29292. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29293. /**
  29294. * Creates a polyhedron mesh.
  29295. * Please consider using the same method from the MeshBuilder class instead.
  29296. * * 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
  29297. * * The parameter `size` (positive float, default 1) sets the polygon size
  29298. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29299. * * 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`
  29300. * * 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
  29301. * * 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)`)
  29302. * * 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
  29303. * * 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
  29304. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29307. * @param name defines the name of the mesh to create
  29308. * @param options defines the options used to create the mesh
  29309. * @param scene defines the hosting scene
  29310. * @returns a new Mesh
  29311. */
  29312. static CreatePolyhedron(name: string, options: {
  29313. type?: number;
  29314. size?: number;
  29315. sizeX?: number;
  29316. sizeY?: number;
  29317. sizeZ?: number;
  29318. custom?: any;
  29319. faceUV?: Vector4[];
  29320. faceColors?: Color4[];
  29321. updatable?: boolean;
  29322. sideOrientation?: number;
  29323. }, scene: Scene): Mesh;
  29324. /**
  29325. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29326. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29327. * * 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`)
  29328. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29329. * * 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
  29330. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29333. * @param name defines the name of the mesh
  29334. * @param options defines the options used to create the mesh
  29335. * @param scene defines the hosting scene
  29336. * @returns a new Mesh
  29337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29338. */
  29339. static CreateIcoSphere(name: string, options: {
  29340. radius?: number;
  29341. flat?: boolean;
  29342. subdivisions?: number;
  29343. sideOrientation?: number;
  29344. updatable?: boolean;
  29345. }, scene: Scene): Mesh;
  29346. /**
  29347. * Creates a decal mesh.
  29348. * Please consider using the same method from the MeshBuilder class instead.
  29349. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29350. * @param name defines the name of the mesh
  29351. * @param sourceMesh defines the mesh receiving the decal
  29352. * @param position sets the position of the decal in world coordinates
  29353. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29354. * @param size sets the decal scaling
  29355. * @param angle sets the angle to rotate the decal
  29356. * @returns a new Mesh
  29357. */
  29358. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29359. /**
  29360. * Prepare internal position array for software CPU skinning
  29361. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29362. */
  29363. setPositionsForCPUSkinning(): Float32Array;
  29364. /**
  29365. * Prepare internal normal array for software CPU skinning
  29366. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29367. */
  29368. setNormalsForCPUSkinning(): Float32Array;
  29369. /**
  29370. * Updates the vertex buffer by applying transformation from the bones
  29371. * @param skeleton defines the skeleton to apply to current mesh
  29372. * @returns the current mesh
  29373. */
  29374. applySkeleton(skeleton: Skeleton): Mesh;
  29375. /**
  29376. * 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
  29377. * @param meshes defines the list of meshes to scan
  29378. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29379. */
  29380. static MinMax(meshes: AbstractMesh[]): {
  29381. min: Vector3;
  29382. max: Vector3;
  29383. };
  29384. /**
  29385. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29386. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29387. * @returns a vector3
  29388. */
  29389. static Center(meshesOrMinMaxVector: {
  29390. min: Vector3;
  29391. max: Vector3;
  29392. } | AbstractMesh[]): Vector3;
  29393. /**
  29394. * Merge the array of meshes into a single mesh for performance reasons.
  29395. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29396. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29397. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29398. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29399. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29400. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29401. * @returns a new mesh
  29402. */
  29403. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29404. /** @hidden */
  29405. addInstance(instance: InstancedMesh): void;
  29406. /** @hidden */
  29407. removeInstance(instance: InstancedMesh): void;
  29408. }
  29409. }
  29410. declare module "babylonjs/Cameras/camera" {
  29411. import { SmartArray } from "babylonjs/Misc/smartArray";
  29412. import { Observable } from "babylonjs/Misc/observable";
  29413. import { Nullable } from "babylonjs/types";
  29414. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29415. import { Scene } from "babylonjs/scene";
  29416. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29417. import { Node } from "babylonjs/node";
  29418. import { Mesh } from "babylonjs/Meshes/mesh";
  29419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29420. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29421. import { Viewport } from "babylonjs/Maths/math.viewport";
  29422. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29424. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29425. import { Ray } from "babylonjs/Culling/ray";
  29426. /**
  29427. * This is the base class of all the camera used in the application.
  29428. * @see https://doc.babylonjs.com/features/cameras
  29429. */
  29430. export class Camera extends Node {
  29431. /** @hidden */
  29432. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29433. /**
  29434. * This is the default projection mode used by the cameras.
  29435. * It helps recreating a feeling of perspective and better appreciate depth.
  29436. * This is the best way to simulate real life cameras.
  29437. */
  29438. static readonly PERSPECTIVE_CAMERA: number;
  29439. /**
  29440. * This helps creating camera with an orthographic mode.
  29441. * 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.
  29442. */
  29443. static readonly ORTHOGRAPHIC_CAMERA: number;
  29444. /**
  29445. * This is the default FOV mode for perspective cameras.
  29446. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29447. */
  29448. static readonly FOVMODE_VERTICAL_FIXED: number;
  29449. /**
  29450. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29451. */
  29452. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29453. /**
  29454. * This specifies ther is no need for a camera rig.
  29455. * Basically only one eye is rendered corresponding to the camera.
  29456. */
  29457. static readonly RIG_MODE_NONE: number;
  29458. /**
  29459. * Simulates a camera Rig with one blue eye and one red eye.
  29460. * This can be use with 3d blue and red glasses.
  29461. */
  29462. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29463. /**
  29464. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29465. */
  29466. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29467. /**
  29468. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29469. */
  29470. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29471. /**
  29472. * Defines that both eyes of the camera will be rendered over under each other.
  29473. */
  29474. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29475. /**
  29476. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29477. */
  29478. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29479. /**
  29480. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29481. */
  29482. static readonly RIG_MODE_VR: number;
  29483. /**
  29484. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29485. */
  29486. static readonly RIG_MODE_WEBVR: number;
  29487. /**
  29488. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29489. */
  29490. static readonly RIG_MODE_CUSTOM: number;
  29491. /**
  29492. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29493. */
  29494. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29495. /**
  29496. * Define the input manager associated with the camera.
  29497. */
  29498. inputs: CameraInputsManager<Camera>;
  29499. /** @hidden */
  29500. _position: Vector3;
  29501. /**
  29502. * Define the current local position of the camera in the scene
  29503. */
  29504. get position(): Vector3;
  29505. set position(newPosition: Vector3);
  29506. /**
  29507. * The vector the camera should consider as up.
  29508. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29509. */
  29510. upVector: Vector3;
  29511. /**
  29512. * Define the current limit on the left side for an orthographic camera
  29513. * In scene unit
  29514. */
  29515. orthoLeft: Nullable<number>;
  29516. /**
  29517. * Define the current limit on the right side for an orthographic camera
  29518. * In scene unit
  29519. */
  29520. orthoRight: Nullable<number>;
  29521. /**
  29522. * Define the current limit on the bottom side for an orthographic camera
  29523. * In scene unit
  29524. */
  29525. orthoBottom: Nullable<number>;
  29526. /**
  29527. * Define the current limit on the top side for an orthographic camera
  29528. * In scene unit
  29529. */
  29530. orthoTop: Nullable<number>;
  29531. /**
  29532. * Field Of View is set in Radians. (default is 0.8)
  29533. */
  29534. fov: number;
  29535. /**
  29536. * Define the minimum distance the camera can see from.
  29537. * This is important to note that the depth buffer are not infinite and the closer it starts
  29538. * the more your scene might encounter depth fighting issue.
  29539. */
  29540. minZ: number;
  29541. /**
  29542. * Define the maximum distance the camera can see to.
  29543. * This is important to note that the depth buffer are not infinite and the further it end
  29544. * the more your scene might encounter depth fighting issue.
  29545. */
  29546. maxZ: number;
  29547. /**
  29548. * Define the default inertia of the camera.
  29549. * This helps giving a smooth feeling to the camera movement.
  29550. */
  29551. inertia: number;
  29552. /**
  29553. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29554. */
  29555. mode: number;
  29556. /**
  29557. * Define whether the camera is intermediate.
  29558. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29559. */
  29560. isIntermediate: boolean;
  29561. /**
  29562. * Define the viewport of the camera.
  29563. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29564. */
  29565. viewport: Viewport;
  29566. /**
  29567. * Restricts the camera to viewing objects with the same layerMask.
  29568. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29569. */
  29570. layerMask: number;
  29571. /**
  29572. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29573. */
  29574. fovMode: number;
  29575. /**
  29576. * Rig mode of the camera.
  29577. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29578. * This is normally controlled byt the camera themselves as internal use.
  29579. */
  29580. cameraRigMode: number;
  29581. /**
  29582. * Defines the distance between both "eyes" in case of a RIG
  29583. */
  29584. interaxialDistance: number;
  29585. /**
  29586. * Defines if stereoscopic rendering is done side by side or over under.
  29587. */
  29588. isStereoscopicSideBySide: boolean;
  29589. /**
  29590. * 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
  29591. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29592. * else in the scene. (Eg. security camera)
  29593. *
  29594. * 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)
  29595. */
  29596. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29597. /**
  29598. * When set, the camera will render to this render target instead of the default canvas
  29599. *
  29600. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29601. */
  29602. outputRenderTarget: Nullable<RenderTargetTexture>;
  29603. /**
  29604. * Observable triggered when the camera view matrix has changed.
  29605. */
  29606. onViewMatrixChangedObservable: Observable<Camera>;
  29607. /**
  29608. * Observable triggered when the camera Projection matrix has changed.
  29609. */
  29610. onProjectionMatrixChangedObservable: Observable<Camera>;
  29611. /**
  29612. * Observable triggered when the inputs have been processed.
  29613. */
  29614. onAfterCheckInputsObservable: Observable<Camera>;
  29615. /**
  29616. * Observable triggered when reset has been called and applied to the camera.
  29617. */
  29618. onRestoreStateObservable: Observable<Camera>;
  29619. /**
  29620. * Is this camera a part of a rig system?
  29621. */
  29622. isRigCamera: boolean;
  29623. /**
  29624. * If isRigCamera set to true this will be set with the parent camera.
  29625. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29626. */
  29627. rigParent?: Camera;
  29628. /** @hidden */
  29629. _cameraRigParams: any;
  29630. /** @hidden */
  29631. _rigCameras: Camera[];
  29632. /** @hidden */
  29633. _rigPostProcess: Nullable<PostProcess>;
  29634. protected _webvrViewMatrix: Matrix;
  29635. /** @hidden */
  29636. _skipRendering: boolean;
  29637. /** @hidden */
  29638. _projectionMatrix: Matrix;
  29639. /** @hidden */
  29640. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29641. /** @hidden */
  29642. _activeMeshes: SmartArray<AbstractMesh>;
  29643. protected _globalPosition: Vector3;
  29644. /** @hidden */
  29645. _computedViewMatrix: Matrix;
  29646. private _doNotComputeProjectionMatrix;
  29647. private _transformMatrix;
  29648. private _frustumPlanes;
  29649. private _refreshFrustumPlanes;
  29650. private _storedFov;
  29651. private _stateStored;
  29652. /**
  29653. * Instantiates a new camera object.
  29654. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29655. * @see https://doc.babylonjs.com/features/cameras
  29656. * @param name Defines the name of the camera in the scene
  29657. * @param position Defines the position of the camera
  29658. * @param scene Defines the scene the camera belongs too
  29659. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29660. */
  29661. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29662. /**
  29663. * Store current camera state (fov, position, etc..)
  29664. * @returns the camera
  29665. */
  29666. storeState(): Camera;
  29667. /**
  29668. * Restores the camera state values if it has been stored. You must call storeState() first
  29669. */
  29670. protected _restoreStateValues(): boolean;
  29671. /**
  29672. * Restored camera state. You must call storeState() first.
  29673. * @returns true if restored and false otherwise
  29674. */
  29675. restoreState(): boolean;
  29676. /**
  29677. * Gets the class name of the camera.
  29678. * @returns the class name
  29679. */
  29680. getClassName(): string;
  29681. /** @hidden */
  29682. readonly _isCamera: boolean;
  29683. /**
  29684. * Gets a string representation of the camera useful for debug purpose.
  29685. * @param fullDetails Defines that a more verboe level of logging is required
  29686. * @returns the string representation
  29687. */
  29688. toString(fullDetails?: boolean): string;
  29689. /**
  29690. * Gets the current world space position of the camera.
  29691. */
  29692. get globalPosition(): Vector3;
  29693. /**
  29694. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29695. * @returns the active meshe list
  29696. */
  29697. getActiveMeshes(): SmartArray<AbstractMesh>;
  29698. /**
  29699. * Check whether a mesh is part of the current active mesh list of the camera
  29700. * @param mesh Defines the mesh to check
  29701. * @returns true if active, false otherwise
  29702. */
  29703. isActiveMesh(mesh: Mesh): boolean;
  29704. /**
  29705. * Is this camera ready to be used/rendered
  29706. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29707. * @return true if the camera is ready
  29708. */
  29709. isReady(completeCheck?: boolean): boolean;
  29710. /** @hidden */
  29711. _initCache(): void;
  29712. /** @hidden */
  29713. _updateCache(ignoreParentClass?: boolean): void;
  29714. /** @hidden */
  29715. _isSynchronized(): boolean;
  29716. /** @hidden */
  29717. _isSynchronizedViewMatrix(): boolean;
  29718. /** @hidden */
  29719. _isSynchronizedProjectionMatrix(): boolean;
  29720. /**
  29721. * Attach the input controls to a specific dom element to get the input from.
  29722. * @param element Defines the element the controls should be listened from
  29723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29724. */
  29725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29726. /**
  29727. * Detach the current controls from the specified dom element.
  29728. * @param element Defines the element to stop listening the inputs from
  29729. */
  29730. detachControl(element: HTMLElement): void;
  29731. /**
  29732. * Update the camera state according to the different inputs gathered during the frame.
  29733. */
  29734. update(): void;
  29735. /** @hidden */
  29736. _checkInputs(): void;
  29737. /** @hidden */
  29738. get rigCameras(): Camera[];
  29739. /**
  29740. * Gets the post process used by the rig cameras
  29741. */
  29742. get rigPostProcess(): Nullable<PostProcess>;
  29743. /**
  29744. * Internal, gets the first post proces.
  29745. * @returns the first post process to be run on this camera.
  29746. */
  29747. _getFirstPostProcess(): Nullable<PostProcess>;
  29748. private _cascadePostProcessesToRigCams;
  29749. /**
  29750. * Attach a post process to the camera.
  29751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29752. * @param postProcess The post process to attach to the camera
  29753. * @param insertAt The position of the post process in case several of them are in use in the scene
  29754. * @returns the position the post process has been inserted at
  29755. */
  29756. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29757. /**
  29758. * Detach a post process to the camera.
  29759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29760. * @param postProcess The post process to detach from the camera
  29761. */
  29762. detachPostProcess(postProcess: PostProcess): void;
  29763. /**
  29764. * Gets the current world matrix of the camera
  29765. */
  29766. getWorldMatrix(): Matrix;
  29767. /** @hidden */
  29768. _getViewMatrix(): Matrix;
  29769. /**
  29770. * Gets the current view matrix of the camera.
  29771. * @param force forces the camera to recompute the matrix without looking at the cached state
  29772. * @returns the view matrix
  29773. */
  29774. getViewMatrix(force?: boolean): Matrix;
  29775. /**
  29776. * Freeze the projection matrix.
  29777. * It will prevent the cache check of the camera projection compute and can speed up perf
  29778. * if no parameter of the camera are meant to change
  29779. * @param projection Defines manually a projection if necessary
  29780. */
  29781. freezeProjectionMatrix(projection?: Matrix): void;
  29782. /**
  29783. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29784. */
  29785. unfreezeProjectionMatrix(): void;
  29786. /**
  29787. * Gets the current projection matrix of the camera.
  29788. * @param force forces the camera to recompute the matrix without looking at the cached state
  29789. * @returns the projection matrix
  29790. */
  29791. getProjectionMatrix(force?: boolean): Matrix;
  29792. /**
  29793. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29794. * @returns a Matrix
  29795. */
  29796. getTransformationMatrix(): Matrix;
  29797. private _updateFrustumPlanes;
  29798. /**
  29799. * Checks if a cullable object (mesh...) is in the camera frustum
  29800. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29801. * @param target The object to check
  29802. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29803. * @returns true if the object is in frustum otherwise false
  29804. */
  29805. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29806. /**
  29807. * Checks if a cullable object (mesh...) is in the camera frustum
  29808. * Unlike isInFrustum this cheks the full bounding box
  29809. * @param target The object to check
  29810. * @returns true if the object is in frustum otherwise false
  29811. */
  29812. isCompletelyInFrustum(target: ICullable): boolean;
  29813. /**
  29814. * Gets a ray in the forward direction from the camera.
  29815. * @param length Defines the length of the ray to create
  29816. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29817. * @param origin Defines the start point of the ray which defaults to the camera position
  29818. * @returns the forward ray
  29819. */
  29820. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29821. /**
  29822. * Releases resources associated with this node.
  29823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29825. */
  29826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29827. /** @hidden */
  29828. _isLeftCamera: boolean;
  29829. /**
  29830. * Gets the left camera of a rig setup in case of Rigged Camera
  29831. */
  29832. get isLeftCamera(): boolean;
  29833. /** @hidden */
  29834. _isRightCamera: boolean;
  29835. /**
  29836. * Gets the right camera of a rig setup in case of Rigged Camera
  29837. */
  29838. get isRightCamera(): boolean;
  29839. /**
  29840. * Gets the left camera of a rig setup in case of Rigged Camera
  29841. */
  29842. get leftCamera(): Nullable<FreeCamera>;
  29843. /**
  29844. * Gets the right camera of a rig setup in case of Rigged Camera
  29845. */
  29846. get rightCamera(): Nullable<FreeCamera>;
  29847. /**
  29848. * Gets the left camera target of a rig setup in case of Rigged Camera
  29849. * @returns the target position
  29850. */
  29851. getLeftTarget(): Nullable<Vector3>;
  29852. /**
  29853. * Gets the right camera target of a rig setup in case of Rigged Camera
  29854. * @returns the target position
  29855. */
  29856. getRightTarget(): Nullable<Vector3>;
  29857. /**
  29858. * @hidden
  29859. */
  29860. setCameraRigMode(mode: number, rigParams: any): void;
  29861. /** @hidden */
  29862. static _setStereoscopicRigMode(camera: Camera): void;
  29863. /** @hidden */
  29864. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29865. /** @hidden */
  29866. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29867. /** @hidden */
  29868. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29869. /** @hidden */
  29870. _getVRProjectionMatrix(): Matrix;
  29871. protected _updateCameraRotationMatrix(): void;
  29872. protected _updateWebVRCameraRotationMatrix(): void;
  29873. /**
  29874. * This function MUST be overwritten by the different WebVR cameras available.
  29875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29876. * @hidden
  29877. */
  29878. _getWebVRProjectionMatrix(): Matrix;
  29879. /**
  29880. * This function MUST be overwritten by the different WebVR cameras available.
  29881. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29882. * @hidden
  29883. */
  29884. _getWebVRViewMatrix(): Matrix;
  29885. /** @hidden */
  29886. setCameraRigParameter(name: string, value: any): void;
  29887. /**
  29888. * needs to be overridden by children so sub has required properties to be copied
  29889. * @hidden
  29890. */
  29891. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29892. /**
  29893. * May need to be overridden by children
  29894. * @hidden
  29895. */
  29896. _updateRigCameras(): void;
  29897. /** @hidden */
  29898. _setupInputs(): void;
  29899. /**
  29900. * Serialiaze the camera setup to a json represention
  29901. * @returns the JSON representation
  29902. */
  29903. serialize(): any;
  29904. /**
  29905. * Clones the current camera.
  29906. * @param name The cloned camera name
  29907. * @returns the cloned camera
  29908. */
  29909. clone(name: string): Camera;
  29910. /**
  29911. * Gets the direction of the camera relative to a given local axis.
  29912. * @param localAxis Defines the reference axis to provide a relative direction.
  29913. * @return the direction
  29914. */
  29915. getDirection(localAxis: Vector3): Vector3;
  29916. /**
  29917. * Returns the current camera absolute rotation
  29918. */
  29919. get absoluteRotation(): Quaternion;
  29920. /**
  29921. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29922. * @param localAxis Defines the reference axis to provide a relative direction.
  29923. * @param result Defines the vector to store the result in
  29924. */
  29925. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29926. /**
  29927. * Gets a camera constructor for a given camera type
  29928. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29929. * @param name The name of the camera the result will be able to instantiate
  29930. * @param scene The scene the result will construct the camera in
  29931. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29932. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29933. * @returns a factory method to construc the camera
  29934. */
  29935. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29936. /**
  29937. * Compute the world matrix of the camera.
  29938. * @returns the camera world matrix
  29939. */
  29940. computeWorldMatrix(): Matrix;
  29941. /**
  29942. * Parse a JSON and creates the camera from the parsed information
  29943. * @param parsedCamera The JSON to parse
  29944. * @param scene The scene to instantiate the camera in
  29945. * @returns the newly constructed camera
  29946. */
  29947. static Parse(parsedCamera: any, scene: Scene): Camera;
  29948. }
  29949. }
  29950. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29951. import { Nullable } from "babylonjs/types";
  29952. import { Scene } from "babylonjs/scene";
  29953. import { Vector4 } from "babylonjs/Maths/math.vector";
  29954. import { Mesh } from "babylonjs/Meshes/mesh";
  29955. /**
  29956. * Class containing static functions to help procedurally build meshes
  29957. */
  29958. export class DiscBuilder {
  29959. /**
  29960. * Creates a plane polygonal mesh. By default, this is a disc
  29961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29962. * * 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
  29963. * * 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
  29964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29967. * @param name defines the name of the mesh
  29968. * @param options defines the options used to create the mesh
  29969. * @param scene defines the hosting scene
  29970. * @returns the plane polygonal mesh
  29971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29972. */
  29973. static CreateDisc(name: string, options: {
  29974. radius?: number;
  29975. tessellation?: number;
  29976. arc?: number;
  29977. updatable?: boolean;
  29978. sideOrientation?: number;
  29979. frontUVs?: Vector4;
  29980. backUVs?: Vector4;
  29981. }, scene?: Nullable<Scene>): Mesh;
  29982. }
  29983. }
  29984. declare module "babylonjs/Materials/fresnelParameters" {
  29985. import { DeepImmutable } from "babylonjs/types";
  29986. import { Color3 } from "babylonjs/Maths/math.color";
  29987. /**
  29988. * Options to be used when creating a FresnelParameters.
  29989. */
  29990. export type IFresnelParametersCreationOptions = {
  29991. /**
  29992. * Define the color used on edges (grazing angle)
  29993. */
  29994. leftColor?: Color3;
  29995. /**
  29996. * Define the color used on center
  29997. */
  29998. rightColor?: Color3;
  29999. /**
  30000. * Define bias applied to computed fresnel term
  30001. */
  30002. bias?: number;
  30003. /**
  30004. * Defined the power exponent applied to fresnel term
  30005. */
  30006. power?: number;
  30007. /**
  30008. * Define if the fresnel effect is enable or not.
  30009. */
  30010. isEnabled?: boolean;
  30011. };
  30012. /**
  30013. * Serialized format for FresnelParameters.
  30014. */
  30015. export type IFresnelParametersSerialized = {
  30016. /**
  30017. * Define the color used on edges (grazing angle) [as an array]
  30018. */
  30019. leftColor: number[];
  30020. /**
  30021. * Define the color used on center [as an array]
  30022. */
  30023. rightColor: number[];
  30024. /**
  30025. * Define bias applied to computed fresnel term
  30026. */
  30027. bias: number;
  30028. /**
  30029. * Defined the power exponent applied to fresnel term
  30030. */
  30031. power?: number;
  30032. /**
  30033. * Define if the fresnel effect is enable or not.
  30034. */
  30035. isEnabled: boolean;
  30036. };
  30037. /**
  30038. * This represents all the required information to add a fresnel effect on a material:
  30039. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30040. */
  30041. export class FresnelParameters {
  30042. private _isEnabled;
  30043. /**
  30044. * Define if the fresnel effect is enable or not.
  30045. */
  30046. get isEnabled(): boolean;
  30047. set isEnabled(value: boolean);
  30048. /**
  30049. * Define the color used on edges (grazing angle)
  30050. */
  30051. leftColor: Color3;
  30052. /**
  30053. * Define the color used on center
  30054. */
  30055. rightColor: Color3;
  30056. /**
  30057. * Define bias applied to computed fresnel term
  30058. */
  30059. bias: number;
  30060. /**
  30061. * Defined the power exponent applied to fresnel term
  30062. */
  30063. power: number;
  30064. /**
  30065. * Creates a new FresnelParameters object.
  30066. *
  30067. * @param options provide your own settings to optionally to override defaults
  30068. */
  30069. constructor(options?: IFresnelParametersCreationOptions);
  30070. /**
  30071. * Clones the current fresnel and its valuues
  30072. * @returns a clone fresnel configuration
  30073. */
  30074. clone(): FresnelParameters;
  30075. /**
  30076. * Determines equality between FresnelParameters objects
  30077. * @param otherFresnelParameters defines the second operand
  30078. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30079. */
  30080. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30081. /**
  30082. * Serializes the current fresnel parameters to a JSON representation.
  30083. * @return the JSON serialization
  30084. */
  30085. serialize(): IFresnelParametersSerialized;
  30086. /**
  30087. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30088. * @param parsedFresnelParameters Define the JSON representation
  30089. * @returns the parsed parameters
  30090. */
  30091. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30092. }
  30093. }
  30094. declare module "babylonjs/Materials/materialFlags" {
  30095. /**
  30096. * This groups all the flags used to control the materials channel.
  30097. */
  30098. export class MaterialFlags {
  30099. private static _DiffuseTextureEnabled;
  30100. /**
  30101. * Are diffuse textures enabled in the application.
  30102. */
  30103. static get DiffuseTextureEnabled(): boolean;
  30104. static set DiffuseTextureEnabled(value: boolean);
  30105. private static _DetailTextureEnabled;
  30106. /**
  30107. * Are detail textures enabled in the application.
  30108. */
  30109. static get DetailTextureEnabled(): boolean;
  30110. static set DetailTextureEnabled(value: boolean);
  30111. private static _AmbientTextureEnabled;
  30112. /**
  30113. * Are ambient textures enabled in the application.
  30114. */
  30115. static get AmbientTextureEnabled(): boolean;
  30116. static set AmbientTextureEnabled(value: boolean);
  30117. private static _OpacityTextureEnabled;
  30118. /**
  30119. * Are opacity textures enabled in the application.
  30120. */
  30121. static get OpacityTextureEnabled(): boolean;
  30122. static set OpacityTextureEnabled(value: boolean);
  30123. private static _ReflectionTextureEnabled;
  30124. /**
  30125. * Are reflection textures enabled in the application.
  30126. */
  30127. static get ReflectionTextureEnabled(): boolean;
  30128. static set ReflectionTextureEnabled(value: boolean);
  30129. private static _EmissiveTextureEnabled;
  30130. /**
  30131. * Are emissive textures enabled in the application.
  30132. */
  30133. static get EmissiveTextureEnabled(): boolean;
  30134. static set EmissiveTextureEnabled(value: boolean);
  30135. private static _SpecularTextureEnabled;
  30136. /**
  30137. * Are specular textures enabled in the application.
  30138. */
  30139. static get SpecularTextureEnabled(): boolean;
  30140. static set SpecularTextureEnabled(value: boolean);
  30141. private static _BumpTextureEnabled;
  30142. /**
  30143. * Are bump textures enabled in the application.
  30144. */
  30145. static get BumpTextureEnabled(): boolean;
  30146. static set BumpTextureEnabled(value: boolean);
  30147. private static _LightmapTextureEnabled;
  30148. /**
  30149. * Are lightmap textures enabled in the application.
  30150. */
  30151. static get LightmapTextureEnabled(): boolean;
  30152. static set LightmapTextureEnabled(value: boolean);
  30153. private static _RefractionTextureEnabled;
  30154. /**
  30155. * Are refraction textures enabled in the application.
  30156. */
  30157. static get RefractionTextureEnabled(): boolean;
  30158. static set RefractionTextureEnabled(value: boolean);
  30159. private static _ColorGradingTextureEnabled;
  30160. /**
  30161. * Are color grading textures enabled in the application.
  30162. */
  30163. static get ColorGradingTextureEnabled(): boolean;
  30164. static set ColorGradingTextureEnabled(value: boolean);
  30165. private static _FresnelEnabled;
  30166. /**
  30167. * Are fresnels enabled in the application.
  30168. */
  30169. static get FresnelEnabled(): boolean;
  30170. static set FresnelEnabled(value: boolean);
  30171. private static _ClearCoatTextureEnabled;
  30172. /**
  30173. * Are clear coat textures enabled in the application.
  30174. */
  30175. static get ClearCoatTextureEnabled(): boolean;
  30176. static set ClearCoatTextureEnabled(value: boolean);
  30177. private static _ClearCoatBumpTextureEnabled;
  30178. /**
  30179. * Are clear coat bump textures enabled in the application.
  30180. */
  30181. static get ClearCoatBumpTextureEnabled(): boolean;
  30182. static set ClearCoatBumpTextureEnabled(value: boolean);
  30183. private static _ClearCoatTintTextureEnabled;
  30184. /**
  30185. * Are clear coat tint textures enabled in the application.
  30186. */
  30187. static get ClearCoatTintTextureEnabled(): boolean;
  30188. static set ClearCoatTintTextureEnabled(value: boolean);
  30189. private static _SheenTextureEnabled;
  30190. /**
  30191. * Are sheen textures enabled in the application.
  30192. */
  30193. static get SheenTextureEnabled(): boolean;
  30194. static set SheenTextureEnabled(value: boolean);
  30195. private static _AnisotropicTextureEnabled;
  30196. /**
  30197. * Are anisotropic textures enabled in the application.
  30198. */
  30199. static get AnisotropicTextureEnabled(): boolean;
  30200. static set AnisotropicTextureEnabled(value: boolean);
  30201. private static _ThicknessTextureEnabled;
  30202. /**
  30203. * Are thickness textures enabled in the application.
  30204. */
  30205. static get ThicknessTextureEnabled(): boolean;
  30206. static set ThicknessTextureEnabled(value: boolean);
  30207. }
  30208. }
  30209. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30210. /** @hidden */
  30211. export var defaultFragmentDeclaration: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30217. /** @hidden */
  30218. export var defaultUboDeclaration: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30224. /** @hidden */
  30225. export var prePassDeclaration: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30231. /** @hidden */
  30232. export var lightFragmentDeclaration: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30238. /** @hidden */
  30239. export var lightUboDeclaration: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30245. /** @hidden */
  30246. export var lightsFragmentFunctions: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30252. /** @hidden */
  30253. export var shadowsFragmentFunctions: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30259. /** @hidden */
  30260. export var fresnelFunction: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30266. /** @hidden */
  30267. export var bumpFragmentMainFunctions: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30273. /** @hidden */
  30274. export var bumpFragmentFunctions: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30280. /** @hidden */
  30281. export var logDepthDeclaration: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30287. /** @hidden */
  30288. export var bumpFragment: {
  30289. name: string;
  30290. shader: string;
  30291. };
  30292. }
  30293. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30294. /** @hidden */
  30295. export var depthPrePass: {
  30296. name: string;
  30297. shader: string;
  30298. };
  30299. }
  30300. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30301. /** @hidden */
  30302. export var lightFragment: {
  30303. name: string;
  30304. shader: string;
  30305. };
  30306. }
  30307. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30308. /** @hidden */
  30309. export var logDepthFragment: {
  30310. name: string;
  30311. shader: string;
  30312. };
  30313. }
  30314. declare module "babylonjs/Shaders/default.fragment" {
  30315. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30316. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30317. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  30318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30319. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30320. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30321. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30322. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30323. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30324. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30325. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30326. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30327. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30328. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30329. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30330. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30331. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30332. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30333. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30334. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30335. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30336. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30337. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30338. /** @hidden */
  30339. export var defaultPixelShader: {
  30340. name: string;
  30341. shader: string;
  30342. };
  30343. }
  30344. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30345. /** @hidden */
  30346. export var defaultVertexDeclaration: {
  30347. name: string;
  30348. shader: string;
  30349. };
  30350. }
  30351. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30352. /** @hidden */
  30353. export var bumpVertexDeclaration: {
  30354. name: string;
  30355. shader: string;
  30356. };
  30357. }
  30358. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30359. /** @hidden */
  30360. export var bumpVertex: {
  30361. name: string;
  30362. shader: string;
  30363. };
  30364. }
  30365. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30366. /** @hidden */
  30367. export var fogVertex: {
  30368. name: string;
  30369. shader: string;
  30370. };
  30371. }
  30372. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30373. /** @hidden */
  30374. export var shadowsVertex: {
  30375. name: string;
  30376. shader: string;
  30377. };
  30378. }
  30379. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30380. /** @hidden */
  30381. export var pointCloudVertex: {
  30382. name: string;
  30383. shader: string;
  30384. };
  30385. }
  30386. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30387. /** @hidden */
  30388. export var logDepthVertex: {
  30389. name: string;
  30390. shader: string;
  30391. };
  30392. }
  30393. declare module "babylonjs/Shaders/default.vertex" {
  30394. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30395. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30396. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30397. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30399. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30400. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30401. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30402. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30403. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30406. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30408. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30409. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30410. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30411. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30412. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30413. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30414. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30415. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30416. /** @hidden */
  30417. export var defaultVertexShader: {
  30418. name: string;
  30419. shader: string;
  30420. };
  30421. }
  30422. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30423. import { Nullable } from "babylonjs/types";
  30424. import { Scene } from "babylonjs/scene";
  30425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30426. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30428. /**
  30429. * @hidden
  30430. */
  30431. export interface IMaterialDetailMapDefines {
  30432. DETAIL: boolean;
  30433. DETAILDIRECTUV: number;
  30434. DETAIL_NORMALBLENDMETHOD: number;
  30435. /** @hidden */
  30436. _areTexturesDirty: boolean;
  30437. }
  30438. /**
  30439. * Define the code related to the detail map parameters of a material
  30440. *
  30441. * Inspired from:
  30442. * 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
  30443. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30444. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30445. */
  30446. export class DetailMapConfiguration {
  30447. private _texture;
  30448. /**
  30449. * The detail texture of the material.
  30450. */
  30451. texture: Nullable<BaseTexture>;
  30452. /**
  30453. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30454. * Bigger values mean stronger blending
  30455. */
  30456. diffuseBlendLevel: number;
  30457. /**
  30458. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30459. * Bigger values mean stronger blending. Only used with PBR materials
  30460. */
  30461. roughnessBlendLevel: number;
  30462. /**
  30463. * Defines how strong the bump effect from the detail map is
  30464. * Bigger values mean stronger effect
  30465. */
  30466. bumpLevel: number;
  30467. private _normalBlendMethod;
  30468. /**
  30469. * The method used to blend the bump and detail normals together
  30470. */
  30471. normalBlendMethod: number;
  30472. private _isEnabled;
  30473. /**
  30474. * Enable or disable the detail map on this material
  30475. */
  30476. isEnabled: boolean;
  30477. /** @hidden */
  30478. private _internalMarkAllSubMeshesAsTexturesDirty;
  30479. /** @hidden */
  30480. _markAllSubMeshesAsTexturesDirty(): void;
  30481. /**
  30482. * Instantiate a new detail map
  30483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30484. */
  30485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30486. /**
  30487. * Gets whether the submesh is ready to be used or not.
  30488. * @param defines the list of "defines" to update.
  30489. * @param scene defines the scene the material belongs to.
  30490. * @returns - boolean indicating that the submesh is ready or not.
  30491. */
  30492. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30493. /**
  30494. * Update the defines for detail map usage
  30495. * @param defines the list of "defines" to update.
  30496. * @param scene defines the scene the material belongs to.
  30497. */
  30498. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30499. /**
  30500. * Binds the material data.
  30501. * @param uniformBuffer defines the Uniform buffer to fill in.
  30502. * @param scene defines the scene the material belongs to.
  30503. * @param isFrozen defines whether the material is frozen or not.
  30504. */
  30505. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30506. /**
  30507. * Checks to see if a texture is used in the material.
  30508. * @param texture - Base texture to use.
  30509. * @returns - Boolean specifying if a texture is used in the material.
  30510. */
  30511. hasTexture(texture: BaseTexture): boolean;
  30512. /**
  30513. * Returns an array of the actively used textures.
  30514. * @param activeTextures Array of BaseTextures
  30515. */
  30516. getActiveTextures(activeTextures: BaseTexture[]): void;
  30517. /**
  30518. * Returns the animatable textures.
  30519. * @param animatables Array of animatable textures.
  30520. */
  30521. getAnimatables(animatables: IAnimatable[]): void;
  30522. /**
  30523. * Disposes the resources of the material.
  30524. * @param forceDisposeTextures - Forces the disposal of all textures.
  30525. */
  30526. dispose(forceDisposeTextures?: boolean): void;
  30527. /**
  30528. * Get the current class name useful for serialization or dynamic coding.
  30529. * @returns "DetailMap"
  30530. */
  30531. getClassName(): string;
  30532. /**
  30533. * Add the required uniforms to the current list.
  30534. * @param uniforms defines the current uniform list.
  30535. */
  30536. static AddUniforms(uniforms: string[]): void;
  30537. /**
  30538. * Add the required samplers to the current list.
  30539. * @param samplers defines the current sampler list.
  30540. */
  30541. static AddSamplers(samplers: string[]): void;
  30542. /**
  30543. * Add the required uniforms to the current buffer.
  30544. * @param uniformBuffer defines the current uniform buffer.
  30545. */
  30546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30547. /**
  30548. * Makes a duplicate of the current instance into another one.
  30549. * @param detailMap define the instance where to copy the info
  30550. */
  30551. copyTo(detailMap: DetailMapConfiguration): void;
  30552. /**
  30553. * Serializes this detail map instance
  30554. * @returns - An object with the serialized instance.
  30555. */
  30556. serialize(): any;
  30557. /**
  30558. * Parses a detail map setting from a serialized object.
  30559. * @param source - Serialized object.
  30560. * @param scene Defines the scene we are parsing for
  30561. * @param rootUrl Defines the rootUrl to load from
  30562. */
  30563. parse(source: any, scene: Scene, rootUrl: string): void;
  30564. }
  30565. }
  30566. declare module "babylonjs/Materials/standardMaterial" {
  30567. import { SmartArray } from "babylonjs/Misc/smartArray";
  30568. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30569. import { Nullable } from "babylonjs/types";
  30570. import { Scene } from "babylonjs/scene";
  30571. import { Matrix } from "babylonjs/Maths/math.vector";
  30572. import { Color3 } from "babylonjs/Maths/math.color";
  30573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30575. import { Mesh } from "babylonjs/Meshes/mesh";
  30576. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30577. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30578. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30579. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30580. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30583. import "babylonjs/Shaders/default.fragment";
  30584. import "babylonjs/Shaders/default.vertex";
  30585. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30586. /** @hidden */
  30587. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30588. MAINUV1: boolean;
  30589. MAINUV2: boolean;
  30590. DIFFUSE: boolean;
  30591. DIFFUSEDIRECTUV: number;
  30592. DETAIL: boolean;
  30593. DETAILDIRECTUV: number;
  30594. DETAIL_NORMALBLENDMETHOD: number;
  30595. AMBIENT: boolean;
  30596. AMBIENTDIRECTUV: number;
  30597. OPACITY: boolean;
  30598. OPACITYDIRECTUV: number;
  30599. OPACITYRGB: boolean;
  30600. REFLECTION: boolean;
  30601. EMISSIVE: boolean;
  30602. EMISSIVEDIRECTUV: number;
  30603. SPECULAR: boolean;
  30604. SPECULARDIRECTUV: number;
  30605. BUMP: boolean;
  30606. BUMPDIRECTUV: number;
  30607. PARALLAX: boolean;
  30608. PARALLAXOCCLUSION: boolean;
  30609. SPECULAROVERALPHA: boolean;
  30610. CLIPPLANE: boolean;
  30611. CLIPPLANE2: boolean;
  30612. CLIPPLANE3: boolean;
  30613. CLIPPLANE4: boolean;
  30614. CLIPPLANE5: boolean;
  30615. CLIPPLANE6: boolean;
  30616. ALPHATEST: boolean;
  30617. DEPTHPREPASS: boolean;
  30618. ALPHAFROMDIFFUSE: boolean;
  30619. POINTSIZE: boolean;
  30620. FOG: boolean;
  30621. SPECULARTERM: boolean;
  30622. DIFFUSEFRESNEL: boolean;
  30623. OPACITYFRESNEL: boolean;
  30624. REFLECTIONFRESNEL: boolean;
  30625. REFRACTIONFRESNEL: boolean;
  30626. EMISSIVEFRESNEL: boolean;
  30627. FRESNEL: boolean;
  30628. NORMAL: boolean;
  30629. UV1: boolean;
  30630. UV2: boolean;
  30631. VERTEXCOLOR: boolean;
  30632. VERTEXALPHA: boolean;
  30633. NUM_BONE_INFLUENCERS: number;
  30634. BonesPerMesh: number;
  30635. BONETEXTURE: boolean;
  30636. INSTANCES: boolean;
  30637. THIN_INSTANCES: boolean;
  30638. GLOSSINESS: boolean;
  30639. ROUGHNESS: boolean;
  30640. EMISSIVEASILLUMINATION: boolean;
  30641. LINKEMISSIVEWITHDIFFUSE: boolean;
  30642. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30643. LIGHTMAP: boolean;
  30644. LIGHTMAPDIRECTUV: number;
  30645. OBJECTSPACE_NORMALMAP: boolean;
  30646. USELIGHTMAPASSHADOWMAP: boolean;
  30647. REFLECTIONMAP_3D: boolean;
  30648. REFLECTIONMAP_SPHERICAL: boolean;
  30649. REFLECTIONMAP_PLANAR: boolean;
  30650. REFLECTIONMAP_CUBIC: boolean;
  30651. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30652. REFLECTIONMAP_PROJECTION: boolean;
  30653. REFLECTIONMAP_SKYBOX: boolean;
  30654. REFLECTIONMAP_EXPLICIT: boolean;
  30655. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30656. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30657. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30658. INVERTCUBICMAP: boolean;
  30659. LOGARITHMICDEPTH: boolean;
  30660. REFRACTION: boolean;
  30661. REFRACTIONMAP_3D: boolean;
  30662. REFLECTIONOVERALPHA: boolean;
  30663. TWOSIDEDLIGHTING: boolean;
  30664. SHADOWFLOAT: boolean;
  30665. MORPHTARGETS: boolean;
  30666. MORPHTARGETS_NORMAL: boolean;
  30667. MORPHTARGETS_TANGENT: boolean;
  30668. MORPHTARGETS_UV: boolean;
  30669. NUM_MORPH_INFLUENCERS: number;
  30670. NONUNIFORMSCALING: boolean;
  30671. PREMULTIPLYALPHA: boolean;
  30672. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30673. ALPHABLEND: boolean;
  30674. PREPASS: boolean;
  30675. SCENE_MRT_COUNT: number;
  30676. RGBDLIGHTMAP: boolean;
  30677. RGBDREFLECTION: boolean;
  30678. RGBDREFRACTION: boolean;
  30679. IMAGEPROCESSING: boolean;
  30680. VIGNETTE: boolean;
  30681. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30682. VIGNETTEBLENDMODEOPAQUE: boolean;
  30683. TONEMAPPING: boolean;
  30684. TONEMAPPING_ACES: boolean;
  30685. CONTRAST: boolean;
  30686. COLORCURVES: boolean;
  30687. COLORGRADING: boolean;
  30688. COLORGRADING3D: boolean;
  30689. SAMPLER3DGREENDEPTH: boolean;
  30690. SAMPLER3DBGRMAP: boolean;
  30691. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30692. MULTIVIEW: boolean;
  30693. /**
  30694. * If the reflection texture on this material is in linear color space
  30695. * @hidden
  30696. */
  30697. IS_REFLECTION_LINEAR: boolean;
  30698. /**
  30699. * If the refraction texture on this material is in linear color space
  30700. * @hidden
  30701. */
  30702. IS_REFRACTION_LINEAR: boolean;
  30703. EXPOSURE: boolean;
  30704. constructor();
  30705. setReflectionMode(modeToEnable: string): void;
  30706. }
  30707. /**
  30708. * This is the default material used in Babylon. It is the best trade off between quality
  30709. * and performances.
  30710. * @see https://doc.babylonjs.com/babylon101/materials
  30711. */
  30712. export class StandardMaterial extends PushMaterial {
  30713. private _diffuseTexture;
  30714. /**
  30715. * The basic texture of the material as viewed under a light.
  30716. */
  30717. diffuseTexture: Nullable<BaseTexture>;
  30718. private _ambientTexture;
  30719. /**
  30720. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30721. */
  30722. ambientTexture: Nullable<BaseTexture>;
  30723. private _opacityTexture;
  30724. /**
  30725. * Define the transparency of the material from a texture.
  30726. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30727. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30728. */
  30729. opacityTexture: Nullable<BaseTexture>;
  30730. private _reflectionTexture;
  30731. /**
  30732. * Define the texture used to display the reflection.
  30733. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30734. */
  30735. reflectionTexture: Nullable<BaseTexture>;
  30736. private _emissiveTexture;
  30737. /**
  30738. * Define texture of the material as if self lit.
  30739. * This will be mixed in the final result even in the absence of light.
  30740. */
  30741. emissiveTexture: Nullable<BaseTexture>;
  30742. private _specularTexture;
  30743. /**
  30744. * Define how the color and intensity of the highlight given by the light in the material.
  30745. */
  30746. specularTexture: Nullable<BaseTexture>;
  30747. private _bumpTexture;
  30748. /**
  30749. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30750. * 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.
  30751. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30752. */
  30753. bumpTexture: Nullable<BaseTexture>;
  30754. private _lightmapTexture;
  30755. /**
  30756. * Complex lighting can be computationally expensive to compute at runtime.
  30757. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30758. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30759. */
  30760. lightmapTexture: Nullable<BaseTexture>;
  30761. private _refractionTexture;
  30762. /**
  30763. * Define the texture used to display the refraction.
  30764. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30765. */
  30766. refractionTexture: Nullable<BaseTexture>;
  30767. /**
  30768. * The color of the material lit by the environmental background lighting.
  30769. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30770. */
  30771. ambientColor: Color3;
  30772. /**
  30773. * The basic color of the material as viewed under a light.
  30774. */
  30775. diffuseColor: Color3;
  30776. /**
  30777. * Define how the color and intensity of the highlight given by the light in the material.
  30778. */
  30779. specularColor: Color3;
  30780. /**
  30781. * Define the color of the material as if self lit.
  30782. * This will be mixed in the final result even in the absence of light.
  30783. */
  30784. emissiveColor: Color3;
  30785. /**
  30786. * Defines how sharp are the highlights in the material.
  30787. * The bigger the value the sharper giving a more glossy feeling to the result.
  30788. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30789. */
  30790. specularPower: number;
  30791. private _useAlphaFromDiffuseTexture;
  30792. /**
  30793. * Does the transparency come from the diffuse texture alpha channel.
  30794. */
  30795. useAlphaFromDiffuseTexture: boolean;
  30796. private _useEmissiveAsIllumination;
  30797. /**
  30798. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30799. */
  30800. useEmissiveAsIllumination: boolean;
  30801. private _linkEmissiveWithDiffuse;
  30802. /**
  30803. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30804. * the emissive level when the final color is close to one.
  30805. */
  30806. linkEmissiveWithDiffuse: boolean;
  30807. private _useSpecularOverAlpha;
  30808. /**
  30809. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30810. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30811. */
  30812. useSpecularOverAlpha: boolean;
  30813. private _useReflectionOverAlpha;
  30814. /**
  30815. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30816. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30817. */
  30818. useReflectionOverAlpha: boolean;
  30819. private _disableLighting;
  30820. /**
  30821. * Does lights from the scene impacts this material.
  30822. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30823. */
  30824. disableLighting: boolean;
  30825. private _useObjectSpaceNormalMap;
  30826. /**
  30827. * Allows using an object space normal map (instead of tangent space).
  30828. */
  30829. useObjectSpaceNormalMap: boolean;
  30830. private _useParallax;
  30831. /**
  30832. * Is parallax enabled or not.
  30833. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30834. */
  30835. useParallax: boolean;
  30836. private _useParallaxOcclusion;
  30837. /**
  30838. * Is parallax occlusion enabled or not.
  30839. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30840. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30841. */
  30842. useParallaxOcclusion: boolean;
  30843. /**
  30844. * 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.
  30845. */
  30846. parallaxScaleBias: number;
  30847. private _roughness;
  30848. /**
  30849. * Helps to define how blurry the reflections should appears in the material.
  30850. */
  30851. roughness: number;
  30852. /**
  30853. * In case of refraction, define the value of the index of refraction.
  30854. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30855. */
  30856. indexOfRefraction: number;
  30857. /**
  30858. * Invert the refraction texture alongside the y axis.
  30859. * It can be useful with procedural textures or probe for instance.
  30860. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30861. */
  30862. invertRefractionY: boolean;
  30863. /**
  30864. * Defines the alpha limits in alpha test mode.
  30865. */
  30866. alphaCutOff: number;
  30867. private _useLightmapAsShadowmap;
  30868. /**
  30869. * In case of light mapping, define whether the map contains light or shadow informations.
  30870. */
  30871. useLightmapAsShadowmap: boolean;
  30872. private _diffuseFresnelParameters;
  30873. /**
  30874. * Define the diffuse fresnel parameters of the material.
  30875. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30876. */
  30877. diffuseFresnelParameters: FresnelParameters;
  30878. private _opacityFresnelParameters;
  30879. /**
  30880. * Define the opacity fresnel parameters of the material.
  30881. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30882. */
  30883. opacityFresnelParameters: FresnelParameters;
  30884. private _reflectionFresnelParameters;
  30885. /**
  30886. * Define the reflection fresnel parameters of the material.
  30887. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30888. */
  30889. reflectionFresnelParameters: FresnelParameters;
  30890. private _refractionFresnelParameters;
  30891. /**
  30892. * Define the refraction fresnel parameters of the material.
  30893. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30894. */
  30895. refractionFresnelParameters: FresnelParameters;
  30896. private _emissiveFresnelParameters;
  30897. /**
  30898. * Define the emissive fresnel parameters of the material.
  30899. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30900. */
  30901. emissiveFresnelParameters: FresnelParameters;
  30902. private _useReflectionFresnelFromSpecular;
  30903. /**
  30904. * If true automatically deducts the fresnels values from the material specularity.
  30905. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30906. */
  30907. useReflectionFresnelFromSpecular: boolean;
  30908. private _useGlossinessFromSpecularMapAlpha;
  30909. /**
  30910. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30911. */
  30912. useGlossinessFromSpecularMapAlpha: boolean;
  30913. private _maxSimultaneousLights;
  30914. /**
  30915. * Defines the maximum number of lights that can be used in the material
  30916. */
  30917. maxSimultaneousLights: number;
  30918. private _invertNormalMapX;
  30919. /**
  30920. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30921. */
  30922. invertNormalMapX: boolean;
  30923. private _invertNormalMapY;
  30924. /**
  30925. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30926. */
  30927. invertNormalMapY: boolean;
  30928. private _twoSidedLighting;
  30929. /**
  30930. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30931. */
  30932. twoSidedLighting: boolean;
  30933. /**
  30934. * Default configuration related to image processing available in the standard Material.
  30935. */
  30936. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30937. /**
  30938. * Gets the image processing configuration used either in this material.
  30939. */
  30940. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30941. /**
  30942. * Sets the Default image processing configuration used either in the this material.
  30943. *
  30944. * If sets to null, the scene one is in use.
  30945. */
  30946. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30947. /**
  30948. * Keep track of the image processing observer to allow dispose and replace.
  30949. */
  30950. private _imageProcessingObserver;
  30951. /**
  30952. * Attaches a new image processing configuration to the Standard Material.
  30953. * @param configuration
  30954. */
  30955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30956. /**
  30957. * Gets wether the color curves effect is enabled.
  30958. */
  30959. get cameraColorCurvesEnabled(): boolean;
  30960. /**
  30961. * Sets wether the color curves effect is enabled.
  30962. */
  30963. set cameraColorCurvesEnabled(value: boolean);
  30964. /**
  30965. * Gets wether the color grading effect is enabled.
  30966. */
  30967. get cameraColorGradingEnabled(): boolean;
  30968. /**
  30969. * Gets wether the color grading effect is enabled.
  30970. */
  30971. set cameraColorGradingEnabled(value: boolean);
  30972. /**
  30973. * Gets wether tonemapping is enabled or not.
  30974. */
  30975. get cameraToneMappingEnabled(): boolean;
  30976. /**
  30977. * Sets wether tonemapping is enabled or not
  30978. */
  30979. set cameraToneMappingEnabled(value: boolean);
  30980. /**
  30981. * The camera exposure used on this material.
  30982. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30983. * This corresponds to a photographic exposure.
  30984. */
  30985. get cameraExposure(): number;
  30986. /**
  30987. * The camera exposure used on this material.
  30988. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30989. * This corresponds to a photographic exposure.
  30990. */
  30991. set cameraExposure(value: number);
  30992. /**
  30993. * Gets The camera contrast used on this material.
  30994. */
  30995. get cameraContrast(): number;
  30996. /**
  30997. * Sets The camera contrast used on this material.
  30998. */
  30999. set cameraContrast(value: number);
  31000. /**
  31001. * Gets the Color Grading 2D Lookup Texture.
  31002. */
  31003. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31004. /**
  31005. * Sets the Color Grading 2D Lookup Texture.
  31006. */
  31007. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31008. /**
  31009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31011. * 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;
  31012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31013. */
  31014. get cameraColorCurves(): Nullable<ColorCurves>;
  31015. /**
  31016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31018. * 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;
  31019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31020. */
  31021. set cameraColorCurves(value: Nullable<ColorCurves>);
  31022. /**
  31023. * Should this material render to several textures at once
  31024. */
  31025. get shouldRenderToMRT(): boolean;
  31026. /**
  31027. * Defines the detail map parameters for the material.
  31028. */
  31029. readonly detailMap: DetailMapConfiguration;
  31030. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31031. protected _worldViewProjectionMatrix: Matrix;
  31032. protected _globalAmbientColor: Color3;
  31033. protected _useLogarithmicDepth: boolean;
  31034. protected _rebuildInParallel: boolean;
  31035. /**
  31036. * Instantiates a new standard material.
  31037. * This is the default material used in Babylon. It is the best trade off between quality
  31038. * and performances.
  31039. * @see https://doc.babylonjs.com/babylon101/materials
  31040. * @param name Define the name of the material in the scene
  31041. * @param scene Define the scene the material belong to
  31042. */
  31043. constructor(name: string, scene: Scene);
  31044. /**
  31045. * Gets a boolean indicating that current material needs to register RTT
  31046. */
  31047. get hasRenderTargetTextures(): boolean;
  31048. /**
  31049. * Gets the current class name of the material e.g. "StandardMaterial"
  31050. * Mainly use in serialization.
  31051. * @returns the class name
  31052. */
  31053. getClassName(): string;
  31054. /**
  31055. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31056. * You can try switching to logarithmic depth.
  31057. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31058. */
  31059. get useLogarithmicDepth(): boolean;
  31060. set useLogarithmicDepth(value: boolean);
  31061. /**
  31062. * Specifies if the material will require alpha blending
  31063. * @returns a boolean specifying if alpha blending is needed
  31064. */
  31065. needAlphaBlending(): boolean;
  31066. /**
  31067. * Specifies if this material should be rendered in alpha test mode
  31068. * @returns a boolean specifying if an alpha test is needed.
  31069. */
  31070. needAlphaTesting(): boolean;
  31071. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31072. /**
  31073. * Get the texture used for alpha test purpose.
  31074. * @returns the diffuse texture in case of the standard material.
  31075. */
  31076. getAlphaTestTexture(): Nullable<BaseTexture>;
  31077. /**
  31078. * Get if the submesh is ready to be used and all its information available.
  31079. * Child classes can use it to update shaders
  31080. * @param mesh defines the mesh to check
  31081. * @param subMesh defines which submesh to check
  31082. * @param useInstances specifies that instances should be used
  31083. * @returns a boolean indicating that the submesh is ready or not
  31084. */
  31085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31086. /**
  31087. * Builds the material UBO layouts.
  31088. * Used internally during the effect preparation.
  31089. */
  31090. buildUniformLayout(): void;
  31091. /**
  31092. * Unbinds the material from the mesh
  31093. */
  31094. unbind(): void;
  31095. /**
  31096. * Binds the submesh to this material by preparing the effect and shader to draw
  31097. * @param world defines the world transformation matrix
  31098. * @param mesh defines the mesh containing the submesh
  31099. * @param subMesh defines the submesh to bind the material to
  31100. */
  31101. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31102. /**
  31103. * Get the list of animatables in the material.
  31104. * @returns the list of animatables object used in the material
  31105. */
  31106. getAnimatables(): IAnimatable[];
  31107. /**
  31108. * Gets the active textures from the material
  31109. * @returns an array of textures
  31110. */
  31111. getActiveTextures(): BaseTexture[];
  31112. /**
  31113. * Specifies if the material uses a texture
  31114. * @param texture defines the texture to check against the material
  31115. * @returns a boolean specifying if the material uses the texture
  31116. */
  31117. hasTexture(texture: BaseTexture): boolean;
  31118. /**
  31119. * Disposes the material
  31120. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31121. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31122. */
  31123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31124. /**
  31125. * Makes a duplicate of the material, and gives it a new name
  31126. * @param name defines the new name for the duplicated material
  31127. * @returns the cloned material
  31128. */
  31129. clone(name: string): StandardMaterial;
  31130. /**
  31131. * Serializes this material in a JSON representation
  31132. * @returns the serialized material object
  31133. */
  31134. serialize(): any;
  31135. /**
  31136. * Creates a standard material from parsed material data
  31137. * @param source defines the JSON representation of the material
  31138. * @param scene defines the hosting scene
  31139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31140. * @returns a new standard material
  31141. */
  31142. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31143. /**
  31144. * Are diffuse textures enabled in the application.
  31145. */
  31146. static get DiffuseTextureEnabled(): boolean;
  31147. static set DiffuseTextureEnabled(value: boolean);
  31148. /**
  31149. * Are detail textures enabled in the application.
  31150. */
  31151. static get DetailTextureEnabled(): boolean;
  31152. static set DetailTextureEnabled(value: boolean);
  31153. /**
  31154. * Are ambient textures enabled in the application.
  31155. */
  31156. static get AmbientTextureEnabled(): boolean;
  31157. static set AmbientTextureEnabled(value: boolean);
  31158. /**
  31159. * Are opacity textures enabled in the application.
  31160. */
  31161. static get OpacityTextureEnabled(): boolean;
  31162. static set OpacityTextureEnabled(value: boolean);
  31163. /**
  31164. * Are reflection textures enabled in the application.
  31165. */
  31166. static get ReflectionTextureEnabled(): boolean;
  31167. static set ReflectionTextureEnabled(value: boolean);
  31168. /**
  31169. * Are emissive textures enabled in the application.
  31170. */
  31171. static get EmissiveTextureEnabled(): boolean;
  31172. static set EmissiveTextureEnabled(value: boolean);
  31173. /**
  31174. * Are specular textures enabled in the application.
  31175. */
  31176. static get SpecularTextureEnabled(): boolean;
  31177. static set SpecularTextureEnabled(value: boolean);
  31178. /**
  31179. * Are bump textures enabled in the application.
  31180. */
  31181. static get BumpTextureEnabled(): boolean;
  31182. static set BumpTextureEnabled(value: boolean);
  31183. /**
  31184. * Are lightmap textures enabled in the application.
  31185. */
  31186. static get LightmapTextureEnabled(): boolean;
  31187. static set LightmapTextureEnabled(value: boolean);
  31188. /**
  31189. * Are refraction textures enabled in the application.
  31190. */
  31191. static get RefractionTextureEnabled(): boolean;
  31192. static set RefractionTextureEnabled(value: boolean);
  31193. /**
  31194. * Are color grading textures enabled in the application.
  31195. */
  31196. static get ColorGradingTextureEnabled(): boolean;
  31197. static set ColorGradingTextureEnabled(value: boolean);
  31198. /**
  31199. * Are fresnels enabled in the application.
  31200. */
  31201. static get FresnelEnabled(): boolean;
  31202. static set FresnelEnabled(value: boolean);
  31203. }
  31204. }
  31205. declare module "babylonjs/Particles/solidParticleSystem" {
  31206. import { Nullable } from "babylonjs/types";
  31207. import { Mesh } from "babylonjs/Meshes/mesh";
  31208. import { Scene, IDisposable } from "babylonjs/scene";
  31209. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31210. import { Material } from "babylonjs/Materials/material";
  31211. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31212. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31213. /**
  31214. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31215. *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.
  31216. * The SPS is also a particle system. It provides some methods to manage the particles.
  31217. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31218. *
  31219. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31220. */
  31221. export class SolidParticleSystem implements IDisposable {
  31222. /**
  31223. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31224. * Example : var p = SPS.particles[i];
  31225. */
  31226. particles: SolidParticle[];
  31227. /**
  31228. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31229. */
  31230. nbParticles: number;
  31231. /**
  31232. * If the particles must ever face the camera (default false). Useful for planar particles.
  31233. */
  31234. billboard: boolean;
  31235. /**
  31236. * Recompute normals when adding a shape
  31237. */
  31238. recomputeNormals: boolean;
  31239. /**
  31240. * This a counter ofr your own usage. It's not set by any SPS functions.
  31241. */
  31242. counter: number;
  31243. /**
  31244. * The SPS name. This name is also given to the underlying mesh.
  31245. */
  31246. name: string;
  31247. /**
  31248. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31249. */
  31250. mesh: Mesh;
  31251. /**
  31252. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31253. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31254. */
  31255. vars: any;
  31256. /**
  31257. * This array is populated when the SPS is set as 'pickable'.
  31258. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31259. * Each element of this array is an object `{idx: int, faceId: int}`.
  31260. * `idx` is the picked particle index in the `SPS.particles` array
  31261. * `faceId` is the picked face index counted within this particle.
  31262. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31263. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31264. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31265. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31266. */
  31267. pickedParticles: {
  31268. idx: number;
  31269. faceId: number;
  31270. }[];
  31271. /**
  31272. * This array is populated when the SPS is set as 'pickable'
  31273. * Each key of this array is a submesh index.
  31274. * Each element of this array is a second array defined like this :
  31275. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31276. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31277. * `idx` is the picked particle index in the `SPS.particles` array
  31278. * `faceId` is the picked face index counted within this particle.
  31279. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31280. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31281. */
  31282. pickedBySubMesh: {
  31283. idx: number;
  31284. faceId: number;
  31285. }[][];
  31286. /**
  31287. * This array is populated when `enableDepthSort` is set to true.
  31288. * Each element of this array is an instance of the class DepthSortedParticle.
  31289. */
  31290. depthSortedParticles: DepthSortedParticle[];
  31291. /**
  31292. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31293. * @hidden
  31294. */
  31295. _bSphereOnly: boolean;
  31296. /**
  31297. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31298. * @hidden
  31299. */
  31300. _bSphereRadiusFactor: number;
  31301. private _scene;
  31302. private _positions;
  31303. private _indices;
  31304. private _normals;
  31305. private _colors;
  31306. private _uvs;
  31307. private _indices32;
  31308. private _positions32;
  31309. private _normals32;
  31310. private _fixedNormal32;
  31311. private _colors32;
  31312. private _uvs32;
  31313. private _index;
  31314. private _updatable;
  31315. private _pickable;
  31316. private _isVisibilityBoxLocked;
  31317. private _alwaysVisible;
  31318. private _depthSort;
  31319. private _expandable;
  31320. private _shapeCounter;
  31321. private _copy;
  31322. private _color;
  31323. private _computeParticleColor;
  31324. private _computeParticleTexture;
  31325. private _computeParticleRotation;
  31326. private _computeParticleVertex;
  31327. private _computeBoundingBox;
  31328. private _depthSortParticles;
  31329. private _camera;
  31330. private _mustUnrotateFixedNormals;
  31331. private _particlesIntersect;
  31332. private _needs32Bits;
  31333. private _isNotBuilt;
  31334. private _lastParticleId;
  31335. private _idxOfId;
  31336. private _multimaterialEnabled;
  31337. private _useModelMaterial;
  31338. private _indicesByMaterial;
  31339. private _materialIndexes;
  31340. private _depthSortFunction;
  31341. private _materialSortFunction;
  31342. private _materials;
  31343. private _multimaterial;
  31344. private _materialIndexesById;
  31345. private _defaultMaterial;
  31346. private _autoUpdateSubMeshes;
  31347. private _tmpVertex;
  31348. /**
  31349. * Creates a SPS (Solid Particle System) object.
  31350. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31351. * @param scene (Scene) is the scene in which the SPS is added.
  31352. * @param options defines the options of the sps e.g.
  31353. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31354. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31355. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31356. * * 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.
  31357. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31358. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31359. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31360. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31361. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31362. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31363. */
  31364. constructor(name: string, scene: Scene, options?: {
  31365. updatable?: boolean;
  31366. isPickable?: boolean;
  31367. enableDepthSort?: boolean;
  31368. particleIntersection?: boolean;
  31369. boundingSphereOnly?: boolean;
  31370. bSphereRadiusFactor?: number;
  31371. expandable?: boolean;
  31372. useModelMaterial?: boolean;
  31373. enableMultiMaterial?: boolean;
  31374. });
  31375. /**
  31376. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31377. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31378. * @returns the created mesh
  31379. */
  31380. buildMesh(): Mesh;
  31381. /**
  31382. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31383. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31384. * Thus the particles generated from `digest()` have their property `position` set yet.
  31385. * @param mesh ( Mesh ) is the mesh to be digested
  31386. * @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
  31387. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31388. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31389. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31390. * @returns the current SPS
  31391. */
  31392. digest(mesh: Mesh, options?: {
  31393. facetNb?: number;
  31394. number?: number;
  31395. delta?: number;
  31396. storage?: [];
  31397. }): SolidParticleSystem;
  31398. /**
  31399. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31400. * @hidden
  31401. */
  31402. private _unrotateFixedNormals;
  31403. /**
  31404. * Resets the temporary working copy particle
  31405. * @hidden
  31406. */
  31407. private _resetCopy;
  31408. /**
  31409. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31410. * @param p the current index in the positions array to be updated
  31411. * @param ind the current index in the indices array
  31412. * @param shape a Vector3 array, the shape geometry
  31413. * @param positions the positions array to be updated
  31414. * @param meshInd the shape indices array
  31415. * @param indices the indices array to be updated
  31416. * @param meshUV the shape uv array
  31417. * @param uvs the uv array to be updated
  31418. * @param meshCol the shape color array
  31419. * @param colors the color array to be updated
  31420. * @param meshNor the shape normals array
  31421. * @param normals the normals array to be updated
  31422. * @param idx the particle index
  31423. * @param idxInShape the particle index in its shape
  31424. * @param options the addShape() method passed options
  31425. * @model the particle model
  31426. * @hidden
  31427. */
  31428. private _meshBuilder;
  31429. /**
  31430. * Returns a shape Vector3 array from positions float array
  31431. * @param positions float array
  31432. * @returns a vector3 array
  31433. * @hidden
  31434. */
  31435. private _posToShape;
  31436. /**
  31437. * Returns a shapeUV array from a float uvs (array deep copy)
  31438. * @param uvs as a float array
  31439. * @returns a shapeUV array
  31440. * @hidden
  31441. */
  31442. private _uvsToShapeUV;
  31443. /**
  31444. * Adds a new particle object in the particles array
  31445. * @param idx particle index in particles array
  31446. * @param id particle id
  31447. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31448. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31449. * @param model particle ModelShape object
  31450. * @param shapeId model shape identifier
  31451. * @param idxInShape index of the particle in the current model
  31452. * @param bInfo model bounding info object
  31453. * @param storage target storage array, if any
  31454. * @hidden
  31455. */
  31456. private _addParticle;
  31457. /**
  31458. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31459. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31460. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31461. * @param nb (positive integer) the number of particles to be created from this model
  31462. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31463. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31464. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31465. * @returns the number of shapes in the system
  31466. */
  31467. addShape(mesh: Mesh, nb: number, options?: {
  31468. positionFunction?: any;
  31469. vertexFunction?: any;
  31470. storage?: [];
  31471. }): number;
  31472. /**
  31473. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31474. * @hidden
  31475. */
  31476. private _rebuildParticle;
  31477. /**
  31478. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31479. * @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.
  31480. * @returns the SPS.
  31481. */
  31482. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31483. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31484. * Returns an array with the removed particles.
  31485. * 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.
  31486. * The SPS can't be empty so at least one particle needs to remain in place.
  31487. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31488. * @param start index of the first particle to remove
  31489. * @param end index of the last particle to remove (included)
  31490. * @returns an array populated with the removed particles
  31491. */
  31492. removeParticles(start: number, end: number): SolidParticle[];
  31493. /**
  31494. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31495. * @param solidParticleArray an array populated with Solid Particles objects
  31496. * @returns the SPS
  31497. */
  31498. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31499. /**
  31500. * Creates a new particle and modifies the SPS mesh geometry :
  31501. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31502. * - calls _addParticle() to populate the particle array
  31503. * factorized code from addShape() and insertParticlesFromArray()
  31504. * @param idx particle index in the particles array
  31505. * @param i particle index in its shape
  31506. * @param modelShape particle ModelShape object
  31507. * @param shape shape vertex array
  31508. * @param meshInd shape indices array
  31509. * @param meshUV shape uv array
  31510. * @param meshCol shape color array
  31511. * @param meshNor shape normals array
  31512. * @param bbInfo shape bounding info
  31513. * @param storage target particle storage
  31514. * @options addShape() passed options
  31515. * @hidden
  31516. */
  31517. private _insertNewParticle;
  31518. /**
  31519. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31520. * This method calls `updateParticle()` for each particle of the SPS.
  31521. * For an animated SPS, it is usually called within the render loop.
  31522. * 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.
  31523. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31524. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31525. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31526. * @returns the SPS.
  31527. */
  31528. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31529. /**
  31530. * Disposes the SPS.
  31531. */
  31532. dispose(): void;
  31533. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31534. * idx is the particle index in the SPS
  31535. * faceId is the picked face index counted within this particle.
  31536. * Returns null if the pickInfo can't identify a picked particle.
  31537. * @param pickingInfo (PickingInfo object)
  31538. * @returns {idx: number, faceId: number} or null
  31539. */
  31540. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31541. idx: number;
  31542. faceId: number;
  31543. }>;
  31544. /**
  31545. * Returns a SolidParticle object from its identifier : particle.id
  31546. * @param id (integer) the particle Id
  31547. * @returns the searched particle or null if not found in the SPS.
  31548. */
  31549. getParticleById(id: number): Nullable<SolidParticle>;
  31550. /**
  31551. * Returns a new array populated with the particles having the passed shapeId.
  31552. * @param shapeId (integer) the shape identifier
  31553. * @returns a new solid particle array
  31554. */
  31555. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31556. /**
  31557. * Populates the passed array "ref" with the particles having the passed shapeId.
  31558. * @param shapeId the shape identifier
  31559. * @returns the SPS
  31560. * @param ref
  31561. */
  31562. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31563. /**
  31564. * Computes the required SubMeshes according the materials assigned to the particles.
  31565. * @returns the solid particle system.
  31566. * Does nothing if called before the SPS mesh is built.
  31567. */
  31568. computeSubMeshes(): SolidParticleSystem;
  31569. /**
  31570. * Sorts the solid particles by material when MultiMaterial is enabled.
  31571. * Updates the indices32 array.
  31572. * Updates the indicesByMaterial array.
  31573. * Updates the mesh indices array.
  31574. * @returns the SPS
  31575. * @hidden
  31576. */
  31577. private _sortParticlesByMaterial;
  31578. /**
  31579. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31580. * @hidden
  31581. */
  31582. private _setMaterialIndexesById;
  31583. /**
  31584. * Returns an array with unique values of Materials from the passed array
  31585. * @param array the material array to be checked and filtered
  31586. * @hidden
  31587. */
  31588. private _filterUniqueMaterialId;
  31589. /**
  31590. * Sets a new Standard Material as _defaultMaterial if not already set.
  31591. * @hidden
  31592. */
  31593. private _setDefaultMaterial;
  31594. /**
  31595. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31596. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31597. * @returns the SPS.
  31598. */
  31599. refreshVisibleSize(): SolidParticleSystem;
  31600. /**
  31601. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31602. * @param size the size (float) of the visibility box
  31603. * note : this doesn't lock the SPS mesh bounding box.
  31604. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31605. */
  31606. setVisibilityBox(size: number): void;
  31607. /**
  31608. * Gets whether the SPS as always visible or not
  31609. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31610. */
  31611. get isAlwaysVisible(): boolean;
  31612. /**
  31613. * Sets the SPS as always visible or not
  31614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31615. */
  31616. set isAlwaysVisible(val: boolean);
  31617. /**
  31618. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31620. */
  31621. set isVisibilityBoxLocked(val: boolean);
  31622. /**
  31623. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31625. */
  31626. get isVisibilityBoxLocked(): boolean;
  31627. /**
  31628. * Tells to `setParticles()` to compute the particle rotations or not.
  31629. * Default value : true. The SPS is faster when it's set to false.
  31630. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31631. */
  31632. set computeParticleRotation(val: boolean);
  31633. /**
  31634. * Tells to `setParticles()` to compute the particle colors or not.
  31635. * Default value : true. The SPS is faster when it's set to false.
  31636. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31637. */
  31638. set computeParticleColor(val: boolean);
  31639. set computeParticleTexture(val: boolean);
  31640. /**
  31641. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31642. * Default value : false. The SPS is faster when it's set to false.
  31643. * Note : the particle custom vertex positions aren't stored values.
  31644. */
  31645. set computeParticleVertex(val: boolean);
  31646. /**
  31647. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31648. */
  31649. set computeBoundingBox(val: boolean);
  31650. /**
  31651. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31652. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31653. * Default : `true`
  31654. */
  31655. set depthSortParticles(val: boolean);
  31656. /**
  31657. * Gets if `setParticles()` computes the particle rotations or not.
  31658. * Default value : true. The SPS is faster when it's set to false.
  31659. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31660. */
  31661. get computeParticleRotation(): boolean;
  31662. /**
  31663. * Gets if `setParticles()` computes the particle colors or not.
  31664. * Default value : true. The SPS is faster when it's set to false.
  31665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31666. */
  31667. get computeParticleColor(): boolean;
  31668. /**
  31669. * Gets if `setParticles()` computes the particle textures or not.
  31670. * Default value : true. The SPS is faster when it's set to false.
  31671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31672. */
  31673. get computeParticleTexture(): boolean;
  31674. /**
  31675. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31676. * Default value : false. The SPS is faster when it's set to false.
  31677. * Note : the particle custom vertex positions aren't stored values.
  31678. */
  31679. get computeParticleVertex(): boolean;
  31680. /**
  31681. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31682. */
  31683. get computeBoundingBox(): boolean;
  31684. /**
  31685. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31686. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31687. * Default : `true`
  31688. */
  31689. get depthSortParticles(): boolean;
  31690. /**
  31691. * Gets if the SPS is created as expandable at construction time.
  31692. * Default : `false`
  31693. */
  31694. get expandable(): boolean;
  31695. /**
  31696. * Gets if the SPS supports the Multi Materials
  31697. */
  31698. get multimaterialEnabled(): boolean;
  31699. /**
  31700. * Gets if the SPS uses the model materials for its own multimaterial.
  31701. */
  31702. get useModelMaterial(): boolean;
  31703. /**
  31704. * The SPS used material array.
  31705. */
  31706. get materials(): Material[];
  31707. /**
  31708. * Sets the SPS MultiMaterial from the passed materials.
  31709. * Note : the passed array is internally copied and not used then by reference.
  31710. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31711. */
  31712. setMultiMaterial(materials: Material[]): void;
  31713. /**
  31714. * The SPS computed multimaterial object
  31715. */
  31716. get multimaterial(): MultiMaterial;
  31717. set multimaterial(mm: MultiMaterial);
  31718. /**
  31719. * If the subMeshes must be updated on the next call to setParticles()
  31720. */
  31721. get autoUpdateSubMeshes(): boolean;
  31722. set autoUpdateSubMeshes(val: boolean);
  31723. /**
  31724. * This function does nothing. It may be overwritten to set all the particle first values.
  31725. * The SPS doesn't call this function, you may have to call it by your own.
  31726. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31727. */
  31728. initParticles(): void;
  31729. /**
  31730. * This function does nothing. It may be overwritten to recycle a particle.
  31731. * The SPS doesn't call this function, you may have to call it by your own.
  31732. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31733. * @param particle The particle to recycle
  31734. * @returns the recycled particle
  31735. */
  31736. recycleParticle(particle: SolidParticle): SolidParticle;
  31737. /**
  31738. * Updates a particle : this function should be overwritten by the user.
  31739. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31740. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31741. * @example : just set a particle position or velocity and recycle conditions
  31742. * @param particle The particle to update
  31743. * @returns the updated particle
  31744. */
  31745. updateParticle(particle: SolidParticle): SolidParticle;
  31746. /**
  31747. * Updates a vertex of a particle : it can be overwritten by the user.
  31748. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31749. * @param particle the current particle
  31750. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31751. * @param pt the index of the current vertex in the particle shape
  31752. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31753. * @example : just set a vertex particle position or color
  31754. * @returns the sps
  31755. */
  31756. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31757. /**
  31758. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31759. * This does nothing and may be overwritten by the user.
  31760. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31761. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31762. * @param update the boolean update value actually passed to setParticles()
  31763. */
  31764. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31765. /**
  31766. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31767. * This will be passed three parameters.
  31768. * This does nothing and may be overwritten by the user.
  31769. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31770. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31771. * @param update the boolean update value actually passed to setParticles()
  31772. */
  31773. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31774. }
  31775. }
  31776. declare module "babylonjs/Particles/solidParticle" {
  31777. import { Nullable } from "babylonjs/types";
  31778. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31779. import { Color4 } from "babylonjs/Maths/math.color";
  31780. import { Mesh } from "babylonjs/Meshes/mesh";
  31781. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31782. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31783. import { Plane } from "babylonjs/Maths/math.plane";
  31784. import { Material } from "babylonjs/Materials/material";
  31785. /**
  31786. * Represents one particle of a solid particle system.
  31787. */
  31788. export class SolidParticle {
  31789. /**
  31790. * particle global index
  31791. */
  31792. idx: number;
  31793. /**
  31794. * particle identifier
  31795. */
  31796. id: number;
  31797. /**
  31798. * The color of the particle
  31799. */
  31800. color: Nullable<Color4>;
  31801. /**
  31802. * The world space position of the particle.
  31803. */
  31804. position: Vector3;
  31805. /**
  31806. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31807. */
  31808. rotation: Vector3;
  31809. /**
  31810. * The world space rotation quaternion of the particle.
  31811. */
  31812. rotationQuaternion: Nullable<Quaternion>;
  31813. /**
  31814. * The scaling of the particle.
  31815. */
  31816. scaling: Vector3;
  31817. /**
  31818. * The uvs of the particle.
  31819. */
  31820. uvs: Vector4;
  31821. /**
  31822. * The current speed of the particle.
  31823. */
  31824. velocity: Vector3;
  31825. /**
  31826. * The pivot point in the particle local space.
  31827. */
  31828. pivot: Vector3;
  31829. /**
  31830. * Must the particle be translated from its pivot point in its local space ?
  31831. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31832. * Default : false
  31833. */
  31834. translateFromPivot: boolean;
  31835. /**
  31836. * Is the particle active or not ?
  31837. */
  31838. alive: boolean;
  31839. /**
  31840. * Is the particle visible or not ?
  31841. */
  31842. isVisible: boolean;
  31843. /**
  31844. * Index of this particle in the global "positions" array (Internal use)
  31845. * @hidden
  31846. */
  31847. _pos: number;
  31848. /**
  31849. * @hidden Index of this particle in the global "indices" array (Internal use)
  31850. */
  31851. _ind: number;
  31852. /**
  31853. * @hidden ModelShape of this particle (Internal use)
  31854. */
  31855. _model: ModelShape;
  31856. /**
  31857. * ModelShape id of this particle
  31858. */
  31859. shapeId: number;
  31860. /**
  31861. * Index of the particle in its shape id
  31862. */
  31863. idxInShape: number;
  31864. /**
  31865. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31866. */
  31867. _modelBoundingInfo: BoundingInfo;
  31868. /**
  31869. * @hidden Particle BoundingInfo object (Internal use)
  31870. */
  31871. _boundingInfo: BoundingInfo;
  31872. /**
  31873. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31874. */
  31875. _sps: SolidParticleSystem;
  31876. /**
  31877. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31878. */
  31879. _stillInvisible: boolean;
  31880. /**
  31881. * @hidden Last computed particle rotation matrix
  31882. */
  31883. _rotationMatrix: number[];
  31884. /**
  31885. * Parent particle Id, if any.
  31886. * Default null.
  31887. */
  31888. parentId: Nullable<number>;
  31889. /**
  31890. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31891. */
  31892. materialIndex: Nullable<number>;
  31893. /**
  31894. * Custom object or properties.
  31895. */
  31896. props: Nullable<any>;
  31897. /**
  31898. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31899. * The possible values are :
  31900. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31901. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31902. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31903. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31904. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31905. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31906. * */
  31907. cullingStrategy: number;
  31908. /**
  31909. * @hidden Internal global position in the SPS.
  31910. */
  31911. _globalPosition: Vector3;
  31912. /**
  31913. * Creates a Solid Particle object.
  31914. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31915. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31916. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31917. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31918. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31919. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31920. * @param shapeId (integer) is the model shape identifier in the SPS.
  31921. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31922. * @param sps defines the sps it is associated to
  31923. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31924. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31925. */
  31926. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31927. /**
  31928. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31929. * @param target the particle target
  31930. * @returns the current particle
  31931. */
  31932. copyToRef(target: SolidParticle): SolidParticle;
  31933. /**
  31934. * Legacy support, changed scale to scaling
  31935. */
  31936. get scale(): Vector3;
  31937. /**
  31938. * Legacy support, changed scale to scaling
  31939. */
  31940. set scale(scale: Vector3);
  31941. /**
  31942. * Legacy support, changed quaternion to rotationQuaternion
  31943. */
  31944. get quaternion(): Nullable<Quaternion>;
  31945. /**
  31946. * Legacy support, changed quaternion to rotationQuaternion
  31947. */
  31948. set quaternion(q: Nullable<Quaternion>);
  31949. /**
  31950. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31951. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31952. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31953. * @returns true if it intersects
  31954. */
  31955. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31956. /**
  31957. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31958. * A particle is in the frustum if its bounding box intersects the frustum
  31959. * @param frustumPlanes defines the frustum to test
  31960. * @returns true if the particle is in the frustum planes
  31961. */
  31962. isInFrustum(frustumPlanes: Plane[]): boolean;
  31963. /**
  31964. * get the rotation matrix of the particle
  31965. * @hidden
  31966. */
  31967. getRotationMatrix(m: Matrix): void;
  31968. }
  31969. /**
  31970. * Represents the shape of the model used by one particle of a solid particle system.
  31971. * SPS internal tool, don't use it manually.
  31972. */
  31973. export class ModelShape {
  31974. /**
  31975. * The shape id
  31976. * @hidden
  31977. */
  31978. shapeID: number;
  31979. /**
  31980. * flat array of model positions (internal use)
  31981. * @hidden
  31982. */
  31983. _shape: Vector3[];
  31984. /**
  31985. * flat array of model UVs (internal use)
  31986. * @hidden
  31987. */
  31988. _shapeUV: number[];
  31989. /**
  31990. * color array of the model
  31991. * @hidden
  31992. */
  31993. _shapeColors: number[];
  31994. /**
  31995. * indices array of the model
  31996. * @hidden
  31997. */
  31998. _indices: number[];
  31999. /**
  32000. * normals array of the model
  32001. * @hidden
  32002. */
  32003. _normals: number[];
  32004. /**
  32005. * length of the shape in the model indices array (internal use)
  32006. * @hidden
  32007. */
  32008. _indicesLength: number;
  32009. /**
  32010. * Custom position function (internal use)
  32011. * @hidden
  32012. */
  32013. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32014. /**
  32015. * Custom vertex function (internal use)
  32016. * @hidden
  32017. */
  32018. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32019. /**
  32020. * Model material (internal use)
  32021. * @hidden
  32022. */
  32023. _material: Nullable<Material>;
  32024. /**
  32025. * 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.
  32026. * SPS internal tool, don't use it manually.
  32027. * @hidden
  32028. */
  32029. 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>);
  32030. }
  32031. /**
  32032. * Represents a Depth Sorted Particle in the solid particle system.
  32033. * @hidden
  32034. */
  32035. export class DepthSortedParticle {
  32036. /**
  32037. * Particle index
  32038. */
  32039. idx: number;
  32040. /**
  32041. * Index of the particle in the "indices" array
  32042. */
  32043. ind: number;
  32044. /**
  32045. * Length of the particle shape in the "indices" array
  32046. */
  32047. indicesLength: number;
  32048. /**
  32049. * Squared distance from the particle to the camera
  32050. */
  32051. sqDistance: number;
  32052. /**
  32053. * Material index when used with MultiMaterials
  32054. */
  32055. materialIndex: number;
  32056. /**
  32057. * Creates a new sorted particle
  32058. * @param materialIndex
  32059. */
  32060. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32061. }
  32062. /**
  32063. * Represents a solid particle vertex
  32064. */
  32065. export class SolidParticleVertex {
  32066. /**
  32067. * Vertex position
  32068. */
  32069. position: Vector3;
  32070. /**
  32071. * Vertex color
  32072. */
  32073. color: Color4;
  32074. /**
  32075. * Vertex UV
  32076. */
  32077. uv: Vector2;
  32078. /**
  32079. * Creates a new solid particle vertex
  32080. */
  32081. constructor();
  32082. /** Vertex x coordinate */
  32083. get x(): number;
  32084. set x(val: number);
  32085. /** Vertex y coordinate */
  32086. get y(): number;
  32087. set y(val: number);
  32088. /** Vertex z coordinate */
  32089. get z(): number;
  32090. set z(val: number);
  32091. }
  32092. }
  32093. declare module "babylonjs/Collisions/meshCollisionData" {
  32094. import { Collider } from "babylonjs/Collisions/collider";
  32095. import { Vector3 } from "babylonjs/Maths/math.vector";
  32096. import { Nullable } from "babylonjs/types";
  32097. import { Observer } from "babylonjs/Misc/observable";
  32098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32099. /**
  32100. * @hidden
  32101. */
  32102. export class _MeshCollisionData {
  32103. _checkCollisions: boolean;
  32104. _collisionMask: number;
  32105. _collisionGroup: number;
  32106. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32107. _collider: Nullable<Collider>;
  32108. _oldPositionForCollisions: Vector3;
  32109. _diffPositionForCollisions: Vector3;
  32110. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32111. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32112. }
  32113. }
  32114. declare module "babylonjs/Meshes/abstractMesh" {
  32115. import { Observable } from "babylonjs/Misc/observable";
  32116. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32117. import { Camera } from "babylonjs/Cameras/camera";
  32118. import { Scene, IDisposable } from "babylonjs/scene";
  32119. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32120. import { Node } from "babylonjs/node";
  32121. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32123. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32124. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32125. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32126. import { Material } from "babylonjs/Materials/material";
  32127. import { Light } from "babylonjs/Lights/light";
  32128. import { Skeleton } from "babylonjs/Bones/skeleton";
  32129. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32130. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32131. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32133. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32134. import { Plane } from "babylonjs/Maths/math.plane";
  32135. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32136. import { Ray } from "babylonjs/Culling/ray";
  32137. import { Collider } from "babylonjs/Collisions/collider";
  32138. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32139. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32140. /** @hidden */
  32141. class _FacetDataStorage {
  32142. facetPositions: Vector3[];
  32143. facetNormals: Vector3[];
  32144. facetPartitioning: number[][];
  32145. facetNb: number;
  32146. partitioningSubdivisions: number;
  32147. partitioningBBoxRatio: number;
  32148. facetDataEnabled: boolean;
  32149. facetParameters: any;
  32150. bbSize: Vector3;
  32151. subDiv: {
  32152. max: number;
  32153. X: number;
  32154. Y: number;
  32155. Z: number;
  32156. };
  32157. facetDepthSort: boolean;
  32158. facetDepthSortEnabled: boolean;
  32159. depthSortedIndices: IndicesArray;
  32160. depthSortedFacets: {
  32161. ind: number;
  32162. sqDistance: number;
  32163. }[];
  32164. facetDepthSortFunction: (f1: {
  32165. ind: number;
  32166. sqDistance: number;
  32167. }, f2: {
  32168. ind: number;
  32169. sqDistance: number;
  32170. }) => number;
  32171. facetDepthSortFrom: Vector3;
  32172. facetDepthSortOrigin: Vector3;
  32173. invertedMatrix: Matrix;
  32174. }
  32175. /**
  32176. * @hidden
  32177. **/
  32178. class _InternalAbstractMeshDataInfo {
  32179. _hasVertexAlpha: boolean;
  32180. _useVertexColors: boolean;
  32181. _numBoneInfluencers: number;
  32182. _applyFog: boolean;
  32183. _receiveShadows: boolean;
  32184. _facetData: _FacetDataStorage;
  32185. _visibility: number;
  32186. _skeleton: Nullable<Skeleton>;
  32187. _layerMask: number;
  32188. _computeBonesUsingShaders: boolean;
  32189. _isActive: boolean;
  32190. _onlyForInstances: boolean;
  32191. _isActiveIntermediate: boolean;
  32192. _onlyForInstancesIntermediate: boolean;
  32193. _actAsRegularMesh: boolean;
  32194. }
  32195. /**
  32196. * Class used to store all common mesh properties
  32197. */
  32198. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32199. /** No occlusion */
  32200. static OCCLUSION_TYPE_NONE: number;
  32201. /** Occlusion set to optimisitic */
  32202. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32203. /** Occlusion set to strict */
  32204. static OCCLUSION_TYPE_STRICT: number;
  32205. /** Use an accurante occlusion algorithm */
  32206. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32207. /** Use a conservative occlusion algorithm */
  32208. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32209. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32210. * Test order :
  32211. * Is the bounding sphere outside the frustum ?
  32212. * If not, are the bounding box vertices outside the frustum ?
  32213. * It not, then the cullable object is in the frustum.
  32214. */
  32215. static readonly CULLINGSTRATEGY_STANDARD: number;
  32216. /** Culling strategy : Bounding Sphere Only.
  32217. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32218. * It's also less accurate than the standard because some not visible objects can still be selected.
  32219. * Test : is the bounding sphere outside the frustum ?
  32220. * If not, then the cullable object is in the frustum.
  32221. */
  32222. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32223. /** Culling strategy : Optimistic Inclusion.
  32224. * This in an inclusion test first, then the standard exclusion test.
  32225. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32226. * 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.
  32227. * Anyway, it's as accurate as the standard strategy.
  32228. * Test :
  32229. * Is the cullable object bounding sphere center in the frustum ?
  32230. * If not, apply the default culling strategy.
  32231. */
  32232. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32233. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32234. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32235. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32236. * 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.
  32237. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32238. * Test :
  32239. * Is the cullable object bounding sphere center in the frustum ?
  32240. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32241. */
  32242. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32243. /**
  32244. * No billboard
  32245. */
  32246. static get BILLBOARDMODE_NONE(): number;
  32247. /** Billboard on X axis */
  32248. static get BILLBOARDMODE_X(): number;
  32249. /** Billboard on Y axis */
  32250. static get BILLBOARDMODE_Y(): number;
  32251. /** Billboard on Z axis */
  32252. static get BILLBOARDMODE_Z(): number;
  32253. /** Billboard on all axes */
  32254. static get BILLBOARDMODE_ALL(): number;
  32255. /** Billboard on using position instead of orientation */
  32256. static get BILLBOARDMODE_USE_POSITION(): number;
  32257. /** @hidden */
  32258. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32259. /**
  32260. * The culling strategy to use to check whether the mesh must be rendered or not.
  32261. * This value can be changed at any time and will be used on the next render mesh selection.
  32262. * The possible values are :
  32263. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32264. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32265. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32266. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32267. * Please read each static variable documentation to get details about the culling process.
  32268. * */
  32269. cullingStrategy: number;
  32270. /**
  32271. * Gets the number of facets in the mesh
  32272. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32273. */
  32274. get facetNb(): number;
  32275. /**
  32276. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32277. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32278. */
  32279. get partitioningSubdivisions(): number;
  32280. set partitioningSubdivisions(nb: number);
  32281. /**
  32282. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32283. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32285. */
  32286. get partitioningBBoxRatio(): number;
  32287. set partitioningBBoxRatio(ratio: number);
  32288. /**
  32289. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32290. * Works only for updatable meshes.
  32291. * Doesn't work with multi-materials
  32292. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32293. */
  32294. get mustDepthSortFacets(): boolean;
  32295. set mustDepthSortFacets(sort: boolean);
  32296. /**
  32297. * The location (Vector3) where the facet depth sort must be computed from.
  32298. * By default, the active camera position.
  32299. * Used only when facet depth sort is enabled
  32300. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32301. */
  32302. get facetDepthSortFrom(): Vector3;
  32303. set facetDepthSortFrom(location: Vector3);
  32304. /**
  32305. * gets a boolean indicating if facetData is enabled
  32306. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32307. */
  32308. get isFacetDataEnabled(): boolean;
  32309. /** @hidden */
  32310. _updateNonUniformScalingState(value: boolean): boolean;
  32311. /**
  32312. * An event triggered when this mesh collides with another one
  32313. */
  32314. onCollideObservable: Observable<AbstractMesh>;
  32315. /** Set a function to call when this mesh collides with another one */
  32316. set onCollide(callback: () => void);
  32317. /**
  32318. * An event triggered when the collision's position changes
  32319. */
  32320. onCollisionPositionChangeObservable: Observable<Vector3>;
  32321. /** Set a function to call when the collision's position changes */
  32322. set onCollisionPositionChange(callback: () => void);
  32323. /**
  32324. * An event triggered when material is changed
  32325. */
  32326. onMaterialChangedObservable: Observable<AbstractMesh>;
  32327. /**
  32328. * Gets or sets the orientation for POV movement & rotation
  32329. */
  32330. definedFacingForward: boolean;
  32331. /** @hidden */
  32332. _occlusionQuery: Nullable<WebGLQuery>;
  32333. /** @hidden */
  32334. _renderingGroup: Nullable<RenderingGroup>;
  32335. /**
  32336. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32337. */
  32338. get visibility(): number;
  32339. /**
  32340. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32341. */
  32342. set visibility(value: number);
  32343. /** Gets or sets the alpha index used to sort transparent meshes
  32344. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32345. */
  32346. alphaIndex: number;
  32347. /**
  32348. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32349. */
  32350. isVisible: boolean;
  32351. /**
  32352. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32353. */
  32354. isPickable: boolean;
  32355. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32356. showSubMeshesBoundingBox: boolean;
  32357. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32358. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32359. */
  32360. isBlocker: boolean;
  32361. /**
  32362. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32363. */
  32364. enablePointerMoveEvents: boolean;
  32365. /**
  32366. * Specifies the rendering group id for this mesh (0 by default)
  32367. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32368. */
  32369. renderingGroupId: number;
  32370. private _material;
  32371. /** Gets or sets current material */
  32372. get material(): Nullable<Material>;
  32373. set material(value: Nullable<Material>);
  32374. /**
  32375. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32376. * @see https://doc.babylonjs.com/babylon101/shadows
  32377. */
  32378. get receiveShadows(): boolean;
  32379. set receiveShadows(value: boolean);
  32380. /** Defines color to use when rendering outline */
  32381. outlineColor: Color3;
  32382. /** Define width to use when rendering outline */
  32383. outlineWidth: number;
  32384. /** Defines color to use when rendering overlay */
  32385. overlayColor: Color3;
  32386. /** Defines alpha to use when rendering overlay */
  32387. overlayAlpha: number;
  32388. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32389. get hasVertexAlpha(): boolean;
  32390. set hasVertexAlpha(value: boolean);
  32391. /** 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) */
  32392. get useVertexColors(): boolean;
  32393. set useVertexColors(value: boolean);
  32394. /**
  32395. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32396. */
  32397. get computeBonesUsingShaders(): boolean;
  32398. set computeBonesUsingShaders(value: boolean);
  32399. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32400. get numBoneInfluencers(): number;
  32401. set numBoneInfluencers(value: number);
  32402. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32403. get applyFog(): boolean;
  32404. set applyFog(value: boolean);
  32405. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32406. useOctreeForRenderingSelection: boolean;
  32407. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32408. useOctreeForPicking: boolean;
  32409. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32410. useOctreeForCollisions: boolean;
  32411. /**
  32412. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32413. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32414. */
  32415. get layerMask(): number;
  32416. set layerMask(value: number);
  32417. /**
  32418. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32419. */
  32420. alwaysSelectAsActiveMesh: boolean;
  32421. /**
  32422. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32423. */
  32424. doNotSyncBoundingInfo: boolean;
  32425. /**
  32426. * Gets or sets the current action manager
  32427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32428. */
  32429. actionManager: Nullable<AbstractActionManager>;
  32430. private _meshCollisionData;
  32431. /**
  32432. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32433. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32434. */
  32435. ellipsoid: Vector3;
  32436. /**
  32437. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32438. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32439. */
  32440. ellipsoidOffset: Vector3;
  32441. /**
  32442. * Gets or sets a collision mask used to mask collisions (default is -1).
  32443. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32444. */
  32445. get collisionMask(): number;
  32446. set collisionMask(mask: number);
  32447. /**
  32448. * Gets or sets the current collision group mask (-1 by default).
  32449. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32450. */
  32451. get collisionGroup(): number;
  32452. set collisionGroup(mask: number);
  32453. /**
  32454. * Gets or sets current surrounding meshes (null by default).
  32455. *
  32456. * By default collision detection is tested against every mesh in the scene.
  32457. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32458. * meshes will be tested for the collision.
  32459. *
  32460. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32461. */
  32462. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32463. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32464. /**
  32465. * Defines edge width used when edgesRenderer is enabled
  32466. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32467. */
  32468. edgesWidth: number;
  32469. /**
  32470. * Defines edge color used when edgesRenderer is enabled
  32471. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32472. */
  32473. edgesColor: Color4;
  32474. /** @hidden */
  32475. _edgesRenderer: Nullable<IEdgesRenderer>;
  32476. /** @hidden */
  32477. _masterMesh: Nullable<AbstractMesh>;
  32478. /** @hidden */
  32479. _boundingInfo: Nullable<BoundingInfo>;
  32480. /** @hidden */
  32481. _renderId: number;
  32482. /**
  32483. * Gets or sets the list of subMeshes
  32484. * @see https://doc.babylonjs.com/how_to/multi_materials
  32485. */
  32486. subMeshes: SubMesh[];
  32487. /** @hidden */
  32488. _intersectionsInProgress: AbstractMesh[];
  32489. /** @hidden */
  32490. _unIndexed: boolean;
  32491. /** @hidden */
  32492. _lightSources: Light[];
  32493. /** Gets the list of lights affecting that mesh */
  32494. get lightSources(): Light[];
  32495. /** @hidden */
  32496. get _positions(): Nullable<Vector3[]>;
  32497. /** @hidden */
  32498. _waitingData: {
  32499. lods: Nullable<any>;
  32500. actions: Nullable<any>;
  32501. freezeWorldMatrix: Nullable<boolean>;
  32502. };
  32503. /** @hidden */
  32504. _bonesTransformMatrices: Nullable<Float32Array>;
  32505. /** @hidden */
  32506. _transformMatrixTexture: Nullable<RawTexture>;
  32507. /**
  32508. * Gets or sets a skeleton to apply skining transformations
  32509. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32510. */
  32511. set skeleton(value: Nullable<Skeleton>);
  32512. get skeleton(): Nullable<Skeleton>;
  32513. /**
  32514. * An event triggered when the mesh is rebuilt.
  32515. */
  32516. onRebuildObservable: Observable<AbstractMesh>;
  32517. /**
  32518. * Creates a new AbstractMesh
  32519. * @param name defines the name of the mesh
  32520. * @param scene defines the hosting scene
  32521. */
  32522. constructor(name: string, scene?: Nullable<Scene>);
  32523. /**
  32524. * Returns the string "AbstractMesh"
  32525. * @returns "AbstractMesh"
  32526. */
  32527. getClassName(): string;
  32528. /**
  32529. * Gets a string representation of the current mesh
  32530. * @param fullDetails defines a boolean indicating if full details must be included
  32531. * @returns a string representation of the current mesh
  32532. */
  32533. toString(fullDetails?: boolean): string;
  32534. /**
  32535. * @hidden
  32536. */
  32537. protected _getEffectiveParent(): Nullable<Node>;
  32538. /** @hidden */
  32539. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32540. /** @hidden */
  32541. _rebuild(): void;
  32542. /** @hidden */
  32543. _resyncLightSources(): void;
  32544. /** @hidden */
  32545. _resyncLightSource(light: Light): void;
  32546. /** @hidden */
  32547. _unBindEffect(): void;
  32548. /** @hidden */
  32549. _removeLightSource(light: Light, dispose: boolean): void;
  32550. private _markSubMeshesAsDirty;
  32551. /** @hidden */
  32552. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32553. /** @hidden */
  32554. _markSubMeshesAsAttributesDirty(): void;
  32555. /** @hidden */
  32556. _markSubMeshesAsMiscDirty(): void;
  32557. /**
  32558. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32559. */
  32560. get scaling(): Vector3;
  32561. set scaling(newScaling: Vector3);
  32562. /**
  32563. * Returns true if the mesh is blocked. Implemented by child classes
  32564. */
  32565. get isBlocked(): boolean;
  32566. /**
  32567. * Returns the mesh itself by default. Implemented by child classes
  32568. * @param camera defines the camera to use to pick the right LOD level
  32569. * @returns the currentAbstractMesh
  32570. */
  32571. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32572. /**
  32573. * Returns 0 by default. Implemented by child classes
  32574. * @returns an integer
  32575. */
  32576. getTotalVertices(): number;
  32577. /**
  32578. * Returns a positive integer : the total number of indices in this mesh geometry.
  32579. * @returns the numner of indices or zero if the mesh has no geometry.
  32580. */
  32581. getTotalIndices(): number;
  32582. /**
  32583. * Returns null by default. Implemented by child classes
  32584. * @returns null
  32585. */
  32586. getIndices(): Nullable<IndicesArray>;
  32587. /**
  32588. * Returns the array of the requested vertex data kind. Implemented by child classes
  32589. * @param kind defines the vertex data kind to use
  32590. * @returns null
  32591. */
  32592. getVerticesData(kind: string): Nullable<FloatArray>;
  32593. /**
  32594. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32595. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32596. * Note that a new underlying VertexBuffer object is created each call.
  32597. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32598. * @param kind defines vertex data kind:
  32599. * * VertexBuffer.PositionKind
  32600. * * VertexBuffer.UVKind
  32601. * * VertexBuffer.UV2Kind
  32602. * * VertexBuffer.UV3Kind
  32603. * * VertexBuffer.UV4Kind
  32604. * * VertexBuffer.UV5Kind
  32605. * * VertexBuffer.UV6Kind
  32606. * * VertexBuffer.ColorKind
  32607. * * VertexBuffer.MatricesIndicesKind
  32608. * * VertexBuffer.MatricesIndicesExtraKind
  32609. * * VertexBuffer.MatricesWeightsKind
  32610. * * VertexBuffer.MatricesWeightsExtraKind
  32611. * @param data defines the data source
  32612. * @param updatable defines if the data must be flagged as updatable (or static)
  32613. * @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
  32614. * @returns the current mesh
  32615. */
  32616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32617. /**
  32618. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32619. * If the mesh has no geometry, it is simply returned as it is.
  32620. * @param kind defines vertex data kind:
  32621. * * VertexBuffer.PositionKind
  32622. * * VertexBuffer.UVKind
  32623. * * VertexBuffer.UV2Kind
  32624. * * VertexBuffer.UV3Kind
  32625. * * VertexBuffer.UV4Kind
  32626. * * VertexBuffer.UV5Kind
  32627. * * VertexBuffer.UV6Kind
  32628. * * VertexBuffer.ColorKind
  32629. * * VertexBuffer.MatricesIndicesKind
  32630. * * VertexBuffer.MatricesIndicesExtraKind
  32631. * * VertexBuffer.MatricesWeightsKind
  32632. * * VertexBuffer.MatricesWeightsExtraKind
  32633. * @param data defines the data source
  32634. * @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
  32635. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32636. * @returns the current mesh
  32637. */
  32638. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32639. /**
  32640. * Sets the mesh indices,
  32641. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32642. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32643. * @param totalVertices Defines the total number of vertices
  32644. * @returns the current mesh
  32645. */
  32646. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32647. /**
  32648. * Gets a boolean indicating if specific vertex data is present
  32649. * @param kind defines the vertex data kind to use
  32650. * @returns true is data kind is present
  32651. */
  32652. isVerticesDataPresent(kind: string): boolean;
  32653. /**
  32654. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32655. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32656. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32657. * @returns a BoundingInfo
  32658. */
  32659. getBoundingInfo(): BoundingInfo;
  32660. /**
  32661. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32662. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32663. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32664. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32665. * @returns the current mesh
  32666. */
  32667. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32668. /**
  32669. * Overwrite the current bounding info
  32670. * @param boundingInfo defines the new bounding info
  32671. * @returns the current mesh
  32672. */
  32673. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32674. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32675. get useBones(): boolean;
  32676. /** @hidden */
  32677. _preActivate(): void;
  32678. /** @hidden */
  32679. _preActivateForIntermediateRendering(renderId: number): void;
  32680. /** @hidden */
  32681. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32682. /** @hidden */
  32683. _postActivate(): void;
  32684. /** @hidden */
  32685. _freeze(): void;
  32686. /** @hidden */
  32687. _unFreeze(): void;
  32688. /**
  32689. * Gets the current world matrix
  32690. * @returns a Matrix
  32691. */
  32692. getWorldMatrix(): Matrix;
  32693. /** @hidden */
  32694. _getWorldMatrixDeterminant(): number;
  32695. /**
  32696. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32697. */
  32698. get isAnInstance(): boolean;
  32699. /**
  32700. * Gets a boolean indicating if this mesh has instances
  32701. */
  32702. get hasInstances(): boolean;
  32703. /**
  32704. * Gets a boolean indicating if this mesh has thin instances
  32705. */
  32706. get hasThinInstances(): boolean;
  32707. /**
  32708. * Perform relative position change from the point of view of behind the front of the mesh.
  32709. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32710. * Supports definition of mesh facing forward or backward
  32711. * @param amountRight defines the distance on the right axis
  32712. * @param amountUp defines the distance on the up axis
  32713. * @param amountForward defines the distance on the forward axis
  32714. * @returns the current mesh
  32715. */
  32716. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32717. /**
  32718. * Calculate relative position change from the point of view of behind the front of the mesh.
  32719. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32720. * Supports definition of mesh facing forward or backward
  32721. * @param amountRight defines the distance on the right axis
  32722. * @param amountUp defines the distance on the up axis
  32723. * @param amountForward defines the distance on the forward axis
  32724. * @returns the new displacement vector
  32725. */
  32726. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32727. /**
  32728. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32729. * Supports definition of mesh facing forward or backward
  32730. * @param flipBack defines the flip
  32731. * @param twirlClockwise defines the twirl
  32732. * @param tiltRight defines the tilt
  32733. * @returns the current mesh
  32734. */
  32735. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32736. /**
  32737. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32738. * Supports definition of mesh facing forward or backward.
  32739. * @param flipBack defines the flip
  32740. * @param twirlClockwise defines the twirl
  32741. * @param tiltRight defines the tilt
  32742. * @returns the new rotation vector
  32743. */
  32744. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32745. /**
  32746. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32747. * This means the mesh underlying bounding box and sphere are recomputed.
  32748. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32749. * @returns the current mesh
  32750. */
  32751. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32752. /** @hidden */
  32753. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32754. /** @hidden */
  32755. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32756. /** @hidden */
  32757. _updateBoundingInfo(): AbstractMesh;
  32758. /** @hidden */
  32759. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32760. /** @hidden */
  32761. protected _afterComputeWorldMatrix(): void;
  32762. /** @hidden */
  32763. get _effectiveMesh(): AbstractMesh;
  32764. /**
  32765. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32766. * A mesh is in the frustum if its bounding box intersects the frustum
  32767. * @param frustumPlanes defines the frustum to test
  32768. * @returns true if the mesh is in the frustum planes
  32769. */
  32770. isInFrustum(frustumPlanes: Plane[]): boolean;
  32771. /**
  32772. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32773. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32774. * @param frustumPlanes defines the frustum to test
  32775. * @returns true if the mesh is completely in the frustum planes
  32776. */
  32777. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32778. /**
  32779. * True if the mesh intersects another mesh or a SolidParticle object
  32780. * @param mesh defines a target mesh or SolidParticle to test
  32781. * @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)
  32782. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32783. * @returns true if there is an intersection
  32784. */
  32785. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32786. /**
  32787. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32788. * @param point defines the point to test
  32789. * @returns true if there is an intersection
  32790. */
  32791. intersectsPoint(point: Vector3): boolean;
  32792. /**
  32793. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32794. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32795. */
  32796. get checkCollisions(): boolean;
  32797. set checkCollisions(collisionEnabled: boolean);
  32798. /**
  32799. * Gets Collider object used to compute collisions (not physics)
  32800. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32801. */
  32802. get collider(): Nullable<Collider>;
  32803. /**
  32804. * Move the mesh using collision engine
  32805. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32806. * @param displacement defines the requested displacement vector
  32807. * @returns the current mesh
  32808. */
  32809. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32810. private _onCollisionPositionChange;
  32811. /** @hidden */
  32812. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32813. /** @hidden */
  32814. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32815. /** @hidden */
  32816. _checkCollision(collider: Collider): AbstractMesh;
  32817. /** @hidden */
  32818. _generatePointsArray(): boolean;
  32819. /**
  32820. * Checks if the passed Ray intersects with the mesh
  32821. * @param ray defines the ray to use
  32822. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32823. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32824. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32825. * @returns the picking info
  32826. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32827. */
  32828. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32829. /**
  32830. * Clones the current mesh
  32831. * @param name defines the mesh name
  32832. * @param newParent defines the new mesh parent
  32833. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32834. * @returns the new mesh
  32835. */
  32836. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32837. /**
  32838. * Disposes all the submeshes of the current meshnp
  32839. * @returns the current mesh
  32840. */
  32841. releaseSubMeshes(): AbstractMesh;
  32842. /**
  32843. * Releases resources associated with this abstract mesh.
  32844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32846. */
  32847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32848. /**
  32849. * Adds the passed mesh as a child to the current mesh
  32850. * @param mesh defines the child mesh
  32851. * @returns the current mesh
  32852. */
  32853. addChild(mesh: AbstractMesh): AbstractMesh;
  32854. /**
  32855. * Removes the passed mesh from the current mesh children list
  32856. * @param mesh defines the child mesh
  32857. * @returns the current mesh
  32858. */
  32859. removeChild(mesh: AbstractMesh): AbstractMesh;
  32860. /** @hidden */
  32861. private _initFacetData;
  32862. /**
  32863. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32864. * This method can be called within the render loop.
  32865. * 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
  32866. * @returns the current mesh
  32867. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32868. */
  32869. updateFacetData(): AbstractMesh;
  32870. /**
  32871. * Returns the facetLocalNormals array.
  32872. * The normals are expressed in the mesh local spac
  32873. * @returns an array of Vector3
  32874. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32875. */
  32876. getFacetLocalNormals(): Vector3[];
  32877. /**
  32878. * Returns the facetLocalPositions array.
  32879. * The facet positions are expressed in the mesh local space
  32880. * @returns an array of Vector3
  32881. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32882. */
  32883. getFacetLocalPositions(): Vector3[];
  32884. /**
  32885. * Returns the facetLocalPartioning array
  32886. * @returns an array of array of numbers
  32887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32888. */
  32889. getFacetLocalPartitioning(): number[][];
  32890. /**
  32891. * Returns the i-th facet position in the world system.
  32892. * This method allocates a new Vector3 per call
  32893. * @param i defines the facet index
  32894. * @returns a new Vector3
  32895. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32896. */
  32897. getFacetPosition(i: number): Vector3;
  32898. /**
  32899. * Sets the reference Vector3 with the i-th facet position in the world system
  32900. * @param i defines the facet index
  32901. * @param ref defines the target vector
  32902. * @returns the current mesh
  32903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32904. */
  32905. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32906. /**
  32907. * Returns the i-th facet normal in the world system.
  32908. * This method allocates a new Vector3 per call
  32909. * @param i defines the facet index
  32910. * @returns a new Vector3
  32911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32912. */
  32913. getFacetNormal(i: number): Vector3;
  32914. /**
  32915. * Sets the reference Vector3 with the i-th facet normal in the world system
  32916. * @param i defines the facet index
  32917. * @param ref defines the target vector
  32918. * @returns the current mesh
  32919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32920. */
  32921. getFacetNormalToRef(i: number, ref: Vector3): this;
  32922. /**
  32923. * 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)
  32924. * @param x defines x coordinate
  32925. * @param y defines y coordinate
  32926. * @param z defines z coordinate
  32927. * @returns the array of facet indexes
  32928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32929. */
  32930. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32931. /**
  32932. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32933. * @param projected sets as the (x,y,z) world projection on the facet
  32934. * @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
  32935. * @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
  32936. * @param x defines x coordinate
  32937. * @param y defines y coordinate
  32938. * @param z defines z coordinate
  32939. * @returns the face index if found (or null instead)
  32940. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32941. */
  32942. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32943. /**
  32944. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32945. * @param projected sets as the (x,y,z) local projection on the facet
  32946. * @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
  32947. * @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
  32948. * @param x defines x coordinate
  32949. * @param y defines y coordinate
  32950. * @param z defines z coordinate
  32951. * @returns the face index if found (or null instead)
  32952. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32953. */
  32954. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32955. /**
  32956. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32957. * @returns the parameters
  32958. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32959. */
  32960. getFacetDataParameters(): any;
  32961. /**
  32962. * Disables the feature FacetData and frees the related memory
  32963. * @returns the current mesh
  32964. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32965. */
  32966. disableFacetData(): AbstractMesh;
  32967. /**
  32968. * Updates the AbstractMesh indices array
  32969. * @param indices defines the data source
  32970. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32971. * @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)
  32972. * @returns the current mesh
  32973. */
  32974. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32975. /**
  32976. * Creates new normals data for the mesh
  32977. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32978. * @returns the current mesh
  32979. */
  32980. createNormals(updatable: boolean): AbstractMesh;
  32981. /**
  32982. * Align the mesh with a normal
  32983. * @param normal defines the normal to use
  32984. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32985. * @returns the current mesh
  32986. */
  32987. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32988. /** @hidden */
  32989. _checkOcclusionQuery(): boolean;
  32990. /**
  32991. * Disables the mesh edge rendering mode
  32992. * @returns the currentAbstractMesh
  32993. */
  32994. disableEdgesRendering(): AbstractMesh;
  32995. /**
  32996. * Enables the edge rendering mode on the mesh.
  32997. * This mode makes the mesh edges visible
  32998. * @param epsilon defines the maximal distance between two angles to detect a face
  32999. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33000. * @returns the currentAbstractMesh
  33001. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33002. */
  33003. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33004. /**
  33005. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33006. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33007. */
  33008. getConnectedParticleSystems(): IParticleSystem[];
  33009. }
  33010. }
  33011. declare module "babylonjs/Actions/actionEvent" {
  33012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33013. import { Nullable } from "babylonjs/types";
  33014. import { Sprite } from "babylonjs/Sprites/sprite";
  33015. import { Scene } from "babylonjs/scene";
  33016. import { Vector2 } from "babylonjs/Maths/math.vector";
  33017. /**
  33018. * Interface used to define ActionEvent
  33019. */
  33020. export interface IActionEvent {
  33021. /** The mesh or sprite that triggered the action */
  33022. source: any;
  33023. /** The X mouse cursor position at the time of the event */
  33024. pointerX: number;
  33025. /** The Y mouse cursor position at the time of the event */
  33026. pointerY: number;
  33027. /** The mesh that is currently pointed at (can be null) */
  33028. meshUnderPointer: Nullable<AbstractMesh>;
  33029. /** the original (browser) event that triggered the ActionEvent */
  33030. sourceEvent?: any;
  33031. /** additional data for the event */
  33032. additionalData?: any;
  33033. }
  33034. /**
  33035. * ActionEvent is the event being sent when an action is triggered.
  33036. */
  33037. export class ActionEvent implements IActionEvent {
  33038. /** The mesh or sprite that triggered the action */
  33039. source: any;
  33040. /** The X mouse cursor position at the time of the event */
  33041. pointerX: number;
  33042. /** The Y mouse cursor position at the time of the event */
  33043. pointerY: number;
  33044. /** The mesh that is currently pointed at (can be null) */
  33045. meshUnderPointer: Nullable<AbstractMesh>;
  33046. /** the original (browser) event that triggered the ActionEvent */
  33047. sourceEvent?: any;
  33048. /** additional data for the event */
  33049. additionalData?: any;
  33050. /**
  33051. * Creates a new ActionEvent
  33052. * @param source The mesh or sprite that triggered the action
  33053. * @param pointerX The X mouse cursor position at the time of the event
  33054. * @param pointerY The Y mouse cursor position at the time of the event
  33055. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33056. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33057. * @param additionalData additional data for the event
  33058. */
  33059. constructor(
  33060. /** The mesh or sprite that triggered the action */
  33061. source: any,
  33062. /** The X mouse cursor position at the time of the event */
  33063. pointerX: number,
  33064. /** The Y mouse cursor position at the time of the event */
  33065. pointerY: number,
  33066. /** The mesh that is currently pointed at (can be null) */
  33067. meshUnderPointer: Nullable<AbstractMesh>,
  33068. /** the original (browser) event that triggered the ActionEvent */
  33069. sourceEvent?: any,
  33070. /** additional data for the event */
  33071. additionalData?: any);
  33072. /**
  33073. * Helper function to auto-create an ActionEvent from a source mesh.
  33074. * @param source The source mesh that triggered the event
  33075. * @param evt The original (browser) event
  33076. * @param additionalData additional data for the event
  33077. * @returns the new ActionEvent
  33078. */
  33079. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33080. /**
  33081. * Helper function to auto-create an ActionEvent from a source sprite
  33082. * @param source The source sprite that triggered the event
  33083. * @param scene Scene associated with the sprite
  33084. * @param evt The original (browser) event
  33085. * @param additionalData additional data for the event
  33086. * @returns the new ActionEvent
  33087. */
  33088. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33089. /**
  33090. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33091. * @param scene the scene where the event occurred
  33092. * @param evt The original (browser) event
  33093. * @returns the new ActionEvent
  33094. */
  33095. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33096. /**
  33097. * Helper function to auto-create an ActionEvent from a primitive
  33098. * @param prim defines the target primitive
  33099. * @param pointerPos defines the pointer position
  33100. * @param evt The original (browser) event
  33101. * @param additionalData additional data for the event
  33102. * @returns the new ActionEvent
  33103. */
  33104. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33105. }
  33106. }
  33107. declare module "babylonjs/Actions/abstractActionManager" {
  33108. import { IDisposable } from "babylonjs/scene";
  33109. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33110. import { IAction } from "babylonjs/Actions/action";
  33111. import { Nullable } from "babylonjs/types";
  33112. /**
  33113. * Abstract class used to decouple action Manager from scene and meshes.
  33114. * Do not instantiate.
  33115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33116. */
  33117. export abstract class AbstractActionManager implements IDisposable {
  33118. /** Gets the list of active triggers */
  33119. static Triggers: {
  33120. [key: string]: number;
  33121. };
  33122. /** Gets the cursor to use when hovering items */
  33123. hoverCursor: string;
  33124. /** Gets the list of actions */
  33125. actions: IAction[];
  33126. /**
  33127. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33128. */
  33129. isRecursive: boolean;
  33130. /**
  33131. * Releases all associated resources
  33132. */
  33133. abstract dispose(): void;
  33134. /**
  33135. * Does this action manager has pointer triggers
  33136. */
  33137. abstract get hasPointerTriggers(): boolean;
  33138. /**
  33139. * Does this action manager has pick triggers
  33140. */
  33141. abstract get hasPickTriggers(): boolean;
  33142. /**
  33143. * Process a specific trigger
  33144. * @param trigger defines the trigger to process
  33145. * @param evt defines the event details to be processed
  33146. */
  33147. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33148. /**
  33149. * Does this action manager handles actions of any of the given triggers
  33150. * @param triggers defines the triggers to be tested
  33151. * @return a boolean indicating whether one (or more) of the triggers is handled
  33152. */
  33153. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33154. /**
  33155. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33156. * speed.
  33157. * @param triggerA defines the trigger to be tested
  33158. * @param triggerB defines the trigger to be tested
  33159. * @return a boolean indicating whether one (or more) of the triggers is handled
  33160. */
  33161. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33162. /**
  33163. * Does this action manager handles actions of a given trigger
  33164. * @param trigger defines the trigger to be tested
  33165. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33166. * @return whether the trigger is handled
  33167. */
  33168. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33169. /**
  33170. * Serialize this manager to a JSON object
  33171. * @param name defines the property name to store this manager
  33172. * @returns a JSON representation of this manager
  33173. */
  33174. abstract serialize(name: string): any;
  33175. /**
  33176. * Registers an action to this action manager
  33177. * @param action defines the action to be registered
  33178. * @return the action amended (prepared) after registration
  33179. */
  33180. abstract registerAction(action: IAction): Nullable<IAction>;
  33181. /**
  33182. * Unregisters an action to this action manager
  33183. * @param action defines the action to be unregistered
  33184. * @return a boolean indicating whether the action has been unregistered
  33185. */
  33186. abstract unregisterAction(action: IAction): Boolean;
  33187. /**
  33188. * Does exist one action manager with at least one trigger
  33189. **/
  33190. static get HasTriggers(): boolean;
  33191. /**
  33192. * Does exist one action manager with at least one pick trigger
  33193. **/
  33194. static get HasPickTriggers(): boolean;
  33195. /**
  33196. * Does exist one action manager that handles actions of a given trigger
  33197. * @param trigger defines the trigger to be tested
  33198. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33199. **/
  33200. static HasSpecificTrigger(trigger: number): boolean;
  33201. }
  33202. }
  33203. declare module "babylonjs/node" {
  33204. import { Scene } from "babylonjs/scene";
  33205. import { Nullable } from "babylonjs/types";
  33206. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33207. import { Engine } from "babylonjs/Engines/engine";
  33208. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33209. import { Observable } from "babylonjs/Misc/observable";
  33210. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33211. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33212. import { Animatable } from "babylonjs/Animations/animatable";
  33213. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33214. import { Animation } from "babylonjs/Animations/animation";
  33215. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33217. /**
  33218. * Defines how a node can be built from a string name.
  33219. */
  33220. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33221. /**
  33222. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33223. */
  33224. export class Node implements IBehaviorAware<Node> {
  33225. /** @hidden */
  33226. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33227. private static _NodeConstructors;
  33228. /**
  33229. * Add a new node constructor
  33230. * @param type defines the type name of the node to construct
  33231. * @param constructorFunc defines the constructor function
  33232. */
  33233. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33234. /**
  33235. * Returns a node constructor based on type name
  33236. * @param type defines the type name
  33237. * @param name defines the new node name
  33238. * @param scene defines the hosting scene
  33239. * @param options defines optional options to transmit to constructors
  33240. * @returns the new constructor or null
  33241. */
  33242. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33243. /**
  33244. * Gets or sets the name of the node
  33245. */
  33246. name: string;
  33247. /**
  33248. * Gets or sets the id of the node
  33249. */
  33250. id: string;
  33251. /**
  33252. * Gets or sets the unique id of the node
  33253. */
  33254. uniqueId: number;
  33255. /**
  33256. * Gets or sets a string used to store user defined state for the node
  33257. */
  33258. state: string;
  33259. /**
  33260. * Gets or sets an object used to store user defined information for the node
  33261. */
  33262. metadata: any;
  33263. /**
  33264. * For internal use only. Please do not use.
  33265. */
  33266. reservedDataStore: any;
  33267. /**
  33268. * List of inspectable custom properties (used by the Inspector)
  33269. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33270. */
  33271. inspectableCustomProperties: IInspectable[];
  33272. private _doNotSerialize;
  33273. /**
  33274. * Gets or sets a boolean used to define if the node must be serialized
  33275. */
  33276. get doNotSerialize(): boolean;
  33277. set doNotSerialize(value: boolean);
  33278. /** @hidden */
  33279. _isDisposed: boolean;
  33280. /**
  33281. * Gets a list of Animations associated with the node
  33282. */
  33283. animations: import("babylonjs/Animations/animation").Animation[];
  33284. protected _ranges: {
  33285. [name: string]: Nullable<AnimationRange>;
  33286. };
  33287. /**
  33288. * Callback raised when the node is ready to be used
  33289. */
  33290. onReady: Nullable<(node: Node) => void>;
  33291. private _isEnabled;
  33292. private _isParentEnabled;
  33293. private _isReady;
  33294. /** @hidden */
  33295. _currentRenderId: number;
  33296. private _parentUpdateId;
  33297. /** @hidden */
  33298. _childUpdateId: number;
  33299. /** @hidden */
  33300. _waitingParentId: Nullable<string>;
  33301. /** @hidden */
  33302. _scene: Scene;
  33303. /** @hidden */
  33304. _cache: any;
  33305. private _parentNode;
  33306. private _children;
  33307. /** @hidden */
  33308. _worldMatrix: Matrix;
  33309. /** @hidden */
  33310. _worldMatrixDeterminant: number;
  33311. /** @hidden */
  33312. _worldMatrixDeterminantIsDirty: boolean;
  33313. /** @hidden */
  33314. private _sceneRootNodesIndex;
  33315. /**
  33316. * Gets a boolean indicating if the node has been disposed
  33317. * @returns true if the node was disposed
  33318. */
  33319. isDisposed(): boolean;
  33320. /**
  33321. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33322. * @see https://doc.babylonjs.com/how_to/parenting
  33323. */
  33324. set parent(parent: Nullable<Node>);
  33325. get parent(): Nullable<Node>;
  33326. /** @hidden */
  33327. _addToSceneRootNodes(): void;
  33328. /** @hidden */
  33329. _removeFromSceneRootNodes(): void;
  33330. private _animationPropertiesOverride;
  33331. /**
  33332. * Gets or sets the animation properties override
  33333. */
  33334. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33335. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33336. /**
  33337. * Gets a string idenfifying the name of the class
  33338. * @returns "Node" string
  33339. */
  33340. getClassName(): string;
  33341. /** @hidden */
  33342. readonly _isNode: boolean;
  33343. /**
  33344. * An event triggered when the mesh is disposed
  33345. */
  33346. onDisposeObservable: Observable<Node>;
  33347. private _onDisposeObserver;
  33348. /**
  33349. * Sets a callback that will be raised when the node will be disposed
  33350. */
  33351. set onDispose(callback: () => void);
  33352. /**
  33353. * Creates a new Node
  33354. * @param name the name and id to be given to this node
  33355. * @param scene the scene this node will be added to
  33356. */
  33357. constructor(name: string, scene?: Nullable<Scene>);
  33358. /**
  33359. * Gets the scene of the node
  33360. * @returns a scene
  33361. */
  33362. getScene(): Scene;
  33363. /**
  33364. * Gets the engine of the node
  33365. * @returns a Engine
  33366. */
  33367. getEngine(): Engine;
  33368. private _behaviors;
  33369. /**
  33370. * Attach a behavior to the node
  33371. * @see https://doc.babylonjs.com/features/behaviour
  33372. * @param behavior defines the behavior to attach
  33373. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33374. * @returns the current Node
  33375. */
  33376. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33377. /**
  33378. * Remove an attached behavior
  33379. * @see https://doc.babylonjs.com/features/behaviour
  33380. * @param behavior defines the behavior to attach
  33381. * @returns the current Node
  33382. */
  33383. removeBehavior(behavior: Behavior<Node>): Node;
  33384. /**
  33385. * Gets the list of attached behaviors
  33386. * @see https://doc.babylonjs.com/features/behaviour
  33387. */
  33388. get behaviors(): Behavior<Node>[];
  33389. /**
  33390. * Gets an attached behavior by name
  33391. * @param name defines the name of the behavior to look for
  33392. * @see https://doc.babylonjs.com/features/behaviour
  33393. * @returns null if behavior was not found else the requested behavior
  33394. */
  33395. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33396. /**
  33397. * Returns the latest update of the World matrix
  33398. * @returns a Matrix
  33399. */
  33400. getWorldMatrix(): Matrix;
  33401. /** @hidden */
  33402. _getWorldMatrixDeterminant(): number;
  33403. /**
  33404. * Returns directly the latest state of the mesh World matrix.
  33405. * A Matrix is returned.
  33406. */
  33407. get worldMatrixFromCache(): Matrix;
  33408. /** @hidden */
  33409. _initCache(): void;
  33410. /** @hidden */
  33411. updateCache(force?: boolean): void;
  33412. /** @hidden */
  33413. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33414. /** @hidden */
  33415. _updateCache(ignoreParentClass?: boolean): void;
  33416. /** @hidden */
  33417. _isSynchronized(): boolean;
  33418. /** @hidden */
  33419. _markSyncedWithParent(): void;
  33420. /** @hidden */
  33421. isSynchronizedWithParent(): boolean;
  33422. /** @hidden */
  33423. isSynchronized(): boolean;
  33424. /**
  33425. * Is this node ready to be used/rendered
  33426. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33427. * @return true if the node is ready
  33428. */
  33429. isReady(completeCheck?: boolean): boolean;
  33430. /**
  33431. * Is this node enabled?
  33432. * 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
  33433. * @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
  33434. * @return whether this node (and its parent) is enabled
  33435. */
  33436. isEnabled(checkAncestors?: boolean): boolean;
  33437. /** @hidden */
  33438. protected _syncParentEnabledState(): void;
  33439. /**
  33440. * Set the enabled state of this node
  33441. * @param value defines the new enabled state
  33442. */
  33443. setEnabled(value: boolean): void;
  33444. /**
  33445. * Is this node a descendant of the given node?
  33446. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33447. * @param ancestor defines the parent node to inspect
  33448. * @returns a boolean indicating if this node is a descendant of the given node
  33449. */
  33450. isDescendantOf(ancestor: Node): boolean;
  33451. /** @hidden */
  33452. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33453. /**
  33454. * Will return all nodes that have this node as ascendant
  33455. * @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
  33456. * @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
  33457. * @return all children nodes of all types
  33458. */
  33459. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33460. /**
  33461. * Get all child-meshes of this node
  33462. * @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)
  33463. * @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
  33464. * @returns an array of AbstractMesh
  33465. */
  33466. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33467. /**
  33468. * Get all direct children of this node
  33469. * @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
  33470. * @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)
  33471. * @returns an array of Node
  33472. */
  33473. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33474. /** @hidden */
  33475. _setReady(state: boolean): void;
  33476. /**
  33477. * Get an animation by name
  33478. * @param name defines the name of the animation to look for
  33479. * @returns null if not found else the requested animation
  33480. */
  33481. getAnimationByName(name: string): Nullable<Animation>;
  33482. /**
  33483. * Creates an animation range for this node
  33484. * @param name defines the name of the range
  33485. * @param from defines the starting key
  33486. * @param to defines the end key
  33487. */
  33488. createAnimationRange(name: string, from: number, to: number): void;
  33489. /**
  33490. * Delete a specific animation range
  33491. * @param name defines the name of the range to delete
  33492. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33493. */
  33494. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33495. /**
  33496. * Get an animation range by name
  33497. * @param name defines the name of the animation range to look for
  33498. * @returns null if not found else the requested animation range
  33499. */
  33500. getAnimationRange(name: string): Nullable<AnimationRange>;
  33501. /**
  33502. * Gets the list of all animation ranges defined on this node
  33503. * @returns an array
  33504. */
  33505. getAnimationRanges(): Nullable<AnimationRange>[];
  33506. /**
  33507. * Will start the animation sequence
  33508. * @param name defines the range frames for animation sequence
  33509. * @param loop defines if the animation should loop (false by default)
  33510. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33511. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33512. * @returns the object created for this animation. If range does not exist, it will return null
  33513. */
  33514. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33515. /**
  33516. * Serialize animation ranges into a JSON compatible object
  33517. * @returns serialization object
  33518. */
  33519. serializeAnimationRanges(): any;
  33520. /**
  33521. * Computes the world matrix of the node
  33522. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33523. * @returns the world matrix
  33524. */
  33525. computeWorldMatrix(force?: boolean): Matrix;
  33526. /**
  33527. * Releases resources associated with this node.
  33528. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33529. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33530. */
  33531. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33532. /**
  33533. * Parse animation range data from a serialization object and store them into a given node
  33534. * @param node defines where to store the animation ranges
  33535. * @param parsedNode defines the serialization object to read data from
  33536. * @param scene defines the hosting scene
  33537. */
  33538. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33539. /**
  33540. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33541. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33542. * @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
  33543. * @returns the new bounding vectors
  33544. */
  33545. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33546. min: Vector3;
  33547. max: Vector3;
  33548. };
  33549. }
  33550. }
  33551. declare module "babylonjs/Animations/animation" {
  33552. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33553. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33554. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33555. import { Nullable } from "babylonjs/types";
  33556. import { Scene } from "babylonjs/scene";
  33557. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33558. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33559. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33560. import { Node } from "babylonjs/node";
  33561. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33562. import { Size } from "babylonjs/Maths/math.size";
  33563. import { Animatable } from "babylonjs/Animations/animatable";
  33564. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33565. /**
  33566. * @hidden
  33567. */
  33568. export class _IAnimationState {
  33569. key: number;
  33570. repeatCount: number;
  33571. workValue?: any;
  33572. loopMode?: number;
  33573. offsetValue?: any;
  33574. highLimitValue?: any;
  33575. }
  33576. /**
  33577. * Class used to store any kind of animation
  33578. */
  33579. export class Animation {
  33580. /**Name of the animation */
  33581. name: string;
  33582. /**Property to animate */
  33583. targetProperty: string;
  33584. /**The frames per second of the animation */
  33585. framePerSecond: number;
  33586. /**The data type of the animation */
  33587. dataType: number;
  33588. /**The loop mode of the animation */
  33589. loopMode?: number | undefined;
  33590. /**Specifies if blending should be enabled */
  33591. enableBlending?: boolean | undefined;
  33592. /**
  33593. * Use matrix interpolation instead of using direct key value when animating matrices
  33594. */
  33595. static AllowMatricesInterpolation: boolean;
  33596. /**
  33597. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33598. */
  33599. static AllowMatrixDecomposeForInterpolation: boolean;
  33600. /** Define the Url to load snippets */
  33601. static SnippetUrl: string;
  33602. /** Snippet ID if the animation was created from the snippet server */
  33603. snippetId: string;
  33604. /**
  33605. * Stores the key frames of the animation
  33606. */
  33607. private _keys;
  33608. /**
  33609. * Stores the easing function of the animation
  33610. */
  33611. private _easingFunction;
  33612. /**
  33613. * @hidden Internal use only
  33614. */
  33615. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33616. /**
  33617. * The set of event that will be linked to this animation
  33618. */
  33619. private _events;
  33620. /**
  33621. * Stores an array of target property paths
  33622. */
  33623. targetPropertyPath: string[];
  33624. /**
  33625. * Stores the blending speed of the animation
  33626. */
  33627. blendingSpeed: number;
  33628. /**
  33629. * Stores the animation ranges for the animation
  33630. */
  33631. private _ranges;
  33632. /**
  33633. * @hidden Internal use
  33634. */
  33635. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33636. /**
  33637. * Sets up an animation
  33638. * @param property The property to animate
  33639. * @param animationType The animation type to apply
  33640. * @param framePerSecond The frames per second of the animation
  33641. * @param easingFunction The easing function used in the animation
  33642. * @returns The created animation
  33643. */
  33644. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33645. /**
  33646. * Create and start an animation on a node
  33647. * @param name defines the name of the global animation that will be run on all nodes
  33648. * @param node defines the root node where the animation will take place
  33649. * @param targetProperty defines property to animate
  33650. * @param framePerSecond defines the number of frame per second yo use
  33651. * @param totalFrame defines the number of frames in total
  33652. * @param from defines the initial value
  33653. * @param to defines the final value
  33654. * @param loopMode defines which loop mode you want to use (off by default)
  33655. * @param easingFunction defines the easing function to use (linear by default)
  33656. * @param onAnimationEnd defines the callback to call when animation end
  33657. * @returns the animatable created for this animation
  33658. */
  33659. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33660. /**
  33661. * Create and start an animation on a node and its descendants
  33662. * @param name defines the name of the global animation that will be run on all nodes
  33663. * @param node defines the root node where the animation will take place
  33664. * @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
  33665. * @param targetProperty defines property to animate
  33666. * @param framePerSecond defines the number of frame per second to use
  33667. * @param totalFrame defines the number of frames in total
  33668. * @param from defines the initial value
  33669. * @param to defines the final value
  33670. * @param loopMode defines which loop mode you want to use (off by default)
  33671. * @param easingFunction defines the easing function to use (linear by default)
  33672. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33673. * @returns the list of animatables created for all nodes
  33674. * @example https://www.babylonjs-playground.com/#MH0VLI
  33675. */
  33676. 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[]>;
  33677. /**
  33678. * Creates a new animation, merges it with the existing animations and starts it
  33679. * @param name Name of the animation
  33680. * @param node Node which contains the scene that begins the animations
  33681. * @param targetProperty Specifies which property to animate
  33682. * @param framePerSecond The frames per second of the animation
  33683. * @param totalFrame The total number of frames
  33684. * @param from The frame at the beginning of the animation
  33685. * @param to The frame at the end of the animation
  33686. * @param loopMode Specifies the loop mode of the animation
  33687. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33688. * @param onAnimationEnd Callback to run once the animation is complete
  33689. * @returns Nullable animation
  33690. */
  33691. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33692. /**
  33693. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33694. * @param sourceAnimation defines the Animation containing keyframes to convert
  33695. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33696. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33697. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33698. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33699. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33700. */
  33701. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33702. /**
  33703. * Transition property of an host to the target Value
  33704. * @param property The property to transition
  33705. * @param targetValue The target Value of the property
  33706. * @param host The object where the property to animate belongs
  33707. * @param scene Scene used to run the animation
  33708. * @param frameRate Framerate (in frame/s) to use
  33709. * @param transition The transition type we want to use
  33710. * @param duration The duration of the animation, in milliseconds
  33711. * @param onAnimationEnd Callback trigger at the end of the animation
  33712. * @returns Nullable animation
  33713. */
  33714. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33715. /**
  33716. * Return the array of runtime animations currently using this animation
  33717. */
  33718. get runtimeAnimations(): RuntimeAnimation[];
  33719. /**
  33720. * Specifies if any of the runtime animations are currently running
  33721. */
  33722. get hasRunningRuntimeAnimations(): boolean;
  33723. /**
  33724. * Initializes the animation
  33725. * @param name Name of the animation
  33726. * @param targetProperty Property to animate
  33727. * @param framePerSecond The frames per second of the animation
  33728. * @param dataType The data type of the animation
  33729. * @param loopMode The loop mode of the animation
  33730. * @param enableBlending Specifies if blending should be enabled
  33731. */
  33732. constructor(
  33733. /**Name of the animation */
  33734. name: string,
  33735. /**Property to animate */
  33736. targetProperty: string,
  33737. /**The frames per second of the animation */
  33738. framePerSecond: number,
  33739. /**The data type of the animation */
  33740. dataType: number,
  33741. /**The loop mode of the animation */
  33742. loopMode?: number | undefined,
  33743. /**Specifies if blending should be enabled */
  33744. enableBlending?: boolean | undefined);
  33745. /**
  33746. * Converts the animation to a string
  33747. * @param fullDetails support for multiple levels of logging within scene loading
  33748. * @returns String form of the animation
  33749. */
  33750. toString(fullDetails?: boolean): string;
  33751. /**
  33752. * Add an event to this animation
  33753. * @param event Event to add
  33754. */
  33755. addEvent(event: AnimationEvent): void;
  33756. /**
  33757. * Remove all events found at the given frame
  33758. * @param frame The frame to remove events from
  33759. */
  33760. removeEvents(frame: number): void;
  33761. /**
  33762. * Retrieves all the events from the animation
  33763. * @returns Events from the animation
  33764. */
  33765. getEvents(): AnimationEvent[];
  33766. /**
  33767. * Creates an animation range
  33768. * @param name Name of the animation range
  33769. * @param from Starting frame of the animation range
  33770. * @param to Ending frame of the animation
  33771. */
  33772. createRange(name: string, from: number, to: number): void;
  33773. /**
  33774. * Deletes an animation range by name
  33775. * @param name Name of the animation range to delete
  33776. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33777. */
  33778. deleteRange(name: string, deleteFrames?: boolean): void;
  33779. /**
  33780. * Gets the animation range by name, or null if not defined
  33781. * @param name Name of the animation range
  33782. * @returns Nullable animation range
  33783. */
  33784. getRange(name: string): Nullable<AnimationRange>;
  33785. /**
  33786. * Gets the key frames from the animation
  33787. * @returns The key frames of the animation
  33788. */
  33789. getKeys(): Array<IAnimationKey>;
  33790. /**
  33791. * Gets the highest frame rate of the animation
  33792. * @returns Highest frame rate of the animation
  33793. */
  33794. getHighestFrame(): number;
  33795. /**
  33796. * Gets the easing function of the animation
  33797. * @returns Easing function of the animation
  33798. */
  33799. getEasingFunction(): IEasingFunction;
  33800. /**
  33801. * Sets the easing function of the animation
  33802. * @param easingFunction A custom mathematical formula for animation
  33803. */
  33804. setEasingFunction(easingFunction: EasingFunction): void;
  33805. /**
  33806. * Interpolates a scalar linearly
  33807. * @param startValue Start value of the animation curve
  33808. * @param endValue End value of the animation curve
  33809. * @param gradient Scalar amount to interpolate
  33810. * @returns Interpolated scalar value
  33811. */
  33812. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33813. /**
  33814. * Interpolates a scalar cubically
  33815. * @param startValue Start value of the animation curve
  33816. * @param outTangent End tangent of the animation
  33817. * @param endValue End value of the animation curve
  33818. * @param inTangent Start tangent of the animation curve
  33819. * @param gradient Scalar amount to interpolate
  33820. * @returns Interpolated scalar value
  33821. */
  33822. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33823. /**
  33824. * Interpolates a quaternion using a spherical linear interpolation
  33825. * @param startValue Start value of the animation curve
  33826. * @param endValue End value of the animation curve
  33827. * @param gradient Scalar amount to interpolate
  33828. * @returns Interpolated quaternion value
  33829. */
  33830. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33831. /**
  33832. * Interpolates a quaternion cubically
  33833. * @param startValue Start value of the animation curve
  33834. * @param outTangent End tangent of the animation curve
  33835. * @param endValue End value of the animation curve
  33836. * @param inTangent Start tangent of the animation curve
  33837. * @param gradient Scalar amount to interpolate
  33838. * @returns Interpolated quaternion value
  33839. */
  33840. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33841. /**
  33842. * Interpolates a Vector3 linearl
  33843. * @param startValue Start value of the animation curve
  33844. * @param endValue End value of the animation curve
  33845. * @param gradient Scalar amount to interpolate
  33846. * @returns Interpolated scalar value
  33847. */
  33848. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33849. /**
  33850. * Interpolates a Vector3 cubically
  33851. * @param startValue Start value of the animation curve
  33852. * @param outTangent End tangent of the animation
  33853. * @param endValue End value of the animation curve
  33854. * @param inTangent Start tangent of the animation curve
  33855. * @param gradient Scalar amount to interpolate
  33856. * @returns InterpolatedVector3 value
  33857. */
  33858. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33859. /**
  33860. * Interpolates a Vector2 linearly
  33861. * @param startValue Start value of the animation curve
  33862. * @param endValue End value of the animation curve
  33863. * @param gradient Scalar amount to interpolate
  33864. * @returns Interpolated Vector2 value
  33865. */
  33866. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33867. /**
  33868. * Interpolates a Vector2 cubically
  33869. * @param startValue Start value of the animation curve
  33870. * @param outTangent End tangent of the animation
  33871. * @param endValue End value of the animation curve
  33872. * @param inTangent Start tangent of the animation curve
  33873. * @param gradient Scalar amount to interpolate
  33874. * @returns Interpolated Vector2 value
  33875. */
  33876. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33877. /**
  33878. * Interpolates a size linearly
  33879. * @param startValue Start value of the animation curve
  33880. * @param endValue End value of the animation curve
  33881. * @param gradient Scalar amount to interpolate
  33882. * @returns Interpolated Size value
  33883. */
  33884. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33885. /**
  33886. * Interpolates a Color3 linearly
  33887. * @param startValue Start value of the animation curve
  33888. * @param endValue End value of the animation curve
  33889. * @param gradient Scalar amount to interpolate
  33890. * @returns Interpolated Color3 value
  33891. */
  33892. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33893. /**
  33894. * Interpolates a Color4 linearly
  33895. * @param startValue Start value of the animation curve
  33896. * @param endValue End value of the animation curve
  33897. * @param gradient Scalar amount to interpolate
  33898. * @returns Interpolated Color3 value
  33899. */
  33900. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33901. /**
  33902. * @hidden Internal use only
  33903. */
  33904. _getKeyValue(value: any): any;
  33905. /**
  33906. * @hidden Internal use only
  33907. */
  33908. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33909. /**
  33910. * Defines the function to use to interpolate matrices
  33911. * @param startValue defines the start matrix
  33912. * @param endValue defines the end matrix
  33913. * @param gradient defines the gradient between both matrices
  33914. * @param result defines an optional target matrix where to store the interpolation
  33915. * @returns the interpolated matrix
  33916. */
  33917. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33918. /**
  33919. * Makes a copy of the animation
  33920. * @returns Cloned animation
  33921. */
  33922. clone(): Animation;
  33923. /**
  33924. * Sets the key frames of the animation
  33925. * @param values The animation key frames to set
  33926. */
  33927. setKeys(values: Array<IAnimationKey>): void;
  33928. /**
  33929. * Serializes the animation to an object
  33930. * @returns Serialized object
  33931. */
  33932. serialize(): any;
  33933. /**
  33934. * Float animation type
  33935. */
  33936. static readonly ANIMATIONTYPE_FLOAT: number;
  33937. /**
  33938. * Vector3 animation type
  33939. */
  33940. static readonly ANIMATIONTYPE_VECTOR3: number;
  33941. /**
  33942. * Quaternion animation type
  33943. */
  33944. static readonly ANIMATIONTYPE_QUATERNION: number;
  33945. /**
  33946. * Matrix animation type
  33947. */
  33948. static readonly ANIMATIONTYPE_MATRIX: number;
  33949. /**
  33950. * Color3 animation type
  33951. */
  33952. static readonly ANIMATIONTYPE_COLOR3: number;
  33953. /**
  33954. * Color3 animation type
  33955. */
  33956. static readonly ANIMATIONTYPE_COLOR4: number;
  33957. /**
  33958. * Vector2 animation type
  33959. */
  33960. static readonly ANIMATIONTYPE_VECTOR2: number;
  33961. /**
  33962. * Size animation type
  33963. */
  33964. static readonly ANIMATIONTYPE_SIZE: number;
  33965. /**
  33966. * Relative Loop Mode
  33967. */
  33968. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33969. /**
  33970. * Cycle Loop Mode
  33971. */
  33972. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33973. /**
  33974. * Constant Loop Mode
  33975. */
  33976. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33977. /** @hidden */
  33978. static _UniversalLerp(left: any, right: any, amount: number): any;
  33979. /**
  33980. * Parses an animation object and creates an animation
  33981. * @param parsedAnimation Parsed animation object
  33982. * @returns Animation object
  33983. */
  33984. static Parse(parsedAnimation: any): Animation;
  33985. /**
  33986. * Appends the serialized animations from the source animations
  33987. * @param source Source containing the animations
  33988. * @param destination Target to store the animations
  33989. */
  33990. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33991. /**
  33992. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33993. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33994. * @param url defines the url to load from
  33995. * @returns a promise that will resolve to the new animation or an array of animations
  33996. */
  33997. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33998. /**
  33999. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34000. * @param snippetId defines the snippet to load
  34001. * @returns a promise that will resolve to the new animation or a new array of animations
  34002. */
  34003. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34004. }
  34005. }
  34006. declare module "babylonjs/Animations/animatable.interface" {
  34007. import { Nullable } from "babylonjs/types";
  34008. import { Animation } from "babylonjs/Animations/animation";
  34009. /**
  34010. * Interface containing an array of animations
  34011. */
  34012. export interface IAnimatable {
  34013. /**
  34014. * Array of animations
  34015. */
  34016. animations: Nullable<Array<Animation>>;
  34017. }
  34018. }
  34019. declare module "babylonjs/Misc/decorators" {
  34020. import { Nullable } from "babylonjs/types";
  34021. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34022. import { Scene } from "babylonjs/scene";
  34023. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34024. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34025. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34027. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34028. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34029. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34030. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34031. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34032. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34033. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34034. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34035. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34036. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34037. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34038. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34039. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34040. /**
  34041. * Decorator used to define property that can be serialized as reference to a camera
  34042. * @param sourceName defines the name of the property to decorate
  34043. */
  34044. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34045. /**
  34046. * Class used to help serialization objects
  34047. */
  34048. export class SerializationHelper {
  34049. /** @hidden */
  34050. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34051. /** @hidden */
  34052. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34053. /** @hidden */
  34054. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34055. /** @hidden */
  34056. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34057. /**
  34058. * Appends the serialized animations from the source animations
  34059. * @param source Source containing the animations
  34060. * @param destination Target to store the animations
  34061. */
  34062. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34063. /**
  34064. * Static function used to serialized a specific entity
  34065. * @param entity defines the entity to serialize
  34066. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34067. * @returns a JSON compatible object representing the serialization of the entity
  34068. */
  34069. static Serialize<T>(entity: T, serializationObject?: any): any;
  34070. /**
  34071. * Creates a new entity from a serialization data object
  34072. * @param creationFunction defines a function used to instanciated the new entity
  34073. * @param source defines the source serialization data
  34074. * @param scene defines the hosting scene
  34075. * @param rootUrl defines the root url for resources
  34076. * @returns a new entity
  34077. */
  34078. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34079. /**
  34080. * Clones an object
  34081. * @param creationFunction defines the function used to instanciate the new object
  34082. * @param source defines the source object
  34083. * @returns the cloned object
  34084. */
  34085. static Clone<T>(creationFunction: () => T, source: T): T;
  34086. /**
  34087. * Instanciates a new object based on a source one (some data will be shared between both object)
  34088. * @param creationFunction defines the function used to instanciate the new object
  34089. * @param source defines the source object
  34090. * @returns the new object
  34091. */
  34092. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34093. }
  34094. }
  34095. declare module "babylonjs/Materials/Textures/baseTexture" {
  34096. import { Observable } from "babylonjs/Misc/observable";
  34097. import { Nullable } from "babylonjs/types";
  34098. import { Scene } from "babylonjs/scene";
  34099. import { Matrix } from "babylonjs/Maths/math.vector";
  34100. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34101. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34102. import { ISize } from "babylonjs/Maths/math.size";
  34103. import "babylonjs/Misc/fileTools";
  34104. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34105. /**
  34106. * Base class of all the textures in babylon.
  34107. * It groups all the common properties the materials, post process, lights... might need
  34108. * in order to make a correct use of the texture.
  34109. */
  34110. export class BaseTexture implements IAnimatable {
  34111. /**
  34112. * Default anisotropic filtering level for the application.
  34113. * It is set to 4 as a good tradeoff between perf and quality.
  34114. */
  34115. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34116. /**
  34117. * Gets or sets the unique id of the texture
  34118. */
  34119. uniqueId: number;
  34120. /**
  34121. * Define the name of the texture.
  34122. */
  34123. name: string;
  34124. /**
  34125. * Gets or sets an object used to store user defined information.
  34126. */
  34127. metadata: any;
  34128. /**
  34129. * For internal use only. Please do not use.
  34130. */
  34131. reservedDataStore: any;
  34132. private _hasAlpha;
  34133. /**
  34134. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34135. */
  34136. set hasAlpha(value: boolean);
  34137. get hasAlpha(): boolean;
  34138. /**
  34139. * Defines if the alpha value should be determined via the rgb values.
  34140. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34141. */
  34142. getAlphaFromRGB: boolean;
  34143. /**
  34144. * Intensity or strength of the texture.
  34145. * It is commonly used by materials to fine tune the intensity of the texture
  34146. */
  34147. level: number;
  34148. /**
  34149. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34150. * This is part of the texture as textures usually maps to one uv set.
  34151. */
  34152. coordinatesIndex: number;
  34153. private _coordinatesMode;
  34154. /**
  34155. * How a texture is mapped.
  34156. *
  34157. * | Value | Type | Description |
  34158. * | ----- | ----------------------------------- | ----------- |
  34159. * | 0 | EXPLICIT_MODE | |
  34160. * | 1 | SPHERICAL_MODE | |
  34161. * | 2 | PLANAR_MODE | |
  34162. * | 3 | CUBIC_MODE | |
  34163. * | 4 | PROJECTION_MODE | |
  34164. * | 5 | SKYBOX_MODE | |
  34165. * | 6 | INVCUBIC_MODE | |
  34166. * | 7 | EQUIRECTANGULAR_MODE | |
  34167. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34168. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34169. */
  34170. set coordinatesMode(value: number);
  34171. get coordinatesMode(): number;
  34172. /**
  34173. * | Value | Type | Description |
  34174. * | ----- | ------------------ | ----------- |
  34175. * | 0 | CLAMP_ADDRESSMODE | |
  34176. * | 1 | WRAP_ADDRESSMODE | |
  34177. * | 2 | MIRROR_ADDRESSMODE | |
  34178. */
  34179. wrapU: number;
  34180. /**
  34181. * | Value | Type | Description |
  34182. * | ----- | ------------------ | ----------- |
  34183. * | 0 | CLAMP_ADDRESSMODE | |
  34184. * | 1 | WRAP_ADDRESSMODE | |
  34185. * | 2 | MIRROR_ADDRESSMODE | |
  34186. */
  34187. wrapV: number;
  34188. /**
  34189. * | Value | Type | Description |
  34190. * | ----- | ------------------ | ----------- |
  34191. * | 0 | CLAMP_ADDRESSMODE | |
  34192. * | 1 | WRAP_ADDRESSMODE | |
  34193. * | 2 | MIRROR_ADDRESSMODE | |
  34194. */
  34195. wrapR: number;
  34196. /**
  34197. * With compliant hardware and browser (supporting anisotropic filtering)
  34198. * this defines the level of anisotropic filtering in the texture.
  34199. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34200. */
  34201. anisotropicFilteringLevel: number;
  34202. /**
  34203. * Define if the texture is a cube texture or if false a 2d texture.
  34204. */
  34205. get isCube(): boolean;
  34206. set isCube(value: boolean);
  34207. /**
  34208. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34209. */
  34210. get is3D(): boolean;
  34211. set is3D(value: boolean);
  34212. /**
  34213. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34214. */
  34215. get is2DArray(): boolean;
  34216. set is2DArray(value: boolean);
  34217. /**
  34218. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34219. * HDR texture are usually stored in linear space.
  34220. * This only impacts the PBR and Background materials
  34221. */
  34222. gammaSpace: boolean;
  34223. /**
  34224. * Gets or sets whether or not the texture contains RGBD data.
  34225. */
  34226. get isRGBD(): boolean;
  34227. set isRGBD(value: boolean);
  34228. /**
  34229. * Is Z inverted in the texture (useful in a cube texture).
  34230. */
  34231. invertZ: boolean;
  34232. /**
  34233. * Are mip maps generated for this texture or not.
  34234. */
  34235. get noMipmap(): boolean;
  34236. /**
  34237. * @hidden
  34238. */
  34239. lodLevelInAlpha: boolean;
  34240. /**
  34241. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34242. */
  34243. get lodGenerationOffset(): number;
  34244. set lodGenerationOffset(value: number);
  34245. /**
  34246. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34247. */
  34248. get lodGenerationScale(): number;
  34249. set lodGenerationScale(value: number);
  34250. /**
  34251. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34252. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34253. * average roughness values.
  34254. */
  34255. get linearSpecularLOD(): boolean;
  34256. set linearSpecularLOD(value: boolean);
  34257. /**
  34258. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34259. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34260. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34261. */
  34262. get irradianceTexture(): Nullable<BaseTexture>;
  34263. set irradianceTexture(value: Nullable<BaseTexture>);
  34264. /**
  34265. * Define if the texture is a render target.
  34266. */
  34267. isRenderTarget: boolean;
  34268. /**
  34269. * Define the unique id of the texture in the scene.
  34270. */
  34271. get uid(): string;
  34272. /** @hidden */
  34273. _prefiltered: boolean;
  34274. /**
  34275. * Return a string representation of the texture.
  34276. * @returns the texture as a string
  34277. */
  34278. toString(): string;
  34279. /**
  34280. * Get the class name of the texture.
  34281. * @returns "BaseTexture"
  34282. */
  34283. getClassName(): string;
  34284. /**
  34285. * Define the list of animation attached to the texture.
  34286. */
  34287. animations: import("babylonjs/Animations/animation").Animation[];
  34288. /**
  34289. * An event triggered when the texture is disposed.
  34290. */
  34291. onDisposeObservable: Observable<BaseTexture>;
  34292. private _onDisposeObserver;
  34293. /**
  34294. * Callback triggered when the texture has been disposed.
  34295. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34296. */
  34297. set onDispose(callback: () => void);
  34298. /**
  34299. * Define the current state of the loading sequence when in delayed load mode.
  34300. */
  34301. delayLoadState: number;
  34302. private _scene;
  34303. private _engine;
  34304. /** @hidden */
  34305. _texture: Nullable<InternalTexture>;
  34306. private _uid;
  34307. /**
  34308. * Define if the texture is preventinga material to render or not.
  34309. * If not and the texture is not ready, the engine will use a default black texture instead.
  34310. */
  34311. get isBlocking(): boolean;
  34312. /**
  34313. * Instantiates a new BaseTexture.
  34314. * Base class of all the textures in babylon.
  34315. * It groups all the common properties the materials, post process, lights... might need
  34316. * in order to make a correct use of the texture.
  34317. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34318. */
  34319. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34320. /**
  34321. * Get the scene the texture belongs to.
  34322. * @returns the scene or null if undefined
  34323. */
  34324. getScene(): Nullable<Scene>;
  34325. /** @hidden */
  34326. protected _getEngine(): Nullable<ThinEngine>;
  34327. /**
  34328. * Get the texture transform matrix used to offset tile the texture for istance.
  34329. * @returns the transformation matrix
  34330. */
  34331. getTextureMatrix(): Matrix;
  34332. /**
  34333. * Get the texture reflection matrix used to rotate/transform the reflection.
  34334. * @returns the reflection matrix
  34335. */
  34336. getReflectionTextureMatrix(): Matrix;
  34337. /**
  34338. * Get the underlying lower level texture from Babylon.
  34339. * @returns the insternal texture
  34340. */
  34341. getInternalTexture(): Nullable<InternalTexture>;
  34342. /**
  34343. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34344. * @returns true if ready or not blocking
  34345. */
  34346. isReadyOrNotBlocking(): boolean;
  34347. /**
  34348. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34349. * @returns true if fully ready
  34350. */
  34351. isReady(): boolean;
  34352. private _cachedSize;
  34353. /**
  34354. * Get the size of the texture.
  34355. * @returns the texture size.
  34356. */
  34357. getSize(): ISize;
  34358. /**
  34359. * Get the base size of the texture.
  34360. * It can be different from the size if the texture has been resized for POT for instance
  34361. * @returns the base size
  34362. */
  34363. getBaseSize(): ISize;
  34364. /**
  34365. * Update the sampling mode of the texture.
  34366. * Default is Trilinear mode.
  34367. *
  34368. * | Value | Type | Description |
  34369. * | ----- | ------------------ | ----------- |
  34370. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34371. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34372. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34373. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34374. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34375. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34376. * | 7 | NEAREST_LINEAR | |
  34377. * | 8 | NEAREST_NEAREST | |
  34378. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34379. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34380. * | 11 | LINEAR_LINEAR | |
  34381. * | 12 | LINEAR_NEAREST | |
  34382. *
  34383. * > _mag_: magnification filter (close to the viewer)
  34384. * > _min_: minification filter (far from the viewer)
  34385. * > _mip_: filter used between mip map levels
  34386. *@param samplingMode Define the new sampling mode of the texture
  34387. */
  34388. updateSamplingMode(samplingMode: number): void;
  34389. /**
  34390. * Scales the texture if is `canRescale()`
  34391. * @param ratio the resize factor we want to use to rescale
  34392. */
  34393. scale(ratio: number): void;
  34394. /**
  34395. * Get if the texture can rescale.
  34396. */
  34397. get canRescale(): boolean;
  34398. /** @hidden */
  34399. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34400. /** @hidden */
  34401. _rebuild(): void;
  34402. /**
  34403. * Triggers the load sequence in delayed load mode.
  34404. */
  34405. delayLoad(): void;
  34406. /**
  34407. * Clones the texture.
  34408. * @returns the cloned texture
  34409. */
  34410. clone(): Nullable<BaseTexture>;
  34411. /**
  34412. * Get the texture underlying type (INT, FLOAT...)
  34413. */
  34414. get textureType(): number;
  34415. /**
  34416. * Get the texture underlying format (RGB, RGBA...)
  34417. */
  34418. get textureFormat(): number;
  34419. /**
  34420. * Indicates that textures need to be re-calculated for all materials
  34421. */
  34422. protected _markAllSubMeshesAsTexturesDirty(): void;
  34423. /**
  34424. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34425. * This will returns an RGBA array buffer containing either in values (0-255) or
  34426. * float values (0-1) depending of the underlying buffer type.
  34427. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34428. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34429. * @param buffer defines a user defined buffer to fill with data (can be null)
  34430. * @returns The Array buffer containing the pixels data.
  34431. */
  34432. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34433. /**
  34434. * Release and destroy the underlying lower level texture aka internalTexture.
  34435. */
  34436. releaseInternalTexture(): void;
  34437. /** @hidden */
  34438. get _lodTextureHigh(): Nullable<BaseTexture>;
  34439. /** @hidden */
  34440. get _lodTextureMid(): Nullable<BaseTexture>;
  34441. /** @hidden */
  34442. get _lodTextureLow(): Nullable<BaseTexture>;
  34443. /**
  34444. * Dispose the texture and release its associated resources.
  34445. */
  34446. dispose(): void;
  34447. /**
  34448. * Serialize the texture into a JSON representation that can be parsed later on.
  34449. * @returns the JSON representation of the texture
  34450. */
  34451. serialize(): any;
  34452. /**
  34453. * Helper function to be called back once a list of texture contains only ready textures.
  34454. * @param textures Define the list of textures to wait for
  34455. * @param callback Define the callback triggered once the entire list will be ready
  34456. */
  34457. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34458. private static _isScene;
  34459. }
  34460. }
  34461. declare module "babylonjs/Materials/effect" {
  34462. import { Observable } from "babylonjs/Misc/observable";
  34463. import { Nullable } from "babylonjs/types";
  34464. import { IDisposable } from "babylonjs/scene";
  34465. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34466. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34467. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34468. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34469. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34470. import { Engine } from "babylonjs/Engines/engine";
  34471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34473. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34474. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34475. /**
  34476. * Options to be used when creating an effect.
  34477. */
  34478. export interface IEffectCreationOptions {
  34479. /**
  34480. * Atrributes that will be used in the shader.
  34481. */
  34482. attributes: string[];
  34483. /**
  34484. * Uniform varible names that will be set in the shader.
  34485. */
  34486. uniformsNames: string[];
  34487. /**
  34488. * Uniform buffer variable names that will be set in the shader.
  34489. */
  34490. uniformBuffersNames: string[];
  34491. /**
  34492. * Sampler texture variable names that will be set in the shader.
  34493. */
  34494. samplers: string[];
  34495. /**
  34496. * Define statements that will be set in the shader.
  34497. */
  34498. defines: any;
  34499. /**
  34500. * Possible fallbacks for this effect to improve performance when needed.
  34501. */
  34502. fallbacks: Nullable<IEffectFallbacks>;
  34503. /**
  34504. * Callback that will be called when the shader is compiled.
  34505. */
  34506. onCompiled: Nullable<(effect: Effect) => void>;
  34507. /**
  34508. * Callback that will be called if an error occurs during shader compilation.
  34509. */
  34510. onError: Nullable<(effect: Effect, errors: string) => void>;
  34511. /**
  34512. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34513. */
  34514. indexParameters?: any;
  34515. /**
  34516. * Max number of lights that can be used in the shader.
  34517. */
  34518. maxSimultaneousLights?: number;
  34519. /**
  34520. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34521. */
  34522. transformFeedbackVaryings?: Nullable<string[]>;
  34523. /**
  34524. * 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
  34525. */
  34526. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34527. /**
  34528. * Is this effect rendering to several color attachments ?
  34529. */
  34530. multiTarget?: boolean;
  34531. }
  34532. /**
  34533. * Effect containing vertex and fragment shader that can be executed on an object.
  34534. */
  34535. export class Effect implements IDisposable {
  34536. /**
  34537. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34538. */
  34539. static ShadersRepository: string;
  34540. /**
  34541. * Enable logging of the shader code when a compilation error occurs
  34542. */
  34543. static LogShaderCodeOnCompilationError: boolean;
  34544. /**
  34545. * Name of the effect.
  34546. */
  34547. name: any;
  34548. /**
  34549. * String container all the define statements that should be set on the shader.
  34550. */
  34551. defines: string;
  34552. /**
  34553. * Callback that will be called when the shader is compiled.
  34554. */
  34555. onCompiled: Nullable<(effect: Effect) => void>;
  34556. /**
  34557. * Callback that will be called if an error occurs during shader compilation.
  34558. */
  34559. onError: Nullable<(effect: Effect, errors: string) => void>;
  34560. /**
  34561. * Callback that will be called when effect is bound.
  34562. */
  34563. onBind: Nullable<(effect: Effect) => void>;
  34564. /**
  34565. * Unique ID of the effect.
  34566. */
  34567. uniqueId: number;
  34568. /**
  34569. * Observable that will be called when the shader is compiled.
  34570. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34571. */
  34572. onCompileObservable: Observable<Effect>;
  34573. /**
  34574. * Observable that will be called if an error occurs during shader compilation.
  34575. */
  34576. onErrorObservable: Observable<Effect>;
  34577. /** @hidden */
  34578. _onBindObservable: Nullable<Observable<Effect>>;
  34579. /**
  34580. * @hidden
  34581. * Specifies if the effect was previously ready
  34582. */
  34583. _wasPreviouslyReady: boolean;
  34584. /**
  34585. * Observable that will be called when effect is bound.
  34586. */
  34587. get onBindObservable(): Observable<Effect>;
  34588. /** @hidden */
  34589. _bonesComputationForcedToCPU: boolean;
  34590. /** @hidden */
  34591. _multiTarget: boolean;
  34592. private static _uniqueIdSeed;
  34593. private _engine;
  34594. private _uniformBuffersNames;
  34595. private _uniformBuffersNamesList;
  34596. private _uniformsNames;
  34597. private _samplerList;
  34598. private _samplers;
  34599. private _isReady;
  34600. private _compilationError;
  34601. private _allFallbacksProcessed;
  34602. private _attributesNames;
  34603. private _attributes;
  34604. private _attributeLocationByName;
  34605. private _uniforms;
  34606. /**
  34607. * Key for the effect.
  34608. * @hidden
  34609. */
  34610. _key: string;
  34611. private _indexParameters;
  34612. private _fallbacks;
  34613. private _vertexSourceCode;
  34614. private _fragmentSourceCode;
  34615. private _vertexSourceCodeOverride;
  34616. private _fragmentSourceCodeOverride;
  34617. private _transformFeedbackVaryings;
  34618. /**
  34619. * Compiled shader to webGL program.
  34620. * @hidden
  34621. */
  34622. _pipelineContext: Nullable<IPipelineContext>;
  34623. private _valueCache;
  34624. private static _baseCache;
  34625. /**
  34626. * Instantiates an effect.
  34627. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34628. * @param baseName Name of the effect.
  34629. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34630. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34631. * @param samplers List of sampler variables that will be passed to the shader.
  34632. * @param engine Engine to be used to render the effect
  34633. * @param defines Define statements to be added to the shader.
  34634. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34635. * @param onCompiled Callback that will be called when the shader is compiled.
  34636. * @param onError Callback that will be called if an error occurs during shader compilation.
  34637. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34638. */
  34639. 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);
  34640. private _useFinalCode;
  34641. /**
  34642. * Unique key for this effect
  34643. */
  34644. get key(): string;
  34645. /**
  34646. * If the effect has been compiled and prepared.
  34647. * @returns if the effect is compiled and prepared.
  34648. */
  34649. isReady(): boolean;
  34650. private _isReadyInternal;
  34651. /**
  34652. * The engine the effect was initialized with.
  34653. * @returns the engine.
  34654. */
  34655. getEngine(): Engine;
  34656. /**
  34657. * The pipeline context for this effect
  34658. * @returns the associated pipeline context
  34659. */
  34660. getPipelineContext(): Nullable<IPipelineContext>;
  34661. /**
  34662. * The set of names of attribute variables for the shader.
  34663. * @returns An array of attribute names.
  34664. */
  34665. getAttributesNames(): string[];
  34666. /**
  34667. * Returns the attribute at the given index.
  34668. * @param index The index of the attribute.
  34669. * @returns The location of the attribute.
  34670. */
  34671. getAttributeLocation(index: number): number;
  34672. /**
  34673. * Returns the attribute based on the name of the variable.
  34674. * @param name of the attribute to look up.
  34675. * @returns the attribute location.
  34676. */
  34677. getAttributeLocationByName(name: string): number;
  34678. /**
  34679. * The number of attributes.
  34680. * @returns the numnber of attributes.
  34681. */
  34682. getAttributesCount(): number;
  34683. /**
  34684. * Gets the index of a uniform variable.
  34685. * @param uniformName of the uniform to look up.
  34686. * @returns the index.
  34687. */
  34688. getUniformIndex(uniformName: string): number;
  34689. /**
  34690. * Returns the attribute based on the name of the variable.
  34691. * @param uniformName of the uniform to look up.
  34692. * @returns the location of the uniform.
  34693. */
  34694. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34695. /**
  34696. * Returns an array of sampler variable names
  34697. * @returns The array of sampler variable names.
  34698. */
  34699. getSamplers(): string[];
  34700. /**
  34701. * Returns an array of uniform variable names
  34702. * @returns The array of uniform variable names.
  34703. */
  34704. getUniformNames(): string[];
  34705. /**
  34706. * Returns an array of uniform buffer variable names
  34707. * @returns The array of uniform buffer variable names.
  34708. */
  34709. getUniformBuffersNames(): string[];
  34710. /**
  34711. * Returns the index parameters used to create the effect
  34712. * @returns The index parameters object
  34713. */
  34714. getIndexParameters(): any;
  34715. /**
  34716. * The error from the last compilation.
  34717. * @returns the error string.
  34718. */
  34719. getCompilationError(): string;
  34720. /**
  34721. * Gets a boolean indicating that all fallbacks were used during compilation
  34722. * @returns true if all fallbacks were used
  34723. */
  34724. allFallbacksProcessed(): boolean;
  34725. /**
  34726. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34727. * @param func The callback to be used.
  34728. */
  34729. executeWhenCompiled(func: (effect: Effect) => void): void;
  34730. private _checkIsReady;
  34731. private _loadShader;
  34732. /**
  34733. * Gets the vertex shader source code of this effect
  34734. */
  34735. get vertexSourceCode(): string;
  34736. /**
  34737. * Gets the fragment shader source code of this effect
  34738. */
  34739. get fragmentSourceCode(): string;
  34740. /**
  34741. * Recompiles the webGL program
  34742. * @param vertexSourceCode The source code for the vertex shader.
  34743. * @param fragmentSourceCode The source code for the fragment shader.
  34744. * @param onCompiled Callback called when completed.
  34745. * @param onError Callback called on error.
  34746. * @hidden
  34747. */
  34748. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34749. /**
  34750. * Prepares the effect
  34751. * @hidden
  34752. */
  34753. _prepareEffect(): void;
  34754. private _getShaderCodeAndErrorLine;
  34755. private _processCompilationErrors;
  34756. /**
  34757. * Checks if the effect is supported. (Must be called after compilation)
  34758. */
  34759. get isSupported(): boolean;
  34760. /**
  34761. * Binds a texture to the engine to be used as output of the shader.
  34762. * @param channel Name of the output variable.
  34763. * @param texture Texture to bind.
  34764. * @hidden
  34765. */
  34766. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34767. /**
  34768. * Sets a texture on the engine to be used in the shader.
  34769. * @param channel Name of the sampler variable.
  34770. * @param texture Texture to set.
  34771. */
  34772. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34773. /**
  34774. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34775. * @param channel Name of the sampler variable.
  34776. * @param texture Texture to set.
  34777. */
  34778. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34779. /**
  34780. * Sets an array of textures on the engine to be used in the shader.
  34781. * @param channel Name of the variable.
  34782. * @param textures Textures to set.
  34783. */
  34784. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34785. /**
  34786. * 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)
  34787. * @param channel Name of the sampler variable.
  34788. * @param postProcess Post process to get the input texture from.
  34789. */
  34790. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34791. /**
  34792. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34793. * 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)
  34794. * @param channel Name of the sampler variable.
  34795. * @param postProcess Post process to get the output texture from.
  34796. */
  34797. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34798. /** @hidden */
  34799. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34800. /** @hidden */
  34801. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34802. /** @hidden */
  34803. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34804. /** @hidden */
  34805. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34806. /**
  34807. * Binds a buffer to a uniform.
  34808. * @param buffer Buffer to bind.
  34809. * @param name Name of the uniform variable to bind to.
  34810. */
  34811. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34812. /**
  34813. * Binds block to a uniform.
  34814. * @param blockName Name of the block to bind.
  34815. * @param index Index to bind.
  34816. */
  34817. bindUniformBlock(blockName: string, index: number): void;
  34818. /**
  34819. * Sets an interger value on a uniform variable.
  34820. * @param uniformName Name of the variable.
  34821. * @param value Value to be set.
  34822. * @returns this effect.
  34823. */
  34824. setInt(uniformName: string, value: number): Effect;
  34825. /**
  34826. * Sets an int array on a uniform variable.
  34827. * @param uniformName Name of the variable.
  34828. * @param array array to be set.
  34829. * @returns this effect.
  34830. */
  34831. setIntArray(uniformName: string, array: Int32Array): Effect;
  34832. /**
  34833. * 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)
  34834. * @param uniformName Name of the variable.
  34835. * @param array array to be set.
  34836. * @returns this effect.
  34837. */
  34838. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34839. /**
  34840. * 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)
  34841. * @param uniformName Name of the variable.
  34842. * @param array array to be set.
  34843. * @returns this effect.
  34844. */
  34845. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34846. /**
  34847. * 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)
  34848. * @param uniformName Name of the variable.
  34849. * @param array array to be set.
  34850. * @returns this effect.
  34851. */
  34852. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34853. /**
  34854. * Sets an float array on a uniform variable.
  34855. * @param uniformName Name of the variable.
  34856. * @param array array to be set.
  34857. * @returns this effect.
  34858. */
  34859. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34860. /**
  34861. * 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)
  34862. * @param uniformName Name of the variable.
  34863. * @param array array to be set.
  34864. * @returns this effect.
  34865. */
  34866. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34867. /**
  34868. * 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)
  34869. * @param uniformName Name of the variable.
  34870. * @param array array to be set.
  34871. * @returns this effect.
  34872. */
  34873. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34874. /**
  34875. * 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)
  34876. * @param uniformName Name of the variable.
  34877. * @param array array to be set.
  34878. * @returns this effect.
  34879. */
  34880. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34881. /**
  34882. * Sets an array on a uniform variable.
  34883. * @param uniformName Name of the variable.
  34884. * @param array array to be set.
  34885. * @returns this effect.
  34886. */
  34887. setArray(uniformName: string, array: number[]): Effect;
  34888. /**
  34889. * 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)
  34890. * @param uniformName Name of the variable.
  34891. * @param array array to be set.
  34892. * @returns this effect.
  34893. */
  34894. setArray2(uniformName: string, array: number[]): Effect;
  34895. /**
  34896. * 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)
  34897. * @param uniformName Name of the variable.
  34898. * @param array array to be set.
  34899. * @returns this effect.
  34900. */
  34901. setArray3(uniformName: string, array: number[]): Effect;
  34902. /**
  34903. * 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)
  34904. * @param uniformName Name of the variable.
  34905. * @param array array to be set.
  34906. * @returns this effect.
  34907. */
  34908. setArray4(uniformName: string, array: number[]): Effect;
  34909. /**
  34910. * Sets matrices on a uniform variable.
  34911. * @param uniformName Name of the variable.
  34912. * @param matrices matrices to be set.
  34913. * @returns this effect.
  34914. */
  34915. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34916. /**
  34917. * Sets matrix on a uniform variable.
  34918. * @param uniformName Name of the variable.
  34919. * @param matrix matrix to be set.
  34920. * @returns this effect.
  34921. */
  34922. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34923. /**
  34924. * 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)
  34925. * @param uniformName Name of the variable.
  34926. * @param matrix matrix to be set.
  34927. * @returns this effect.
  34928. */
  34929. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34930. /**
  34931. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34932. * @param uniformName Name of the variable.
  34933. * @param matrix matrix to be set.
  34934. * @returns this effect.
  34935. */
  34936. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34937. /**
  34938. * Sets a float on a uniform variable.
  34939. * @param uniformName Name of the variable.
  34940. * @param value value to be set.
  34941. * @returns this effect.
  34942. */
  34943. setFloat(uniformName: string, value: number): Effect;
  34944. /**
  34945. * Sets a boolean on a uniform variable.
  34946. * @param uniformName Name of the variable.
  34947. * @param bool value to be set.
  34948. * @returns this effect.
  34949. */
  34950. setBool(uniformName: string, bool: boolean): Effect;
  34951. /**
  34952. * Sets a Vector2 on a uniform variable.
  34953. * @param uniformName Name of the variable.
  34954. * @param vector2 vector2 to be set.
  34955. * @returns this effect.
  34956. */
  34957. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34958. /**
  34959. * Sets a float2 on a uniform variable.
  34960. * @param uniformName Name of the variable.
  34961. * @param x First float in float2.
  34962. * @param y Second float in float2.
  34963. * @returns this effect.
  34964. */
  34965. setFloat2(uniformName: string, x: number, y: number): Effect;
  34966. /**
  34967. * Sets a Vector3 on a uniform variable.
  34968. * @param uniformName Name of the variable.
  34969. * @param vector3 Value to be set.
  34970. * @returns this effect.
  34971. */
  34972. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34973. /**
  34974. * Sets a float3 on a uniform variable.
  34975. * @param uniformName Name of the variable.
  34976. * @param x First float in float3.
  34977. * @param y Second float in float3.
  34978. * @param z Third float in float3.
  34979. * @returns this effect.
  34980. */
  34981. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34982. /**
  34983. * Sets a Vector4 on a uniform variable.
  34984. * @param uniformName Name of the variable.
  34985. * @param vector4 Value to be set.
  34986. * @returns this effect.
  34987. */
  34988. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34989. /**
  34990. * Sets a float4 on a uniform variable.
  34991. * @param uniformName Name of the variable.
  34992. * @param x First float in float4.
  34993. * @param y Second float in float4.
  34994. * @param z Third float in float4.
  34995. * @param w Fourth float in float4.
  34996. * @returns this effect.
  34997. */
  34998. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34999. /**
  35000. * Sets a Color3 on a uniform variable.
  35001. * @param uniformName Name of the variable.
  35002. * @param color3 Value to be set.
  35003. * @returns this effect.
  35004. */
  35005. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35006. /**
  35007. * Sets a Color4 on a uniform variable.
  35008. * @param uniformName Name of the variable.
  35009. * @param color3 Value to be set.
  35010. * @param alpha Alpha value to be set.
  35011. * @returns this effect.
  35012. */
  35013. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35014. /**
  35015. * Sets a Color4 on a uniform variable
  35016. * @param uniformName defines the name of the variable
  35017. * @param color4 defines the value to be set
  35018. * @returns this effect.
  35019. */
  35020. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35021. /** Release all associated resources */
  35022. dispose(): void;
  35023. /**
  35024. * This function will add a new shader to the shader store
  35025. * @param name the name of the shader
  35026. * @param pixelShader optional pixel shader content
  35027. * @param vertexShader optional vertex shader content
  35028. */
  35029. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35030. /**
  35031. * Store of each shader (The can be looked up using effect.key)
  35032. */
  35033. static ShadersStore: {
  35034. [key: string]: string;
  35035. };
  35036. /**
  35037. * Store of each included file for a shader (The can be looked up using effect.key)
  35038. */
  35039. static IncludesShadersStore: {
  35040. [key: string]: string;
  35041. };
  35042. /**
  35043. * Resets the cache of effects.
  35044. */
  35045. static ResetCache(): void;
  35046. }
  35047. }
  35048. declare module "babylonjs/Engines/engineCapabilities" {
  35049. /**
  35050. * Interface used to describe the capabilities of the engine relatively to the current browser
  35051. */
  35052. export interface EngineCapabilities {
  35053. /** Maximum textures units per fragment shader */
  35054. maxTexturesImageUnits: number;
  35055. /** Maximum texture units per vertex shader */
  35056. maxVertexTextureImageUnits: number;
  35057. /** Maximum textures units in the entire pipeline */
  35058. maxCombinedTexturesImageUnits: number;
  35059. /** Maximum texture size */
  35060. maxTextureSize: number;
  35061. /** Maximum texture samples */
  35062. maxSamples?: number;
  35063. /** Maximum cube texture size */
  35064. maxCubemapTextureSize: number;
  35065. /** Maximum render texture size */
  35066. maxRenderTextureSize: number;
  35067. /** Maximum number of vertex attributes */
  35068. maxVertexAttribs: number;
  35069. /** Maximum number of varyings */
  35070. maxVaryingVectors: number;
  35071. /** Maximum number of uniforms per vertex shader */
  35072. maxVertexUniformVectors: number;
  35073. /** Maximum number of uniforms per fragment shader */
  35074. maxFragmentUniformVectors: number;
  35075. /** Defines if standard derivates (dx/dy) are supported */
  35076. standardDerivatives: boolean;
  35077. /** Defines if s3tc texture compression is supported */
  35078. s3tc?: WEBGL_compressed_texture_s3tc;
  35079. /** Defines if pvrtc texture compression is supported */
  35080. pvrtc: any;
  35081. /** Defines if etc1 texture compression is supported */
  35082. etc1: any;
  35083. /** Defines if etc2 texture compression is supported */
  35084. etc2: any;
  35085. /** Defines if astc texture compression is supported */
  35086. astc: any;
  35087. /** Defines if float textures are supported */
  35088. textureFloat: boolean;
  35089. /** Defines if vertex array objects are supported */
  35090. vertexArrayObject: boolean;
  35091. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35092. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35093. /** Gets the maximum level of anisotropy supported */
  35094. maxAnisotropy: number;
  35095. /** Defines if instancing is supported */
  35096. instancedArrays: boolean;
  35097. /** Defines if 32 bits indices are supported */
  35098. uintIndices: boolean;
  35099. /** Defines if high precision shaders are supported */
  35100. highPrecisionShaderSupported: boolean;
  35101. /** Defines if depth reading in the fragment shader is supported */
  35102. fragmentDepthSupported: boolean;
  35103. /** Defines if float texture linear filtering is supported*/
  35104. textureFloatLinearFiltering: boolean;
  35105. /** Defines if rendering to float textures is supported */
  35106. textureFloatRender: boolean;
  35107. /** Defines if half float textures are supported*/
  35108. textureHalfFloat: boolean;
  35109. /** Defines if half float texture linear filtering is supported*/
  35110. textureHalfFloatLinearFiltering: boolean;
  35111. /** Defines if rendering to half float textures is supported */
  35112. textureHalfFloatRender: boolean;
  35113. /** Defines if textureLOD shader command is supported */
  35114. textureLOD: boolean;
  35115. /** Defines if draw buffers extension is supported */
  35116. drawBuffersExtension: boolean;
  35117. /** Defines if depth textures are supported */
  35118. depthTextureExtension: boolean;
  35119. /** Defines if float color buffer are supported */
  35120. colorBufferFloat: boolean;
  35121. /** Gets disjoint timer query extension (null if not supported) */
  35122. timerQuery?: EXT_disjoint_timer_query;
  35123. /** Defines if timestamp can be used with timer query */
  35124. canUseTimestampForTimerQuery: boolean;
  35125. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35126. multiview?: any;
  35127. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35128. oculusMultiview?: any;
  35129. /** Function used to let the system compiles shaders in background */
  35130. parallelShaderCompile?: {
  35131. COMPLETION_STATUS_KHR: number;
  35132. };
  35133. /** Max number of texture samples for MSAA */
  35134. maxMSAASamples: number;
  35135. /** Defines if the blend min max extension is supported */
  35136. blendMinMax: boolean;
  35137. }
  35138. }
  35139. declare module "babylonjs/States/depthCullingState" {
  35140. import { Nullable } from "babylonjs/types";
  35141. /**
  35142. * @hidden
  35143. **/
  35144. export class DepthCullingState {
  35145. private _isDepthTestDirty;
  35146. private _isDepthMaskDirty;
  35147. private _isDepthFuncDirty;
  35148. private _isCullFaceDirty;
  35149. private _isCullDirty;
  35150. private _isZOffsetDirty;
  35151. private _isFrontFaceDirty;
  35152. private _depthTest;
  35153. private _depthMask;
  35154. private _depthFunc;
  35155. private _cull;
  35156. private _cullFace;
  35157. private _zOffset;
  35158. private _frontFace;
  35159. /**
  35160. * Initializes the state.
  35161. */
  35162. constructor();
  35163. get isDirty(): boolean;
  35164. get zOffset(): number;
  35165. set zOffset(value: number);
  35166. get cullFace(): Nullable<number>;
  35167. set cullFace(value: Nullable<number>);
  35168. get cull(): Nullable<boolean>;
  35169. set cull(value: Nullable<boolean>);
  35170. get depthFunc(): Nullable<number>;
  35171. set depthFunc(value: Nullable<number>);
  35172. get depthMask(): boolean;
  35173. set depthMask(value: boolean);
  35174. get depthTest(): boolean;
  35175. set depthTest(value: boolean);
  35176. get frontFace(): Nullable<number>;
  35177. set frontFace(value: Nullable<number>);
  35178. reset(): void;
  35179. apply(gl: WebGLRenderingContext): void;
  35180. }
  35181. }
  35182. declare module "babylonjs/States/stencilState" {
  35183. /**
  35184. * @hidden
  35185. **/
  35186. export class StencilState {
  35187. /** 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 */
  35188. static readonly ALWAYS: number;
  35189. /** Passed to stencilOperation to specify that stencil value must be kept */
  35190. static readonly KEEP: number;
  35191. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35192. static readonly REPLACE: number;
  35193. private _isStencilTestDirty;
  35194. private _isStencilMaskDirty;
  35195. private _isStencilFuncDirty;
  35196. private _isStencilOpDirty;
  35197. private _stencilTest;
  35198. private _stencilMask;
  35199. private _stencilFunc;
  35200. private _stencilFuncRef;
  35201. private _stencilFuncMask;
  35202. private _stencilOpStencilFail;
  35203. private _stencilOpDepthFail;
  35204. private _stencilOpStencilDepthPass;
  35205. get isDirty(): boolean;
  35206. get stencilFunc(): number;
  35207. set stencilFunc(value: number);
  35208. get stencilFuncRef(): number;
  35209. set stencilFuncRef(value: number);
  35210. get stencilFuncMask(): number;
  35211. set stencilFuncMask(value: number);
  35212. get stencilOpStencilFail(): number;
  35213. set stencilOpStencilFail(value: number);
  35214. get stencilOpDepthFail(): number;
  35215. set stencilOpDepthFail(value: number);
  35216. get stencilOpStencilDepthPass(): number;
  35217. set stencilOpStencilDepthPass(value: number);
  35218. get stencilMask(): number;
  35219. set stencilMask(value: number);
  35220. get stencilTest(): boolean;
  35221. set stencilTest(value: boolean);
  35222. constructor();
  35223. reset(): void;
  35224. apply(gl: WebGLRenderingContext): void;
  35225. }
  35226. }
  35227. declare module "babylonjs/States/alphaCullingState" {
  35228. /**
  35229. * @hidden
  35230. **/
  35231. export class AlphaState {
  35232. private _isAlphaBlendDirty;
  35233. private _isBlendFunctionParametersDirty;
  35234. private _isBlendEquationParametersDirty;
  35235. private _isBlendConstantsDirty;
  35236. private _alphaBlend;
  35237. private _blendFunctionParameters;
  35238. private _blendEquationParameters;
  35239. private _blendConstants;
  35240. /**
  35241. * Initializes the state.
  35242. */
  35243. constructor();
  35244. get isDirty(): boolean;
  35245. get alphaBlend(): boolean;
  35246. set alphaBlend(value: boolean);
  35247. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35248. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35249. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35250. reset(): void;
  35251. apply(gl: WebGLRenderingContext): void;
  35252. }
  35253. }
  35254. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35255. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35256. /** @hidden */
  35257. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35258. attributeProcessor(attribute: string): string;
  35259. varyingProcessor(varying: string, isFragment: boolean): string;
  35260. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35261. }
  35262. }
  35263. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35264. /**
  35265. * Interface for attribute information associated with buffer instanciation
  35266. */
  35267. export interface InstancingAttributeInfo {
  35268. /**
  35269. * Name of the GLSL attribute
  35270. * if attribute index is not specified, this is used to retrieve the index from the effect
  35271. */
  35272. attributeName: string;
  35273. /**
  35274. * Index/offset of the attribute in the vertex shader
  35275. * if not specified, this will be computes from the name.
  35276. */
  35277. index?: number;
  35278. /**
  35279. * size of the attribute, 1, 2, 3 or 4
  35280. */
  35281. attributeSize: number;
  35282. /**
  35283. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35284. */
  35285. offset: number;
  35286. /**
  35287. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35288. * default to 1
  35289. */
  35290. divisor?: number;
  35291. /**
  35292. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35293. * default is FLOAT
  35294. */
  35295. attributeType?: number;
  35296. /**
  35297. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35298. */
  35299. normalized?: boolean;
  35300. }
  35301. }
  35302. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35304. import { Nullable } from "babylonjs/types";
  35305. module "babylonjs/Engines/thinEngine" {
  35306. interface ThinEngine {
  35307. /**
  35308. * Update a video texture
  35309. * @param texture defines the texture to update
  35310. * @param video defines the video element to use
  35311. * @param invertY defines if data must be stored with Y axis inverted
  35312. */
  35313. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35314. }
  35315. }
  35316. }
  35317. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35319. import { Nullable } from "babylonjs/types";
  35320. module "babylonjs/Engines/thinEngine" {
  35321. interface ThinEngine {
  35322. /**
  35323. * Creates a dynamic texture
  35324. * @param width defines the width of the texture
  35325. * @param height defines the height of the texture
  35326. * @param generateMipMaps defines if the engine should generate the mip levels
  35327. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35328. * @returns the dynamic texture inside an InternalTexture
  35329. */
  35330. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35331. /**
  35332. * Update the content of a dynamic texture
  35333. * @param texture defines the texture to update
  35334. * @param canvas defines the canvas containing the source
  35335. * @param invertY defines if data must be stored with Y axis inverted
  35336. * @param premulAlpha defines if alpha is stored as premultiplied
  35337. * @param format defines the format of the data
  35338. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35339. */
  35340. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35341. }
  35342. }
  35343. }
  35344. declare module "babylonjs/Materials/Textures/videoTexture" {
  35345. import { Observable } from "babylonjs/Misc/observable";
  35346. import { Nullable } from "babylonjs/types";
  35347. import { Scene } from "babylonjs/scene";
  35348. import { Texture } from "babylonjs/Materials/Textures/texture";
  35349. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35350. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35351. /**
  35352. * Settings for finer control over video usage
  35353. */
  35354. export interface VideoTextureSettings {
  35355. /**
  35356. * Applies `autoplay` to video, if specified
  35357. */
  35358. autoPlay?: boolean;
  35359. /**
  35360. * Applies `loop` to video, if specified
  35361. */
  35362. loop?: boolean;
  35363. /**
  35364. * Automatically updates internal texture from video at every frame in the render loop
  35365. */
  35366. autoUpdateTexture: boolean;
  35367. /**
  35368. * Image src displayed during the video loading or until the user interacts with the video.
  35369. */
  35370. poster?: string;
  35371. }
  35372. /**
  35373. * If you want to display a video in your scene, this is the special texture for that.
  35374. * This special texture works similar to other textures, with the exception of a few parameters.
  35375. * @see https://doc.babylonjs.com/how_to/video_texture
  35376. */
  35377. export class VideoTexture extends Texture {
  35378. /**
  35379. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35380. */
  35381. readonly autoUpdateTexture: boolean;
  35382. /**
  35383. * The video instance used by the texture internally
  35384. */
  35385. readonly video: HTMLVideoElement;
  35386. private _onUserActionRequestedObservable;
  35387. /**
  35388. * Event triggerd when a dom action is required by the user to play the video.
  35389. * This happens due to recent changes in browser policies preventing video to auto start.
  35390. */
  35391. get onUserActionRequestedObservable(): Observable<Texture>;
  35392. private _generateMipMaps;
  35393. private _stillImageCaptured;
  35394. private _displayingPosterTexture;
  35395. private _settings;
  35396. private _createInternalTextureOnEvent;
  35397. private _frameId;
  35398. private _currentSrc;
  35399. /**
  35400. * Creates a video texture.
  35401. * If you want to display a video in your scene, this is the special texture for that.
  35402. * This special texture works similar to other textures, with the exception of a few parameters.
  35403. * @see https://doc.babylonjs.com/how_to/video_texture
  35404. * @param name optional name, will detect from video source, if not defined
  35405. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35406. * @param scene is obviously the current scene.
  35407. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35408. * @param invertY is false by default but can be used to invert video on Y axis
  35409. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35410. * @param settings allows finer control over video usage
  35411. */
  35412. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35413. private _getName;
  35414. private _getVideo;
  35415. private _createInternalTexture;
  35416. private reset;
  35417. /**
  35418. * @hidden Internal method to initiate `update`.
  35419. */
  35420. _rebuild(): void;
  35421. /**
  35422. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35423. */
  35424. update(): void;
  35425. /**
  35426. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35427. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35428. */
  35429. updateTexture(isVisible: boolean): void;
  35430. protected _updateInternalTexture: () => void;
  35431. /**
  35432. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35433. * @param url New url.
  35434. */
  35435. updateURL(url: string): void;
  35436. /**
  35437. * Clones the texture.
  35438. * @returns the cloned texture
  35439. */
  35440. clone(): VideoTexture;
  35441. /**
  35442. * Dispose the texture and release its associated resources.
  35443. */
  35444. dispose(): void;
  35445. /**
  35446. * Creates a video texture straight from a stream.
  35447. * @param scene Define the scene the texture should be created in
  35448. * @param stream Define the stream the texture should be created from
  35449. * @returns The created video texture as a promise
  35450. */
  35451. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35452. /**
  35453. * Creates a video texture straight from your WebCam video feed.
  35454. * @param scene Define the scene the texture should be created in
  35455. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35456. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35457. * @returns The created video texture as a promise
  35458. */
  35459. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35460. minWidth: number;
  35461. maxWidth: number;
  35462. minHeight: number;
  35463. maxHeight: number;
  35464. deviceId: string;
  35465. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35466. /**
  35467. * Creates a video texture straight from your WebCam video feed.
  35468. * @param scene Define the scene the texture should be created in
  35469. * @param onReady Define a callback to triggered once the texture will be ready
  35470. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35471. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35472. */
  35473. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35474. minWidth: number;
  35475. maxWidth: number;
  35476. minHeight: number;
  35477. maxHeight: number;
  35478. deviceId: string;
  35479. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35480. }
  35481. }
  35482. declare module "babylonjs/Engines/thinEngine" {
  35483. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35484. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35485. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35487. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35488. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35489. import { Observable } from "babylonjs/Misc/observable";
  35490. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35491. import { StencilState } from "babylonjs/States/stencilState";
  35492. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35493. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35494. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35495. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35496. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35497. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35498. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35499. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35500. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35502. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35503. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35504. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35505. import { WebRequest } from "babylonjs/Misc/webRequest";
  35506. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35507. /**
  35508. * Defines the interface used by objects working like Scene
  35509. * @hidden
  35510. */
  35511. export interface ISceneLike {
  35512. _addPendingData(data: any): void;
  35513. _removePendingData(data: any): void;
  35514. offlineProvider: IOfflineProvider;
  35515. }
  35516. /** Interface defining initialization parameters for Engine class */
  35517. export interface EngineOptions extends WebGLContextAttributes {
  35518. /**
  35519. * Defines if the engine should no exceed a specified device ratio
  35520. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35521. */
  35522. limitDeviceRatio?: number;
  35523. /**
  35524. * Defines if webvr should be enabled automatically
  35525. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35526. */
  35527. autoEnableWebVR?: boolean;
  35528. /**
  35529. * Defines if webgl2 should be turned off even if supported
  35530. * @see https://doc.babylonjs.com/features/webgl2
  35531. */
  35532. disableWebGL2Support?: boolean;
  35533. /**
  35534. * Defines if webaudio should be initialized as well
  35535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35536. */
  35537. audioEngine?: boolean;
  35538. /**
  35539. * Defines if animations should run using a deterministic lock step
  35540. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35541. */
  35542. deterministicLockstep?: boolean;
  35543. /** Defines the maximum steps to use with deterministic lock step mode */
  35544. lockstepMaxSteps?: number;
  35545. /** Defines the seconds between each deterministic lock step */
  35546. timeStep?: number;
  35547. /**
  35548. * Defines that engine should ignore context lost events
  35549. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35550. */
  35551. doNotHandleContextLost?: boolean;
  35552. /**
  35553. * Defines that engine should ignore modifying touch action attribute and style
  35554. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35555. */
  35556. doNotHandleTouchAction?: boolean;
  35557. /**
  35558. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35559. */
  35560. useHighPrecisionFloats?: boolean;
  35561. /**
  35562. * Make the canvas XR Compatible for XR sessions
  35563. */
  35564. xrCompatible?: boolean;
  35565. /**
  35566. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35567. */
  35568. useHighPrecisionMatrix?: boolean;
  35569. }
  35570. /**
  35571. * The base engine class (root of all engines)
  35572. */
  35573. export class ThinEngine {
  35574. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35575. static ExceptionList: ({
  35576. key: string;
  35577. capture: string;
  35578. captureConstraint: number;
  35579. targets: string[];
  35580. } | {
  35581. key: string;
  35582. capture: null;
  35583. captureConstraint: null;
  35584. targets: string[];
  35585. })[];
  35586. /** @hidden */
  35587. static _TextureLoaders: IInternalTextureLoader[];
  35588. /**
  35589. * Returns the current npm package of the sdk
  35590. */
  35591. static get NpmPackage(): string;
  35592. /**
  35593. * Returns the current version of the framework
  35594. */
  35595. static get Version(): string;
  35596. /**
  35597. * Returns a string describing the current engine
  35598. */
  35599. get description(): string;
  35600. /**
  35601. * Gets or sets the epsilon value used by collision engine
  35602. */
  35603. static CollisionsEpsilon: number;
  35604. /**
  35605. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35606. */
  35607. static get ShadersRepository(): string;
  35608. static set ShadersRepository(value: string);
  35609. /** @hidden */
  35610. _shaderProcessor: IShaderProcessor;
  35611. /**
  35612. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35613. */
  35614. forcePOTTextures: boolean;
  35615. /**
  35616. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35617. */
  35618. isFullscreen: boolean;
  35619. /**
  35620. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35621. */
  35622. cullBackFaces: boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35625. */
  35626. renderEvenInBackground: boolean;
  35627. /**
  35628. * Gets or sets a boolean indicating that cache can be kept between frames
  35629. */
  35630. preventCacheWipeBetweenFrames: boolean;
  35631. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35632. validateShaderPrograms: boolean;
  35633. /**
  35634. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35635. * This can provide greater z depth for distant objects.
  35636. */
  35637. useReverseDepthBuffer: boolean;
  35638. /**
  35639. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35640. */
  35641. disableUniformBuffers: boolean;
  35642. /** @hidden */
  35643. _uniformBuffers: UniformBuffer[];
  35644. /**
  35645. * Gets a boolean indicating that the engine supports uniform buffers
  35646. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35647. */
  35648. get supportsUniformBuffers(): boolean;
  35649. /** @hidden */
  35650. _gl: WebGLRenderingContext;
  35651. /** @hidden */
  35652. _webGLVersion: number;
  35653. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35654. protected _windowIsBackground: boolean;
  35655. protected _creationOptions: EngineOptions;
  35656. protected _highPrecisionShadersAllowed: boolean;
  35657. /** @hidden */
  35658. get _shouldUseHighPrecisionShader(): boolean;
  35659. /**
  35660. * Gets a boolean indicating that only power of 2 textures are supported
  35661. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35662. */
  35663. get needPOTTextures(): boolean;
  35664. /** @hidden */
  35665. _badOS: boolean;
  35666. /** @hidden */
  35667. _badDesktopOS: boolean;
  35668. private _hardwareScalingLevel;
  35669. /** @hidden */
  35670. _caps: EngineCapabilities;
  35671. private _isStencilEnable;
  35672. private _glVersion;
  35673. private _glRenderer;
  35674. private _glVendor;
  35675. /** @hidden */
  35676. _videoTextureSupported: boolean;
  35677. protected _renderingQueueLaunched: boolean;
  35678. protected _activeRenderLoops: (() => void)[];
  35679. /**
  35680. * Observable signaled when a context lost event is raised
  35681. */
  35682. onContextLostObservable: Observable<ThinEngine>;
  35683. /**
  35684. * Observable signaled when a context restored event is raised
  35685. */
  35686. onContextRestoredObservable: Observable<ThinEngine>;
  35687. private _onContextLost;
  35688. private _onContextRestored;
  35689. protected _contextWasLost: boolean;
  35690. /** @hidden */
  35691. _doNotHandleContextLost: boolean;
  35692. /**
  35693. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35694. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35695. */
  35696. get doNotHandleContextLost(): boolean;
  35697. set doNotHandleContextLost(value: boolean);
  35698. /**
  35699. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35700. */
  35701. disableVertexArrayObjects: boolean;
  35702. /** @hidden */
  35703. protected _colorWrite: boolean;
  35704. /** @hidden */
  35705. protected _colorWriteChanged: boolean;
  35706. /** @hidden */
  35707. protected _depthCullingState: DepthCullingState;
  35708. /** @hidden */
  35709. protected _stencilState: StencilState;
  35710. /** @hidden */
  35711. _alphaState: AlphaState;
  35712. /** @hidden */
  35713. _alphaMode: number;
  35714. /** @hidden */
  35715. _alphaEquation: number;
  35716. /** @hidden */
  35717. _internalTexturesCache: InternalTexture[];
  35718. /** @hidden */
  35719. protected _activeChannel: number;
  35720. private _currentTextureChannel;
  35721. /** @hidden */
  35722. protected _boundTexturesCache: {
  35723. [key: string]: Nullable<InternalTexture>;
  35724. };
  35725. /** @hidden */
  35726. protected _currentEffect: Nullable<Effect>;
  35727. /** @hidden */
  35728. protected _currentProgram: Nullable<WebGLProgram>;
  35729. private _compiledEffects;
  35730. private _vertexAttribArraysEnabled;
  35731. /** @hidden */
  35732. protected _cachedViewport: Nullable<IViewportLike>;
  35733. private _cachedVertexArrayObject;
  35734. /** @hidden */
  35735. protected _cachedVertexBuffers: any;
  35736. /** @hidden */
  35737. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35738. /** @hidden */
  35739. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35740. /** @hidden */
  35741. _currentRenderTarget: Nullable<InternalTexture>;
  35742. private _uintIndicesCurrentlySet;
  35743. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35744. /** @hidden */
  35745. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35746. /** @hidden */
  35747. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35748. private _currentBufferPointers;
  35749. private _currentInstanceLocations;
  35750. private _currentInstanceBuffers;
  35751. private _textureUnits;
  35752. /** @hidden */
  35753. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35754. /** @hidden */
  35755. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35756. /** @hidden */
  35757. _boundRenderFunction: any;
  35758. private _vaoRecordInProgress;
  35759. private _mustWipeVertexAttributes;
  35760. private _emptyTexture;
  35761. private _emptyCubeTexture;
  35762. private _emptyTexture3D;
  35763. private _emptyTexture2DArray;
  35764. /** @hidden */
  35765. _frameHandler: number;
  35766. private _nextFreeTextureSlots;
  35767. private _maxSimultaneousTextures;
  35768. private _activeRequests;
  35769. /** @hidden */
  35770. _transformTextureUrl: Nullable<(url: string) => string>;
  35771. protected get _supportsHardwareTextureRescaling(): boolean;
  35772. private _framebufferDimensionsObject;
  35773. /**
  35774. * sets the object from which width and height will be taken from when getting render width and height
  35775. * Will fallback to the gl object
  35776. * @param dimensions the framebuffer width and height that will be used.
  35777. */
  35778. set framebufferDimensionsObject(dimensions: Nullable<{
  35779. framebufferWidth: number;
  35780. framebufferHeight: number;
  35781. }>);
  35782. /**
  35783. * Gets the current viewport
  35784. */
  35785. get currentViewport(): Nullable<IViewportLike>;
  35786. /**
  35787. * Gets the default empty texture
  35788. */
  35789. get emptyTexture(): InternalTexture;
  35790. /**
  35791. * Gets the default empty 3D texture
  35792. */
  35793. get emptyTexture3D(): InternalTexture;
  35794. /**
  35795. * Gets the default empty 2D array texture
  35796. */
  35797. get emptyTexture2DArray(): InternalTexture;
  35798. /**
  35799. * Gets the default empty cube texture
  35800. */
  35801. get emptyCubeTexture(): InternalTexture;
  35802. /**
  35803. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35804. */
  35805. readonly premultipliedAlpha: boolean;
  35806. /**
  35807. * Observable event triggered before each texture is initialized
  35808. */
  35809. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35810. /**
  35811. * Creates a new engine
  35812. * @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
  35813. * @param antialias defines enable antialiasing (default: false)
  35814. * @param options defines further options to be sent to the getContext() function
  35815. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35816. */
  35817. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35818. private _rebuildInternalTextures;
  35819. private _rebuildEffects;
  35820. /**
  35821. * Gets a boolean indicating if all created effects are ready
  35822. * @returns true if all effects are ready
  35823. */
  35824. areAllEffectsReady(): boolean;
  35825. protected _rebuildBuffers(): void;
  35826. protected _initGLContext(): void;
  35827. /**
  35828. * Gets version of the current webGL context
  35829. */
  35830. get webGLVersion(): number;
  35831. /**
  35832. * Gets a string idenfifying the name of the class
  35833. * @returns "Engine" string
  35834. */
  35835. getClassName(): string;
  35836. /**
  35837. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35838. */
  35839. get isStencilEnable(): boolean;
  35840. /** @hidden */
  35841. _prepareWorkingCanvas(): void;
  35842. /**
  35843. * Reset the texture cache to empty state
  35844. */
  35845. resetTextureCache(): void;
  35846. /**
  35847. * Gets an object containing information about the current webGL context
  35848. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35849. */
  35850. getGlInfo(): {
  35851. vendor: string;
  35852. renderer: string;
  35853. version: string;
  35854. };
  35855. /**
  35856. * Defines the hardware scaling level.
  35857. * By default the hardware scaling level is computed from the window device ratio.
  35858. * 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.
  35859. * @param level defines the level to use
  35860. */
  35861. setHardwareScalingLevel(level: number): void;
  35862. /**
  35863. * Gets the current hardware scaling level.
  35864. * By default the hardware scaling level is computed from the window device ratio.
  35865. * 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.
  35866. * @returns a number indicating the current hardware scaling level
  35867. */
  35868. getHardwareScalingLevel(): number;
  35869. /**
  35870. * Gets the list of loaded textures
  35871. * @returns an array containing all loaded textures
  35872. */
  35873. getLoadedTexturesCache(): InternalTexture[];
  35874. /**
  35875. * Gets the object containing all engine capabilities
  35876. * @returns the EngineCapabilities object
  35877. */
  35878. getCaps(): EngineCapabilities;
  35879. /**
  35880. * stop executing a render loop function and remove it from the execution array
  35881. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35882. */
  35883. stopRenderLoop(renderFunction?: () => void): void;
  35884. /** @hidden */
  35885. _renderLoop(): void;
  35886. /**
  35887. * Gets the HTML canvas attached with the current webGL context
  35888. * @returns a HTML canvas
  35889. */
  35890. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35891. /**
  35892. * Gets host window
  35893. * @returns the host window object
  35894. */
  35895. getHostWindow(): Nullable<Window>;
  35896. /**
  35897. * Gets the current render width
  35898. * @param useScreen defines if screen size must be used (or the current render target if any)
  35899. * @returns a number defining the current render width
  35900. */
  35901. getRenderWidth(useScreen?: boolean): number;
  35902. /**
  35903. * Gets the current render height
  35904. * @param useScreen defines if screen size must be used (or the current render target if any)
  35905. * @returns a number defining the current render height
  35906. */
  35907. getRenderHeight(useScreen?: boolean): number;
  35908. /**
  35909. * Can be used to override the current requestAnimationFrame requester.
  35910. * @hidden
  35911. */
  35912. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35913. /**
  35914. * Register and execute a render loop. The engine can have more than one render function
  35915. * @param renderFunction defines the function to continuously execute
  35916. */
  35917. runRenderLoop(renderFunction: () => void): void;
  35918. /**
  35919. * Clear the current render buffer or the current render target (if any is set up)
  35920. * @param color defines the color to use
  35921. * @param backBuffer defines if the back buffer must be cleared
  35922. * @param depth defines if the depth buffer must be cleared
  35923. * @param stencil defines if the stencil buffer must be cleared
  35924. */
  35925. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35926. private _viewportCached;
  35927. /** @hidden */
  35928. _viewport(x: number, y: number, width: number, height: number): void;
  35929. /**
  35930. * Set the WebGL's viewport
  35931. * @param viewport defines the viewport element to be used
  35932. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35933. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35934. */
  35935. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35936. /**
  35937. * Begin a new frame
  35938. */
  35939. beginFrame(): void;
  35940. /**
  35941. * Enf the current frame
  35942. */
  35943. endFrame(): void;
  35944. /**
  35945. * Resize the view according to the canvas' size
  35946. */
  35947. resize(): void;
  35948. /**
  35949. * Force a specific size of the canvas
  35950. * @param width defines the new canvas' width
  35951. * @param height defines the new canvas' height
  35952. * @returns true if the size was changed
  35953. */
  35954. setSize(width: number, height: number): boolean;
  35955. /**
  35956. * Binds the frame buffer to the specified texture.
  35957. * @param texture The texture to render to or null for the default canvas
  35958. * @param faceIndex The face of the texture to render to in case of cube texture
  35959. * @param requiredWidth The width of the target to render to
  35960. * @param requiredHeight The height of the target to render to
  35961. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35962. * @param lodLevel defines the lod level to bind to the frame buffer
  35963. * @param layer defines the 2d array index to bind to frame buffer to
  35964. */
  35965. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35966. /** @hidden */
  35967. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35968. /**
  35969. * Unbind the current render target texture from the webGL context
  35970. * @param texture defines the render target texture to unbind
  35971. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35972. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35973. */
  35974. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35975. /**
  35976. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35977. */
  35978. flushFramebuffer(): void;
  35979. /**
  35980. * Unbind the current render target and bind the default framebuffer
  35981. */
  35982. restoreDefaultFramebuffer(): void;
  35983. /** @hidden */
  35984. protected _resetVertexBufferBinding(): void;
  35985. /**
  35986. * Creates a vertex buffer
  35987. * @param data the data for the vertex buffer
  35988. * @returns the new WebGL static buffer
  35989. */
  35990. createVertexBuffer(data: DataArray): DataBuffer;
  35991. private _createVertexBuffer;
  35992. /**
  35993. * Creates a dynamic vertex buffer
  35994. * @param data the data for the dynamic vertex buffer
  35995. * @returns the new WebGL dynamic buffer
  35996. */
  35997. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35998. protected _resetIndexBufferBinding(): void;
  35999. /**
  36000. * Creates a new index buffer
  36001. * @param indices defines the content of the index buffer
  36002. * @param updatable defines if the index buffer must be updatable
  36003. * @returns a new webGL buffer
  36004. */
  36005. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36006. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36007. /**
  36008. * Bind a webGL buffer to the webGL context
  36009. * @param buffer defines the buffer to bind
  36010. */
  36011. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36012. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36013. private bindBuffer;
  36014. /**
  36015. * update the bound buffer with the given data
  36016. * @param data defines the data to update
  36017. */
  36018. updateArrayBuffer(data: Float32Array): void;
  36019. private _vertexAttribPointer;
  36020. /** @hidden */
  36021. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36022. private _bindVertexBuffersAttributes;
  36023. /**
  36024. * Records a vertex array object
  36025. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36026. * @param vertexBuffers defines the list of vertex buffers to store
  36027. * @param indexBuffer defines the index buffer to store
  36028. * @param effect defines the effect to store
  36029. * @returns the new vertex array object
  36030. */
  36031. recordVertexArrayObject(vertexBuffers: {
  36032. [key: string]: VertexBuffer;
  36033. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36034. /**
  36035. * Bind a specific vertex array object
  36036. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36037. * @param vertexArrayObject defines the vertex array object to bind
  36038. * @param indexBuffer defines the index buffer to bind
  36039. */
  36040. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36041. /**
  36042. * Bind webGl buffers directly to the webGL context
  36043. * @param vertexBuffer defines the vertex buffer to bind
  36044. * @param indexBuffer defines the index buffer to bind
  36045. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36046. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36047. * @param effect defines the effect associated with the vertex buffer
  36048. */
  36049. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36050. private _unbindVertexArrayObject;
  36051. /**
  36052. * Bind a list of vertex buffers to the webGL context
  36053. * @param vertexBuffers defines the list of vertex buffers to bind
  36054. * @param indexBuffer defines the index buffer to bind
  36055. * @param effect defines the effect associated with the vertex buffers
  36056. */
  36057. bindBuffers(vertexBuffers: {
  36058. [key: string]: Nullable<VertexBuffer>;
  36059. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36060. /**
  36061. * Unbind all instance attributes
  36062. */
  36063. unbindInstanceAttributes(): void;
  36064. /**
  36065. * Release and free the memory of a vertex array object
  36066. * @param vao defines the vertex array object to delete
  36067. */
  36068. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36069. /** @hidden */
  36070. _releaseBuffer(buffer: DataBuffer): boolean;
  36071. protected _deleteBuffer(buffer: DataBuffer): void;
  36072. /**
  36073. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36074. * @param instancesBuffer defines the webGL buffer to update and bind
  36075. * @param data defines the data to store in the buffer
  36076. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36077. */
  36078. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36079. /**
  36080. * Bind the content of a webGL buffer used with instantiation
  36081. * @param instancesBuffer defines the webGL buffer to bind
  36082. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36083. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36084. */
  36085. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36086. /**
  36087. * Disable the instance attribute corresponding to the name in parameter
  36088. * @param name defines the name of the attribute to disable
  36089. */
  36090. disableInstanceAttributeByName(name: string): void;
  36091. /**
  36092. * Disable the instance attribute corresponding to the location in parameter
  36093. * @param attributeLocation defines the attribute location of the attribute to disable
  36094. */
  36095. disableInstanceAttribute(attributeLocation: number): void;
  36096. /**
  36097. * Disable the attribute corresponding to the location in parameter
  36098. * @param attributeLocation defines the attribute location of the attribute to disable
  36099. */
  36100. disableAttributeByIndex(attributeLocation: number): void;
  36101. /**
  36102. * Send a draw order
  36103. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36104. * @param indexStart defines the starting index
  36105. * @param indexCount defines the number of index to draw
  36106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36107. */
  36108. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36109. /**
  36110. * Draw a list of points
  36111. * @param verticesStart defines the index of first vertex to draw
  36112. * @param verticesCount defines the count of vertices to draw
  36113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36114. */
  36115. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36116. /**
  36117. * Draw a list of unindexed primitives
  36118. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36119. * @param verticesStart defines the index of first vertex to draw
  36120. * @param verticesCount defines the count of vertices to draw
  36121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36122. */
  36123. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36124. /**
  36125. * Draw a list of indexed primitives
  36126. * @param fillMode defines the primitive to use
  36127. * @param indexStart defines the starting index
  36128. * @param indexCount defines the number of index to draw
  36129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36130. */
  36131. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36132. /**
  36133. * Draw a list of unindexed primitives
  36134. * @param fillMode defines the primitive to use
  36135. * @param verticesStart defines the index of first vertex to draw
  36136. * @param verticesCount defines the count of vertices to draw
  36137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36138. */
  36139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36140. private _drawMode;
  36141. /** @hidden */
  36142. protected _reportDrawCall(): void;
  36143. /** @hidden */
  36144. _releaseEffect(effect: Effect): void;
  36145. /** @hidden */
  36146. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36147. /**
  36148. * Create a new effect (used to store vertex/fragment shaders)
  36149. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36150. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36151. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36152. * @param samplers defines an array of string used to represent textures
  36153. * @param defines defines the string containing the defines to use to compile the shaders
  36154. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36155. * @param onCompiled defines a function to call when the effect creation is successful
  36156. * @param onError defines a function to call when the effect creation has failed
  36157. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36158. * @returns the new Effect
  36159. */
  36160. 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;
  36161. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36162. private _compileShader;
  36163. private _compileRawShader;
  36164. /** @hidden */
  36165. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36166. /**
  36167. * Directly creates a webGL program
  36168. * @param pipelineContext defines the pipeline context to attach to
  36169. * @param vertexCode defines the vertex shader code to use
  36170. * @param fragmentCode defines the fragment shader code to use
  36171. * @param context defines the webGL context to use (if not set, the current one will be used)
  36172. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36173. * @returns the new webGL program
  36174. */
  36175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36176. /**
  36177. * Creates a webGL program
  36178. * @param pipelineContext defines the pipeline context to attach to
  36179. * @param vertexCode defines the vertex shader code to use
  36180. * @param fragmentCode defines the fragment shader code to use
  36181. * @param defines defines the string containing the defines to use to compile the shaders
  36182. * @param context defines the webGL context to use (if not set, the current one will be used)
  36183. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36184. * @returns the new webGL program
  36185. */
  36186. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36187. /**
  36188. * Creates a new pipeline context
  36189. * @returns the new pipeline
  36190. */
  36191. createPipelineContext(): IPipelineContext;
  36192. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36193. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36194. /** @hidden */
  36195. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36196. /** @hidden */
  36197. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36198. /** @hidden */
  36199. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36200. /**
  36201. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36202. * @param pipelineContext defines the pipeline context to use
  36203. * @param uniformsNames defines the list of uniform names
  36204. * @returns an array of webGL uniform locations
  36205. */
  36206. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36207. /**
  36208. * Gets the lsit of active attributes for a given webGL program
  36209. * @param pipelineContext defines the pipeline context to use
  36210. * @param attributesNames defines the list of attribute names to get
  36211. * @returns an array of indices indicating the offset of each attribute
  36212. */
  36213. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36214. /**
  36215. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36216. * @param effect defines the effect to activate
  36217. */
  36218. enableEffect(effect: Nullable<Effect>): void;
  36219. /**
  36220. * Set the value of an uniform to a number (int)
  36221. * @param uniform defines the webGL uniform location where to store the value
  36222. * @param value defines the int number to store
  36223. */
  36224. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36225. /**
  36226. * Set the value of an uniform to an array of int32
  36227. * @param uniform defines the webGL uniform location where to store the value
  36228. * @param array defines the array of int32 to store
  36229. */
  36230. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36231. /**
  36232. * Set the value of an uniform to an array of int32 (stored as vec2)
  36233. * @param uniform defines the webGL uniform location where to store the value
  36234. * @param array defines the array of int32 to store
  36235. */
  36236. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36237. /**
  36238. * Set the value of an uniform to an array of int32 (stored as vec3)
  36239. * @param uniform defines the webGL uniform location where to store the value
  36240. * @param array defines the array of int32 to store
  36241. */
  36242. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36243. /**
  36244. * Set the value of an uniform to an array of int32 (stored as vec4)
  36245. * @param uniform defines the webGL uniform location where to store the value
  36246. * @param array defines the array of int32 to store
  36247. */
  36248. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36249. /**
  36250. * Set the value of an uniform to an array of number
  36251. * @param uniform defines the webGL uniform location where to store the value
  36252. * @param array defines the array of number to store
  36253. */
  36254. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36255. /**
  36256. * Set the value of an uniform to an array of number (stored as vec2)
  36257. * @param uniform defines the webGL uniform location where to store the value
  36258. * @param array defines the array of number to store
  36259. */
  36260. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36261. /**
  36262. * Set the value of an uniform to an array of number (stored as vec3)
  36263. * @param uniform defines the webGL uniform location where to store the value
  36264. * @param array defines the array of number to store
  36265. */
  36266. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36267. /**
  36268. * Set the value of an uniform to an array of number (stored as vec4)
  36269. * @param uniform defines the webGL uniform location where to store the value
  36270. * @param array defines the array of number to store
  36271. */
  36272. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36273. /**
  36274. * Set the value of an uniform to an array of float32 (stored as matrices)
  36275. * @param uniform defines the webGL uniform location where to store the value
  36276. * @param matrices defines the array of float32 to store
  36277. */
  36278. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36279. /**
  36280. * Set the value of an uniform to a matrix (3x3)
  36281. * @param uniform defines the webGL uniform location where to store the value
  36282. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36283. */
  36284. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36285. /**
  36286. * Set the value of an uniform to a matrix (2x2)
  36287. * @param uniform defines the webGL uniform location where to store the value
  36288. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36289. */
  36290. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36291. /**
  36292. * Set the value of an uniform to a number (float)
  36293. * @param uniform defines the webGL uniform location where to store the value
  36294. * @param value defines the float number to store
  36295. */
  36296. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36297. /**
  36298. * Set the value of an uniform to a vec2
  36299. * @param uniform defines the webGL uniform location where to store the value
  36300. * @param x defines the 1st component of the value
  36301. * @param y defines the 2nd component of the value
  36302. */
  36303. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36304. /**
  36305. * Set the value of an uniform to a vec3
  36306. * @param uniform defines the webGL uniform location where to store the value
  36307. * @param x defines the 1st component of the value
  36308. * @param y defines the 2nd component of the value
  36309. * @param z defines the 3rd component of the value
  36310. */
  36311. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36312. /**
  36313. * Set the value of an uniform to a vec4
  36314. * @param uniform defines the webGL uniform location where to store the value
  36315. * @param x defines the 1st component of the value
  36316. * @param y defines the 2nd component of the value
  36317. * @param z defines the 3rd component of the value
  36318. * @param w defines the 4th component of the value
  36319. */
  36320. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36321. /**
  36322. * Apply all cached states (depth, culling, stencil and alpha)
  36323. */
  36324. applyStates(): void;
  36325. /**
  36326. * Enable or disable color writing
  36327. * @param enable defines the state to set
  36328. */
  36329. setColorWrite(enable: boolean): void;
  36330. /**
  36331. * Gets a boolean indicating if color writing is enabled
  36332. * @returns the current color writing state
  36333. */
  36334. getColorWrite(): boolean;
  36335. /**
  36336. * Gets the depth culling state manager
  36337. */
  36338. get depthCullingState(): DepthCullingState;
  36339. /**
  36340. * Gets the alpha state manager
  36341. */
  36342. get alphaState(): AlphaState;
  36343. /**
  36344. * Gets the stencil state manager
  36345. */
  36346. get stencilState(): StencilState;
  36347. /**
  36348. * Clears the list of texture accessible through engine.
  36349. * This can help preventing texture load conflict due to name collision.
  36350. */
  36351. clearInternalTexturesCache(): void;
  36352. /**
  36353. * Force the entire cache to be cleared
  36354. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36355. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36356. */
  36357. wipeCaches(bruteForce?: boolean): void;
  36358. /** @hidden */
  36359. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36360. min: number;
  36361. mag: number;
  36362. };
  36363. /** @hidden */
  36364. _createTexture(): WebGLTexture;
  36365. /**
  36366. * Usually called from Texture.ts.
  36367. * Passed information to create a WebGLTexture
  36368. * @param url defines a value which contains one of the following:
  36369. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36370. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36371. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36372. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36373. * @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)
  36374. * @param scene needed for loading to the correct scene
  36375. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36376. * @param onLoad optional callback to be called upon successful completion
  36377. * @param onError optional callback to be called upon failure
  36378. * @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
  36379. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36380. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36381. * @param forcedExtension defines the extension to use to pick the right loader
  36382. * @param mimeType defines an optional mime type
  36383. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36384. */
  36385. 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;
  36386. /**
  36387. * Loads an image as an HTMLImageElement.
  36388. * @param input url string, ArrayBuffer, or Blob to load
  36389. * @param onLoad callback called when the image successfully loads
  36390. * @param onError callback called when the image fails to load
  36391. * @param offlineProvider offline provider for caching
  36392. * @param mimeType optional mime type
  36393. * @returns the HTMLImageElement of the loaded image
  36394. * @hidden
  36395. */
  36396. 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>;
  36397. /**
  36398. * @hidden
  36399. */
  36400. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36401. private _unpackFlipYCached;
  36402. /**
  36403. * In case you are sharing the context with other applications, it might
  36404. * be interested to not cache the unpack flip y state to ensure a consistent
  36405. * value would be set.
  36406. */
  36407. enableUnpackFlipYCached: boolean;
  36408. /** @hidden */
  36409. _unpackFlipY(value: boolean): void;
  36410. /** @hidden */
  36411. _getUnpackAlignement(): number;
  36412. private _getTextureTarget;
  36413. /**
  36414. * Update the sampling mode of a given texture
  36415. * @param samplingMode defines the required sampling mode
  36416. * @param texture defines the texture to update
  36417. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36418. */
  36419. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36420. /**
  36421. * Update the sampling mode of a given texture
  36422. * @param texture defines the texture to update
  36423. * @param wrapU defines the texture wrap mode of the u coordinates
  36424. * @param wrapV defines the texture wrap mode of the v coordinates
  36425. * @param wrapR defines the texture wrap mode of the r coordinates
  36426. */
  36427. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36428. /** @hidden */
  36429. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36430. width: number;
  36431. height: number;
  36432. layers?: number;
  36433. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36434. /** @hidden */
  36435. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36436. /** @hidden */
  36437. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36438. /**
  36439. * Update a portion of an internal texture
  36440. * @param texture defines the texture to update
  36441. * @param imageData defines the data to store into the texture
  36442. * @param xOffset defines the x coordinates of the update rectangle
  36443. * @param yOffset defines the y coordinates of the update rectangle
  36444. * @param width defines the width of the update rectangle
  36445. * @param height defines the height of the update rectangle
  36446. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36447. * @param lod defines the lod level to update (0 by default)
  36448. */
  36449. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36450. /** @hidden */
  36451. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36452. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36453. private _prepareWebGLTexture;
  36454. /** @hidden */
  36455. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36456. private _getDepthStencilBuffer;
  36457. /** @hidden */
  36458. _releaseFramebufferObjects(texture: InternalTexture): void;
  36459. /** @hidden */
  36460. _releaseTexture(texture: InternalTexture): void;
  36461. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36462. protected _setProgram(program: WebGLProgram): void;
  36463. protected _boundUniforms: {
  36464. [key: number]: WebGLUniformLocation;
  36465. };
  36466. /**
  36467. * Binds an effect to the webGL context
  36468. * @param effect defines the effect to bind
  36469. */
  36470. bindSamplers(effect: Effect): void;
  36471. private _activateCurrentTexture;
  36472. /** @hidden */
  36473. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36474. /** @hidden */
  36475. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36476. /**
  36477. * Unbind all textures from the webGL context
  36478. */
  36479. unbindAllTextures(): void;
  36480. /**
  36481. * Sets a texture to the according uniform.
  36482. * @param channel The texture channel
  36483. * @param uniform The uniform to set
  36484. * @param texture The texture to apply
  36485. */
  36486. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36487. private _bindSamplerUniformToChannel;
  36488. private _getTextureWrapMode;
  36489. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36490. /**
  36491. * Sets an array of texture to the webGL context
  36492. * @param channel defines the channel where the texture array must be set
  36493. * @param uniform defines the associated uniform location
  36494. * @param textures defines the array of textures to bind
  36495. */
  36496. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36497. /** @hidden */
  36498. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36499. private _setTextureParameterFloat;
  36500. private _setTextureParameterInteger;
  36501. /**
  36502. * Unbind all vertex attributes from the webGL context
  36503. */
  36504. unbindAllAttributes(): void;
  36505. /**
  36506. * 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
  36507. */
  36508. releaseEffects(): void;
  36509. /**
  36510. * Dispose and release all associated resources
  36511. */
  36512. dispose(): void;
  36513. /**
  36514. * Attach a new callback raised when context lost event is fired
  36515. * @param callback defines the callback to call
  36516. */
  36517. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36518. /**
  36519. * Attach a new callback raised when context restored event is fired
  36520. * @param callback defines the callback to call
  36521. */
  36522. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36523. /**
  36524. * Get the current error code of the webGL context
  36525. * @returns the error code
  36526. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36527. */
  36528. getError(): number;
  36529. private _canRenderToFloatFramebuffer;
  36530. private _canRenderToHalfFloatFramebuffer;
  36531. private _canRenderToFramebuffer;
  36532. /** @hidden */
  36533. _getWebGLTextureType(type: number): number;
  36534. /** @hidden */
  36535. _getInternalFormat(format: number): number;
  36536. /** @hidden */
  36537. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36538. /** @hidden */
  36539. _getRGBAMultiSampleBufferFormat(type: number): number;
  36540. /** @hidden */
  36541. _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;
  36542. /**
  36543. * Loads a file from a url
  36544. * @param url url to load
  36545. * @param onSuccess callback called when the file successfully loads
  36546. * @param onProgress callback called while file is loading (if the server supports this mode)
  36547. * @param offlineProvider defines the offline provider for caching
  36548. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36549. * @param onError callback called when the file fails to load
  36550. * @returns a file request object
  36551. * @hidden
  36552. */
  36553. 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;
  36554. /**
  36555. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36556. * @param x defines the x coordinate of the rectangle where pixels must be read
  36557. * @param y defines the y coordinate of the rectangle where pixels must be read
  36558. * @param width defines the width of the rectangle where pixels must be read
  36559. * @param height defines the height of the rectangle where pixels must be read
  36560. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36561. * @returns a Uint8Array containing RGBA colors
  36562. */
  36563. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36564. private static _isSupported;
  36565. /**
  36566. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36567. * @returns true if the engine can be created
  36568. * @ignorenaming
  36569. */
  36570. static isSupported(): boolean;
  36571. /**
  36572. * Find the next highest power of two.
  36573. * @param x Number to start search from.
  36574. * @return Next highest power of two.
  36575. */
  36576. static CeilingPOT(x: number): number;
  36577. /**
  36578. * Find the next lowest power of two.
  36579. * @param x Number to start search from.
  36580. * @return Next lowest power of two.
  36581. */
  36582. static FloorPOT(x: number): number;
  36583. /**
  36584. * Find the nearest power of two.
  36585. * @param x Number to start search from.
  36586. * @return Next nearest power of two.
  36587. */
  36588. static NearestPOT(x: number): number;
  36589. /**
  36590. * Get the closest exponent of two
  36591. * @param value defines the value to approximate
  36592. * @param max defines the maximum value to return
  36593. * @param mode defines how to define the closest value
  36594. * @returns closest exponent of two of the given value
  36595. */
  36596. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36597. /**
  36598. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36599. * @param func - the function to be called
  36600. * @param requester - the object that will request the next frame. Falls back to window.
  36601. * @returns frame number
  36602. */
  36603. static QueueNewFrame(func: () => void, requester?: any): number;
  36604. /**
  36605. * Gets host document
  36606. * @returns the host document object
  36607. */
  36608. getHostDocument(): Nullable<Document>;
  36609. }
  36610. }
  36611. declare module "babylonjs/Maths/sphericalPolynomial" {
  36612. import { Vector3 } from "babylonjs/Maths/math.vector";
  36613. import { Color3 } from "babylonjs/Maths/math.color";
  36614. /**
  36615. * Class representing spherical harmonics coefficients to the 3rd degree
  36616. */
  36617. export class SphericalHarmonics {
  36618. /**
  36619. * Defines whether or not the harmonics have been prescaled for rendering.
  36620. */
  36621. preScaled: boolean;
  36622. /**
  36623. * The l0,0 coefficients of the spherical harmonics
  36624. */
  36625. l00: Vector3;
  36626. /**
  36627. * The l1,-1 coefficients of the spherical harmonics
  36628. */
  36629. l1_1: Vector3;
  36630. /**
  36631. * The l1,0 coefficients of the spherical harmonics
  36632. */
  36633. l10: Vector3;
  36634. /**
  36635. * The l1,1 coefficients of the spherical harmonics
  36636. */
  36637. l11: Vector3;
  36638. /**
  36639. * The l2,-2 coefficients of the spherical harmonics
  36640. */
  36641. l2_2: Vector3;
  36642. /**
  36643. * The l2,-1 coefficients of the spherical harmonics
  36644. */
  36645. l2_1: Vector3;
  36646. /**
  36647. * The l2,0 coefficients of the spherical harmonics
  36648. */
  36649. l20: Vector3;
  36650. /**
  36651. * The l2,1 coefficients of the spherical harmonics
  36652. */
  36653. l21: Vector3;
  36654. /**
  36655. * The l2,2 coefficients of the spherical harmonics
  36656. */
  36657. l22: Vector3;
  36658. /**
  36659. * Adds a light to the spherical harmonics
  36660. * @param direction the direction of the light
  36661. * @param color the color of the light
  36662. * @param deltaSolidAngle the delta solid angle of the light
  36663. */
  36664. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36665. /**
  36666. * Scales the spherical harmonics by the given amount
  36667. * @param scale the amount to scale
  36668. */
  36669. scaleInPlace(scale: number): void;
  36670. /**
  36671. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36672. *
  36673. * ```
  36674. * E_lm = A_l * L_lm
  36675. * ```
  36676. *
  36677. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36678. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36679. * the scaling factors are given in equation 9.
  36680. */
  36681. convertIncidentRadianceToIrradiance(): void;
  36682. /**
  36683. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36684. *
  36685. * ```
  36686. * L = (1/pi) * E * rho
  36687. * ```
  36688. *
  36689. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36690. */
  36691. convertIrradianceToLambertianRadiance(): void;
  36692. /**
  36693. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36694. * required operations at run time.
  36695. *
  36696. * This is simply done by scaling back the SH with Ylm constants parameter.
  36697. * The trigonometric part being applied by the shader at run time.
  36698. */
  36699. preScaleForRendering(): void;
  36700. /**
  36701. * Constructs a spherical harmonics from an array.
  36702. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36703. * @returns the spherical harmonics
  36704. */
  36705. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36706. /**
  36707. * Gets the spherical harmonics from polynomial
  36708. * @param polynomial the spherical polynomial
  36709. * @returns the spherical harmonics
  36710. */
  36711. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36712. }
  36713. /**
  36714. * Class representing spherical polynomial coefficients to the 3rd degree
  36715. */
  36716. export class SphericalPolynomial {
  36717. private _harmonics;
  36718. /**
  36719. * The spherical harmonics used to create the polynomials.
  36720. */
  36721. get preScaledHarmonics(): SphericalHarmonics;
  36722. /**
  36723. * The x coefficients of the spherical polynomial
  36724. */
  36725. x: Vector3;
  36726. /**
  36727. * The y coefficients of the spherical polynomial
  36728. */
  36729. y: Vector3;
  36730. /**
  36731. * The z coefficients of the spherical polynomial
  36732. */
  36733. z: Vector3;
  36734. /**
  36735. * The xx coefficients of the spherical polynomial
  36736. */
  36737. xx: Vector3;
  36738. /**
  36739. * The yy coefficients of the spherical polynomial
  36740. */
  36741. yy: Vector3;
  36742. /**
  36743. * The zz coefficients of the spherical polynomial
  36744. */
  36745. zz: Vector3;
  36746. /**
  36747. * The xy coefficients of the spherical polynomial
  36748. */
  36749. xy: Vector3;
  36750. /**
  36751. * The yz coefficients of the spherical polynomial
  36752. */
  36753. yz: Vector3;
  36754. /**
  36755. * The zx coefficients of the spherical polynomial
  36756. */
  36757. zx: Vector3;
  36758. /**
  36759. * Adds an ambient color to the spherical polynomial
  36760. * @param color the color to add
  36761. */
  36762. addAmbient(color: Color3): void;
  36763. /**
  36764. * Scales the spherical polynomial by the given amount
  36765. * @param scale the amount to scale
  36766. */
  36767. scaleInPlace(scale: number): void;
  36768. /**
  36769. * Gets the spherical polynomial from harmonics
  36770. * @param harmonics the spherical harmonics
  36771. * @returns the spherical polynomial
  36772. */
  36773. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36774. /**
  36775. * Constructs a spherical polynomial from an array.
  36776. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36777. * @returns the spherical polynomial
  36778. */
  36779. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36780. }
  36781. }
  36782. declare module "babylonjs/Materials/Textures/internalTexture" {
  36783. import { Observable } from "babylonjs/Misc/observable";
  36784. import { Nullable, int } from "babylonjs/types";
  36785. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36787. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36788. /**
  36789. * Defines the source of the internal texture
  36790. */
  36791. export enum InternalTextureSource {
  36792. /**
  36793. * The source of the texture data is unknown
  36794. */
  36795. Unknown = 0,
  36796. /**
  36797. * Texture data comes from an URL
  36798. */
  36799. Url = 1,
  36800. /**
  36801. * Texture data is only used for temporary storage
  36802. */
  36803. Temp = 2,
  36804. /**
  36805. * Texture data comes from raw data (ArrayBuffer)
  36806. */
  36807. Raw = 3,
  36808. /**
  36809. * Texture content is dynamic (video or dynamic texture)
  36810. */
  36811. Dynamic = 4,
  36812. /**
  36813. * Texture content is generated by rendering to it
  36814. */
  36815. RenderTarget = 5,
  36816. /**
  36817. * Texture content is part of a multi render target process
  36818. */
  36819. MultiRenderTarget = 6,
  36820. /**
  36821. * Texture data comes from a cube data file
  36822. */
  36823. Cube = 7,
  36824. /**
  36825. * Texture data comes from a raw cube data
  36826. */
  36827. CubeRaw = 8,
  36828. /**
  36829. * Texture data come from a prefiltered cube data file
  36830. */
  36831. CubePrefiltered = 9,
  36832. /**
  36833. * Texture content is raw 3D data
  36834. */
  36835. Raw3D = 10,
  36836. /**
  36837. * Texture content is raw 2D array data
  36838. */
  36839. Raw2DArray = 11,
  36840. /**
  36841. * Texture content is a depth texture
  36842. */
  36843. Depth = 12,
  36844. /**
  36845. * Texture data comes from a raw cube data encoded with RGBD
  36846. */
  36847. CubeRawRGBD = 13
  36848. }
  36849. /**
  36850. * Class used to store data associated with WebGL texture data for the engine
  36851. * This class should not be used directly
  36852. */
  36853. export class InternalTexture {
  36854. /** @hidden */
  36855. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36856. /**
  36857. * Defines if the texture is ready
  36858. */
  36859. isReady: boolean;
  36860. /**
  36861. * Defines if the texture is a cube texture
  36862. */
  36863. isCube: boolean;
  36864. /**
  36865. * Defines if the texture contains 3D data
  36866. */
  36867. is3D: boolean;
  36868. /**
  36869. * Defines if the texture contains 2D array data
  36870. */
  36871. is2DArray: boolean;
  36872. /**
  36873. * Defines if the texture contains multiview data
  36874. */
  36875. isMultiview: boolean;
  36876. /**
  36877. * Gets the URL used to load this texture
  36878. */
  36879. url: string;
  36880. /**
  36881. * Gets the sampling mode of the texture
  36882. */
  36883. samplingMode: number;
  36884. /**
  36885. * Gets a boolean indicating if the texture needs mipmaps generation
  36886. */
  36887. generateMipMaps: boolean;
  36888. /**
  36889. * Gets the number of samples used by the texture (WebGL2+ only)
  36890. */
  36891. samples: number;
  36892. /**
  36893. * Gets the type of the texture (int, float...)
  36894. */
  36895. type: number;
  36896. /**
  36897. * Gets the format of the texture (RGB, RGBA...)
  36898. */
  36899. format: number;
  36900. /**
  36901. * Observable called when the texture is loaded
  36902. */
  36903. onLoadedObservable: Observable<InternalTexture>;
  36904. /**
  36905. * Gets the width of the texture
  36906. */
  36907. width: number;
  36908. /**
  36909. * Gets the height of the texture
  36910. */
  36911. height: number;
  36912. /**
  36913. * Gets the depth of the texture
  36914. */
  36915. depth: number;
  36916. /**
  36917. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36918. */
  36919. baseWidth: number;
  36920. /**
  36921. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36922. */
  36923. baseHeight: number;
  36924. /**
  36925. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36926. */
  36927. baseDepth: number;
  36928. /**
  36929. * Gets a boolean indicating if the texture is inverted on Y axis
  36930. */
  36931. invertY: boolean;
  36932. /** @hidden */
  36933. _invertVScale: boolean;
  36934. /** @hidden */
  36935. _associatedChannel: number;
  36936. /** @hidden */
  36937. _source: InternalTextureSource;
  36938. /** @hidden */
  36939. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36940. /** @hidden */
  36941. _bufferView: Nullable<ArrayBufferView>;
  36942. /** @hidden */
  36943. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36944. /** @hidden */
  36945. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36946. /** @hidden */
  36947. _size: number;
  36948. /** @hidden */
  36949. _extension: string;
  36950. /** @hidden */
  36951. _files: Nullable<string[]>;
  36952. /** @hidden */
  36953. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36954. /** @hidden */
  36955. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36956. /** @hidden */
  36957. _framebuffer: Nullable<WebGLFramebuffer>;
  36958. /** @hidden */
  36959. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36960. /** @hidden */
  36961. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36962. /** @hidden */
  36963. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36964. /** @hidden */
  36965. _attachments: Nullable<number[]>;
  36966. /** @hidden */
  36967. _textureArray: Nullable<InternalTexture[]>;
  36968. /** @hidden */
  36969. _cachedCoordinatesMode: Nullable<number>;
  36970. /** @hidden */
  36971. _cachedWrapU: Nullable<number>;
  36972. /** @hidden */
  36973. _cachedWrapV: Nullable<number>;
  36974. /** @hidden */
  36975. _cachedWrapR: Nullable<number>;
  36976. /** @hidden */
  36977. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36978. /** @hidden */
  36979. _isDisabled: boolean;
  36980. /** @hidden */
  36981. _compression: Nullable<string>;
  36982. /** @hidden */
  36983. _generateStencilBuffer: boolean;
  36984. /** @hidden */
  36985. _generateDepthBuffer: boolean;
  36986. /** @hidden */
  36987. _comparisonFunction: number;
  36988. /** @hidden */
  36989. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36990. /** @hidden */
  36991. _lodGenerationScale: number;
  36992. /** @hidden */
  36993. _lodGenerationOffset: number;
  36994. /** @hidden */
  36995. _depthStencilTexture: Nullable<InternalTexture>;
  36996. /** @hidden */
  36997. _colorTextureArray: Nullable<WebGLTexture>;
  36998. /** @hidden */
  36999. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37000. /** @hidden */
  37001. _lodTextureHigh: Nullable<BaseTexture>;
  37002. /** @hidden */
  37003. _lodTextureMid: Nullable<BaseTexture>;
  37004. /** @hidden */
  37005. _lodTextureLow: Nullable<BaseTexture>;
  37006. /** @hidden */
  37007. _isRGBD: boolean;
  37008. /** @hidden */
  37009. _linearSpecularLOD: boolean;
  37010. /** @hidden */
  37011. _irradianceTexture: Nullable<BaseTexture>;
  37012. /** @hidden */
  37013. _webGLTexture: Nullable<WebGLTexture>;
  37014. /** @hidden */
  37015. _references: number;
  37016. private _engine;
  37017. /**
  37018. * Gets the Engine the texture belongs to.
  37019. * @returns The babylon engine
  37020. */
  37021. getEngine(): ThinEngine;
  37022. /**
  37023. * Gets the data source type of the texture
  37024. */
  37025. get source(): InternalTextureSource;
  37026. /**
  37027. * Creates a new InternalTexture
  37028. * @param engine defines the engine to use
  37029. * @param source defines the type of data that will be used
  37030. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37031. */
  37032. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37033. /**
  37034. * Increments the number of references (ie. the number of Texture that point to it)
  37035. */
  37036. incrementReferences(): void;
  37037. /**
  37038. * Change the size of the texture (not the size of the content)
  37039. * @param width defines the new width
  37040. * @param height defines the new height
  37041. * @param depth defines the new depth (1 by default)
  37042. */
  37043. updateSize(width: int, height: int, depth?: int): void;
  37044. /** @hidden */
  37045. _rebuild(): void;
  37046. /** @hidden */
  37047. _swapAndDie(target: InternalTexture): void;
  37048. /**
  37049. * Dispose the current allocated resources
  37050. */
  37051. dispose(): void;
  37052. }
  37053. }
  37054. declare module "babylonjs/Audio/analyser" {
  37055. import { Scene } from "babylonjs/scene";
  37056. /**
  37057. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37059. */
  37060. export class Analyser {
  37061. /**
  37062. * Gets or sets the smoothing
  37063. * @ignorenaming
  37064. */
  37065. SMOOTHING: number;
  37066. /**
  37067. * Gets or sets the FFT table size
  37068. * @ignorenaming
  37069. */
  37070. FFT_SIZE: number;
  37071. /**
  37072. * Gets or sets the bar graph amplitude
  37073. * @ignorenaming
  37074. */
  37075. BARGRAPHAMPLITUDE: number;
  37076. /**
  37077. * Gets or sets the position of the debug canvas
  37078. * @ignorenaming
  37079. */
  37080. DEBUGCANVASPOS: {
  37081. x: number;
  37082. y: number;
  37083. };
  37084. /**
  37085. * Gets or sets the debug canvas size
  37086. * @ignorenaming
  37087. */
  37088. DEBUGCANVASSIZE: {
  37089. width: number;
  37090. height: number;
  37091. };
  37092. private _byteFreqs;
  37093. private _byteTime;
  37094. private _floatFreqs;
  37095. private _webAudioAnalyser;
  37096. private _debugCanvas;
  37097. private _debugCanvasContext;
  37098. private _scene;
  37099. private _registerFunc;
  37100. private _audioEngine;
  37101. /**
  37102. * Creates a new analyser
  37103. * @param scene defines hosting scene
  37104. */
  37105. constructor(scene: Scene);
  37106. /**
  37107. * Get the number of data values you will have to play with for the visualization
  37108. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37109. * @returns a number
  37110. */
  37111. getFrequencyBinCount(): number;
  37112. /**
  37113. * Gets the current frequency data as a byte array
  37114. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37115. * @returns a Uint8Array
  37116. */
  37117. getByteFrequencyData(): Uint8Array;
  37118. /**
  37119. * Gets the current waveform as a byte array
  37120. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37121. * @returns a Uint8Array
  37122. */
  37123. getByteTimeDomainData(): Uint8Array;
  37124. /**
  37125. * Gets the current frequency data as a float array
  37126. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37127. * @returns a Float32Array
  37128. */
  37129. getFloatFrequencyData(): Float32Array;
  37130. /**
  37131. * Renders the debug canvas
  37132. */
  37133. drawDebugCanvas(): void;
  37134. /**
  37135. * Stops rendering the debug canvas and removes it
  37136. */
  37137. stopDebugCanvas(): void;
  37138. /**
  37139. * Connects two audio nodes
  37140. * @param inputAudioNode defines first node to connect
  37141. * @param outputAudioNode defines second node to connect
  37142. */
  37143. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37144. /**
  37145. * Releases all associated resources
  37146. */
  37147. dispose(): void;
  37148. }
  37149. }
  37150. declare module "babylonjs/Audio/audioEngine" {
  37151. import { IDisposable } from "babylonjs/scene";
  37152. import { Analyser } from "babylonjs/Audio/analyser";
  37153. import { Nullable } from "babylonjs/types";
  37154. import { Observable } from "babylonjs/Misc/observable";
  37155. /**
  37156. * This represents an audio engine and it is responsible
  37157. * to play, synchronize and analyse sounds throughout the application.
  37158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37159. */
  37160. export interface IAudioEngine extends IDisposable {
  37161. /**
  37162. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37163. */
  37164. readonly canUseWebAudio: boolean;
  37165. /**
  37166. * Gets the current AudioContext if available.
  37167. */
  37168. readonly audioContext: Nullable<AudioContext>;
  37169. /**
  37170. * The master gain node defines the global audio volume of your audio engine.
  37171. */
  37172. readonly masterGain: GainNode;
  37173. /**
  37174. * Gets whether or not mp3 are supported by your browser.
  37175. */
  37176. readonly isMP3supported: boolean;
  37177. /**
  37178. * Gets whether or not ogg are supported by your browser.
  37179. */
  37180. readonly isOGGsupported: boolean;
  37181. /**
  37182. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37183. * @ignoreNaming
  37184. */
  37185. WarnedWebAudioUnsupported: boolean;
  37186. /**
  37187. * Defines if the audio engine relies on a custom unlocked button.
  37188. * In this case, the embedded button will not be displayed.
  37189. */
  37190. useCustomUnlockedButton: boolean;
  37191. /**
  37192. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37193. */
  37194. readonly unlocked: boolean;
  37195. /**
  37196. * Event raised when audio has been unlocked on the browser.
  37197. */
  37198. onAudioUnlockedObservable: Observable<AudioEngine>;
  37199. /**
  37200. * Event raised when audio has been locked on the browser.
  37201. */
  37202. onAudioLockedObservable: Observable<AudioEngine>;
  37203. /**
  37204. * Flags the audio engine in Locked state.
  37205. * This happens due to new browser policies preventing audio to autoplay.
  37206. */
  37207. lock(): void;
  37208. /**
  37209. * Unlocks the audio engine once a user action has been done on the dom.
  37210. * This is helpful to resume play once browser policies have been satisfied.
  37211. */
  37212. unlock(): void;
  37213. /**
  37214. * Gets the global volume sets on the master gain.
  37215. * @returns the global volume if set or -1 otherwise
  37216. */
  37217. getGlobalVolume(): number;
  37218. /**
  37219. * Sets the global volume of your experience (sets on the master gain).
  37220. * @param newVolume Defines the new global volume of the application
  37221. */
  37222. setGlobalVolume(newVolume: number): void;
  37223. /**
  37224. * Connect the audio engine to an audio analyser allowing some amazing
  37225. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37227. * @param analyser The analyser to connect to the engine
  37228. */
  37229. connectToAnalyser(analyser: Analyser): void;
  37230. }
  37231. /**
  37232. * This represents the default audio engine used in babylon.
  37233. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37235. */
  37236. export class AudioEngine implements IAudioEngine {
  37237. private _audioContext;
  37238. private _audioContextInitialized;
  37239. private _muteButton;
  37240. private _hostElement;
  37241. /**
  37242. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37243. */
  37244. canUseWebAudio: boolean;
  37245. /**
  37246. * The master gain node defines the global audio volume of your audio engine.
  37247. */
  37248. masterGain: GainNode;
  37249. /**
  37250. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37251. * @ignoreNaming
  37252. */
  37253. WarnedWebAudioUnsupported: boolean;
  37254. /**
  37255. * Gets whether or not mp3 are supported by your browser.
  37256. */
  37257. isMP3supported: boolean;
  37258. /**
  37259. * Gets whether or not ogg are supported by your browser.
  37260. */
  37261. isOGGsupported: boolean;
  37262. /**
  37263. * Gets whether audio has been unlocked on the device.
  37264. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37265. * a user interaction has happened.
  37266. */
  37267. unlocked: boolean;
  37268. /**
  37269. * Defines if the audio engine relies on a custom unlocked button.
  37270. * In this case, the embedded button will not be displayed.
  37271. */
  37272. useCustomUnlockedButton: boolean;
  37273. /**
  37274. * Event raised when audio has been unlocked on the browser.
  37275. */
  37276. onAudioUnlockedObservable: Observable<AudioEngine>;
  37277. /**
  37278. * Event raised when audio has been locked on the browser.
  37279. */
  37280. onAudioLockedObservable: Observable<AudioEngine>;
  37281. /**
  37282. * Gets the current AudioContext if available.
  37283. */
  37284. get audioContext(): Nullable<AudioContext>;
  37285. private _connectedAnalyser;
  37286. /**
  37287. * Instantiates a new audio engine.
  37288. *
  37289. * There should be only one per page as some browsers restrict the number
  37290. * of audio contexts you can create.
  37291. * @param hostElement defines the host element where to display the mute icon if necessary
  37292. */
  37293. constructor(hostElement?: Nullable<HTMLElement>);
  37294. /**
  37295. * Flags the audio engine in Locked state.
  37296. * This happens due to new browser policies preventing audio to autoplay.
  37297. */
  37298. lock(): void;
  37299. /**
  37300. * Unlocks the audio engine once a user action has been done on the dom.
  37301. * This is helpful to resume play once browser policies have been satisfied.
  37302. */
  37303. unlock(): void;
  37304. private _resumeAudioContext;
  37305. private _initializeAudioContext;
  37306. private _tryToRun;
  37307. private _triggerRunningState;
  37308. private _triggerSuspendedState;
  37309. private _displayMuteButton;
  37310. private _moveButtonToTopLeft;
  37311. private _onResize;
  37312. private _hideMuteButton;
  37313. /**
  37314. * Destroy and release the resources associated with the audio ccontext.
  37315. */
  37316. dispose(): void;
  37317. /**
  37318. * Gets the global volume sets on the master gain.
  37319. * @returns the global volume if set or -1 otherwise
  37320. */
  37321. getGlobalVolume(): number;
  37322. /**
  37323. * Sets the global volume of your experience (sets on the master gain).
  37324. * @param newVolume Defines the new global volume of the application
  37325. */
  37326. setGlobalVolume(newVolume: number): void;
  37327. /**
  37328. * Connect the audio engine to an audio analyser allowing some amazing
  37329. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37331. * @param analyser The analyser to connect to the engine
  37332. */
  37333. connectToAnalyser(analyser: Analyser): void;
  37334. }
  37335. }
  37336. declare module "babylonjs/Loading/loadingScreen" {
  37337. /**
  37338. * Interface used to present a loading screen while loading a scene
  37339. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37340. */
  37341. export interface ILoadingScreen {
  37342. /**
  37343. * Function called to display the loading screen
  37344. */
  37345. displayLoadingUI: () => void;
  37346. /**
  37347. * Function called to hide the loading screen
  37348. */
  37349. hideLoadingUI: () => void;
  37350. /**
  37351. * Gets or sets the color to use for the background
  37352. */
  37353. loadingUIBackgroundColor: string;
  37354. /**
  37355. * Gets or sets the text to display while loading
  37356. */
  37357. loadingUIText: string;
  37358. }
  37359. /**
  37360. * Class used for the default loading screen
  37361. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37362. */
  37363. export class DefaultLoadingScreen implements ILoadingScreen {
  37364. private _renderingCanvas;
  37365. private _loadingText;
  37366. private _loadingDivBackgroundColor;
  37367. private _loadingDiv;
  37368. private _loadingTextDiv;
  37369. /** Gets or sets the logo url to use for the default loading screen */
  37370. static DefaultLogoUrl: string;
  37371. /** Gets or sets the spinner url to use for the default loading screen */
  37372. static DefaultSpinnerUrl: string;
  37373. /**
  37374. * Creates a new default loading screen
  37375. * @param _renderingCanvas defines the canvas used to render the scene
  37376. * @param _loadingText defines the default text to display
  37377. * @param _loadingDivBackgroundColor defines the default background color
  37378. */
  37379. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37380. /**
  37381. * Function called to display the loading screen
  37382. */
  37383. displayLoadingUI(): void;
  37384. /**
  37385. * Function called to hide the loading screen
  37386. */
  37387. hideLoadingUI(): void;
  37388. /**
  37389. * Gets or sets the text to display while loading
  37390. */
  37391. set loadingUIText(text: string);
  37392. get loadingUIText(): string;
  37393. /**
  37394. * Gets or sets the color to use for the background
  37395. */
  37396. get loadingUIBackgroundColor(): string;
  37397. set loadingUIBackgroundColor(color: string);
  37398. private _resizeLoadingUI;
  37399. }
  37400. }
  37401. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37402. /**
  37403. * Interface for any object that can request an animation frame
  37404. */
  37405. export interface ICustomAnimationFrameRequester {
  37406. /**
  37407. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37408. */
  37409. renderFunction?: Function;
  37410. /**
  37411. * Called to request the next frame to render to
  37412. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37413. */
  37414. requestAnimationFrame: Function;
  37415. /**
  37416. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37417. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37418. */
  37419. requestID?: number;
  37420. }
  37421. }
  37422. declare module "babylonjs/Misc/performanceMonitor" {
  37423. /**
  37424. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37425. */
  37426. export class PerformanceMonitor {
  37427. private _enabled;
  37428. private _rollingFrameTime;
  37429. private _lastFrameTimeMs;
  37430. /**
  37431. * constructor
  37432. * @param frameSampleSize The number of samples required to saturate the sliding window
  37433. */
  37434. constructor(frameSampleSize?: number);
  37435. /**
  37436. * Samples current frame
  37437. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37438. */
  37439. sampleFrame(timeMs?: number): void;
  37440. /**
  37441. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37442. */
  37443. get averageFrameTime(): number;
  37444. /**
  37445. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37446. */
  37447. get averageFrameTimeVariance(): number;
  37448. /**
  37449. * Returns the frame time of the most recent frame
  37450. */
  37451. get instantaneousFrameTime(): number;
  37452. /**
  37453. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37454. */
  37455. get averageFPS(): number;
  37456. /**
  37457. * Returns the average framerate in frames per second using the most recent frame time
  37458. */
  37459. get instantaneousFPS(): number;
  37460. /**
  37461. * Returns true if enough samples have been taken to completely fill the sliding window
  37462. */
  37463. get isSaturated(): boolean;
  37464. /**
  37465. * Enables contributions to the sliding window sample set
  37466. */
  37467. enable(): void;
  37468. /**
  37469. * Disables contributions to the sliding window sample set
  37470. * Samples will not be interpolated over the disabled period
  37471. */
  37472. disable(): void;
  37473. /**
  37474. * Returns true if sampling is enabled
  37475. */
  37476. get isEnabled(): boolean;
  37477. /**
  37478. * Resets performance monitor
  37479. */
  37480. reset(): void;
  37481. }
  37482. /**
  37483. * RollingAverage
  37484. *
  37485. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37486. */
  37487. export class RollingAverage {
  37488. /**
  37489. * Current average
  37490. */
  37491. average: number;
  37492. /**
  37493. * Current variance
  37494. */
  37495. variance: number;
  37496. protected _samples: Array<number>;
  37497. protected _sampleCount: number;
  37498. protected _pos: number;
  37499. protected _m2: number;
  37500. /**
  37501. * constructor
  37502. * @param length The number of samples required to saturate the sliding window
  37503. */
  37504. constructor(length: number);
  37505. /**
  37506. * Adds a sample to the sample set
  37507. * @param v The sample value
  37508. */
  37509. add(v: number): void;
  37510. /**
  37511. * Returns previously added values or null if outside of history or outside the sliding window domain
  37512. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37513. * @return Value previously recorded with add() or null if outside of range
  37514. */
  37515. history(i: number): number;
  37516. /**
  37517. * Returns true if enough samples have been taken to completely fill the sliding window
  37518. * @return true if sample-set saturated
  37519. */
  37520. isSaturated(): boolean;
  37521. /**
  37522. * Resets the rolling average (equivalent to 0 samples taken so far)
  37523. */
  37524. reset(): void;
  37525. /**
  37526. * Wraps a value around the sample range boundaries
  37527. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37528. * @return Wrapped position in sample range
  37529. */
  37530. protected _wrapPosition(i: number): number;
  37531. }
  37532. }
  37533. declare module "babylonjs/Misc/perfCounter" {
  37534. /**
  37535. * This class is used to track a performance counter which is number based.
  37536. * The user has access to many properties which give statistics of different nature.
  37537. *
  37538. * The implementer can track two kinds of Performance Counter: time and count.
  37539. * 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.
  37540. * 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.
  37541. */
  37542. export class PerfCounter {
  37543. /**
  37544. * Gets or sets a global boolean to turn on and off all the counters
  37545. */
  37546. static Enabled: boolean;
  37547. /**
  37548. * Returns the smallest value ever
  37549. */
  37550. get min(): number;
  37551. /**
  37552. * Returns the biggest value ever
  37553. */
  37554. get max(): number;
  37555. /**
  37556. * Returns the average value since the performance counter is running
  37557. */
  37558. get average(): number;
  37559. /**
  37560. * Returns the average value of the last second the counter was monitored
  37561. */
  37562. get lastSecAverage(): number;
  37563. /**
  37564. * Returns the current value
  37565. */
  37566. get current(): number;
  37567. /**
  37568. * Gets the accumulated total
  37569. */
  37570. get total(): number;
  37571. /**
  37572. * Gets the total value count
  37573. */
  37574. get count(): number;
  37575. /**
  37576. * Creates a new counter
  37577. */
  37578. constructor();
  37579. /**
  37580. * Call this method to start monitoring a new frame.
  37581. * 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.
  37582. */
  37583. fetchNewFrame(): void;
  37584. /**
  37585. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37586. * @param newCount the count value to add to the monitored count
  37587. * @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.
  37588. */
  37589. addCount(newCount: number, fetchResult: boolean): void;
  37590. /**
  37591. * Start monitoring this performance counter
  37592. */
  37593. beginMonitoring(): void;
  37594. /**
  37595. * Compute the time lapsed since the previous beginMonitoring() call.
  37596. * @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
  37597. */
  37598. endMonitoring(newFrame?: boolean): void;
  37599. private _fetchResult;
  37600. private _startMonitoringTime;
  37601. private _min;
  37602. private _max;
  37603. private _average;
  37604. private _current;
  37605. private _totalValueCount;
  37606. private _totalAccumulated;
  37607. private _lastSecAverage;
  37608. private _lastSecAccumulated;
  37609. private _lastSecTime;
  37610. private _lastSecValueCount;
  37611. }
  37612. }
  37613. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37614. module "babylonjs/Engines/thinEngine" {
  37615. interface ThinEngine {
  37616. /**
  37617. * Sets alpha constants used by some alpha blending modes
  37618. * @param r defines the red component
  37619. * @param g defines the green component
  37620. * @param b defines the blue component
  37621. * @param a defines the alpha component
  37622. */
  37623. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37624. /**
  37625. * Sets the current alpha mode
  37626. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37627. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37628. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37629. */
  37630. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37631. /**
  37632. * Gets the current alpha mode
  37633. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37634. * @returns the current alpha mode
  37635. */
  37636. getAlphaMode(): number;
  37637. /**
  37638. * Sets the current alpha equation
  37639. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37640. */
  37641. setAlphaEquation(equation: number): void;
  37642. /**
  37643. * Gets the current alpha equation.
  37644. * @returns the current alpha equation
  37645. */
  37646. getAlphaEquation(): number;
  37647. }
  37648. }
  37649. }
  37650. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37652. import { Nullable } from "babylonjs/types";
  37653. module "babylonjs/Engines/thinEngine" {
  37654. interface ThinEngine {
  37655. /** @hidden */
  37656. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37657. }
  37658. }
  37659. }
  37660. declare module "babylonjs/Engines/engine" {
  37661. import { Observable } from "babylonjs/Misc/observable";
  37662. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37663. import { Scene } from "babylonjs/scene";
  37664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37665. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37666. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37667. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37668. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37669. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37670. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37671. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37672. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37673. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37674. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37675. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37676. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37677. import "babylonjs/Engines/Extensions/engine.alpha";
  37678. import "babylonjs/Engines/Extensions/engine.readTexture";
  37679. import { Material } from "babylonjs/Materials/material";
  37680. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37681. /**
  37682. * Defines the interface used by display changed events
  37683. */
  37684. export interface IDisplayChangedEventArgs {
  37685. /** Gets the vrDisplay object (if any) */
  37686. vrDisplay: Nullable<any>;
  37687. /** Gets a boolean indicating if webVR is supported */
  37688. vrSupported: boolean;
  37689. }
  37690. /**
  37691. * Defines the interface used by objects containing a viewport (like a camera)
  37692. */
  37693. interface IViewportOwnerLike {
  37694. /**
  37695. * Gets or sets the viewport
  37696. */
  37697. viewport: IViewportLike;
  37698. }
  37699. /**
  37700. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37701. */
  37702. export class Engine extends ThinEngine {
  37703. /** Defines that alpha blending is disabled */
  37704. static readonly ALPHA_DISABLE: number;
  37705. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37706. static readonly ALPHA_ADD: number;
  37707. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37708. static readonly ALPHA_COMBINE: number;
  37709. /** Defines that alpha blending to DEST - SRC * DEST */
  37710. static readonly ALPHA_SUBTRACT: number;
  37711. /** Defines that alpha blending to SRC * DEST */
  37712. static readonly ALPHA_MULTIPLY: number;
  37713. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37714. static readonly ALPHA_MAXIMIZED: number;
  37715. /** Defines that alpha blending to SRC + DEST */
  37716. static readonly ALPHA_ONEONE: number;
  37717. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37718. static readonly ALPHA_PREMULTIPLIED: number;
  37719. /**
  37720. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37721. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37722. */
  37723. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37724. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37725. static readonly ALPHA_INTERPOLATE: number;
  37726. /**
  37727. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37728. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37729. */
  37730. static readonly ALPHA_SCREENMODE: number;
  37731. /** Defines that the ressource is not delayed*/
  37732. static readonly DELAYLOADSTATE_NONE: number;
  37733. /** Defines that the ressource was successfully delay loaded */
  37734. static readonly DELAYLOADSTATE_LOADED: number;
  37735. /** Defines that the ressource is currently delay loading */
  37736. static readonly DELAYLOADSTATE_LOADING: number;
  37737. /** Defines that the ressource is delayed and has not started loading */
  37738. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37740. static readonly NEVER: number;
  37741. /** 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 */
  37742. static readonly ALWAYS: number;
  37743. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37744. static readonly LESS: number;
  37745. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37746. static readonly EQUAL: number;
  37747. /** 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 */
  37748. static readonly LEQUAL: number;
  37749. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37750. static readonly GREATER: number;
  37751. /** 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 */
  37752. static readonly GEQUAL: number;
  37753. /** 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 */
  37754. static readonly NOTEQUAL: number;
  37755. /** Passed to stencilOperation to specify that stencil value must be kept */
  37756. static readonly KEEP: number;
  37757. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37758. static readonly REPLACE: number;
  37759. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37760. static readonly INCR: number;
  37761. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37762. static readonly DECR: number;
  37763. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37764. static readonly INVERT: number;
  37765. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37766. static readonly INCR_WRAP: number;
  37767. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37768. static readonly DECR_WRAP: number;
  37769. /** Texture is not repeating outside of 0..1 UVs */
  37770. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37771. /** Texture is repeating outside of 0..1 UVs */
  37772. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37773. /** Texture is repeating and mirrored */
  37774. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37775. /** ALPHA */
  37776. static readonly TEXTUREFORMAT_ALPHA: number;
  37777. /** LUMINANCE */
  37778. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37779. /** LUMINANCE_ALPHA */
  37780. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37781. /** RGB */
  37782. static readonly TEXTUREFORMAT_RGB: number;
  37783. /** RGBA */
  37784. static readonly TEXTUREFORMAT_RGBA: number;
  37785. /** RED */
  37786. static readonly TEXTUREFORMAT_RED: number;
  37787. /** RED (2nd reference) */
  37788. static readonly TEXTUREFORMAT_R: number;
  37789. /** RG */
  37790. static readonly TEXTUREFORMAT_RG: number;
  37791. /** RED_INTEGER */
  37792. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37793. /** RED_INTEGER (2nd reference) */
  37794. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37795. /** RG_INTEGER */
  37796. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37797. /** RGB_INTEGER */
  37798. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37799. /** RGBA_INTEGER */
  37800. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37801. /** UNSIGNED_BYTE */
  37802. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37803. /** UNSIGNED_BYTE (2nd reference) */
  37804. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37805. /** FLOAT */
  37806. static readonly TEXTURETYPE_FLOAT: number;
  37807. /** HALF_FLOAT */
  37808. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37809. /** BYTE */
  37810. static readonly TEXTURETYPE_BYTE: number;
  37811. /** SHORT */
  37812. static readonly TEXTURETYPE_SHORT: number;
  37813. /** UNSIGNED_SHORT */
  37814. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37815. /** INT */
  37816. static readonly TEXTURETYPE_INT: number;
  37817. /** UNSIGNED_INT */
  37818. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37819. /** UNSIGNED_SHORT_4_4_4_4 */
  37820. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37821. /** UNSIGNED_SHORT_5_5_5_1 */
  37822. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37823. /** UNSIGNED_SHORT_5_6_5 */
  37824. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37825. /** UNSIGNED_INT_2_10_10_10_REV */
  37826. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37827. /** UNSIGNED_INT_24_8 */
  37828. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37829. /** UNSIGNED_INT_10F_11F_11F_REV */
  37830. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37831. /** UNSIGNED_INT_5_9_9_9_REV */
  37832. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37833. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37834. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37835. /** nearest is mag = nearest and min = nearest and mip = linear */
  37836. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37838. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37839. /** Trilinear is mag = linear and min = linear and mip = linear */
  37840. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37841. /** nearest is mag = nearest and min = nearest and mip = linear */
  37842. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37844. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37845. /** Trilinear is mag = linear and min = linear and mip = linear */
  37846. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37847. /** mag = nearest and min = nearest and mip = nearest */
  37848. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37849. /** mag = nearest and min = linear and mip = nearest */
  37850. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37851. /** mag = nearest and min = linear and mip = linear */
  37852. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37853. /** mag = nearest and min = linear and mip = none */
  37854. static readonly TEXTURE_NEAREST_LINEAR: number;
  37855. /** mag = nearest and min = nearest and mip = none */
  37856. static readonly TEXTURE_NEAREST_NEAREST: number;
  37857. /** mag = linear and min = nearest and mip = nearest */
  37858. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37859. /** mag = linear and min = nearest and mip = linear */
  37860. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37861. /** mag = linear and min = linear and mip = none */
  37862. static readonly TEXTURE_LINEAR_LINEAR: number;
  37863. /** mag = linear and min = nearest and mip = none */
  37864. static readonly TEXTURE_LINEAR_NEAREST: number;
  37865. /** Explicit coordinates mode */
  37866. static readonly TEXTURE_EXPLICIT_MODE: number;
  37867. /** Spherical coordinates mode */
  37868. static readonly TEXTURE_SPHERICAL_MODE: number;
  37869. /** Planar coordinates mode */
  37870. static readonly TEXTURE_PLANAR_MODE: number;
  37871. /** Cubic coordinates mode */
  37872. static readonly TEXTURE_CUBIC_MODE: number;
  37873. /** Projection coordinates mode */
  37874. static readonly TEXTURE_PROJECTION_MODE: number;
  37875. /** Skybox coordinates mode */
  37876. static readonly TEXTURE_SKYBOX_MODE: number;
  37877. /** Inverse Cubic coordinates mode */
  37878. static readonly TEXTURE_INVCUBIC_MODE: number;
  37879. /** Equirectangular coordinates mode */
  37880. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37881. /** Equirectangular Fixed coordinates mode */
  37882. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37883. /** Equirectangular Fixed Mirrored coordinates mode */
  37884. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37885. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37886. static readonly SCALEMODE_FLOOR: number;
  37887. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37888. static readonly SCALEMODE_NEAREST: number;
  37889. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37890. static readonly SCALEMODE_CEILING: number;
  37891. /**
  37892. * Returns the current npm package of the sdk
  37893. */
  37894. static get NpmPackage(): string;
  37895. /**
  37896. * Returns the current version of the framework
  37897. */
  37898. static get Version(): string;
  37899. /** Gets the list of created engines */
  37900. static get Instances(): Engine[];
  37901. /**
  37902. * Gets the latest created engine
  37903. */
  37904. static get LastCreatedEngine(): Nullable<Engine>;
  37905. /**
  37906. * Gets the latest created scene
  37907. */
  37908. static get LastCreatedScene(): Nullable<Scene>;
  37909. /**
  37910. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37911. * @param flag defines which part of the materials must be marked as dirty
  37912. * @param predicate defines a predicate used to filter which materials should be affected
  37913. */
  37914. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37915. /**
  37916. * Method called to create the default loading screen.
  37917. * This can be overriden in your own app.
  37918. * @param canvas The rendering canvas element
  37919. * @returns The loading screen
  37920. */
  37921. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37922. /**
  37923. * Method called to create the default rescale post process on each engine.
  37924. */
  37925. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37926. /**
  37927. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37928. **/
  37929. enableOfflineSupport: boolean;
  37930. /**
  37931. * 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)
  37932. **/
  37933. disableManifestCheck: boolean;
  37934. /**
  37935. * Gets the list of created scenes
  37936. */
  37937. scenes: Scene[];
  37938. /**
  37939. * Event raised when a new scene is created
  37940. */
  37941. onNewSceneAddedObservable: Observable<Scene>;
  37942. /**
  37943. * Gets the list of created postprocesses
  37944. */
  37945. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37946. /**
  37947. * Gets a boolean indicating if the pointer is currently locked
  37948. */
  37949. isPointerLock: boolean;
  37950. /**
  37951. * Observable event triggered each time the rendering canvas is resized
  37952. */
  37953. onResizeObservable: Observable<Engine>;
  37954. /**
  37955. * Observable event triggered each time the canvas loses focus
  37956. */
  37957. onCanvasBlurObservable: Observable<Engine>;
  37958. /**
  37959. * Observable event triggered each time the canvas gains focus
  37960. */
  37961. onCanvasFocusObservable: Observable<Engine>;
  37962. /**
  37963. * Observable event triggered each time the canvas receives pointerout event
  37964. */
  37965. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37966. /**
  37967. * Observable raised when the engine begins a new frame
  37968. */
  37969. onBeginFrameObservable: Observable<Engine>;
  37970. /**
  37971. * If set, will be used to request the next animation frame for the render loop
  37972. */
  37973. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37974. /**
  37975. * Observable raised when the engine ends the current frame
  37976. */
  37977. onEndFrameObservable: Observable<Engine>;
  37978. /**
  37979. * Observable raised when the engine is about to compile a shader
  37980. */
  37981. onBeforeShaderCompilationObservable: Observable<Engine>;
  37982. /**
  37983. * Observable raised when the engine has jsut compiled a shader
  37984. */
  37985. onAfterShaderCompilationObservable: Observable<Engine>;
  37986. /**
  37987. * Gets the audio engine
  37988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37989. * @ignorenaming
  37990. */
  37991. static audioEngine: IAudioEngine;
  37992. /**
  37993. * Default AudioEngine factory responsible of creating the Audio Engine.
  37994. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37995. */
  37996. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37997. /**
  37998. * Default offline support factory responsible of creating a tool used to store data locally.
  37999. * By default, this will create a Database object if the workload has been embedded.
  38000. */
  38001. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38002. private _loadingScreen;
  38003. private _pointerLockRequested;
  38004. private _rescalePostProcess;
  38005. private _deterministicLockstep;
  38006. private _lockstepMaxSteps;
  38007. private _timeStep;
  38008. protected get _supportsHardwareTextureRescaling(): boolean;
  38009. private _fps;
  38010. private _deltaTime;
  38011. /** @hidden */
  38012. _drawCalls: PerfCounter;
  38013. /** 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 */
  38014. canvasTabIndex: number;
  38015. /**
  38016. * Turn this value on if you want to pause FPS computation when in background
  38017. */
  38018. disablePerformanceMonitorInBackground: boolean;
  38019. private _performanceMonitor;
  38020. /**
  38021. * Gets the performance monitor attached to this engine
  38022. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38023. */
  38024. get performanceMonitor(): PerformanceMonitor;
  38025. private _onFocus;
  38026. private _onBlur;
  38027. private _onCanvasPointerOut;
  38028. private _onCanvasBlur;
  38029. private _onCanvasFocus;
  38030. private _onFullscreenChange;
  38031. private _onPointerLockChange;
  38032. /**
  38033. * Gets the HTML element used to attach event listeners
  38034. * @returns a HTML element
  38035. */
  38036. getInputElement(): Nullable<HTMLElement>;
  38037. /**
  38038. * Creates a new engine
  38039. * @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
  38040. * @param antialias defines enable antialiasing (default: false)
  38041. * @param options defines further options to be sent to the getContext() function
  38042. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38043. */
  38044. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38045. /**
  38046. * Gets current aspect ratio
  38047. * @param viewportOwner defines the camera to use to get the aspect ratio
  38048. * @param useScreen defines if screen size must be used (or the current render target if any)
  38049. * @returns a number defining the aspect ratio
  38050. */
  38051. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38052. /**
  38053. * Gets current screen aspect ratio
  38054. * @returns a number defining the aspect ratio
  38055. */
  38056. getScreenAspectRatio(): number;
  38057. /**
  38058. * Gets the client rect of the HTML canvas attached with the current webGL context
  38059. * @returns a client rectanglee
  38060. */
  38061. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38062. /**
  38063. * Gets the client rect of the HTML element used for events
  38064. * @returns a client rectanglee
  38065. */
  38066. getInputElementClientRect(): Nullable<ClientRect>;
  38067. /**
  38068. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38070. * @returns true if engine is in deterministic lock step mode
  38071. */
  38072. isDeterministicLockStep(): boolean;
  38073. /**
  38074. * Gets the max steps when engine is running in deterministic lock step
  38075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38076. * @returns the max steps
  38077. */
  38078. getLockstepMaxSteps(): number;
  38079. /**
  38080. * Returns the time in ms between steps when using deterministic lock step.
  38081. * @returns time step in (ms)
  38082. */
  38083. getTimeStep(): number;
  38084. /**
  38085. * Force the mipmap generation for the given render target texture
  38086. * @param texture defines the render target texture to use
  38087. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38088. */
  38089. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38090. /** States */
  38091. /**
  38092. * Set various states to the webGL context
  38093. * @param culling defines backface culling state
  38094. * @param zOffset defines the value to apply to zOffset (0 by default)
  38095. * @param force defines if states must be applied even if cache is up to date
  38096. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38097. */
  38098. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38099. /**
  38100. * Set the z offset to apply to current rendering
  38101. * @param value defines the offset to apply
  38102. */
  38103. setZOffset(value: number): void;
  38104. /**
  38105. * Gets the current value of the zOffset
  38106. * @returns the current zOffset state
  38107. */
  38108. getZOffset(): number;
  38109. /**
  38110. * Enable or disable depth buffering
  38111. * @param enable defines the state to set
  38112. */
  38113. setDepthBuffer(enable: boolean): void;
  38114. /**
  38115. * Gets a boolean indicating if depth writing is enabled
  38116. * @returns the current depth writing state
  38117. */
  38118. getDepthWrite(): boolean;
  38119. /**
  38120. * Enable or disable depth writing
  38121. * @param enable defines the state to set
  38122. */
  38123. setDepthWrite(enable: boolean): void;
  38124. /**
  38125. * Gets a boolean indicating if stencil buffer is enabled
  38126. * @returns the current stencil buffer state
  38127. */
  38128. getStencilBuffer(): boolean;
  38129. /**
  38130. * Enable or disable the stencil buffer
  38131. * @param enable defines if the stencil buffer must be enabled or disabled
  38132. */
  38133. setStencilBuffer(enable: boolean): void;
  38134. /**
  38135. * Gets the current stencil mask
  38136. * @returns a number defining the new stencil mask to use
  38137. */
  38138. getStencilMask(): number;
  38139. /**
  38140. * Sets the current stencil mask
  38141. * @param mask defines the new stencil mask to use
  38142. */
  38143. setStencilMask(mask: number): void;
  38144. /**
  38145. * Gets the current stencil function
  38146. * @returns a number defining the stencil function to use
  38147. */
  38148. getStencilFunction(): number;
  38149. /**
  38150. * Gets the current stencil reference value
  38151. * @returns a number defining the stencil reference value to use
  38152. */
  38153. getStencilFunctionReference(): number;
  38154. /**
  38155. * Gets the current stencil mask
  38156. * @returns a number defining the stencil mask to use
  38157. */
  38158. getStencilFunctionMask(): number;
  38159. /**
  38160. * Sets the current stencil function
  38161. * @param stencilFunc defines the new stencil function to use
  38162. */
  38163. setStencilFunction(stencilFunc: number): void;
  38164. /**
  38165. * Sets the current stencil reference
  38166. * @param reference defines the new stencil reference to use
  38167. */
  38168. setStencilFunctionReference(reference: number): void;
  38169. /**
  38170. * Sets the current stencil mask
  38171. * @param mask defines the new stencil mask to use
  38172. */
  38173. setStencilFunctionMask(mask: number): void;
  38174. /**
  38175. * Gets the current stencil operation when stencil fails
  38176. * @returns a number defining stencil operation to use when stencil fails
  38177. */
  38178. getStencilOperationFail(): number;
  38179. /**
  38180. * Gets the current stencil operation when depth fails
  38181. * @returns a number defining stencil operation to use when depth fails
  38182. */
  38183. getStencilOperationDepthFail(): number;
  38184. /**
  38185. * Gets the current stencil operation when stencil passes
  38186. * @returns a number defining stencil operation to use when stencil passes
  38187. */
  38188. getStencilOperationPass(): number;
  38189. /**
  38190. * Sets the stencil operation to use when stencil fails
  38191. * @param operation defines the stencil operation to use when stencil fails
  38192. */
  38193. setStencilOperationFail(operation: number): void;
  38194. /**
  38195. * Sets the stencil operation to use when depth fails
  38196. * @param operation defines the stencil operation to use when depth fails
  38197. */
  38198. setStencilOperationDepthFail(operation: number): void;
  38199. /**
  38200. * Sets the stencil operation to use when stencil passes
  38201. * @param operation defines the stencil operation to use when stencil passes
  38202. */
  38203. setStencilOperationPass(operation: number): void;
  38204. /**
  38205. * Sets a boolean indicating if the dithering state is enabled or disabled
  38206. * @param value defines the dithering state
  38207. */
  38208. setDitheringState(value: boolean): void;
  38209. /**
  38210. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38211. * @param value defines the rasterizer state
  38212. */
  38213. setRasterizerState(value: boolean): void;
  38214. /**
  38215. * Gets the current depth function
  38216. * @returns a number defining the depth function
  38217. */
  38218. getDepthFunction(): Nullable<number>;
  38219. /**
  38220. * Sets the current depth function
  38221. * @param depthFunc defines the function to use
  38222. */
  38223. setDepthFunction(depthFunc: number): void;
  38224. /**
  38225. * Sets the current depth function to GREATER
  38226. */
  38227. setDepthFunctionToGreater(): void;
  38228. /**
  38229. * Sets the current depth function to GEQUAL
  38230. */
  38231. setDepthFunctionToGreaterOrEqual(): void;
  38232. /**
  38233. * Sets the current depth function to LESS
  38234. */
  38235. setDepthFunctionToLess(): void;
  38236. /**
  38237. * Sets the current depth function to LEQUAL
  38238. */
  38239. setDepthFunctionToLessOrEqual(): void;
  38240. private _cachedStencilBuffer;
  38241. private _cachedStencilFunction;
  38242. private _cachedStencilMask;
  38243. private _cachedStencilOperationPass;
  38244. private _cachedStencilOperationFail;
  38245. private _cachedStencilOperationDepthFail;
  38246. private _cachedStencilReference;
  38247. /**
  38248. * Caches the the state of the stencil buffer
  38249. */
  38250. cacheStencilState(): void;
  38251. /**
  38252. * Restores the state of the stencil buffer
  38253. */
  38254. restoreStencilState(): void;
  38255. /**
  38256. * Directly set the WebGL Viewport
  38257. * @param x defines the x coordinate of the viewport (in screen space)
  38258. * @param y defines the y coordinate of the viewport (in screen space)
  38259. * @param width defines the width of the viewport (in screen space)
  38260. * @param height defines the height of the viewport (in screen space)
  38261. * @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
  38262. */
  38263. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38264. /**
  38265. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38266. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38267. * @param y defines the y-coordinate of the corner of the clear rectangle
  38268. * @param width defines the width of the clear rectangle
  38269. * @param height defines the height of the clear rectangle
  38270. * @param clearColor defines the clear color
  38271. */
  38272. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38273. /**
  38274. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38275. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38276. * @param y defines the y-coordinate of the corner of the clear rectangle
  38277. * @param width defines the width of the clear rectangle
  38278. * @param height defines the height of the clear rectangle
  38279. */
  38280. enableScissor(x: number, y: number, width: number, height: number): void;
  38281. /**
  38282. * Disable previously set scissor test rectangle
  38283. */
  38284. disableScissor(): void;
  38285. protected _reportDrawCall(): void;
  38286. /**
  38287. * Initializes a webVR display and starts listening to display change events
  38288. * The onVRDisplayChangedObservable will be notified upon these changes
  38289. * @returns The onVRDisplayChangedObservable
  38290. */
  38291. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38292. /** @hidden */
  38293. _prepareVRComponent(): void;
  38294. /** @hidden */
  38295. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38296. /** @hidden */
  38297. _submitVRFrame(): void;
  38298. /**
  38299. * Call this function to leave webVR mode
  38300. * Will do nothing if webVR is not supported or if there is no webVR device
  38301. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38302. */
  38303. disableVR(): void;
  38304. /**
  38305. * Gets a boolean indicating that the system is in VR mode and is presenting
  38306. * @returns true if VR mode is engaged
  38307. */
  38308. isVRPresenting(): boolean;
  38309. /** @hidden */
  38310. _requestVRFrame(): void;
  38311. /** @hidden */
  38312. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38313. /**
  38314. * Gets the source code of the vertex shader associated with a specific webGL program
  38315. * @param program defines the program to use
  38316. * @returns a string containing the source code of the vertex shader associated with the program
  38317. */
  38318. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38319. /**
  38320. * Gets the source code of the fragment shader associated with a specific webGL program
  38321. * @param program defines the program to use
  38322. * @returns a string containing the source code of the fragment shader associated with the program
  38323. */
  38324. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38325. /**
  38326. * Sets a depth stencil texture from a render target to the according uniform.
  38327. * @param channel The texture channel
  38328. * @param uniform The uniform to set
  38329. * @param texture The render target texture containing the depth stencil texture to apply
  38330. */
  38331. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38332. /**
  38333. * Sets a texture to the webGL context from a postprocess
  38334. * @param channel defines the channel to use
  38335. * @param postProcess defines the source postprocess
  38336. */
  38337. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38338. /**
  38339. * Binds the output of the passed in post process to the texture channel specified
  38340. * @param channel The channel the texture should be bound to
  38341. * @param postProcess The post process which's output should be bound
  38342. */
  38343. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38344. protected _rebuildBuffers(): void;
  38345. /** @hidden */
  38346. _renderFrame(): void;
  38347. _renderLoop(): void;
  38348. /** @hidden */
  38349. _renderViews(): boolean;
  38350. /**
  38351. * Toggle full screen mode
  38352. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38353. */
  38354. switchFullscreen(requestPointerLock: boolean): void;
  38355. /**
  38356. * Enters full screen mode
  38357. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38358. */
  38359. enterFullscreen(requestPointerLock: boolean): void;
  38360. /**
  38361. * Exits full screen mode
  38362. */
  38363. exitFullscreen(): void;
  38364. /**
  38365. * Enters Pointerlock mode
  38366. */
  38367. enterPointerlock(): void;
  38368. /**
  38369. * Exits Pointerlock mode
  38370. */
  38371. exitPointerlock(): void;
  38372. /**
  38373. * Begin a new frame
  38374. */
  38375. beginFrame(): void;
  38376. /**
  38377. * Enf the current frame
  38378. */
  38379. endFrame(): void;
  38380. resize(): void;
  38381. /**
  38382. * Force a specific size of the canvas
  38383. * @param width defines the new canvas' width
  38384. * @param height defines the new canvas' height
  38385. * @returns true if the size was changed
  38386. */
  38387. setSize(width: number, height: number): boolean;
  38388. /**
  38389. * Updates a dynamic vertex buffer.
  38390. * @param vertexBuffer the vertex buffer to update
  38391. * @param data the data used to update the vertex buffer
  38392. * @param byteOffset the byte offset of the data
  38393. * @param byteLength the byte length of the data
  38394. */
  38395. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38396. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38397. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38398. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38399. _releaseTexture(texture: InternalTexture): void;
  38400. /**
  38401. * @hidden
  38402. * Rescales a texture
  38403. * @param source input texutre
  38404. * @param destination destination texture
  38405. * @param scene scene to use to render the resize
  38406. * @param internalFormat format to use when resizing
  38407. * @param onComplete callback to be called when resize has completed
  38408. */
  38409. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38410. /**
  38411. * Gets the current framerate
  38412. * @returns a number representing the framerate
  38413. */
  38414. getFps(): number;
  38415. /**
  38416. * Gets the time spent between current and previous frame
  38417. * @returns a number representing the delta time in ms
  38418. */
  38419. getDeltaTime(): number;
  38420. private _measureFps;
  38421. /** @hidden */
  38422. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38423. /**
  38424. * Update a dynamic index buffer
  38425. * @param indexBuffer defines the target index buffer
  38426. * @param indices defines the data to update
  38427. * @param offset defines the offset in the target index buffer where update should start
  38428. */
  38429. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38430. /**
  38431. * Updates the sample count of a render target texture
  38432. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38433. * @param texture defines the texture to update
  38434. * @param samples defines the sample count to set
  38435. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38436. */
  38437. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38438. /**
  38439. * Updates a depth texture Comparison Mode and Function.
  38440. * If the comparison Function is equal to 0, the mode will be set to none.
  38441. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38442. * @param texture The texture to set the comparison function for
  38443. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38444. */
  38445. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38446. /**
  38447. * Creates a webGL buffer to use with instanciation
  38448. * @param capacity defines the size of the buffer
  38449. * @returns the webGL buffer
  38450. */
  38451. createInstancesBuffer(capacity: number): DataBuffer;
  38452. /**
  38453. * Delete a webGL buffer used with instanciation
  38454. * @param buffer defines the webGL buffer to delete
  38455. */
  38456. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38457. private _clientWaitAsync;
  38458. /** @hidden */
  38459. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38460. dispose(): void;
  38461. private _disableTouchAction;
  38462. /**
  38463. * Display the loading screen
  38464. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38465. */
  38466. displayLoadingUI(): void;
  38467. /**
  38468. * Hide the loading screen
  38469. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38470. */
  38471. hideLoadingUI(): void;
  38472. /**
  38473. * Gets the current loading screen object
  38474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38475. */
  38476. get loadingScreen(): ILoadingScreen;
  38477. /**
  38478. * Sets the current loading screen object
  38479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38480. */
  38481. set loadingScreen(loadingScreen: ILoadingScreen);
  38482. /**
  38483. * Sets the current loading screen text
  38484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38485. */
  38486. set loadingUIText(text: string);
  38487. /**
  38488. * Sets the current loading screen background color
  38489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38490. */
  38491. set loadingUIBackgroundColor(color: string);
  38492. /** Pointerlock and fullscreen */
  38493. /**
  38494. * Ask the browser to promote the current element to pointerlock mode
  38495. * @param element defines the DOM element to promote
  38496. */
  38497. static _RequestPointerlock(element: HTMLElement): void;
  38498. /**
  38499. * Asks the browser to exit pointerlock mode
  38500. */
  38501. static _ExitPointerlock(): void;
  38502. /**
  38503. * Ask the browser to promote the current element to fullscreen rendering mode
  38504. * @param element defines the DOM element to promote
  38505. */
  38506. static _RequestFullscreen(element: HTMLElement): void;
  38507. /**
  38508. * Asks the browser to exit fullscreen mode
  38509. */
  38510. static _ExitFullscreen(): void;
  38511. }
  38512. }
  38513. declare module "babylonjs/Engines/engineStore" {
  38514. import { Nullable } from "babylonjs/types";
  38515. import { Engine } from "babylonjs/Engines/engine";
  38516. import { Scene } from "babylonjs/scene";
  38517. /**
  38518. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38519. * during the life time of the application.
  38520. */
  38521. export class EngineStore {
  38522. /** Gets the list of created engines */
  38523. static Instances: import("babylonjs/Engines/engine").Engine[];
  38524. /** @hidden */
  38525. static _LastCreatedScene: Nullable<Scene>;
  38526. /**
  38527. * Gets the latest created engine
  38528. */
  38529. static get LastCreatedEngine(): Nullable<Engine>;
  38530. /**
  38531. * Gets the latest created scene
  38532. */
  38533. static get LastCreatedScene(): Nullable<Scene>;
  38534. /**
  38535. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38536. * @ignorenaming
  38537. */
  38538. static UseFallbackTexture: boolean;
  38539. /**
  38540. * Texture content used if a texture cannot loaded
  38541. * @ignorenaming
  38542. */
  38543. static FallbackTexture: string;
  38544. }
  38545. }
  38546. declare module "babylonjs/Misc/promise" {
  38547. /**
  38548. * Helper class that provides a small promise polyfill
  38549. */
  38550. export class PromisePolyfill {
  38551. /**
  38552. * Static function used to check if the polyfill is required
  38553. * If this is the case then the function will inject the polyfill to window.Promise
  38554. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38555. */
  38556. static Apply(force?: boolean): void;
  38557. }
  38558. }
  38559. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38560. /**
  38561. * Interface for screenshot methods with describe argument called `size` as object with options
  38562. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38563. */
  38564. export interface IScreenshotSize {
  38565. /**
  38566. * number in pixels for canvas height
  38567. */
  38568. height?: number;
  38569. /**
  38570. * multiplier allowing render at a higher or lower resolution
  38571. * If value is defined then height and width will be ignored and taken from camera
  38572. */
  38573. precision?: number;
  38574. /**
  38575. * number in pixels for canvas width
  38576. */
  38577. width?: number;
  38578. }
  38579. }
  38580. declare module "babylonjs/Misc/tools" {
  38581. import { Nullable, float } from "babylonjs/types";
  38582. import { DomManagement } from "babylonjs/Misc/domManagement";
  38583. import { WebRequest } from "babylonjs/Misc/webRequest";
  38584. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38585. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38586. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38587. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38588. import { Camera } from "babylonjs/Cameras/camera";
  38589. import { Engine } from "babylonjs/Engines/engine";
  38590. interface IColor4Like {
  38591. r: float;
  38592. g: float;
  38593. b: float;
  38594. a: float;
  38595. }
  38596. /**
  38597. * Class containing a set of static utilities functions
  38598. */
  38599. export class Tools {
  38600. /**
  38601. * Gets or sets the base URL to use to load assets
  38602. */
  38603. static get BaseUrl(): string;
  38604. static set BaseUrl(value: string);
  38605. /**
  38606. * Enable/Disable Custom HTTP Request Headers globally.
  38607. * default = false
  38608. * @see CustomRequestHeaders
  38609. */
  38610. static UseCustomRequestHeaders: boolean;
  38611. /**
  38612. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38613. * i.e. when loading files, where the server/service expects an Authorization header
  38614. */
  38615. static CustomRequestHeaders: {
  38616. [key: string]: string;
  38617. };
  38618. /**
  38619. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38620. */
  38621. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38622. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38623. /**
  38624. * Default behaviour for cors in the application.
  38625. * It can be a string if the expected behavior is identical in the entire app.
  38626. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38627. */
  38628. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38629. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38630. /**
  38631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38632. * @ignorenaming
  38633. */
  38634. static get UseFallbackTexture(): boolean;
  38635. static set UseFallbackTexture(value: boolean);
  38636. /**
  38637. * Use this object to register external classes like custom textures or material
  38638. * to allow the laoders to instantiate them
  38639. */
  38640. static get RegisteredExternalClasses(): {
  38641. [key: string]: Object;
  38642. };
  38643. static set RegisteredExternalClasses(classes: {
  38644. [key: string]: Object;
  38645. });
  38646. /**
  38647. * Texture content used if a texture cannot loaded
  38648. * @ignorenaming
  38649. */
  38650. static get fallbackTexture(): string;
  38651. static set fallbackTexture(value: string);
  38652. /**
  38653. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38654. * @param u defines the coordinate on X axis
  38655. * @param v defines the coordinate on Y axis
  38656. * @param width defines the width of the source data
  38657. * @param height defines the height of the source data
  38658. * @param pixels defines the source byte array
  38659. * @param color defines the output color
  38660. */
  38661. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38662. /**
  38663. * Interpolates between a and b via alpha
  38664. * @param a The lower value (returned when alpha = 0)
  38665. * @param b The upper value (returned when alpha = 1)
  38666. * @param alpha The interpolation-factor
  38667. * @return The mixed value
  38668. */
  38669. static Mix(a: number, b: number, alpha: number): number;
  38670. /**
  38671. * Tries to instantiate a new object from a given class name
  38672. * @param className defines the class name to instantiate
  38673. * @returns the new object or null if the system was not able to do the instantiation
  38674. */
  38675. static Instantiate(className: string): any;
  38676. /**
  38677. * Provides a slice function that will work even on IE
  38678. * @param data defines the array to slice
  38679. * @param start defines the start of the data (optional)
  38680. * @param end defines the end of the data (optional)
  38681. * @returns the new sliced array
  38682. */
  38683. static Slice<T>(data: T, start?: number, end?: number): T;
  38684. /**
  38685. * Polyfill for setImmediate
  38686. * @param action defines the action to execute after the current execution block
  38687. */
  38688. static SetImmediate(action: () => void): void;
  38689. /**
  38690. * Function indicating if a number is an exponent of 2
  38691. * @param value defines the value to test
  38692. * @returns true if the value is an exponent of 2
  38693. */
  38694. static IsExponentOfTwo(value: number): boolean;
  38695. private static _tmpFloatArray;
  38696. /**
  38697. * Returns the nearest 32-bit single precision float representation of a Number
  38698. * @param value A Number. If the parameter is of a different type, it will get converted
  38699. * to a number or to NaN if it cannot be converted
  38700. * @returns number
  38701. */
  38702. static FloatRound(value: number): number;
  38703. /**
  38704. * Extracts the filename from a path
  38705. * @param path defines the path to use
  38706. * @returns the filename
  38707. */
  38708. static GetFilename(path: string): string;
  38709. /**
  38710. * Extracts the "folder" part of a path (everything before the filename).
  38711. * @param uri The URI to extract the info from
  38712. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38713. * @returns The "folder" part of the path
  38714. */
  38715. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38716. /**
  38717. * Extracts text content from a DOM element hierarchy
  38718. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38719. */
  38720. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38721. /**
  38722. * Convert an angle in radians to degrees
  38723. * @param angle defines the angle to convert
  38724. * @returns the angle in degrees
  38725. */
  38726. static ToDegrees(angle: number): number;
  38727. /**
  38728. * Convert an angle in degrees to radians
  38729. * @param angle defines the angle to convert
  38730. * @returns the angle in radians
  38731. */
  38732. static ToRadians(angle: number): number;
  38733. /**
  38734. * Returns an array if obj is not an array
  38735. * @param obj defines the object to evaluate as an array
  38736. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38737. * @returns either obj directly if obj is an array or a new array containing obj
  38738. */
  38739. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38740. /**
  38741. * Gets the pointer prefix to use
  38742. * @param engine defines the engine we are finding the prefix for
  38743. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38744. */
  38745. static GetPointerPrefix(engine: Engine): string;
  38746. /**
  38747. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38748. * @param url define the url we are trying
  38749. * @param element define the dom element where to configure the cors policy
  38750. */
  38751. static SetCorsBehavior(url: string | string[], element: {
  38752. crossOrigin: string | null;
  38753. }): void;
  38754. /**
  38755. * Removes unwanted characters from an url
  38756. * @param url defines the url to clean
  38757. * @returns the cleaned url
  38758. */
  38759. static CleanUrl(url: string): string;
  38760. /**
  38761. * Gets or sets a function used to pre-process url before using them to load assets
  38762. */
  38763. static get PreprocessUrl(): (url: string) => string;
  38764. static set PreprocessUrl(processor: (url: string) => string);
  38765. /**
  38766. * Loads an image as an HTMLImageElement.
  38767. * @param input url string, ArrayBuffer, or Blob to load
  38768. * @param onLoad callback called when the image successfully loads
  38769. * @param onError callback called when the image fails to load
  38770. * @param offlineProvider offline provider for caching
  38771. * @param mimeType optional mime type
  38772. * @returns the HTMLImageElement of the loaded image
  38773. */
  38774. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38775. /**
  38776. * Loads a file from a url
  38777. * @param url url string, ArrayBuffer, or Blob to load
  38778. * @param onSuccess callback called when the file successfully loads
  38779. * @param onProgress callback called while file is loading (if the server supports this mode)
  38780. * @param offlineProvider defines the offline provider for caching
  38781. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38782. * @param onError callback called when the file fails to load
  38783. * @returns a file request object
  38784. */
  38785. 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;
  38786. /**
  38787. * Loads a file from a url
  38788. * @param url the file url to load
  38789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38790. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38791. */
  38792. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38793. /**
  38794. * Load a script (identified by an url). When the url returns, the
  38795. * content of this file is added into a new script element, attached to the DOM (body element)
  38796. * @param scriptUrl defines the url of the script to laod
  38797. * @param onSuccess defines the callback called when the script is loaded
  38798. * @param onError defines the callback to call if an error occurs
  38799. * @param scriptId defines the id of the script element
  38800. */
  38801. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38802. /**
  38803. * Load an asynchronous script (identified by an url). When the url returns, the
  38804. * content of this file is added into a new script element, attached to the DOM (body element)
  38805. * @param scriptUrl defines the url of the script to laod
  38806. * @param scriptId defines the id of the script element
  38807. * @returns a promise request object
  38808. */
  38809. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38810. /**
  38811. * Loads a file from a blob
  38812. * @param fileToLoad defines the blob to use
  38813. * @param callback defines the callback to call when data is loaded
  38814. * @param progressCallback defines the callback to call during loading process
  38815. * @returns a file request object
  38816. */
  38817. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38818. /**
  38819. * Reads a file from a File object
  38820. * @param file defines the file to load
  38821. * @param onSuccess defines the callback to call when data is loaded
  38822. * @param onProgress defines the callback to call during loading process
  38823. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38824. * @param onError defines the callback to call when an error occurs
  38825. * @returns a file request object
  38826. */
  38827. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38828. /**
  38829. * Creates a data url from a given string content
  38830. * @param content defines the content to convert
  38831. * @returns the new data url link
  38832. */
  38833. static FileAsURL(content: string): string;
  38834. /**
  38835. * Format the given number to a specific decimal format
  38836. * @param value defines the number to format
  38837. * @param decimals defines the number of decimals to use
  38838. * @returns the formatted string
  38839. */
  38840. static Format(value: number, decimals?: number): string;
  38841. /**
  38842. * Tries to copy an object by duplicating every property
  38843. * @param source defines the source object
  38844. * @param destination defines the target object
  38845. * @param doNotCopyList defines a list of properties to avoid
  38846. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38847. */
  38848. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38849. /**
  38850. * Gets a boolean indicating if the given object has no own property
  38851. * @param obj defines the object to test
  38852. * @returns true if object has no own property
  38853. */
  38854. static IsEmpty(obj: any): boolean;
  38855. /**
  38856. * Function used to register events at window level
  38857. * @param windowElement defines the Window object to use
  38858. * @param events defines the events to register
  38859. */
  38860. static RegisterTopRootEvents(windowElement: Window, events: {
  38861. name: string;
  38862. handler: Nullable<(e: FocusEvent) => any>;
  38863. }[]): void;
  38864. /**
  38865. * Function used to unregister events from window level
  38866. * @param windowElement defines the Window object to use
  38867. * @param events defines the events to unregister
  38868. */
  38869. static UnregisterTopRootEvents(windowElement: Window, events: {
  38870. name: string;
  38871. handler: Nullable<(e: FocusEvent) => any>;
  38872. }[]): void;
  38873. /**
  38874. * @ignore
  38875. */
  38876. static _ScreenshotCanvas: HTMLCanvasElement;
  38877. /**
  38878. * Dumps the current bound framebuffer
  38879. * @param width defines the rendering width
  38880. * @param height defines the rendering height
  38881. * @param engine defines the hosting engine
  38882. * @param successCallback defines the callback triggered once the data are available
  38883. * @param mimeType defines the mime type of the result
  38884. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38885. */
  38886. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38887. /**
  38888. * Converts the canvas data to blob.
  38889. * This acts as a polyfill for browsers not supporting the to blob function.
  38890. * @param canvas Defines the canvas to extract the data from
  38891. * @param successCallback Defines the callback triggered once the data are available
  38892. * @param mimeType Defines the mime type of the result
  38893. */
  38894. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38895. /**
  38896. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38897. * @param successCallback defines the callback triggered once the data are available
  38898. * @param mimeType defines the mime type of the result
  38899. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38900. */
  38901. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38902. /**
  38903. * Downloads a blob in the browser
  38904. * @param blob defines the blob to download
  38905. * @param fileName defines the name of the downloaded file
  38906. */
  38907. static Download(blob: Blob, fileName: string): void;
  38908. /**
  38909. * Captures a screenshot of the current rendering
  38910. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38911. * @param engine defines the rendering engine
  38912. * @param camera defines the source camera
  38913. * @param size This parameter can be set to a single number or to an object with the
  38914. * following (optional) properties: precision, width, height. If a single number is passed,
  38915. * it will be used for both width and height. If an object is passed, the screenshot size
  38916. * will be derived from the parameters. The precision property is a multiplier allowing
  38917. * rendering at a higher or lower resolution
  38918. * @param successCallback defines the callback receives a single parameter which contains the
  38919. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38920. * src parameter of an <img> to display it
  38921. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38922. * Check your browser for supported MIME types
  38923. */
  38924. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38925. /**
  38926. * Captures a screenshot of the current rendering
  38927. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38928. * @param engine defines the rendering engine
  38929. * @param camera defines the source camera
  38930. * @param size This parameter can be set to a single number or to an object with the
  38931. * following (optional) properties: precision, width, height. If a single number is passed,
  38932. * it will be used for both width and height. If an object is passed, the screenshot size
  38933. * will be derived from the parameters. The precision property is a multiplier allowing
  38934. * rendering at a higher or lower resolution
  38935. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38936. * Check your browser for supported MIME types
  38937. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38938. * to the src parameter of an <img> to display it
  38939. */
  38940. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38941. /**
  38942. * Generates an image screenshot from the specified camera.
  38943. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38944. * @param engine The engine to use for rendering
  38945. * @param camera The camera to use for rendering
  38946. * @param size This parameter can be set to a single number or to an object with the
  38947. * following (optional) properties: precision, width, height. If a single number is passed,
  38948. * it will be used for both width and height. If an object is passed, the screenshot size
  38949. * will be derived from the parameters. The precision property is a multiplier allowing
  38950. * rendering at a higher or lower resolution
  38951. * @param successCallback The callback receives a single parameter which contains the
  38952. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38953. * src parameter of an <img> to display it
  38954. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38955. * Check your browser for supported MIME types
  38956. * @param samples Texture samples (default: 1)
  38957. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38958. * @param fileName A name for for the downloaded file.
  38959. */
  38960. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38961. /**
  38962. * Generates an image screenshot from the specified camera.
  38963. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38964. * @param engine The engine to use for rendering
  38965. * @param camera The camera to use for rendering
  38966. * @param size This parameter can be set to a single number or to an object with the
  38967. * following (optional) properties: precision, width, height. If a single number is passed,
  38968. * it will be used for both width and height. If an object is passed, the screenshot size
  38969. * will be derived from the parameters. The precision property is a multiplier allowing
  38970. * rendering at a higher or lower resolution
  38971. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38972. * Check your browser for supported MIME types
  38973. * @param samples Texture samples (default: 1)
  38974. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38975. * @param fileName A name for for the downloaded file.
  38976. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38977. * to the src parameter of an <img> to display it
  38978. */
  38979. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38980. /**
  38981. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38982. * Be aware Math.random() could cause collisions, but:
  38983. * "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"
  38984. * @returns a pseudo random id
  38985. */
  38986. static RandomId(): string;
  38987. /**
  38988. * Test if the given uri is a base64 string
  38989. * @param uri The uri to test
  38990. * @return True if the uri is a base64 string or false otherwise
  38991. */
  38992. static IsBase64(uri: string): boolean;
  38993. /**
  38994. * Decode the given base64 uri.
  38995. * @param uri The uri to decode
  38996. * @return The decoded base64 data.
  38997. */
  38998. static DecodeBase64(uri: string): ArrayBuffer;
  38999. /**
  39000. * Gets the absolute url.
  39001. * @param url the input url
  39002. * @return the absolute url
  39003. */
  39004. static GetAbsoluteUrl(url: string): string;
  39005. /**
  39006. * No log
  39007. */
  39008. static readonly NoneLogLevel: number;
  39009. /**
  39010. * Only message logs
  39011. */
  39012. static readonly MessageLogLevel: number;
  39013. /**
  39014. * Only warning logs
  39015. */
  39016. static readonly WarningLogLevel: number;
  39017. /**
  39018. * Only error logs
  39019. */
  39020. static readonly ErrorLogLevel: number;
  39021. /**
  39022. * All logs
  39023. */
  39024. static readonly AllLogLevel: number;
  39025. /**
  39026. * Gets a value indicating the number of loading errors
  39027. * @ignorenaming
  39028. */
  39029. static get errorsCount(): number;
  39030. /**
  39031. * Callback called when a new log is added
  39032. */
  39033. static OnNewCacheEntry: (entry: string) => void;
  39034. /**
  39035. * Log a message to the console
  39036. * @param message defines the message to log
  39037. */
  39038. static Log(message: string): void;
  39039. /**
  39040. * Write a warning message to the console
  39041. * @param message defines the message to log
  39042. */
  39043. static Warn(message: string): void;
  39044. /**
  39045. * Write an error message to the console
  39046. * @param message defines the message to log
  39047. */
  39048. static Error(message: string): void;
  39049. /**
  39050. * Gets current log cache (list of logs)
  39051. */
  39052. static get LogCache(): string;
  39053. /**
  39054. * Clears the log cache
  39055. */
  39056. static ClearLogCache(): void;
  39057. /**
  39058. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39059. */
  39060. static set LogLevels(level: number);
  39061. /**
  39062. * Checks if the window object exists
  39063. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39064. */
  39065. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39066. /**
  39067. * No performance log
  39068. */
  39069. static readonly PerformanceNoneLogLevel: number;
  39070. /**
  39071. * Use user marks to log performance
  39072. */
  39073. static readonly PerformanceUserMarkLogLevel: number;
  39074. /**
  39075. * Log performance to the console
  39076. */
  39077. static readonly PerformanceConsoleLogLevel: number;
  39078. private static _performance;
  39079. /**
  39080. * Sets the current performance log level
  39081. */
  39082. static set PerformanceLogLevel(level: number);
  39083. private static _StartPerformanceCounterDisabled;
  39084. private static _EndPerformanceCounterDisabled;
  39085. private static _StartUserMark;
  39086. private static _EndUserMark;
  39087. private static _StartPerformanceConsole;
  39088. private static _EndPerformanceConsole;
  39089. /**
  39090. * Starts a performance counter
  39091. */
  39092. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39093. /**
  39094. * Ends a specific performance coutner
  39095. */
  39096. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39097. /**
  39098. * Gets either window.performance.now() if supported or Date.now() else
  39099. */
  39100. static get Now(): number;
  39101. /**
  39102. * This method will return the name of the class used to create the instance of the given object.
  39103. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39104. * @param object the object to get the class name from
  39105. * @param isType defines if the object is actually a type
  39106. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39107. */
  39108. static GetClassName(object: any, isType?: boolean): string;
  39109. /**
  39110. * Gets the first element of an array satisfying a given predicate
  39111. * @param array defines the array to browse
  39112. * @param predicate defines the predicate to use
  39113. * @returns null if not found or the element
  39114. */
  39115. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39116. /**
  39117. * This method will return the name of the full name of the class, including its owning module (if any).
  39118. * 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).
  39119. * @param object the object to get the class name from
  39120. * @param isType defines if the object is actually a type
  39121. * @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.
  39122. * @ignorenaming
  39123. */
  39124. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39125. /**
  39126. * Returns a promise that resolves after the given amount of time.
  39127. * @param delay Number of milliseconds to delay
  39128. * @returns Promise that resolves after the given amount of time
  39129. */
  39130. static DelayAsync(delay: number): Promise<void>;
  39131. /**
  39132. * Utility function to detect if the current user agent is Safari
  39133. * @returns whether or not the current user agent is safari
  39134. */
  39135. static IsSafari(): boolean;
  39136. }
  39137. /**
  39138. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39139. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39140. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39141. * @param name The name of the class, case should be preserved
  39142. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39143. */
  39144. export function className(name: string, module?: string): (target: Object) => void;
  39145. /**
  39146. * An implementation of a loop for asynchronous functions.
  39147. */
  39148. export class AsyncLoop {
  39149. /**
  39150. * Defines the number of iterations for the loop
  39151. */
  39152. iterations: number;
  39153. /**
  39154. * Defines the current index of the loop.
  39155. */
  39156. index: number;
  39157. private _done;
  39158. private _fn;
  39159. private _successCallback;
  39160. /**
  39161. * Constructor.
  39162. * @param iterations the number of iterations.
  39163. * @param func the function to run each iteration
  39164. * @param successCallback the callback that will be called upon succesful execution
  39165. * @param offset starting offset.
  39166. */
  39167. constructor(
  39168. /**
  39169. * Defines the number of iterations for the loop
  39170. */
  39171. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39172. /**
  39173. * Execute the next iteration. Must be called after the last iteration was finished.
  39174. */
  39175. executeNext(): void;
  39176. /**
  39177. * Break the loop and run the success callback.
  39178. */
  39179. breakLoop(): void;
  39180. /**
  39181. * Create and run an async loop.
  39182. * @param iterations the number of iterations.
  39183. * @param fn the function to run each iteration
  39184. * @param successCallback the callback that will be called upon succesful execution
  39185. * @param offset starting offset.
  39186. * @returns the created async loop object
  39187. */
  39188. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39189. /**
  39190. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39191. * @param iterations total number of iterations
  39192. * @param syncedIterations number of synchronous iterations in each async iteration.
  39193. * @param fn the function to call each iteration.
  39194. * @param callback a success call back that will be called when iterating stops.
  39195. * @param breakFunction a break condition (optional)
  39196. * @param timeout timeout settings for the setTimeout function. default - 0.
  39197. * @returns the created async loop object
  39198. */
  39199. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39200. }
  39201. }
  39202. declare module "babylonjs/Misc/stringDictionary" {
  39203. import { Nullable } from "babylonjs/types";
  39204. /**
  39205. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39206. * The underlying implementation relies on an associative array to ensure the best performances.
  39207. * The value can be anything including 'null' but except 'undefined'
  39208. */
  39209. export class StringDictionary<T> {
  39210. /**
  39211. * This will clear this dictionary and copy the content from the 'source' one.
  39212. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39213. * @param source the dictionary to take the content from and copy to this dictionary
  39214. */
  39215. copyFrom(source: StringDictionary<T>): void;
  39216. /**
  39217. * Get a value based from its key
  39218. * @param key the given key to get the matching value from
  39219. * @return the value if found, otherwise undefined is returned
  39220. */
  39221. get(key: string): T | undefined;
  39222. /**
  39223. * Get a value from its key or add it if it doesn't exist.
  39224. * This method will ensure you that a given key/data will be present in the dictionary.
  39225. * @param key the given key to get the matching value from
  39226. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39227. * The factory will only be invoked if there's no data for the given key.
  39228. * @return the value corresponding to the key.
  39229. */
  39230. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39231. /**
  39232. * Get a value from its key if present in the dictionary otherwise add it
  39233. * @param key the key to get the value from
  39234. * @param val if there's no such key/value pair in the dictionary add it with this value
  39235. * @return the value corresponding to the key
  39236. */
  39237. getOrAdd(key: string, val: T): T;
  39238. /**
  39239. * Check if there's a given key in the dictionary
  39240. * @param key the key to check for
  39241. * @return true if the key is present, false otherwise
  39242. */
  39243. contains(key: string): boolean;
  39244. /**
  39245. * Add a new key and its corresponding value
  39246. * @param key the key to add
  39247. * @param value the value corresponding to the key
  39248. * @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
  39249. */
  39250. add(key: string, value: T): boolean;
  39251. /**
  39252. * Update a specific value associated to a key
  39253. * @param key defines the key to use
  39254. * @param value defines the value to store
  39255. * @returns true if the value was updated (or false if the key was not found)
  39256. */
  39257. set(key: string, value: T): boolean;
  39258. /**
  39259. * Get the element of the given key and remove it from the dictionary
  39260. * @param key defines the key to search
  39261. * @returns the value associated with the key or null if not found
  39262. */
  39263. getAndRemove(key: string): Nullable<T>;
  39264. /**
  39265. * Remove a key/value from the dictionary.
  39266. * @param key the key to remove
  39267. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39268. */
  39269. remove(key: string): boolean;
  39270. /**
  39271. * Clear the whole content of the dictionary
  39272. */
  39273. clear(): void;
  39274. /**
  39275. * Gets the current count
  39276. */
  39277. get count(): number;
  39278. /**
  39279. * Execute a callback on each key/val of the dictionary.
  39280. * Note that you can remove any element in this dictionary in the callback implementation
  39281. * @param callback the callback to execute on a given key/value pair
  39282. */
  39283. forEach(callback: (key: string, val: T) => void): void;
  39284. /**
  39285. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39286. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39287. * Note that you can remove any element in this dictionary in the callback implementation
  39288. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39289. * @returns the first item
  39290. */
  39291. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39292. private _count;
  39293. private _data;
  39294. }
  39295. }
  39296. declare module "babylonjs/Collisions/collisionCoordinator" {
  39297. import { Nullable } from "babylonjs/types";
  39298. import { Scene } from "babylonjs/scene";
  39299. import { Vector3 } from "babylonjs/Maths/math.vector";
  39300. import { Collider } from "babylonjs/Collisions/collider";
  39301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39302. /** @hidden */
  39303. export interface ICollisionCoordinator {
  39304. createCollider(): Collider;
  39305. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39306. init(scene: Scene): void;
  39307. }
  39308. /** @hidden */
  39309. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39310. private _scene;
  39311. private _scaledPosition;
  39312. private _scaledVelocity;
  39313. private _finalPosition;
  39314. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39315. createCollider(): Collider;
  39316. init(scene: Scene): void;
  39317. private _collideWithWorld;
  39318. }
  39319. }
  39320. declare module "babylonjs/Inputs/scene.inputManager" {
  39321. import { Nullable } from "babylonjs/types";
  39322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39323. import { Vector2 } from "babylonjs/Maths/math.vector";
  39324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39325. import { Scene } from "babylonjs/scene";
  39326. /**
  39327. * Class used to manage all inputs for the scene.
  39328. */
  39329. export class InputManager {
  39330. /** The distance in pixel that you have to move to prevent some events */
  39331. static DragMovementThreshold: number;
  39332. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39333. static LongPressDelay: number;
  39334. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39335. static DoubleClickDelay: number;
  39336. /** If you need to check double click without raising a single click at first click, enable this flag */
  39337. static ExclusiveDoubleClickMode: boolean;
  39338. private _wheelEventName;
  39339. private _onPointerMove;
  39340. private _onPointerDown;
  39341. private _onPointerUp;
  39342. private _initClickEvent;
  39343. private _initActionManager;
  39344. private _delayedSimpleClick;
  39345. private _delayedSimpleClickTimeout;
  39346. private _previousDelayedSimpleClickTimeout;
  39347. private _meshPickProceed;
  39348. private _previousButtonPressed;
  39349. private _currentPickResult;
  39350. private _previousPickResult;
  39351. private _totalPointersPressed;
  39352. private _doubleClickOccured;
  39353. private _pointerOverMesh;
  39354. private _pickedDownMesh;
  39355. private _pickedUpMesh;
  39356. private _pointerX;
  39357. private _pointerY;
  39358. private _unTranslatedPointerX;
  39359. private _unTranslatedPointerY;
  39360. private _startingPointerPosition;
  39361. private _previousStartingPointerPosition;
  39362. private _startingPointerTime;
  39363. private _previousStartingPointerTime;
  39364. private _pointerCaptures;
  39365. private _onKeyDown;
  39366. private _onKeyUp;
  39367. private _onCanvasFocusObserver;
  39368. private _onCanvasBlurObserver;
  39369. private _scene;
  39370. /**
  39371. * Creates a new InputManager
  39372. * @param scene defines the hosting scene
  39373. */
  39374. constructor(scene: Scene);
  39375. /**
  39376. * Gets the mesh that is currently under the pointer
  39377. */
  39378. get meshUnderPointer(): Nullable<AbstractMesh>;
  39379. /**
  39380. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39381. */
  39382. get unTranslatedPointer(): Vector2;
  39383. /**
  39384. * Gets or sets the current on-screen X position of the pointer
  39385. */
  39386. get pointerX(): number;
  39387. set pointerX(value: number);
  39388. /**
  39389. * Gets or sets the current on-screen Y position of the pointer
  39390. */
  39391. get pointerY(): number;
  39392. set pointerY(value: number);
  39393. private _updatePointerPosition;
  39394. private _processPointerMove;
  39395. private _setRayOnPointerInfo;
  39396. private _checkPrePointerObservable;
  39397. /**
  39398. * Use this method to simulate a pointer move on a mesh
  39399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39402. */
  39403. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39404. /**
  39405. * Use this method to simulate a pointer down on a mesh
  39406. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39407. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39408. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39409. */
  39410. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39411. private _processPointerDown;
  39412. /** @hidden */
  39413. _isPointerSwiping(): boolean;
  39414. /**
  39415. * Use this method to simulate a pointer up on a mesh
  39416. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39417. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39418. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39419. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39420. */
  39421. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39422. private _processPointerUp;
  39423. /**
  39424. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39425. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39426. * @returns true if the pointer was captured
  39427. */
  39428. isPointerCaptured(pointerId?: number): boolean;
  39429. /**
  39430. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39431. * @param attachUp defines if you want to attach events to pointerup
  39432. * @param attachDown defines if you want to attach events to pointerdown
  39433. * @param attachMove defines if you want to attach events to pointermove
  39434. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39435. */
  39436. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39437. /**
  39438. * Detaches all event handlers
  39439. */
  39440. detachControl(): void;
  39441. /**
  39442. * Force the value of meshUnderPointer
  39443. * @param mesh defines the mesh to use
  39444. */
  39445. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39446. /**
  39447. * Gets the mesh under the pointer
  39448. * @returns a Mesh or null if no mesh is under the pointer
  39449. */
  39450. getPointerOverMesh(): Nullable<AbstractMesh>;
  39451. }
  39452. }
  39453. declare module "babylonjs/Animations/animationGroup" {
  39454. import { Animatable } from "babylonjs/Animations/animatable";
  39455. import { Animation } from "babylonjs/Animations/animation";
  39456. import { Scene, IDisposable } from "babylonjs/scene";
  39457. import { Observable } from "babylonjs/Misc/observable";
  39458. import { Nullable } from "babylonjs/types";
  39459. import "babylonjs/Animations/animatable";
  39460. /**
  39461. * This class defines the direct association between an animation and a target
  39462. */
  39463. export class TargetedAnimation {
  39464. /**
  39465. * Animation to perform
  39466. */
  39467. animation: Animation;
  39468. /**
  39469. * Target to animate
  39470. */
  39471. target: any;
  39472. /**
  39473. * Returns the string "TargetedAnimation"
  39474. * @returns "TargetedAnimation"
  39475. */
  39476. getClassName(): string;
  39477. /**
  39478. * Serialize the object
  39479. * @returns the JSON object representing the current entity
  39480. */
  39481. serialize(): any;
  39482. }
  39483. /**
  39484. * Use this class to create coordinated animations on multiple targets
  39485. */
  39486. export class AnimationGroup implements IDisposable {
  39487. /** The name of the animation group */
  39488. name: string;
  39489. private _scene;
  39490. private _targetedAnimations;
  39491. private _animatables;
  39492. private _from;
  39493. private _to;
  39494. private _isStarted;
  39495. private _isPaused;
  39496. private _speedRatio;
  39497. private _loopAnimation;
  39498. private _isAdditive;
  39499. /**
  39500. * Gets or sets the unique id of the node
  39501. */
  39502. uniqueId: number;
  39503. /**
  39504. * This observable will notify when one animation have ended
  39505. */
  39506. onAnimationEndObservable: Observable<TargetedAnimation>;
  39507. /**
  39508. * Observer raised when one animation loops
  39509. */
  39510. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39511. /**
  39512. * Observer raised when all animations have looped
  39513. */
  39514. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39515. /**
  39516. * This observable will notify when all animations have ended.
  39517. */
  39518. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39519. /**
  39520. * This observable will notify when all animations have paused.
  39521. */
  39522. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39523. /**
  39524. * This observable will notify when all animations are playing.
  39525. */
  39526. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39527. /**
  39528. * Gets the first frame
  39529. */
  39530. get from(): number;
  39531. /**
  39532. * Gets the last frame
  39533. */
  39534. get to(): number;
  39535. /**
  39536. * Define if the animations are started
  39537. */
  39538. get isStarted(): boolean;
  39539. /**
  39540. * Gets a value indicating that the current group is playing
  39541. */
  39542. get isPlaying(): boolean;
  39543. /**
  39544. * Gets or sets the speed ratio to use for all animations
  39545. */
  39546. get speedRatio(): number;
  39547. /**
  39548. * Gets or sets the speed ratio to use for all animations
  39549. */
  39550. set speedRatio(value: number);
  39551. /**
  39552. * Gets or sets if all animations should loop or not
  39553. */
  39554. get loopAnimation(): boolean;
  39555. set loopAnimation(value: boolean);
  39556. /**
  39557. * Gets or sets if all animations should be evaluated additively
  39558. */
  39559. get isAdditive(): boolean;
  39560. set isAdditive(value: boolean);
  39561. /**
  39562. * Gets the targeted animations for this animation group
  39563. */
  39564. get targetedAnimations(): Array<TargetedAnimation>;
  39565. /**
  39566. * returning the list of animatables controlled by this animation group.
  39567. */
  39568. get animatables(): Array<Animatable>;
  39569. /**
  39570. * Gets the list of target animations
  39571. */
  39572. get children(): TargetedAnimation[];
  39573. /**
  39574. * Instantiates a new Animation Group.
  39575. * This helps managing several animations at once.
  39576. * @see https://doc.babylonjs.com/how_to/group
  39577. * @param name Defines the name of the group
  39578. * @param scene Defines the scene the group belongs to
  39579. */
  39580. constructor(
  39581. /** The name of the animation group */
  39582. name: string, scene?: Nullable<Scene>);
  39583. /**
  39584. * Add an animation (with its target) in the group
  39585. * @param animation defines the animation we want to add
  39586. * @param target defines the target of the animation
  39587. * @returns the TargetedAnimation object
  39588. */
  39589. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39590. /**
  39591. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39592. * It can add constant keys at begin or end
  39593. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39594. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39595. * @returns the animation group
  39596. */
  39597. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39598. private _animationLoopCount;
  39599. private _animationLoopFlags;
  39600. private _processLoop;
  39601. /**
  39602. * Start all animations on given targets
  39603. * @param loop defines if animations must loop
  39604. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39605. * @param from defines the from key (optional)
  39606. * @param to defines the to key (optional)
  39607. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39608. * @returns the current animation group
  39609. */
  39610. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39611. /**
  39612. * Pause all animations
  39613. * @returns the animation group
  39614. */
  39615. pause(): AnimationGroup;
  39616. /**
  39617. * Play all animations to initial state
  39618. * This function will start() the animations if they were not started or will restart() them if they were paused
  39619. * @param loop defines if animations must loop
  39620. * @returns the animation group
  39621. */
  39622. play(loop?: boolean): AnimationGroup;
  39623. /**
  39624. * Reset all animations to initial state
  39625. * @returns the animation group
  39626. */
  39627. reset(): AnimationGroup;
  39628. /**
  39629. * Restart animations from key 0
  39630. * @returns the animation group
  39631. */
  39632. restart(): AnimationGroup;
  39633. /**
  39634. * Stop all animations
  39635. * @returns the animation group
  39636. */
  39637. stop(): AnimationGroup;
  39638. /**
  39639. * Set animation weight for all animatables
  39640. * @param weight defines the weight to use
  39641. * @return the animationGroup
  39642. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39643. */
  39644. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39645. /**
  39646. * Synchronize and normalize all animatables with a source animatable
  39647. * @param root defines the root animatable to synchronize with
  39648. * @return the animationGroup
  39649. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39650. */
  39651. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39652. /**
  39653. * Goes to a specific frame in this animation group
  39654. * @param frame the frame number to go to
  39655. * @return the animationGroup
  39656. */
  39657. goToFrame(frame: number): AnimationGroup;
  39658. /**
  39659. * Dispose all associated resources
  39660. */
  39661. dispose(): void;
  39662. private _checkAnimationGroupEnded;
  39663. /**
  39664. * Clone the current animation group and returns a copy
  39665. * @param newName defines the name of the new group
  39666. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39667. * @returns the new aniamtion group
  39668. */
  39669. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39670. /**
  39671. * Serializes the animationGroup to an object
  39672. * @returns Serialized object
  39673. */
  39674. serialize(): any;
  39675. /**
  39676. * Returns a new AnimationGroup object parsed from the source provided.
  39677. * @param parsedAnimationGroup defines the source
  39678. * @param scene defines the scene that will receive the animationGroup
  39679. * @returns a new AnimationGroup
  39680. */
  39681. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39682. /**
  39683. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39684. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39685. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39686. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39687. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39688. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39689. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39690. */
  39691. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39692. /**
  39693. * Returns the string "AnimationGroup"
  39694. * @returns "AnimationGroup"
  39695. */
  39696. getClassName(): string;
  39697. /**
  39698. * Creates a detailled string about the object
  39699. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39700. * @returns a string representing the object
  39701. */
  39702. toString(fullDetails?: boolean): string;
  39703. }
  39704. }
  39705. declare module "babylonjs/scene" {
  39706. import { Nullable } from "babylonjs/types";
  39707. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39708. import { Observable } from "babylonjs/Misc/observable";
  39709. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39710. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39711. import { Geometry } from "babylonjs/Meshes/geometry";
  39712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39715. import { Mesh } from "babylonjs/Meshes/mesh";
  39716. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39717. import { Bone } from "babylonjs/Bones/bone";
  39718. import { Skeleton } from "babylonjs/Bones/skeleton";
  39719. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39720. import { Camera } from "babylonjs/Cameras/camera";
  39721. import { AbstractScene } from "babylonjs/abstractScene";
  39722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39724. import { Material } from "babylonjs/Materials/material";
  39725. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39726. import { Effect } from "babylonjs/Materials/effect";
  39727. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39728. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39729. import { Light } from "babylonjs/Lights/light";
  39730. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39731. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39732. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39733. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39734. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39735. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39736. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39737. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39738. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39739. import { Engine } from "babylonjs/Engines/engine";
  39740. import { Node } from "babylonjs/node";
  39741. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39742. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39743. import { WebRequest } from "babylonjs/Misc/webRequest";
  39744. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39745. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39746. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39747. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39748. import { Plane } from "babylonjs/Maths/math.plane";
  39749. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39750. import { Ray } from "babylonjs/Culling/ray";
  39751. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39752. import { Animation } from "babylonjs/Animations/animation";
  39753. import { Animatable } from "babylonjs/Animations/animatable";
  39754. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39755. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39756. import { Collider } from "babylonjs/Collisions/collider";
  39757. /**
  39758. * Define an interface for all classes that will hold resources
  39759. */
  39760. export interface IDisposable {
  39761. /**
  39762. * Releases all held resources
  39763. */
  39764. dispose(): void;
  39765. }
  39766. /** Interface defining initialization parameters for Scene class */
  39767. export interface SceneOptions {
  39768. /**
  39769. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39770. * It will improve performance when the number of geometries becomes important.
  39771. */
  39772. useGeometryUniqueIdsMap?: boolean;
  39773. /**
  39774. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39775. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39776. */
  39777. useMaterialMeshMap?: boolean;
  39778. /**
  39779. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39780. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39781. */
  39782. useClonedMeshMap?: boolean;
  39783. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39784. virtual?: boolean;
  39785. }
  39786. /**
  39787. * Represents a scene to be rendered by the engine.
  39788. * @see https://doc.babylonjs.com/features/scene
  39789. */
  39790. export class Scene extends AbstractScene implements IAnimatable {
  39791. /** The fog is deactivated */
  39792. static readonly FOGMODE_NONE: number;
  39793. /** The fog density is following an exponential function */
  39794. static readonly FOGMODE_EXP: number;
  39795. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39796. static readonly FOGMODE_EXP2: number;
  39797. /** The fog density is following a linear function. */
  39798. static readonly FOGMODE_LINEAR: number;
  39799. /**
  39800. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39801. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39802. */
  39803. static MinDeltaTime: number;
  39804. /**
  39805. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39806. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39807. */
  39808. static MaxDeltaTime: number;
  39809. /**
  39810. * Factory used to create the default material.
  39811. * @param name The name of the material to create
  39812. * @param scene The scene to create the material for
  39813. * @returns The default material
  39814. */
  39815. static DefaultMaterialFactory(scene: Scene): Material;
  39816. /**
  39817. * Factory used to create the a collision coordinator.
  39818. * @returns The collision coordinator
  39819. */
  39820. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39821. /** @hidden */
  39822. _inputManager: InputManager;
  39823. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39824. cameraToUseForPointers: Nullable<Camera>;
  39825. /** @hidden */
  39826. readonly _isScene: boolean;
  39827. /** @hidden */
  39828. _blockEntityCollection: boolean;
  39829. /**
  39830. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39831. */
  39832. autoClear: boolean;
  39833. /**
  39834. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39835. */
  39836. autoClearDepthAndStencil: boolean;
  39837. /**
  39838. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39839. */
  39840. clearColor: Color4;
  39841. /**
  39842. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39843. */
  39844. ambientColor: Color3;
  39845. /**
  39846. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39847. * It should only be one of the following (if not the default embedded one):
  39848. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39849. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39850. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39851. * The material properties need to be setup according to the type of texture in use.
  39852. */
  39853. environmentBRDFTexture: BaseTexture;
  39854. /** @hidden */
  39855. protected _environmentTexture: Nullable<BaseTexture>;
  39856. /**
  39857. * Texture used in all pbr material as the reflection texture.
  39858. * As in the majority of the scene they are the same (exception for multi room and so on),
  39859. * this is easier to reference from here than from all the materials.
  39860. */
  39861. get environmentTexture(): Nullable<BaseTexture>;
  39862. /**
  39863. * Texture used in all pbr material as the reflection texture.
  39864. * As in the majority of the scene they are the same (exception for multi room and so on),
  39865. * this is easier to set here than in all the materials.
  39866. */
  39867. set environmentTexture(value: Nullable<BaseTexture>);
  39868. /** @hidden */
  39869. protected _environmentIntensity: number;
  39870. /**
  39871. * Intensity of the environment in all pbr material.
  39872. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39873. * As in the majority of the scene they are the same (exception for multi room and so on),
  39874. * this is easier to reference from here than from all the materials.
  39875. */
  39876. get environmentIntensity(): number;
  39877. /**
  39878. * Intensity of the environment in all pbr material.
  39879. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39880. * As in the majority of the scene they are the same (exception for multi room and so on),
  39881. * this is easier to set here than in all the materials.
  39882. */
  39883. set environmentIntensity(value: number);
  39884. /** @hidden */
  39885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39886. /**
  39887. * Default image processing configuration used either in the rendering
  39888. * Forward main pass or through the imageProcessingPostProcess if present.
  39889. * As in the majority of the scene they are the same (exception for multi camera),
  39890. * this is easier to reference from here than from all the materials and post process.
  39891. *
  39892. * No setter as we it is a shared configuration, you can set the values instead.
  39893. */
  39894. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39895. private _forceWireframe;
  39896. /**
  39897. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39898. */
  39899. set forceWireframe(value: boolean);
  39900. get forceWireframe(): boolean;
  39901. private _skipFrustumClipping;
  39902. /**
  39903. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39904. */
  39905. set skipFrustumClipping(value: boolean);
  39906. get skipFrustumClipping(): boolean;
  39907. private _forcePointsCloud;
  39908. /**
  39909. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39910. */
  39911. set forcePointsCloud(value: boolean);
  39912. get forcePointsCloud(): boolean;
  39913. /**
  39914. * Gets or sets the active clipplane 1
  39915. */
  39916. clipPlane: Nullable<Plane>;
  39917. /**
  39918. * Gets or sets the active clipplane 2
  39919. */
  39920. clipPlane2: Nullable<Plane>;
  39921. /**
  39922. * Gets or sets the active clipplane 3
  39923. */
  39924. clipPlane3: Nullable<Plane>;
  39925. /**
  39926. * Gets or sets the active clipplane 4
  39927. */
  39928. clipPlane4: Nullable<Plane>;
  39929. /**
  39930. * Gets or sets the active clipplane 5
  39931. */
  39932. clipPlane5: Nullable<Plane>;
  39933. /**
  39934. * Gets or sets the active clipplane 6
  39935. */
  39936. clipPlane6: Nullable<Plane>;
  39937. /**
  39938. * Gets or sets a boolean indicating if animations are enabled
  39939. */
  39940. animationsEnabled: boolean;
  39941. private _animationPropertiesOverride;
  39942. /**
  39943. * Gets or sets the animation properties override
  39944. */
  39945. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39946. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39947. /**
  39948. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39949. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39950. */
  39951. useConstantAnimationDeltaTime: boolean;
  39952. /**
  39953. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39954. * Please note that it requires to run a ray cast through the scene on every frame
  39955. */
  39956. constantlyUpdateMeshUnderPointer: boolean;
  39957. /**
  39958. * Defines the HTML cursor to use when hovering over interactive elements
  39959. */
  39960. hoverCursor: string;
  39961. /**
  39962. * Defines the HTML default cursor to use (empty by default)
  39963. */
  39964. defaultCursor: string;
  39965. /**
  39966. * Defines whether cursors are handled by the scene.
  39967. */
  39968. doNotHandleCursors: boolean;
  39969. /**
  39970. * This is used to call preventDefault() on pointer down
  39971. * in order to block unwanted artifacts like system double clicks
  39972. */
  39973. preventDefaultOnPointerDown: boolean;
  39974. /**
  39975. * This is used to call preventDefault() on pointer up
  39976. * in order to block unwanted artifacts like system double clicks
  39977. */
  39978. preventDefaultOnPointerUp: boolean;
  39979. /**
  39980. * Gets or sets user defined metadata
  39981. */
  39982. metadata: any;
  39983. /**
  39984. * For internal use only. Please do not use.
  39985. */
  39986. reservedDataStore: any;
  39987. /**
  39988. * Gets the name of the plugin used to load this scene (null by default)
  39989. */
  39990. loadingPluginName: string;
  39991. /**
  39992. * Use this array to add regular expressions used to disable offline support for specific urls
  39993. */
  39994. disableOfflineSupportExceptionRules: RegExp[];
  39995. /**
  39996. * An event triggered when the scene is disposed.
  39997. */
  39998. onDisposeObservable: Observable<Scene>;
  39999. private _onDisposeObserver;
  40000. /** Sets a function to be executed when this scene is disposed. */
  40001. set onDispose(callback: () => void);
  40002. /**
  40003. * An event triggered before rendering the scene (right after animations and physics)
  40004. */
  40005. onBeforeRenderObservable: Observable<Scene>;
  40006. private _onBeforeRenderObserver;
  40007. /** Sets a function to be executed before rendering this scene */
  40008. set beforeRender(callback: Nullable<() => void>);
  40009. /**
  40010. * An event triggered after rendering the scene
  40011. */
  40012. onAfterRenderObservable: Observable<Scene>;
  40013. /**
  40014. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40015. */
  40016. onAfterRenderCameraObservable: Observable<Camera>;
  40017. private _onAfterRenderObserver;
  40018. /** Sets a function to be executed after rendering this scene */
  40019. set afterRender(callback: Nullable<() => void>);
  40020. /**
  40021. * An event triggered before animating the scene
  40022. */
  40023. onBeforeAnimationsObservable: Observable<Scene>;
  40024. /**
  40025. * An event triggered after animations processing
  40026. */
  40027. onAfterAnimationsObservable: Observable<Scene>;
  40028. /**
  40029. * An event triggered before draw calls are ready to be sent
  40030. */
  40031. onBeforeDrawPhaseObservable: Observable<Scene>;
  40032. /**
  40033. * An event triggered after draw calls have been sent
  40034. */
  40035. onAfterDrawPhaseObservable: Observable<Scene>;
  40036. /**
  40037. * An event triggered when the scene is ready
  40038. */
  40039. onReadyObservable: Observable<Scene>;
  40040. /**
  40041. * An event triggered before rendering a camera
  40042. */
  40043. onBeforeCameraRenderObservable: Observable<Camera>;
  40044. private _onBeforeCameraRenderObserver;
  40045. /** Sets a function to be executed before rendering a camera*/
  40046. set beforeCameraRender(callback: () => void);
  40047. /**
  40048. * An event triggered after rendering a camera
  40049. */
  40050. onAfterCameraRenderObservable: Observable<Camera>;
  40051. private _onAfterCameraRenderObserver;
  40052. /** Sets a function to be executed after rendering a camera*/
  40053. set afterCameraRender(callback: () => void);
  40054. /**
  40055. * An event triggered when active meshes evaluation is about to start
  40056. */
  40057. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40058. /**
  40059. * An event triggered when active meshes evaluation is done
  40060. */
  40061. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40062. /**
  40063. * An event triggered when particles rendering is about to start
  40064. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40065. */
  40066. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40067. /**
  40068. * An event triggered when particles rendering is done
  40069. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40070. */
  40071. onAfterParticlesRenderingObservable: Observable<Scene>;
  40072. /**
  40073. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40074. */
  40075. onDataLoadedObservable: Observable<Scene>;
  40076. /**
  40077. * An event triggered when a camera is created
  40078. */
  40079. onNewCameraAddedObservable: Observable<Camera>;
  40080. /**
  40081. * An event triggered when a camera is removed
  40082. */
  40083. onCameraRemovedObservable: Observable<Camera>;
  40084. /**
  40085. * An event triggered when a light is created
  40086. */
  40087. onNewLightAddedObservable: Observable<Light>;
  40088. /**
  40089. * An event triggered when a light is removed
  40090. */
  40091. onLightRemovedObservable: Observable<Light>;
  40092. /**
  40093. * An event triggered when a geometry is created
  40094. */
  40095. onNewGeometryAddedObservable: Observable<Geometry>;
  40096. /**
  40097. * An event triggered when a geometry is removed
  40098. */
  40099. onGeometryRemovedObservable: Observable<Geometry>;
  40100. /**
  40101. * An event triggered when a transform node is created
  40102. */
  40103. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40104. /**
  40105. * An event triggered when a transform node is removed
  40106. */
  40107. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40108. /**
  40109. * An event triggered when a mesh is created
  40110. */
  40111. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40112. /**
  40113. * An event triggered when a mesh is removed
  40114. */
  40115. onMeshRemovedObservable: Observable<AbstractMesh>;
  40116. /**
  40117. * An event triggered when a skeleton is created
  40118. */
  40119. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40120. /**
  40121. * An event triggered when a skeleton is removed
  40122. */
  40123. onSkeletonRemovedObservable: Observable<Skeleton>;
  40124. /**
  40125. * An event triggered when a material is created
  40126. */
  40127. onNewMaterialAddedObservable: Observable<Material>;
  40128. /**
  40129. * An event triggered when a material is removed
  40130. */
  40131. onMaterialRemovedObservable: Observable<Material>;
  40132. /**
  40133. * An event triggered when a texture is created
  40134. */
  40135. onNewTextureAddedObservable: Observable<BaseTexture>;
  40136. /**
  40137. * An event triggered when a texture is removed
  40138. */
  40139. onTextureRemovedObservable: Observable<BaseTexture>;
  40140. /**
  40141. * An event triggered when render targets are about to be rendered
  40142. * Can happen multiple times per frame.
  40143. */
  40144. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40145. /**
  40146. * An event triggered when render targets were rendered.
  40147. * Can happen multiple times per frame.
  40148. */
  40149. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40150. /**
  40151. * An event triggered before calculating deterministic simulation step
  40152. */
  40153. onBeforeStepObservable: Observable<Scene>;
  40154. /**
  40155. * An event triggered after calculating deterministic simulation step
  40156. */
  40157. onAfterStepObservable: Observable<Scene>;
  40158. /**
  40159. * An event triggered when the activeCamera property is updated
  40160. */
  40161. onActiveCameraChanged: Observable<Scene>;
  40162. /**
  40163. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40164. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40165. * 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)
  40166. */
  40167. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40168. /**
  40169. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40170. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40171. * 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)
  40172. */
  40173. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40174. /**
  40175. * This Observable will when a mesh has been imported into the scene.
  40176. */
  40177. onMeshImportedObservable: Observable<AbstractMesh>;
  40178. /**
  40179. * This Observable will when an animation file has been imported into the scene.
  40180. */
  40181. onAnimationFileImportedObservable: Observable<Scene>;
  40182. /**
  40183. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40184. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40185. */
  40186. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40187. /** @hidden */
  40188. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40189. /**
  40190. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40191. */
  40192. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40193. /**
  40194. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40195. */
  40196. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40197. /**
  40198. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40199. */
  40200. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40201. /** Callback called when a pointer move is detected */
  40202. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40203. /** Callback called when a pointer down is detected */
  40204. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40205. /** Callback called when a pointer up is detected */
  40206. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40207. /** Callback called when a pointer pick is detected */
  40208. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40209. /**
  40210. * 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).
  40211. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40212. */
  40213. onPrePointerObservable: Observable<PointerInfoPre>;
  40214. /**
  40215. * Observable event triggered each time an input event is received from the rendering canvas
  40216. */
  40217. onPointerObservable: Observable<PointerInfo>;
  40218. /**
  40219. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40220. */
  40221. get unTranslatedPointer(): Vector2;
  40222. /**
  40223. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40224. */
  40225. static get DragMovementThreshold(): number;
  40226. static set DragMovementThreshold(value: number);
  40227. /**
  40228. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40229. */
  40230. static get LongPressDelay(): number;
  40231. static set LongPressDelay(value: number);
  40232. /**
  40233. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40234. */
  40235. static get DoubleClickDelay(): number;
  40236. static set DoubleClickDelay(value: number);
  40237. /** If you need to check double click without raising a single click at first click, enable this flag */
  40238. static get ExclusiveDoubleClickMode(): boolean;
  40239. static set ExclusiveDoubleClickMode(value: boolean);
  40240. /** @hidden */
  40241. _mirroredCameraPosition: Nullable<Vector3>;
  40242. /**
  40243. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40244. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40245. */
  40246. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40247. /**
  40248. * Observable event triggered each time an keyboard event is received from the hosting window
  40249. */
  40250. onKeyboardObservable: Observable<KeyboardInfo>;
  40251. private _useRightHandedSystem;
  40252. /**
  40253. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40254. */
  40255. set useRightHandedSystem(value: boolean);
  40256. get useRightHandedSystem(): boolean;
  40257. private _timeAccumulator;
  40258. private _currentStepId;
  40259. private _currentInternalStep;
  40260. /**
  40261. * Sets the step Id used by deterministic lock step
  40262. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40263. * @param newStepId defines the step Id
  40264. */
  40265. setStepId(newStepId: number): void;
  40266. /**
  40267. * Gets the step Id used by deterministic lock step
  40268. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40269. * @returns the step Id
  40270. */
  40271. getStepId(): number;
  40272. /**
  40273. * Gets the internal step used by deterministic lock step
  40274. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40275. * @returns the internal step
  40276. */
  40277. getInternalStep(): number;
  40278. private _fogEnabled;
  40279. /**
  40280. * Gets or sets a boolean indicating if fog is enabled on this scene
  40281. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40282. * (Default is true)
  40283. */
  40284. set fogEnabled(value: boolean);
  40285. get fogEnabled(): boolean;
  40286. private _fogMode;
  40287. /**
  40288. * Gets or sets the fog mode to use
  40289. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40290. * | mode | value |
  40291. * | --- | --- |
  40292. * | FOGMODE_NONE | 0 |
  40293. * | FOGMODE_EXP | 1 |
  40294. * | FOGMODE_EXP2 | 2 |
  40295. * | FOGMODE_LINEAR | 3 |
  40296. */
  40297. set fogMode(value: number);
  40298. get fogMode(): number;
  40299. /**
  40300. * Gets or sets the fog color to use
  40301. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40302. * (Default is Color3(0.2, 0.2, 0.3))
  40303. */
  40304. fogColor: Color3;
  40305. /**
  40306. * Gets or sets the fog density to use
  40307. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40308. * (Default is 0.1)
  40309. */
  40310. fogDensity: number;
  40311. /**
  40312. * Gets or sets the fog start distance to use
  40313. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40314. * (Default is 0)
  40315. */
  40316. fogStart: number;
  40317. /**
  40318. * Gets or sets the fog end distance to use
  40319. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40320. * (Default is 1000)
  40321. */
  40322. fogEnd: number;
  40323. /**
  40324. * Flag indicating that the frame buffer binding is handled by another component
  40325. */
  40326. prePass: boolean;
  40327. private _shadowsEnabled;
  40328. /**
  40329. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40330. */
  40331. set shadowsEnabled(value: boolean);
  40332. get shadowsEnabled(): boolean;
  40333. private _lightsEnabled;
  40334. /**
  40335. * Gets or sets a boolean indicating if lights are enabled on this scene
  40336. */
  40337. set lightsEnabled(value: boolean);
  40338. get lightsEnabled(): boolean;
  40339. /** All of the active cameras added to this scene. */
  40340. activeCameras: Camera[];
  40341. /** @hidden */
  40342. _activeCamera: Nullable<Camera>;
  40343. /** Gets or sets the current active camera */
  40344. get activeCamera(): Nullable<Camera>;
  40345. set activeCamera(value: Nullable<Camera>);
  40346. private _defaultMaterial;
  40347. /** The default material used on meshes when no material is affected */
  40348. get defaultMaterial(): Material;
  40349. /** The default material used on meshes when no material is affected */
  40350. set defaultMaterial(value: Material);
  40351. private _texturesEnabled;
  40352. /**
  40353. * Gets or sets a boolean indicating if textures are enabled on this scene
  40354. */
  40355. set texturesEnabled(value: boolean);
  40356. get texturesEnabled(): boolean;
  40357. /**
  40358. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40359. */
  40360. physicsEnabled: boolean;
  40361. /**
  40362. * Gets or sets a boolean indicating if particles are enabled on this scene
  40363. */
  40364. particlesEnabled: boolean;
  40365. /**
  40366. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40367. */
  40368. spritesEnabled: boolean;
  40369. private _skeletonsEnabled;
  40370. /**
  40371. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40372. */
  40373. set skeletonsEnabled(value: boolean);
  40374. get skeletonsEnabled(): boolean;
  40375. /**
  40376. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40377. */
  40378. lensFlaresEnabled: boolean;
  40379. /**
  40380. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40381. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40382. */
  40383. collisionsEnabled: boolean;
  40384. private _collisionCoordinator;
  40385. /** @hidden */
  40386. get collisionCoordinator(): ICollisionCoordinator;
  40387. /**
  40388. * Defines the gravity applied to this scene (used only for collisions)
  40389. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40390. */
  40391. gravity: Vector3;
  40392. /**
  40393. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40394. */
  40395. postProcessesEnabled: boolean;
  40396. /**
  40397. * The list of postprocesses added to the scene
  40398. */
  40399. postProcesses: PostProcess[];
  40400. /**
  40401. * Gets the current postprocess manager
  40402. */
  40403. postProcessManager: PostProcessManager;
  40404. /**
  40405. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40406. */
  40407. renderTargetsEnabled: boolean;
  40408. /**
  40409. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40410. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40411. */
  40412. dumpNextRenderTargets: boolean;
  40413. /**
  40414. * The list of user defined render targets added to the scene
  40415. */
  40416. customRenderTargets: RenderTargetTexture[];
  40417. /**
  40418. * Defines if texture loading must be delayed
  40419. * If true, textures will only be loaded when they need to be rendered
  40420. */
  40421. useDelayedTextureLoading: boolean;
  40422. /**
  40423. * Gets the list of meshes imported to the scene through SceneLoader
  40424. */
  40425. importedMeshesFiles: String[];
  40426. /**
  40427. * Gets or sets a boolean indicating if probes are enabled on this scene
  40428. */
  40429. probesEnabled: boolean;
  40430. /**
  40431. * Gets or sets the current offline provider to use to store scene data
  40432. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40433. */
  40434. offlineProvider: IOfflineProvider;
  40435. /**
  40436. * Gets or sets the action manager associated with the scene
  40437. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40438. */
  40439. actionManager: AbstractActionManager;
  40440. private _meshesForIntersections;
  40441. /**
  40442. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40443. */
  40444. proceduralTexturesEnabled: boolean;
  40445. private _engine;
  40446. private _totalVertices;
  40447. /** @hidden */
  40448. _activeIndices: PerfCounter;
  40449. /** @hidden */
  40450. _activeParticles: PerfCounter;
  40451. /** @hidden */
  40452. _activeBones: PerfCounter;
  40453. private _animationRatio;
  40454. /** @hidden */
  40455. _animationTimeLast: number;
  40456. /** @hidden */
  40457. _animationTime: number;
  40458. /**
  40459. * Gets or sets a general scale for animation speed
  40460. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40461. */
  40462. animationTimeScale: number;
  40463. /** @hidden */
  40464. _cachedMaterial: Nullable<Material>;
  40465. /** @hidden */
  40466. _cachedEffect: Nullable<Effect>;
  40467. /** @hidden */
  40468. _cachedVisibility: Nullable<number>;
  40469. private _renderId;
  40470. private _frameId;
  40471. private _executeWhenReadyTimeoutId;
  40472. private _intermediateRendering;
  40473. private _viewUpdateFlag;
  40474. private _projectionUpdateFlag;
  40475. /** @hidden */
  40476. _toBeDisposed: Nullable<IDisposable>[];
  40477. private _activeRequests;
  40478. /** @hidden */
  40479. _pendingData: any[];
  40480. private _isDisposed;
  40481. /**
  40482. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40483. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40484. */
  40485. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40486. private _activeMeshes;
  40487. private _processedMaterials;
  40488. private _renderTargets;
  40489. /** @hidden */
  40490. _activeParticleSystems: SmartArray<IParticleSystem>;
  40491. private _activeSkeletons;
  40492. private _softwareSkinnedMeshes;
  40493. private _renderingManager;
  40494. /** @hidden */
  40495. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40496. private _transformMatrix;
  40497. private _sceneUbo;
  40498. /** @hidden */
  40499. _viewMatrix: Matrix;
  40500. private _projectionMatrix;
  40501. /** @hidden */
  40502. _forcedViewPosition: Nullable<Vector3>;
  40503. /** @hidden */
  40504. _frustumPlanes: Plane[];
  40505. /**
  40506. * Gets the list of frustum planes (built from the active camera)
  40507. */
  40508. get frustumPlanes(): Plane[];
  40509. /**
  40510. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40511. * This is useful if there are more lights that the maximum simulteanous authorized
  40512. */
  40513. requireLightSorting: boolean;
  40514. /** @hidden */
  40515. readonly useMaterialMeshMap: boolean;
  40516. /** @hidden */
  40517. readonly useClonedMeshMap: boolean;
  40518. private _externalData;
  40519. private _uid;
  40520. /**
  40521. * @hidden
  40522. * Backing store of defined scene components.
  40523. */
  40524. _components: ISceneComponent[];
  40525. /**
  40526. * @hidden
  40527. * Backing store of defined scene components.
  40528. */
  40529. _serializableComponents: ISceneSerializableComponent[];
  40530. /**
  40531. * List of components to register on the next registration step.
  40532. */
  40533. private _transientComponents;
  40534. /**
  40535. * Registers the transient components if needed.
  40536. */
  40537. private _registerTransientComponents;
  40538. /**
  40539. * @hidden
  40540. * Add a component to the scene.
  40541. * Note that the ccomponent could be registered on th next frame if this is called after
  40542. * the register component stage.
  40543. * @param component Defines the component to add to the scene
  40544. */
  40545. _addComponent(component: ISceneComponent): void;
  40546. /**
  40547. * @hidden
  40548. * Gets a component from the scene.
  40549. * @param name defines the name of the component to retrieve
  40550. * @returns the component or null if not present
  40551. */
  40552. _getComponent(name: string): Nullable<ISceneComponent>;
  40553. /**
  40554. * @hidden
  40555. * Defines the actions happening before camera updates.
  40556. */
  40557. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40558. /**
  40559. * @hidden
  40560. * Defines the actions happening before clear the canvas.
  40561. */
  40562. _beforeClearStage: Stage<SimpleStageAction>;
  40563. /**
  40564. * @hidden
  40565. * Defines the actions when collecting render targets for the frame.
  40566. */
  40567. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40568. /**
  40569. * @hidden
  40570. * Defines the actions happening for one camera in the frame.
  40571. */
  40572. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40573. /**
  40574. * @hidden
  40575. * Defines the actions happening during the per mesh ready checks.
  40576. */
  40577. _isReadyForMeshStage: Stage<MeshStageAction>;
  40578. /**
  40579. * @hidden
  40580. * Defines the actions happening before evaluate active mesh checks.
  40581. */
  40582. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40583. /**
  40584. * @hidden
  40585. * Defines the actions happening during the evaluate sub mesh checks.
  40586. */
  40587. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40588. /**
  40589. * @hidden
  40590. * Defines the actions happening during the active mesh stage.
  40591. */
  40592. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40593. /**
  40594. * @hidden
  40595. * Defines the actions happening during the per camera render target step.
  40596. */
  40597. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40598. /**
  40599. * @hidden
  40600. * Defines the actions happening just before the active camera is drawing.
  40601. */
  40602. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40603. /**
  40604. * @hidden
  40605. * Defines the actions happening just before a render target is drawing.
  40606. */
  40607. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40608. /**
  40609. * @hidden
  40610. * Defines the actions happening just before a rendering group is drawing.
  40611. */
  40612. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40613. /**
  40614. * @hidden
  40615. * Defines the actions happening just before a mesh is drawing.
  40616. */
  40617. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40618. /**
  40619. * @hidden
  40620. * Defines the actions happening just after a mesh has been drawn.
  40621. */
  40622. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40623. /**
  40624. * @hidden
  40625. * Defines the actions happening just after a rendering group has been drawn.
  40626. */
  40627. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40628. /**
  40629. * @hidden
  40630. * Defines the actions happening just after the active camera has been drawn.
  40631. */
  40632. _afterCameraDrawStage: Stage<CameraStageAction>;
  40633. /**
  40634. * @hidden
  40635. * Defines the actions happening just after a render target has been drawn.
  40636. */
  40637. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40638. /**
  40639. * @hidden
  40640. * Defines the actions happening just after rendering all cameras and computing intersections.
  40641. */
  40642. _afterRenderStage: Stage<SimpleStageAction>;
  40643. /**
  40644. * @hidden
  40645. * Defines the actions happening when a pointer move event happens.
  40646. */
  40647. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40648. /**
  40649. * @hidden
  40650. * Defines the actions happening when a pointer down event happens.
  40651. */
  40652. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40653. /**
  40654. * @hidden
  40655. * Defines the actions happening when a pointer up event happens.
  40656. */
  40657. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40658. /**
  40659. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40660. */
  40661. private geometriesByUniqueId;
  40662. /**
  40663. * Creates a new Scene
  40664. * @param engine defines the engine to use to render this scene
  40665. * @param options defines the scene options
  40666. */
  40667. constructor(engine: Engine, options?: SceneOptions);
  40668. /**
  40669. * Gets a string idenfifying the name of the class
  40670. * @returns "Scene" string
  40671. */
  40672. getClassName(): string;
  40673. private _defaultMeshCandidates;
  40674. /**
  40675. * @hidden
  40676. */
  40677. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40678. private _defaultSubMeshCandidates;
  40679. /**
  40680. * @hidden
  40681. */
  40682. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40683. /**
  40684. * Sets the default candidate providers for the scene.
  40685. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40686. * and getCollidingSubMeshCandidates to their default function
  40687. */
  40688. setDefaultCandidateProviders(): void;
  40689. /**
  40690. * Gets the mesh that is currently under the pointer
  40691. */
  40692. get meshUnderPointer(): Nullable<AbstractMesh>;
  40693. /**
  40694. * Gets or sets the current on-screen X position of the pointer
  40695. */
  40696. get pointerX(): number;
  40697. set pointerX(value: number);
  40698. /**
  40699. * Gets or sets the current on-screen Y position of the pointer
  40700. */
  40701. get pointerY(): number;
  40702. set pointerY(value: number);
  40703. /**
  40704. * Gets the cached material (ie. the latest rendered one)
  40705. * @returns the cached material
  40706. */
  40707. getCachedMaterial(): Nullable<Material>;
  40708. /**
  40709. * Gets the cached effect (ie. the latest rendered one)
  40710. * @returns the cached effect
  40711. */
  40712. getCachedEffect(): Nullable<Effect>;
  40713. /**
  40714. * Gets the cached visibility state (ie. the latest rendered one)
  40715. * @returns the cached visibility state
  40716. */
  40717. getCachedVisibility(): Nullable<number>;
  40718. /**
  40719. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40720. * @param material defines the current material
  40721. * @param effect defines the current effect
  40722. * @param visibility defines the current visibility state
  40723. * @returns true if one parameter is not cached
  40724. */
  40725. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40726. /**
  40727. * Gets the engine associated with the scene
  40728. * @returns an Engine
  40729. */
  40730. getEngine(): Engine;
  40731. /**
  40732. * Gets the total number of vertices rendered per frame
  40733. * @returns the total number of vertices rendered per frame
  40734. */
  40735. getTotalVertices(): number;
  40736. /**
  40737. * Gets the performance counter for total vertices
  40738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40739. */
  40740. get totalVerticesPerfCounter(): PerfCounter;
  40741. /**
  40742. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40743. * @returns the total number of active indices rendered per frame
  40744. */
  40745. getActiveIndices(): number;
  40746. /**
  40747. * Gets the performance counter for active indices
  40748. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40749. */
  40750. get totalActiveIndicesPerfCounter(): PerfCounter;
  40751. /**
  40752. * Gets the total number of active particles rendered per frame
  40753. * @returns the total number of active particles rendered per frame
  40754. */
  40755. getActiveParticles(): number;
  40756. /**
  40757. * Gets the performance counter for active particles
  40758. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40759. */
  40760. get activeParticlesPerfCounter(): PerfCounter;
  40761. /**
  40762. * Gets the total number of active bones rendered per frame
  40763. * @returns the total number of active bones rendered per frame
  40764. */
  40765. getActiveBones(): number;
  40766. /**
  40767. * Gets the performance counter for active bones
  40768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40769. */
  40770. get activeBonesPerfCounter(): PerfCounter;
  40771. /**
  40772. * Gets the array of active meshes
  40773. * @returns an array of AbstractMesh
  40774. */
  40775. getActiveMeshes(): SmartArray<AbstractMesh>;
  40776. /**
  40777. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40778. * @returns a number
  40779. */
  40780. getAnimationRatio(): number;
  40781. /**
  40782. * Gets an unique Id for the current render phase
  40783. * @returns a number
  40784. */
  40785. getRenderId(): number;
  40786. /**
  40787. * Gets an unique Id for the current frame
  40788. * @returns a number
  40789. */
  40790. getFrameId(): number;
  40791. /** Call this function if you want to manually increment the render Id*/
  40792. incrementRenderId(): void;
  40793. private _createUbo;
  40794. /**
  40795. * Use this method to simulate a pointer move on a mesh
  40796. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40797. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40798. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40799. * @returns the current scene
  40800. */
  40801. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40802. /**
  40803. * Use this method to simulate a pointer down on a mesh
  40804. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40805. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40806. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40807. * @returns the current scene
  40808. */
  40809. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40810. /**
  40811. * Use this method to simulate a pointer up on a mesh
  40812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40815. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40816. * @returns the current scene
  40817. */
  40818. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40819. /**
  40820. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40821. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40822. * @returns true if the pointer was captured
  40823. */
  40824. isPointerCaptured(pointerId?: number): boolean;
  40825. /**
  40826. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40827. * @param attachUp defines if you want to attach events to pointerup
  40828. * @param attachDown defines if you want to attach events to pointerdown
  40829. * @param attachMove defines if you want to attach events to pointermove
  40830. */
  40831. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40832. /** Detaches all event handlers*/
  40833. detachControl(): void;
  40834. /**
  40835. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40836. * Delay loaded resources are not taking in account
  40837. * @return true if all required resources are ready
  40838. */
  40839. isReady(): boolean;
  40840. /** Resets all cached information relative to material (including effect and visibility) */
  40841. resetCachedMaterial(): void;
  40842. /**
  40843. * Registers a function to be called before every frame render
  40844. * @param func defines the function to register
  40845. */
  40846. registerBeforeRender(func: () => void): void;
  40847. /**
  40848. * Unregisters a function called before every frame render
  40849. * @param func defines the function to unregister
  40850. */
  40851. unregisterBeforeRender(func: () => void): void;
  40852. /**
  40853. * Registers a function to be called after every frame render
  40854. * @param func defines the function to register
  40855. */
  40856. registerAfterRender(func: () => void): void;
  40857. /**
  40858. * Unregisters a function called after every frame render
  40859. * @param func defines the function to unregister
  40860. */
  40861. unregisterAfterRender(func: () => void): void;
  40862. private _executeOnceBeforeRender;
  40863. /**
  40864. * The provided function will run before render once and will be disposed afterwards.
  40865. * A timeout delay can be provided so that the function will be executed in N ms.
  40866. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40867. * @param func The function to be executed.
  40868. * @param timeout optional delay in ms
  40869. */
  40870. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40871. /** @hidden */
  40872. _addPendingData(data: any): void;
  40873. /** @hidden */
  40874. _removePendingData(data: any): void;
  40875. /**
  40876. * Returns the number of items waiting to be loaded
  40877. * @returns the number of items waiting to be loaded
  40878. */
  40879. getWaitingItemsCount(): number;
  40880. /**
  40881. * Returns a boolean indicating if the scene is still loading data
  40882. */
  40883. get isLoading(): boolean;
  40884. /**
  40885. * Registers a function to be executed when the scene is ready
  40886. * @param {Function} func - the function to be executed
  40887. */
  40888. executeWhenReady(func: () => void): void;
  40889. /**
  40890. * Returns a promise that resolves when the scene is ready
  40891. * @returns A promise that resolves when the scene is ready
  40892. */
  40893. whenReadyAsync(): Promise<void>;
  40894. /** @hidden */
  40895. _checkIsReady(): void;
  40896. /**
  40897. * Gets all animatable attached to the scene
  40898. */
  40899. get animatables(): Animatable[];
  40900. /**
  40901. * Resets the last animation time frame.
  40902. * Useful to override when animations start running when loading a scene for the first time.
  40903. */
  40904. resetLastAnimationTimeFrame(): void;
  40905. /**
  40906. * Gets the current view matrix
  40907. * @returns a Matrix
  40908. */
  40909. getViewMatrix(): Matrix;
  40910. /**
  40911. * Gets the current projection matrix
  40912. * @returns a Matrix
  40913. */
  40914. getProjectionMatrix(): Matrix;
  40915. /**
  40916. * Gets the current transform matrix
  40917. * @returns a Matrix made of View * Projection
  40918. */
  40919. getTransformMatrix(): Matrix;
  40920. /**
  40921. * Sets the current transform matrix
  40922. * @param viewL defines the View matrix to use
  40923. * @param projectionL defines the Projection matrix to use
  40924. * @param viewR defines the right View matrix to use (if provided)
  40925. * @param projectionR defines the right Projection matrix to use (if provided)
  40926. */
  40927. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40928. /**
  40929. * Gets the uniform buffer used to store scene data
  40930. * @returns a UniformBuffer
  40931. */
  40932. getSceneUniformBuffer(): UniformBuffer;
  40933. /**
  40934. * Gets an unique (relatively to the current scene) Id
  40935. * @returns an unique number for the scene
  40936. */
  40937. getUniqueId(): number;
  40938. /**
  40939. * Add a mesh to the list of scene's meshes
  40940. * @param newMesh defines the mesh to add
  40941. * @param recursive if all child meshes should also be added to the scene
  40942. */
  40943. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40944. /**
  40945. * Remove a mesh for the list of scene's meshes
  40946. * @param toRemove defines the mesh to remove
  40947. * @param recursive if all child meshes should also be removed from the scene
  40948. * @returns the index where the mesh was in the mesh list
  40949. */
  40950. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40951. /**
  40952. * Add a transform node to the list of scene's transform nodes
  40953. * @param newTransformNode defines the transform node to add
  40954. */
  40955. addTransformNode(newTransformNode: TransformNode): void;
  40956. /**
  40957. * Remove a transform node for the list of scene's transform nodes
  40958. * @param toRemove defines the transform node to remove
  40959. * @returns the index where the transform node was in the transform node list
  40960. */
  40961. removeTransformNode(toRemove: TransformNode): number;
  40962. /**
  40963. * Remove a skeleton for the list of scene's skeletons
  40964. * @param toRemove defines the skeleton to remove
  40965. * @returns the index where the skeleton was in the skeleton list
  40966. */
  40967. removeSkeleton(toRemove: Skeleton): number;
  40968. /**
  40969. * Remove a morph target for the list of scene's morph targets
  40970. * @param toRemove defines the morph target to remove
  40971. * @returns the index where the morph target was in the morph target list
  40972. */
  40973. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40974. /**
  40975. * Remove a light for the list of scene's lights
  40976. * @param toRemove defines the light to remove
  40977. * @returns the index where the light was in the light list
  40978. */
  40979. removeLight(toRemove: Light): number;
  40980. /**
  40981. * Remove a camera for the list of scene's cameras
  40982. * @param toRemove defines the camera to remove
  40983. * @returns the index where the camera was in the camera list
  40984. */
  40985. removeCamera(toRemove: Camera): number;
  40986. /**
  40987. * Remove a particle system for the list of scene's particle systems
  40988. * @param toRemove defines the particle system to remove
  40989. * @returns the index where the particle system was in the particle system list
  40990. */
  40991. removeParticleSystem(toRemove: IParticleSystem): number;
  40992. /**
  40993. * Remove a animation for the list of scene's animations
  40994. * @param toRemove defines the animation to remove
  40995. * @returns the index where the animation was in the animation list
  40996. */
  40997. removeAnimation(toRemove: Animation): number;
  40998. /**
  40999. * Will stop the animation of the given target
  41000. * @param target - the target
  41001. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41002. * @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)
  41003. */
  41004. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41005. /**
  41006. * Removes the given animation group from this scene.
  41007. * @param toRemove The animation group to remove
  41008. * @returns The index of the removed animation group
  41009. */
  41010. removeAnimationGroup(toRemove: AnimationGroup): number;
  41011. /**
  41012. * Removes the given multi-material from this scene.
  41013. * @param toRemove The multi-material to remove
  41014. * @returns The index of the removed multi-material
  41015. */
  41016. removeMultiMaterial(toRemove: MultiMaterial): number;
  41017. /**
  41018. * Removes the given material from this scene.
  41019. * @param toRemove The material to remove
  41020. * @returns The index of the removed material
  41021. */
  41022. removeMaterial(toRemove: Material): number;
  41023. /**
  41024. * Removes the given action manager from this scene.
  41025. * @param toRemove The action manager to remove
  41026. * @returns The index of the removed action manager
  41027. */
  41028. removeActionManager(toRemove: AbstractActionManager): number;
  41029. /**
  41030. * Removes the given texture from this scene.
  41031. * @param toRemove The texture to remove
  41032. * @returns The index of the removed texture
  41033. */
  41034. removeTexture(toRemove: BaseTexture): number;
  41035. /**
  41036. * Adds the given light to this scene
  41037. * @param newLight The light to add
  41038. */
  41039. addLight(newLight: Light): void;
  41040. /**
  41041. * Sorts the list list based on light priorities
  41042. */
  41043. sortLightsByPriority(): void;
  41044. /**
  41045. * Adds the given camera to this scene
  41046. * @param newCamera The camera to add
  41047. */
  41048. addCamera(newCamera: Camera): void;
  41049. /**
  41050. * Adds the given skeleton to this scene
  41051. * @param newSkeleton The skeleton to add
  41052. */
  41053. addSkeleton(newSkeleton: Skeleton): void;
  41054. /**
  41055. * Adds the given particle system to this scene
  41056. * @param newParticleSystem The particle system to add
  41057. */
  41058. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41059. /**
  41060. * Adds the given animation to this scene
  41061. * @param newAnimation The animation to add
  41062. */
  41063. addAnimation(newAnimation: Animation): void;
  41064. /**
  41065. * Adds the given animation group to this scene.
  41066. * @param newAnimationGroup The animation group to add
  41067. */
  41068. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41069. /**
  41070. * Adds the given multi-material to this scene
  41071. * @param newMultiMaterial The multi-material to add
  41072. */
  41073. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41074. /**
  41075. * Adds the given material to this scene
  41076. * @param newMaterial The material to add
  41077. */
  41078. addMaterial(newMaterial: Material): void;
  41079. /**
  41080. * Adds the given morph target to this scene
  41081. * @param newMorphTargetManager The morph target to add
  41082. */
  41083. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41084. /**
  41085. * Adds the given geometry to this scene
  41086. * @param newGeometry The geometry to add
  41087. */
  41088. addGeometry(newGeometry: Geometry): void;
  41089. /**
  41090. * Adds the given action manager to this scene
  41091. * @param newActionManager The action manager to add
  41092. */
  41093. addActionManager(newActionManager: AbstractActionManager): void;
  41094. /**
  41095. * Adds the given texture to this scene.
  41096. * @param newTexture The texture to add
  41097. */
  41098. addTexture(newTexture: BaseTexture): void;
  41099. /**
  41100. * Switch active camera
  41101. * @param newCamera defines the new active camera
  41102. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41103. */
  41104. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41105. /**
  41106. * sets the active camera of the scene using its ID
  41107. * @param id defines the camera's ID
  41108. * @return the new active camera or null if none found.
  41109. */
  41110. setActiveCameraByID(id: string): Nullable<Camera>;
  41111. /**
  41112. * sets the active camera of the scene using its name
  41113. * @param name defines the camera's name
  41114. * @returns the new active camera or null if none found.
  41115. */
  41116. setActiveCameraByName(name: string): Nullable<Camera>;
  41117. /**
  41118. * get an animation group using its name
  41119. * @param name defines the material's name
  41120. * @return the animation group or null if none found.
  41121. */
  41122. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41123. /**
  41124. * Get a material using its unique id
  41125. * @param uniqueId defines the material's unique id
  41126. * @return the material or null if none found.
  41127. */
  41128. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41129. /**
  41130. * get a material using its id
  41131. * @param id defines the material's ID
  41132. * @return the material or null if none found.
  41133. */
  41134. getMaterialByID(id: string): Nullable<Material>;
  41135. /**
  41136. * Gets a the last added material using a given id
  41137. * @param id defines the material's ID
  41138. * @return the last material with the given id or null if none found.
  41139. */
  41140. getLastMaterialByID(id: string): Nullable<Material>;
  41141. /**
  41142. * Gets a material using its name
  41143. * @param name defines the material's name
  41144. * @return the material or null if none found.
  41145. */
  41146. getMaterialByName(name: string): Nullable<Material>;
  41147. /**
  41148. * Get a texture using its unique id
  41149. * @param uniqueId defines the texture's unique id
  41150. * @return the texture or null if none found.
  41151. */
  41152. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41153. /**
  41154. * Gets a camera using its id
  41155. * @param id defines the id to look for
  41156. * @returns the camera or null if not found
  41157. */
  41158. getCameraByID(id: string): Nullable<Camera>;
  41159. /**
  41160. * Gets a camera using its unique id
  41161. * @param uniqueId defines the unique id to look for
  41162. * @returns the camera or null if not found
  41163. */
  41164. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41165. /**
  41166. * Gets a camera using its name
  41167. * @param name defines the camera's name
  41168. * @return the camera or null if none found.
  41169. */
  41170. getCameraByName(name: string): Nullable<Camera>;
  41171. /**
  41172. * Gets a bone using its id
  41173. * @param id defines the bone's id
  41174. * @return the bone or null if not found
  41175. */
  41176. getBoneByID(id: string): Nullable<Bone>;
  41177. /**
  41178. * Gets a bone using its id
  41179. * @param name defines the bone's name
  41180. * @return the bone or null if not found
  41181. */
  41182. getBoneByName(name: string): Nullable<Bone>;
  41183. /**
  41184. * Gets a light node using its name
  41185. * @param name defines the the light's name
  41186. * @return the light or null if none found.
  41187. */
  41188. getLightByName(name: string): Nullable<Light>;
  41189. /**
  41190. * Gets a light node using its id
  41191. * @param id defines the light's id
  41192. * @return the light or null if none found.
  41193. */
  41194. getLightByID(id: string): Nullable<Light>;
  41195. /**
  41196. * Gets a light node using its scene-generated unique ID
  41197. * @param uniqueId defines the light's unique id
  41198. * @return the light or null if none found.
  41199. */
  41200. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41201. /**
  41202. * Gets a particle system by id
  41203. * @param id defines the particle system id
  41204. * @return the corresponding system or null if none found
  41205. */
  41206. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41207. /**
  41208. * Gets a geometry using its ID
  41209. * @param id defines the geometry's id
  41210. * @return the geometry or null if none found.
  41211. */
  41212. getGeometryByID(id: string): Nullable<Geometry>;
  41213. private _getGeometryByUniqueID;
  41214. /**
  41215. * Add a new geometry to this scene
  41216. * @param geometry defines the geometry to be added to the scene.
  41217. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41218. * @return a boolean defining if the geometry was added or not
  41219. */
  41220. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41221. /**
  41222. * Removes an existing geometry
  41223. * @param geometry defines the geometry to be removed from the scene
  41224. * @return a boolean defining if the geometry was removed or not
  41225. */
  41226. removeGeometry(geometry: Geometry): boolean;
  41227. /**
  41228. * Gets the list of geometries attached to the scene
  41229. * @returns an array of Geometry
  41230. */
  41231. getGeometries(): Geometry[];
  41232. /**
  41233. * Gets the first added mesh found of a given ID
  41234. * @param id defines the id to search for
  41235. * @return the mesh found or null if not found at all
  41236. */
  41237. getMeshByID(id: string): Nullable<AbstractMesh>;
  41238. /**
  41239. * Gets a list of meshes using their id
  41240. * @param id defines the id to search for
  41241. * @returns a list of meshes
  41242. */
  41243. getMeshesByID(id: string): Array<AbstractMesh>;
  41244. /**
  41245. * Gets the first added transform node found of a given ID
  41246. * @param id defines the id to search for
  41247. * @return the found transform node or null if not found at all.
  41248. */
  41249. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41250. /**
  41251. * Gets a transform node with its auto-generated unique id
  41252. * @param uniqueId efines the unique id to search for
  41253. * @return the found transform node or null if not found at all.
  41254. */
  41255. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41256. /**
  41257. * Gets a list of transform nodes using their id
  41258. * @param id defines the id to search for
  41259. * @returns a list of transform nodes
  41260. */
  41261. getTransformNodesByID(id: string): Array<TransformNode>;
  41262. /**
  41263. * Gets a mesh with its auto-generated unique id
  41264. * @param uniqueId defines the unique id to search for
  41265. * @return the found mesh or null if not found at all.
  41266. */
  41267. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41268. /**
  41269. * Gets a the last added mesh using a given id
  41270. * @param id defines the id to search for
  41271. * @return the found mesh or null if not found at all.
  41272. */
  41273. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41274. /**
  41275. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41276. * @param id defines the id to search for
  41277. * @return the found node or null if not found at all
  41278. */
  41279. getLastEntryByID(id: string): Nullable<Node>;
  41280. /**
  41281. * Gets a node (Mesh, Camera, Light) using a given id
  41282. * @param id defines the id to search for
  41283. * @return the found node or null if not found at all
  41284. */
  41285. getNodeByID(id: string): Nullable<Node>;
  41286. /**
  41287. * Gets a node (Mesh, Camera, Light) using a given name
  41288. * @param name defines the name to search for
  41289. * @return the found node or null if not found at all.
  41290. */
  41291. getNodeByName(name: string): Nullable<Node>;
  41292. /**
  41293. * Gets a mesh using a given name
  41294. * @param name defines the name to search for
  41295. * @return the found mesh or null if not found at all.
  41296. */
  41297. getMeshByName(name: string): Nullable<AbstractMesh>;
  41298. /**
  41299. * Gets a transform node using a given name
  41300. * @param name defines the name to search for
  41301. * @return the found transform node or null if not found at all.
  41302. */
  41303. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41304. /**
  41305. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41306. * @param id defines the id to search for
  41307. * @return the found skeleton or null if not found at all.
  41308. */
  41309. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41310. /**
  41311. * Gets a skeleton using a given auto generated unique id
  41312. * @param uniqueId defines the unique id to search for
  41313. * @return the found skeleton or null if not found at all.
  41314. */
  41315. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41316. /**
  41317. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41318. * @param id defines the id to search for
  41319. * @return the found skeleton or null if not found at all.
  41320. */
  41321. getSkeletonById(id: string): Nullable<Skeleton>;
  41322. /**
  41323. * Gets a skeleton using a given name
  41324. * @param name defines the name to search for
  41325. * @return the found skeleton or null if not found at all.
  41326. */
  41327. getSkeletonByName(name: string): Nullable<Skeleton>;
  41328. /**
  41329. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41330. * @param id defines the id to search for
  41331. * @return the found morph target manager or null if not found at all.
  41332. */
  41333. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41334. /**
  41335. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41336. * @param id defines the id to search for
  41337. * @return the found morph target or null if not found at all.
  41338. */
  41339. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41340. /**
  41341. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41342. * @param name defines the name to search for
  41343. * @return the found morph target or null if not found at all.
  41344. */
  41345. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41346. /**
  41347. * Gets a boolean indicating if the given mesh is active
  41348. * @param mesh defines the mesh to look for
  41349. * @returns true if the mesh is in the active list
  41350. */
  41351. isActiveMesh(mesh: AbstractMesh): boolean;
  41352. /**
  41353. * Return a unique id as a string which can serve as an identifier for the scene
  41354. */
  41355. get uid(): string;
  41356. /**
  41357. * Add an externaly attached data from its key.
  41358. * This method call will fail and return false, if such key already exists.
  41359. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41360. * @param key the unique key that identifies the data
  41361. * @param data the data object to associate to the key for this Engine instance
  41362. * @return true if no such key were already present and the data was added successfully, false otherwise
  41363. */
  41364. addExternalData<T>(key: string, data: T): boolean;
  41365. /**
  41366. * Get an externaly attached data from its key
  41367. * @param key the unique key that identifies the data
  41368. * @return the associated data, if present (can be null), or undefined if not present
  41369. */
  41370. getExternalData<T>(key: string): Nullable<T>;
  41371. /**
  41372. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41373. * @param key the unique key that identifies the data
  41374. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41375. * @return the associated data, can be null if the factory returned null.
  41376. */
  41377. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41378. /**
  41379. * Remove an externaly attached data from the Engine instance
  41380. * @param key the unique key that identifies the data
  41381. * @return true if the data was successfully removed, false if it doesn't exist
  41382. */
  41383. removeExternalData(key: string): boolean;
  41384. private _evaluateSubMesh;
  41385. /**
  41386. * Clear the processed materials smart array preventing retention point in material dispose.
  41387. */
  41388. freeProcessedMaterials(): void;
  41389. private _preventFreeActiveMeshesAndRenderingGroups;
  41390. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41391. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41392. * when disposing several meshes in a row or a hierarchy of meshes.
  41393. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41394. */
  41395. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41396. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41397. /**
  41398. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41399. */
  41400. freeActiveMeshes(): void;
  41401. /**
  41402. * Clear the info related to rendering groups preventing retention points during dispose.
  41403. */
  41404. freeRenderingGroups(): void;
  41405. /** @hidden */
  41406. _isInIntermediateRendering(): boolean;
  41407. /**
  41408. * Lambda returning the list of potentially active meshes.
  41409. */
  41410. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41411. /**
  41412. * Lambda returning the list of potentially active sub meshes.
  41413. */
  41414. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41415. /**
  41416. * Lambda returning the list of potentially intersecting sub meshes.
  41417. */
  41418. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41419. /**
  41420. * Lambda returning the list of potentially colliding sub meshes.
  41421. */
  41422. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41423. private _activeMeshesFrozen;
  41424. private _skipEvaluateActiveMeshesCompletely;
  41425. /**
  41426. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41427. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41428. * @returns the current scene
  41429. */
  41430. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41431. /**
  41432. * Use this function to restart evaluating active meshes on every frame
  41433. * @returns the current scene
  41434. */
  41435. unfreezeActiveMeshes(): Scene;
  41436. private _evaluateActiveMeshes;
  41437. private _activeMesh;
  41438. /**
  41439. * Update the transform matrix to update from the current active camera
  41440. * @param force defines a boolean used to force the update even if cache is up to date
  41441. */
  41442. updateTransformMatrix(force?: boolean): void;
  41443. private _bindFrameBuffer;
  41444. /** @hidden */
  41445. _allowPostProcessClearColor: boolean;
  41446. /** @hidden */
  41447. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41448. private _processSubCameras;
  41449. private _checkIntersections;
  41450. /** @hidden */
  41451. _advancePhysicsEngineStep(step: number): void;
  41452. /**
  41453. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41454. */
  41455. getDeterministicFrameTime: () => number;
  41456. /** @hidden */
  41457. _animate(): void;
  41458. /** Execute all animations (for a frame) */
  41459. animate(): void;
  41460. /**
  41461. * Render the scene
  41462. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41463. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41464. */
  41465. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41466. /**
  41467. * Freeze all materials
  41468. * A frozen material will not be updatable but should be faster to render
  41469. */
  41470. freezeMaterials(): void;
  41471. /**
  41472. * Unfreeze all materials
  41473. * A frozen material will not be updatable but should be faster to render
  41474. */
  41475. unfreezeMaterials(): void;
  41476. /**
  41477. * Releases all held ressources
  41478. */
  41479. dispose(): void;
  41480. /**
  41481. * Gets if the scene is already disposed
  41482. */
  41483. get isDisposed(): boolean;
  41484. /**
  41485. * Call this function to reduce memory footprint of the scene.
  41486. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41487. */
  41488. clearCachedVertexData(): void;
  41489. /**
  41490. * This function will remove the local cached buffer data from texture.
  41491. * It will save memory but will prevent the texture from being rebuilt
  41492. */
  41493. cleanCachedTextureBuffer(): void;
  41494. /**
  41495. * Get the world extend vectors with an optional filter
  41496. *
  41497. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41498. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41499. */
  41500. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41501. min: Vector3;
  41502. max: Vector3;
  41503. };
  41504. /**
  41505. * Creates a ray that can be used to pick in the scene
  41506. * @param x defines the x coordinate of the origin (on-screen)
  41507. * @param y defines the y coordinate of the origin (on-screen)
  41508. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41509. * @param camera defines the camera to use for the picking
  41510. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41511. * @returns a Ray
  41512. */
  41513. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41514. /**
  41515. * Creates a ray that can be used to pick in the scene
  41516. * @param x defines the x coordinate of the origin (on-screen)
  41517. * @param y defines the y coordinate of the origin (on-screen)
  41518. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41519. * @param result defines the ray where to store the picking ray
  41520. * @param camera defines the camera to use for the picking
  41521. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41522. * @returns the current scene
  41523. */
  41524. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41525. /**
  41526. * Creates a ray that can be used to pick in the scene
  41527. * @param x defines the x coordinate of the origin (on-screen)
  41528. * @param y defines the y coordinate of the origin (on-screen)
  41529. * @param camera defines the camera to use for the picking
  41530. * @returns a Ray
  41531. */
  41532. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41533. /**
  41534. * Creates a ray that can be used to pick in the scene
  41535. * @param x defines the x coordinate of the origin (on-screen)
  41536. * @param y defines the y coordinate of the origin (on-screen)
  41537. * @param result defines the ray where to store the picking ray
  41538. * @param camera defines the camera to use for the picking
  41539. * @returns the current scene
  41540. */
  41541. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41542. /** Launch a ray to try to pick a mesh in the scene
  41543. * @param x position on screen
  41544. * @param y position on screen
  41545. * @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
  41546. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41547. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41548. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41549. * @returns a PickingInfo
  41550. */
  41551. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41552. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41553. * @param x position on screen
  41554. * @param y position on screen
  41555. * @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
  41556. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41557. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41558. * @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)
  41559. */
  41560. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41561. /** Use the given ray to pick a mesh in the scene
  41562. * @param ray The ray to use to pick meshes
  41563. * @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
  41564. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41565. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41566. * @returns a PickingInfo
  41567. */
  41568. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41569. /**
  41570. * Launch a ray to try to pick a mesh in the scene
  41571. * @param x X position on screen
  41572. * @param y Y position on screen
  41573. * @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
  41574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41576. * @returns an array of PickingInfo
  41577. */
  41578. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41579. /**
  41580. * Launch a ray to try to pick a mesh in the scene
  41581. * @param ray Ray to use
  41582. * @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
  41583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41584. * @returns an array of PickingInfo
  41585. */
  41586. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41587. /**
  41588. * Force the value of meshUnderPointer
  41589. * @param mesh defines the mesh to use
  41590. */
  41591. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41592. /**
  41593. * Gets the mesh under the pointer
  41594. * @returns a Mesh or null if no mesh is under the pointer
  41595. */
  41596. getPointerOverMesh(): Nullable<AbstractMesh>;
  41597. /** @hidden */
  41598. _rebuildGeometries(): void;
  41599. /** @hidden */
  41600. _rebuildTextures(): void;
  41601. private _getByTags;
  41602. /**
  41603. * Get a list of meshes by tags
  41604. * @param tagsQuery defines the tags query to use
  41605. * @param forEach defines a predicate used to filter results
  41606. * @returns an array of Mesh
  41607. */
  41608. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41609. /**
  41610. * Get a list of cameras by tags
  41611. * @param tagsQuery defines the tags query to use
  41612. * @param forEach defines a predicate used to filter results
  41613. * @returns an array of Camera
  41614. */
  41615. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41616. /**
  41617. * Get a list of lights by tags
  41618. * @param tagsQuery defines the tags query to use
  41619. * @param forEach defines a predicate used to filter results
  41620. * @returns an array of Light
  41621. */
  41622. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41623. /**
  41624. * Get a list of materials by tags
  41625. * @param tagsQuery defines the tags query to use
  41626. * @param forEach defines a predicate used to filter results
  41627. * @returns an array of Material
  41628. */
  41629. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41630. /**
  41631. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41632. * This allowed control for front to back rendering or reversly depending of the special needs.
  41633. *
  41634. * @param renderingGroupId The rendering group id corresponding to its index
  41635. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41636. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41637. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41638. */
  41639. 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;
  41640. /**
  41641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41642. *
  41643. * @param renderingGroupId The rendering group id corresponding to its index
  41644. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41645. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41646. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41647. */
  41648. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41649. /**
  41650. * Gets the current auto clear configuration for one rendering group of the rendering
  41651. * manager.
  41652. * @param index the rendering group index to get the information for
  41653. * @returns The auto clear setup for the requested rendering group
  41654. */
  41655. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41656. private _blockMaterialDirtyMechanism;
  41657. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41658. get blockMaterialDirtyMechanism(): boolean;
  41659. set blockMaterialDirtyMechanism(value: boolean);
  41660. /**
  41661. * Will flag all materials as dirty to trigger new shader compilation
  41662. * @param flag defines the flag used to specify which material part must be marked as dirty
  41663. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41664. */
  41665. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41666. /** @hidden */
  41667. _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;
  41668. /** @hidden */
  41669. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41670. /** @hidden */
  41671. _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;
  41672. /** @hidden */
  41673. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41674. /** @hidden */
  41675. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41676. /** @hidden */
  41677. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41678. }
  41679. }
  41680. declare module "babylonjs/assetContainer" {
  41681. import { AbstractScene } from "babylonjs/abstractScene";
  41682. import { Scene } from "babylonjs/scene";
  41683. import { Mesh } from "babylonjs/Meshes/mesh";
  41684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41685. import { Skeleton } from "babylonjs/Bones/skeleton";
  41686. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41687. import { Animatable } from "babylonjs/Animations/animatable";
  41688. import { Nullable } from "babylonjs/types";
  41689. import { Node } from "babylonjs/node";
  41690. /**
  41691. * Set of assets to keep when moving a scene into an asset container.
  41692. */
  41693. export class KeepAssets extends AbstractScene {
  41694. }
  41695. /**
  41696. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41697. */
  41698. export class InstantiatedEntries {
  41699. /**
  41700. * List of new root nodes (eg. nodes with no parent)
  41701. */
  41702. rootNodes: TransformNode[];
  41703. /**
  41704. * List of new skeletons
  41705. */
  41706. skeletons: Skeleton[];
  41707. /**
  41708. * List of new animation groups
  41709. */
  41710. animationGroups: AnimationGroup[];
  41711. }
  41712. /**
  41713. * Container with a set of assets that can be added or removed from a scene.
  41714. */
  41715. export class AssetContainer extends AbstractScene {
  41716. private _wasAddedToScene;
  41717. /**
  41718. * The scene the AssetContainer belongs to.
  41719. */
  41720. scene: Scene;
  41721. /**
  41722. * Instantiates an AssetContainer.
  41723. * @param scene The scene the AssetContainer belongs to.
  41724. */
  41725. constructor(scene: Scene);
  41726. /**
  41727. * Instantiate or clone all meshes and add the new ones to the scene.
  41728. * Skeletons and animation groups will all be cloned
  41729. * @param nameFunction defines an optional function used to get new names for clones
  41730. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41731. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41732. */
  41733. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41734. /**
  41735. * Adds all the assets from the container to the scene.
  41736. */
  41737. addAllToScene(): void;
  41738. /**
  41739. * Removes all the assets in the container from the scene
  41740. */
  41741. removeAllFromScene(): void;
  41742. /**
  41743. * Disposes all the assets in the container
  41744. */
  41745. dispose(): void;
  41746. private _moveAssets;
  41747. /**
  41748. * Removes all the assets contained in the scene and adds them to the container.
  41749. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41750. */
  41751. moveAllFromScene(keepAssets?: KeepAssets): void;
  41752. /**
  41753. * 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.
  41754. * @returns the root mesh
  41755. */
  41756. createRootMesh(): Mesh;
  41757. /**
  41758. * Merge animations (direct and animation groups) from this asset container into a scene
  41759. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41760. * @param animatables set of animatables to retarget to a node from the scene
  41761. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41762. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41763. */
  41764. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41765. }
  41766. }
  41767. declare module "babylonjs/abstractScene" {
  41768. import { Scene } from "babylonjs/scene";
  41769. import { Nullable } from "babylonjs/types";
  41770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41772. import { Geometry } from "babylonjs/Meshes/geometry";
  41773. import { Skeleton } from "babylonjs/Bones/skeleton";
  41774. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41775. import { AssetContainer } from "babylonjs/assetContainer";
  41776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41777. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41779. import { Material } from "babylonjs/Materials/material";
  41780. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41781. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41782. import { Camera } from "babylonjs/Cameras/camera";
  41783. import { Light } from "babylonjs/Lights/light";
  41784. import { Node } from "babylonjs/node";
  41785. import { Animation } from "babylonjs/Animations/animation";
  41786. /**
  41787. * Defines how the parser contract is defined.
  41788. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41789. */
  41790. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41791. /**
  41792. * Defines how the individual parser contract is defined.
  41793. * These parser can parse an individual asset
  41794. */
  41795. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41796. /**
  41797. * Base class of the scene acting as a container for the different elements composing a scene.
  41798. * This class is dynamically extended by the different components of the scene increasing
  41799. * flexibility and reducing coupling
  41800. */
  41801. export abstract class AbstractScene {
  41802. /**
  41803. * Stores the list of available parsers in the application.
  41804. */
  41805. private static _BabylonFileParsers;
  41806. /**
  41807. * Stores the list of available individual parsers in the application.
  41808. */
  41809. private static _IndividualBabylonFileParsers;
  41810. /**
  41811. * Adds a parser in the list of available ones
  41812. * @param name Defines the name of the parser
  41813. * @param parser Defines the parser to add
  41814. */
  41815. static AddParser(name: string, parser: BabylonFileParser): void;
  41816. /**
  41817. * Gets a general parser from the list of avaialble ones
  41818. * @param name Defines the name of the parser
  41819. * @returns the requested parser or null
  41820. */
  41821. static GetParser(name: string): Nullable<BabylonFileParser>;
  41822. /**
  41823. * Adds n individual parser in the list of available ones
  41824. * @param name Defines the name of the parser
  41825. * @param parser Defines the parser to add
  41826. */
  41827. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41828. /**
  41829. * Gets an individual parser from the list of avaialble ones
  41830. * @param name Defines the name of the parser
  41831. * @returns the requested parser or null
  41832. */
  41833. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41834. /**
  41835. * Parser json data and populate both a scene and its associated container object
  41836. * @param jsonData Defines the data to parse
  41837. * @param scene Defines the scene to parse the data for
  41838. * @param container Defines the container attached to the parsing sequence
  41839. * @param rootUrl Defines the root url of the data
  41840. */
  41841. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41842. /**
  41843. * Gets the list of root nodes (ie. nodes with no parent)
  41844. */
  41845. rootNodes: Node[];
  41846. /** All of the cameras added to this scene
  41847. * @see https://doc.babylonjs.com/babylon101/cameras
  41848. */
  41849. cameras: Camera[];
  41850. /**
  41851. * All of the lights added to this scene
  41852. * @see https://doc.babylonjs.com/babylon101/lights
  41853. */
  41854. lights: Light[];
  41855. /**
  41856. * All of the (abstract) meshes added to this scene
  41857. */
  41858. meshes: AbstractMesh[];
  41859. /**
  41860. * The list of skeletons added to the scene
  41861. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41862. */
  41863. skeletons: Skeleton[];
  41864. /**
  41865. * All of the particle systems added to this scene
  41866. * @see https://doc.babylonjs.com/babylon101/particles
  41867. */
  41868. particleSystems: IParticleSystem[];
  41869. /**
  41870. * Gets a list of Animations associated with the scene
  41871. */
  41872. animations: Animation[];
  41873. /**
  41874. * All of the animation groups added to this scene
  41875. * @see https://doc.babylonjs.com/how_to/group
  41876. */
  41877. animationGroups: AnimationGroup[];
  41878. /**
  41879. * All of the multi-materials added to this scene
  41880. * @see https://doc.babylonjs.com/how_to/multi_materials
  41881. */
  41882. multiMaterials: MultiMaterial[];
  41883. /**
  41884. * All of the materials added to this scene
  41885. * In the context of a Scene, it is not supposed to be modified manually.
  41886. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41887. * Note also that the order of the Material within the array is not significant and might change.
  41888. * @see https://doc.babylonjs.com/babylon101/materials
  41889. */
  41890. materials: Material[];
  41891. /**
  41892. * The list of morph target managers added to the scene
  41893. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41894. */
  41895. morphTargetManagers: MorphTargetManager[];
  41896. /**
  41897. * The list of geometries used in the scene.
  41898. */
  41899. geometries: Geometry[];
  41900. /**
  41901. * All of the tranform nodes added to this scene
  41902. * In the context of a Scene, it is not supposed to be modified manually.
  41903. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41904. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41905. * @see https://doc.babylonjs.com/how_to/transformnode
  41906. */
  41907. transformNodes: TransformNode[];
  41908. /**
  41909. * ActionManagers available on the scene.
  41910. */
  41911. actionManagers: AbstractActionManager[];
  41912. /**
  41913. * Textures to keep.
  41914. */
  41915. textures: BaseTexture[];
  41916. /**
  41917. * Environment texture for the scene
  41918. */
  41919. environmentTexture: Nullable<BaseTexture>;
  41920. /**
  41921. * @returns all meshes, lights, cameras, transformNodes and bones
  41922. */
  41923. getNodes(): Array<Node>;
  41924. }
  41925. }
  41926. declare module "babylonjs/Audio/sound" {
  41927. import { Observable } from "babylonjs/Misc/observable";
  41928. import { Vector3 } from "babylonjs/Maths/math.vector";
  41929. import { Nullable } from "babylonjs/types";
  41930. import { Scene } from "babylonjs/scene";
  41931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41932. /**
  41933. * Interface used to define options for Sound class
  41934. */
  41935. export interface ISoundOptions {
  41936. /**
  41937. * Does the sound autoplay once loaded.
  41938. */
  41939. autoplay?: boolean;
  41940. /**
  41941. * Does the sound loop after it finishes playing once.
  41942. */
  41943. loop?: boolean;
  41944. /**
  41945. * Sound's volume
  41946. */
  41947. volume?: number;
  41948. /**
  41949. * Is it a spatial sound?
  41950. */
  41951. spatialSound?: boolean;
  41952. /**
  41953. * Maximum distance to hear that sound
  41954. */
  41955. maxDistance?: number;
  41956. /**
  41957. * Uses user defined attenuation function
  41958. */
  41959. useCustomAttenuation?: boolean;
  41960. /**
  41961. * Define the roll off factor of spatial sounds.
  41962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41963. */
  41964. rolloffFactor?: number;
  41965. /**
  41966. * Define the reference distance the sound should be heard perfectly.
  41967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41968. */
  41969. refDistance?: number;
  41970. /**
  41971. * Define the distance attenuation model the sound will follow.
  41972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41973. */
  41974. distanceModel?: string;
  41975. /**
  41976. * Defines the playback speed (1 by default)
  41977. */
  41978. playbackRate?: number;
  41979. /**
  41980. * Defines if the sound is from a streaming source
  41981. */
  41982. streaming?: boolean;
  41983. /**
  41984. * Defines an optional length (in seconds) inside the sound file
  41985. */
  41986. length?: number;
  41987. /**
  41988. * Defines an optional offset (in seconds) inside the sound file
  41989. */
  41990. offset?: number;
  41991. /**
  41992. * If true, URLs will not be required to state the audio file codec to use.
  41993. */
  41994. skipCodecCheck?: boolean;
  41995. }
  41996. /**
  41997. * Defines a sound that can be played in the application.
  41998. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42000. */
  42001. export class Sound {
  42002. /**
  42003. * The name of the sound in the scene.
  42004. */
  42005. name: string;
  42006. /**
  42007. * Does the sound autoplay once loaded.
  42008. */
  42009. autoplay: boolean;
  42010. /**
  42011. * Does the sound loop after it finishes playing once.
  42012. */
  42013. loop: boolean;
  42014. /**
  42015. * Does the sound use a custom attenuation curve to simulate the falloff
  42016. * happening when the source gets further away from the camera.
  42017. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42018. */
  42019. useCustomAttenuation: boolean;
  42020. /**
  42021. * The sound track id this sound belongs to.
  42022. */
  42023. soundTrackId: number;
  42024. /**
  42025. * Is this sound currently played.
  42026. */
  42027. isPlaying: boolean;
  42028. /**
  42029. * Is this sound currently paused.
  42030. */
  42031. isPaused: boolean;
  42032. /**
  42033. * Does this sound enables spatial sound.
  42034. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42035. */
  42036. spatialSound: boolean;
  42037. /**
  42038. * Define the reference distance the sound should be heard perfectly.
  42039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42040. */
  42041. refDistance: number;
  42042. /**
  42043. * Define the roll off factor of spatial sounds.
  42044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42045. */
  42046. rolloffFactor: number;
  42047. /**
  42048. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42050. */
  42051. maxDistance: number;
  42052. /**
  42053. * Define the distance attenuation model the sound will follow.
  42054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42055. */
  42056. distanceModel: string;
  42057. /**
  42058. * @hidden
  42059. * Back Compat
  42060. **/
  42061. onended: () => any;
  42062. /**
  42063. * Gets or sets an object used to store user defined information for the sound.
  42064. */
  42065. metadata: any;
  42066. /**
  42067. * Observable event when the current playing sound finishes.
  42068. */
  42069. onEndedObservable: Observable<Sound>;
  42070. private _panningModel;
  42071. private _playbackRate;
  42072. private _streaming;
  42073. private _startTime;
  42074. private _startOffset;
  42075. private _position;
  42076. /** @hidden */
  42077. _positionInEmitterSpace: boolean;
  42078. private _localDirection;
  42079. private _volume;
  42080. private _isReadyToPlay;
  42081. private _isDirectional;
  42082. private _readyToPlayCallback;
  42083. private _audioBuffer;
  42084. private _soundSource;
  42085. private _streamingSource;
  42086. private _soundPanner;
  42087. private _soundGain;
  42088. private _inputAudioNode;
  42089. private _outputAudioNode;
  42090. private _coneInnerAngle;
  42091. private _coneOuterAngle;
  42092. private _coneOuterGain;
  42093. private _scene;
  42094. private _connectedTransformNode;
  42095. private _customAttenuationFunction;
  42096. private _registerFunc;
  42097. private _isOutputConnected;
  42098. private _htmlAudioElement;
  42099. private _urlType;
  42100. private _length?;
  42101. private _offset?;
  42102. /** @hidden */
  42103. static _SceneComponentInitialization: (scene: Scene) => void;
  42104. /**
  42105. * Create a sound and attach it to a scene
  42106. * @param name Name of your sound
  42107. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42108. * @param scene defines the scene the sound belongs to
  42109. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42110. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42111. */
  42112. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42113. /**
  42114. * Release the sound and its associated resources
  42115. */
  42116. dispose(): void;
  42117. /**
  42118. * Gets if the sounds is ready to be played or not.
  42119. * @returns true if ready, otherwise false
  42120. */
  42121. isReady(): boolean;
  42122. private _soundLoaded;
  42123. /**
  42124. * Sets the data of the sound from an audiobuffer
  42125. * @param audioBuffer The audioBuffer containing the data
  42126. */
  42127. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42128. /**
  42129. * Updates the current sounds options such as maxdistance, loop...
  42130. * @param options A JSON object containing values named as the object properties
  42131. */
  42132. updateOptions(options: ISoundOptions): void;
  42133. private _createSpatialParameters;
  42134. private _updateSpatialParameters;
  42135. /**
  42136. * Switch the panning model to HRTF:
  42137. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42139. */
  42140. switchPanningModelToHRTF(): void;
  42141. /**
  42142. * Switch the panning model to Equal Power:
  42143. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42145. */
  42146. switchPanningModelToEqualPower(): void;
  42147. private _switchPanningModel;
  42148. /**
  42149. * Connect this sound to a sound track audio node like gain...
  42150. * @param soundTrackAudioNode the sound track audio node to connect to
  42151. */
  42152. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42153. /**
  42154. * Transform this sound into a directional source
  42155. * @param coneInnerAngle Size of the inner cone in degree
  42156. * @param coneOuterAngle Size of the outer cone in degree
  42157. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42158. */
  42159. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42160. /**
  42161. * Gets or sets the inner angle for the directional cone.
  42162. */
  42163. get directionalConeInnerAngle(): number;
  42164. /**
  42165. * Gets or sets the inner angle for the directional cone.
  42166. */
  42167. set directionalConeInnerAngle(value: number);
  42168. /**
  42169. * Gets or sets the outer angle for the directional cone.
  42170. */
  42171. get directionalConeOuterAngle(): number;
  42172. /**
  42173. * Gets or sets the outer angle for the directional cone.
  42174. */
  42175. set directionalConeOuterAngle(value: number);
  42176. /**
  42177. * Sets the position of the emitter if spatial sound is enabled
  42178. * @param newPosition Defines the new posisiton
  42179. */
  42180. setPosition(newPosition: Vector3): void;
  42181. /**
  42182. * Sets the local direction of the emitter if spatial sound is enabled
  42183. * @param newLocalDirection Defines the new local direction
  42184. */
  42185. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42186. private _updateDirection;
  42187. /** @hidden */
  42188. updateDistanceFromListener(): void;
  42189. /**
  42190. * Sets a new custom attenuation function for the sound.
  42191. * @param callback Defines the function used for the attenuation
  42192. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42193. */
  42194. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42195. /**
  42196. * Play the sound
  42197. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42198. * @param offset (optional) Start the sound at a specific time in seconds
  42199. * @param length (optional) Sound duration (in seconds)
  42200. */
  42201. play(time?: number, offset?: number, length?: number): void;
  42202. private _onended;
  42203. /**
  42204. * Stop the sound
  42205. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42206. */
  42207. stop(time?: number): void;
  42208. /**
  42209. * Put the sound in pause
  42210. */
  42211. pause(): void;
  42212. /**
  42213. * Sets a dedicated volume for this sounds
  42214. * @param newVolume Define the new volume of the sound
  42215. * @param time Define time for gradual change to new volume
  42216. */
  42217. setVolume(newVolume: number, time?: number): void;
  42218. /**
  42219. * Set the sound play back rate
  42220. * @param newPlaybackRate Define the playback rate the sound should be played at
  42221. */
  42222. setPlaybackRate(newPlaybackRate: number): void;
  42223. /**
  42224. * Gets the volume of the sound.
  42225. * @returns the volume of the sound
  42226. */
  42227. getVolume(): number;
  42228. /**
  42229. * Attach the sound to a dedicated mesh
  42230. * @param transformNode The transform node to connect the sound with
  42231. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42232. */
  42233. attachToMesh(transformNode: TransformNode): void;
  42234. /**
  42235. * Detach the sound from the previously attached mesh
  42236. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42237. */
  42238. detachFromMesh(): void;
  42239. private _onRegisterAfterWorldMatrixUpdate;
  42240. /**
  42241. * Clone the current sound in the scene.
  42242. * @returns the new sound clone
  42243. */
  42244. clone(): Nullable<Sound>;
  42245. /**
  42246. * Gets the current underlying audio buffer containing the data
  42247. * @returns the audio buffer
  42248. */
  42249. getAudioBuffer(): Nullable<AudioBuffer>;
  42250. /**
  42251. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42252. * @returns the source node
  42253. */
  42254. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42255. /**
  42256. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42257. * @returns the gain node
  42258. */
  42259. getSoundGain(): Nullable<GainNode>;
  42260. /**
  42261. * Serializes the Sound in a JSON representation
  42262. * @returns the JSON representation of the sound
  42263. */
  42264. serialize(): any;
  42265. /**
  42266. * Parse a JSON representation of a sound to innstantiate in a given scene
  42267. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42268. * @param scene Define the scene the new parsed sound should be created in
  42269. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42270. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42271. * @returns the newly parsed sound
  42272. */
  42273. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42274. }
  42275. }
  42276. declare module "babylonjs/Actions/directAudioActions" {
  42277. import { Action } from "babylonjs/Actions/action";
  42278. import { Condition } from "babylonjs/Actions/condition";
  42279. import { Sound } from "babylonjs/Audio/sound";
  42280. /**
  42281. * This defines an action helpful to play a defined sound on a triggered action.
  42282. */
  42283. export class PlaySoundAction extends Action {
  42284. private _sound;
  42285. /**
  42286. * Instantiate the action
  42287. * @param triggerOptions defines the trigger options
  42288. * @param sound defines the sound to play
  42289. * @param condition defines the trigger related conditions
  42290. */
  42291. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42292. /** @hidden */
  42293. _prepare(): void;
  42294. /**
  42295. * Execute the action and play the sound.
  42296. */
  42297. execute(): void;
  42298. /**
  42299. * Serializes the actions and its related information.
  42300. * @param parent defines the object to serialize in
  42301. * @returns the serialized object
  42302. */
  42303. serialize(parent: any): any;
  42304. }
  42305. /**
  42306. * This defines an action helpful to stop a defined sound on a triggered action.
  42307. */
  42308. export class StopSoundAction extends Action {
  42309. private _sound;
  42310. /**
  42311. * Instantiate the action
  42312. * @param triggerOptions defines the trigger options
  42313. * @param sound defines the sound to stop
  42314. * @param condition defines the trigger related conditions
  42315. */
  42316. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42317. /** @hidden */
  42318. _prepare(): void;
  42319. /**
  42320. * Execute the action and stop the sound.
  42321. */
  42322. execute(): void;
  42323. /**
  42324. * Serializes the actions and its related information.
  42325. * @param parent defines the object to serialize in
  42326. * @returns the serialized object
  42327. */
  42328. serialize(parent: any): any;
  42329. }
  42330. }
  42331. declare module "babylonjs/Actions/interpolateValueAction" {
  42332. import { Action } from "babylonjs/Actions/action";
  42333. import { Condition } from "babylonjs/Actions/condition";
  42334. import { Observable } from "babylonjs/Misc/observable";
  42335. /**
  42336. * This defines an action responsible to change the value of a property
  42337. * by interpolating between its current value and the newly set one once triggered.
  42338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42339. */
  42340. export class InterpolateValueAction extends Action {
  42341. /**
  42342. * Defines the path of the property where the value should be interpolated
  42343. */
  42344. propertyPath: string;
  42345. /**
  42346. * Defines the target value at the end of the interpolation.
  42347. */
  42348. value: any;
  42349. /**
  42350. * Defines the time it will take for the property to interpolate to the value.
  42351. */
  42352. duration: number;
  42353. /**
  42354. * Defines if the other scene animations should be stopped when the action has been triggered
  42355. */
  42356. stopOtherAnimations?: boolean;
  42357. /**
  42358. * Defines a callback raised once the interpolation animation has been done.
  42359. */
  42360. onInterpolationDone?: () => void;
  42361. /**
  42362. * Observable triggered once the interpolation animation has been done.
  42363. */
  42364. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42365. private _target;
  42366. private _effectiveTarget;
  42367. private _property;
  42368. /**
  42369. * Instantiate the action
  42370. * @param triggerOptions defines the trigger options
  42371. * @param target defines the object containing the value to interpolate
  42372. * @param propertyPath defines the path to the property in the target object
  42373. * @param value defines the target value at the end of the interpolation
  42374. * @param duration deines the time it will take for the property to interpolate to the value.
  42375. * @param condition defines the trigger related conditions
  42376. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42377. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42378. */
  42379. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42380. /** @hidden */
  42381. _prepare(): void;
  42382. /**
  42383. * Execute the action starts the value interpolation.
  42384. */
  42385. execute(): void;
  42386. /**
  42387. * Serializes the actions and its related information.
  42388. * @param parent defines the object to serialize in
  42389. * @returns the serialized object
  42390. */
  42391. serialize(parent: any): any;
  42392. }
  42393. }
  42394. declare module "babylonjs/Actions/index" {
  42395. export * from "babylonjs/Actions/abstractActionManager";
  42396. export * from "babylonjs/Actions/action";
  42397. export * from "babylonjs/Actions/actionEvent";
  42398. export * from "babylonjs/Actions/actionManager";
  42399. export * from "babylonjs/Actions/condition";
  42400. export * from "babylonjs/Actions/directActions";
  42401. export * from "babylonjs/Actions/directAudioActions";
  42402. export * from "babylonjs/Actions/interpolateValueAction";
  42403. }
  42404. declare module "babylonjs/Animations/index" {
  42405. export * from "babylonjs/Animations/animatable";
  42406. export * from "babylonjs/Animations/animation";
  42407. export * from "babylonjs/Animations/animationGroup";
  42408. export * from "babylonjs/Animations/animationPropertiesOverride";
  42409. export * from "babylonjs/Animations/easing";
  42410. export * from "babylonjs/Animations/runtimeAnimation";
  42411. export * from "babylonjs/Animations/animationEvent";
  42412. export * from "babylonjs/Animations/animationGroup";
  42413. export * from "babylonjs/Animations/animationKey";
  42414. export * from "babylonjs/Animations/animationRange";
  42415. export * from "babylonjs/Animations/animatable.interface";
  42416. }
  42417. declare module "babylonjs/Audio/soundTrack" {
  42418. import { Sound } from "babylonjs/Audio/sound";
  42419. import { Analyser } from "babylonjs/Audio/analyser";
  42420. import { Scene } from "babylonjs/scene";
  42421. /**
  42422. * Options allowed during the creation of a sound track.
  42423. */
  42424. export interface ISoundTrackOptions {
  42425. /**
  42426. * The volume the sound track should take during creation
  42427. */
  42428. volume?: number;
  42429. /**
  42430. * Define if the sound track is the main sound track of the scene
  42431. */
  42432. mainTrack?: boolean;
  42433. }
  42434. /**
  42435. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42436. * It will be also used in a future release to apply effects on a specific track.
  42437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42438. */
  42439. export class SoundTrack {
  42440. /**
  42441. * The unique identifier of the sound track in the scene.
  42442. */
  42443. id: number;
  42444. /**
  42445. * The list of sounds included in the sound track.
  42446. */
  42447. soundCollection: Array<Sound>;
  42448. private _outputAudioNode;
  42449. private _scene;
  42450. private _connectedAnalyser;
  42451. private _options;
  42452. private _isInitialized;
  42453. /**
  42454. * Creates a new sound track.
  42455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42456. * @param scene Define the scene the sound track belongs to
  42457. * @param options
  42458. */
  42459. constructor(scene: Scene, options?: ISoundTrackOptions);
  42460. private _initializeSoundTrackAudioGraph;
  42461. /**
  42462. * Release the sound track and its associated resources
  42463. */
  42464. dispose(): void;
  42465. /**
  42466. * Adds a sound to this sound track
  42467. * @param sound define the cound to add
  42468. * @ignoreNaming
  42469. */
  42470. AddSound(sound: Sound): void;
  42471. /**
  42472. * Removes a sound to this sound track
  42473. * @param sound define the cound to remove
  42474. * @ignoreNaming
  42475. */
  42476. RemoveSound(sound: Sound): void;
  42477. /**
  42478. * Set a global volume for the full sound track.
  42479. * @param newVolume Define the new volume of the sound track
  42480. */
  42481. setVolume(newVolume: number): void;
  42482. /**
  42483. * Switch the panning model to HRTF:
  42484. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42485. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42486. */
  42487. switchPanningModelToHRTF(): void;
  42488. /**
  42489. * Switch the panning model to Equal Power:
  42490. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42492. */
  42493. switchPanningModelToEqualPower(): void;
  42494. /**
  42495. * Connect the sound track to an audio analyser allowing some amazing
  42496. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42498. * @param analyser The analyser to connect to the engine
  42499. */
  42500. connectToAnalyser(analyser: Analyser): void;
  42501. }
  42502. }
  42503. declare module "babylonjs/Audio/audioSceneComponent" {
  42504. import { Sound } from "babylonjs/Audio/sound";
  42505. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42506. import { Nullable } from "babylonjs/types";
  42507. import { Vector3 } from "babylonjs/Maths/math.vector";
  42508. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42509. import { Scene } from "babylonjs/scene";
  42510. import { AbstractScene } from "babylonjs/abstractScene";
  42511. import "babylonjs/Audio/audioEngine";
  42512. module "babylonjs/abstractScene" {
  42513. interface AbstractScene {
  42514. /**
  42515. * The list of sounds used in the scene.
  42516. */
  42517. sounds: Nullable<Array<Sound>>;
  42518. }
  42519. }
  42520. module "babylonjs/scene" {
  42521. interface Scene {
  42522. /**
  42523. * @hidden
  42524. * Backing field
  42525. */
  42526. _mainSoundTrack: SoundTrack;
  42527. /**
  42528. * The main sound track played by the scene.
  42529. * It cotains your primary collection of sounds.
  42530. */
  42531. mainSoundTrack: SoundTrack;
  42532. /**
  42533. * The list of sound tracks added to the scene
  42534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42535. */
  42536. soundTracks: Nullable<Array<SoundTrack>>;
  42537. /**
  42538. * Gets a sound using a given name
  42539. * @param name defines the name to search for
  42540. * @return the found sound or null if not found at all.
  42541. */
  42542. getSoundByName(name: string): Nullable<Sound>;
  42543. /**
  42544. * Gets or sets if audio support is enabled
  42545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42546. */
  42547. audioEnabled: boolean;
  42548. /**
  42549. * Gets or sets if audio will be output to headphones
  42550. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42551. */
  42552. headphone: boolean;
  42553. /**
  42554. * Gets or sets custom audio listener position provider
  42555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42556. */
  42557. audioListenerPositionProvider: Nullable<() => Vector3>;
  42558. /**
  42559. * Gets or sets a refresh rate when using 3D audio positioning
  42560. */
  42561. audioPositioningRefreshRate: number;
  42562. }
  42563. }
  42564. /**
  42565. * Defines the sound scene component responsible to manage any sounds
  42566. * in a given scene.
  42567. */
  42568. export class AudioSceneComponent implements ISceneSerializableComponent {
  42569. /**
  42570. * The component name helpfull to identify the component in the list of scene components.
  42571. */
  42572. readonly name: string;
  42573. /**
  42574. * The scene the component belongs to.
  42575. */
  42576. scene: Scene;
  42577. private _audioEnabled;
  42578. /**
  42579. * Gets whether audio is enabled or not.
  42580. * Please use related enable/disable method to switch state.
  42581. */
  42582. get audioEnabled(): boolean;
  42583. private _headphone;
  42584. /**
  42585. * Gets whether audio is outputing to headphone or not.
  42586. * Please use the according Switch methods to change output.
  42587. */
  42588. get headphone(): boolean;
  42589. /**
  42590. * Gets or sets a refresh rate when using 3D audio positioning
  42591. */
  42592. audioPositioningRefreshRate: number;
  42593. private _audioListenerPositionProvider;
  42594. /**
  42595. * Gets the current audio listener position provider
  42596. */
  42597. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42598. /**
  42599. * Sets a custom listener position for all sounds in the scene
  42600. * By default, this is the position of the first active camera
  42601. */
  42602. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42603. /**
  42604. * Creates a new instance of the component for the given scene
  42605. * @param scene Defines the scene to register the component in
  42606. */
  42607. constructor(scene: Scene);
  42608. /**
  42609. * Registers the component in a given scene
  42610. */
  42611. register(): void;
  42612. /**
  42613. * Rebuilds the elements related to this component in case of
  42614. * context lost for instance.
  42615. */
  42616. rebuild(): void;
  42617. /**
  42618. * Serializes the component data to the specified json object
  42619. * @param serializationObject The object to serialize to
  42620. */
  42621. serialize(serializationObject: any): void;
  42622. /**
  42623. * Adds all the elements from the container to the scene
  42624. * @param container the container holding the elements
  42625. */
  42626. addFromContainer(container: AbstractScene): void;
  42627. /**
  42628. * Removes all the elements in the container from the scene
  42629. * @param container contains the elements to remove
  42630. * @param dispose if the removed element should be disposed (default: false)
  42631. */
  42632. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42633. /**
  42634. * Disposes the component and the associated ressources.
  42635. */
  42636. dispose(): void;
  42637. /**
  42638. * Disables audio in the associated scene.
  42639. */
  42640. disableAudio(): void;
  42641. /**
  42642. * Enables audio in the associated scene.
  42643. */
  42644. enableAudio(): void;
  42645. /**
  42646. * Switch audio to headphone output.
  42647. */
  42648. switchAudioModeForHeadphones(): void;
  42649. /**
  42650. * Switch audio to normal speakers.
  42651. */
  42652. switchAudioModeForNormalSpeakers(): void;
  42653. private _cachedCameraDirection;
  42654. private _cachedCameraPosition;
  42655. private _lastCheck;
  42656. private _afterRender;
  42657. }
  42658. }
  42659. declare module "babylonjs/Audio/weightedsound" {
  42660. import { Sound } from "babylonjs/Audio/sound";
  42661. /**
  42662. * Wraps one or more Sound objects and selects one with random weight for playback.
  42663. */
  42664. export class WeightedSound {
  42665. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42666. loop: boolean;
  42667. private _coneInnerAngle;
  42668. private _coneOuterAngle;
  42669. private _volume;
  42670. /** A Sound is currently playing. */
  42671. isPlaying: boolean;
  42672. /** A Sound is currently paused. */
  42673. isPaused: boolean;
  42674. private _sounds;
  42675. private _weights;
  42676. private _currentIndex?;
  42677. /**
  42678. * Creates a new WeightedSound from the list of sounds given.
  42679. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42680. * @param sounds Array of Sounds that will be selected from.
  42681. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42682. */
  42683. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42684. /**
  42685. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42686. */
  42687. get directionalConeInnerAngle(): number;
  42688. /**
  42689. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42690. */
  42691. set directionalConeInnerAngle(value: number);
  42692. /**
  42693. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42694. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42695. */
  42696. get directionalConeOuterAngle(): number;
  42697. /**
  42698. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42699. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42700. */
  42701. set directionalConeOuterAngle(value: number);
  42702. /**
  42703. * Playback volume.
  42704. */
  42705. get volume(): number;
  42706. /**
  42707. * Playback volume.
  42708. */
  42709. set volume(value: number);
  42710. private _onended;
  42711. /**
  42712. * Suspend playback
  42713. */
  42714. pause(): void;
  42715. /**
  42716. * Stop playback
  42717. */
  42718. stop(): void;
  42719. /**
  42720. * Start playback.
  42721. * @param startOffset Position the clip head at a specific time in seconds.
  42722. */
  42723. play(startOffset?: number): void;
  42724. }
  42725. }
  42726. declare module "babylonjs/Audio/index" {
  42727. export * from "babylonjs/Audio/analyser";
  42728. export * from "babylonjs/Audio/audioEngine";
  42729. export * from "babylonjs/Audio/audioSceneComponent";
  42730. export * from "babylonjs/Audio/sound";
  42731. export * from "babylonjs/Audio/soundTrack";
  42732. export * from "babylonjs/Audio/weightedsound";
  42733. }
  42734. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42735. import { Behavior } from "babylonjs/Behaviors/behavior";
  42736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42737. import { BackEase } from "babylonjs/Animations/easing";
  42738. /**
  42739. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42740. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42741. */
  42742. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42743. /**
  42744. * Gets the name of the behavior.
  42745. */
  42746. get name(): string;
  42747. /**
  42748. * The easing function used by animations
  42749. */
  42750. static EasingFunction: BackEase;
  42751. /**
  42752. * The easing mode used by animations
  42753. */
  42754. static EasingMode: number;
  42755. /**
  42756. * The duration of the animation, in milliseconds
  42757. */
  42758. transitionDuration: number;
  42759. /**
  42760. * Length of the distance animated by the transition when lower radius is reached
  42761. */
  42762. lowerRadiusTransitionRange: number;
  42763. /**
  42764. * Length of the distance animated by the transition when upper radius is reached
  42765. */
  42766. upperRadiusTransitionRange: number;
  42767. private _autoTransitionRange;
  42768. /**
  42769. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42770. */
  42771. get autoTransitionRange(): boolean;
  42772. /**
  42773. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42774. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42775. */
  42776. set autoTransitionRange(value: boolean);
  42777. private _attachedCamera;
  42778. private _onAfterCheckInputsObserver;
  42779. private _onMeshTargetChangedObserver;
  42780. /**
  42781. * Initializes the behavior.
  42782. */
  42783. init(): void;
  42784. /**
  42785. * Attaches the behavior to its arc rotate camera.
  42786. * @param camera Defines the camera to attach the behavior to
  42787. */
  42788. attach(camera: ArcRotateCamera): void;
  42789. /**
  42790. * Detaches the behavior from its current arc rotate camera.
  42791. */
  42792. detach(): void;
  42793. private _radiusIsAnimating;
  42794. private _radiusBounceTransition;
  42795. private _animatables;
  42796. private _cachedWheelPrecision;
  42797. /**
  42798. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42799. * @param radiusLimit The limit to check against.
  42800. * @return Bool to indicate if at limit.
  42801. */
  42802. private _isRadiusAtLimit;
  42803. /**
  42804. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42805. * @param radiusDelta The delta by which to animate to. Can be negative.
  42806. */
  42807. private _applyBoundRadiusAnimation;
  42808. /**
  42809. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42810. */
  42811. protected _clearAnimationLocks(): void;
  42812. /**
  42813. * Stops and removes all animations that have been applied to the camera
  42814. */
  42815. stopAllAnimations(): void;
  42816. }
  42817. }
  42818. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42819. import { Behavior } from "babylonjs/Behaviors/behavior";
  42820. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42821. import { ExponentialEase } from "babylonjs/Animations/easing";
  42822. import { Nullable } from "babylonjs/types";
  42823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42824. import { Vector3 } from "babylonjs/Maths/math.vector";
  42825. /**
  42826. * 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.
  42827. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42828. */
  42829. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42830. /**
  42831. * Gets the name of the behavior.
  42832. */
  42833. get name(): string;
  42834. private _mode;
  42835. private _radiusScale;
  42836. private _positionScale;
  42837. private _defaultElevation;
  42838. private _elevationReturnTime;
  42839. private _elevationReturnWaitTime;
  42840. private _zoomStopsAnimation;
  42841. private _framingTime;
  42842. /**
  42843. * The easing function used by animations
  42844. */
  42845. static EasingFunction: ExponentialEase;
  42846. /**
  42847. * The easing mode used by animations
  42848. */
  42849. static EasingMode: number;
  42850. /**
  42851. * Sets the current mode used by the behavior
  42852. */
  42853. set mode(mode: number);
  42854. /**
  42855. * Gets current mode used by the behavior.
  42856. */
  42857. get mode(): number;
  42858. /**
  42859. * Sets the scale applied to the radius (1 by default)
  42860. */
  42861. set radiusScale(radius: number);
  42862. /**
  42863. * Gets the scale applied to the radius
  42864. */
  42865. get radiusScale(): number;
  42866. /**
  42867. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42868. */
  42869. set positionScale(scale: number);
  42870. /**
  42871. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42872. */
  42873. get positionScale(): number;
  42874. /**
  42875. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42876. * behaviour is triggered, in radians.
  42877. */
  42878. set defaultElevation(elevation: number);
  42879. /**
  42880. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42881. * behaviour is triggered, in radians.
  42882. */
  42883. get defaultElevation(): number;
  42884. /**
  42885. * Sets the time (in milliseconds) taken to return to the default beta position.
  42886. * Negative value indicates camera should not return to default.
  42887. */
  42888. set elevationReturnTime(speed: number);
  42889. /**
  42890. * Gets the time (in milliseconds) taken to return to the default beta position.
  42891. * Negative value indicates camera should not return to default.
  42892. */
  42893. get elevationReturnTime(): number;
  42894. /**
  42895. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42896. */
  42897. set elevationReturnWaitTime(time: number);
  42898. /**
  42899. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42900. */
  42901. get elevationReturnWaitTime(): number;
  42902. /**
  42903. * Sets the flag that indicates if user zooming should stop animation.
  42904. */
  42905. set zoomStopsAnimation(flag: boolean);
  42906. /**
  42907. * Gets the flag that indicates if user zooming should stop animation.
  42908. */
  42909. get zoomStopsAnimation(): boolean;
  42910. /**
  42911. * Sets the transition time when framing the mesh, in milliseconds
  42912. */
  42913. set framingTime(time: number);
  42914. /**
  42915. * Gets the transition time when framing the mesh, in milliseconds
  42916. */
  42917. get framingTime(): number;
  42918. /**
  42919. * Define if the behavior should automatically change the configured
  42920. * camera limits and sensibilities.
  42921. */
  42922. autoCorrectCameraLimitsAndSensibility: boolean;
  42923. private _onPrePointerObservableObserver;
  42924. private _onAfterCheckInputsObserver;
  42925. private _onMeshTargetChangedObserver;
  42926. private _attachedCamera;
  42927. private _isPointerDown;
  42928. private _lastInteractionTime;
  42929. /**
  42930. * Initializes the behavior.
  42931. */
  42932. init(): void;
  42933. /**
  42934. * Attaches the behavior to its arc rotate camera.
  42935. * @param camera Defines the camera to attach the behavior to
  42936. */
  42937. attach(camera: ArcRotateCamera): void;
  42938. /**
  42939. * Detaches the behavior from its current arc rotate camera.
  42940. */
  42941. detach(): void;
  42942. private _animatables;
  42943. private _betaIsAnimating;
  42944. private _betaTransition;
  42945. private _radiusTransition;
  42946. private _vectorTransition;
  42947. /**
  42948. * Targets the given mesh and updates zoom level accordingly.
  42949. * @param mesh The mesh to target.
  42950. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42951. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42952. */
  42953. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42954. /**
  42955. * Targets the given mesh with its children and updates zoom level accordingly.
  42956. * @param mesh The mesh to target.
  42957. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42958. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42959. */
  42960. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42961. /**
  42962. * Targets the given meshes with their children and updates zoom level accordingly.
  42963. * @param meshes The mesh to target.
  42964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42966. */
  42967. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42968. /**
  42969. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42970. * @param minimumWorld Determines the smaller position of the bounding box extend
  42971. * @param maximumWorld Determines the bigger position of the bounding box extend
  42972. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42973. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42974. */
  42975. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42976. /**
  42977. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42978. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42979. * frustum width.
  42980. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42981. * to fully enclose the mesh in the viewing frustum.
  42982. */
  42983. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42984. /**
  42985. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42986. * is automatically returned to its default position (expected to be above ground plane).
  42987. */
  42988. private _maintainCameraAboveGround;
  42989. /**
  42990. * Returns the frustum slope based on the canvas ratio and camera FOV
  42991. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42992. */
  42993. private _getFrustumSlope;
  42994. /**
  42995. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42996. */
  42997. private _clearAnimationLocks;
  42998. /**
  42999. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43000. */
  43001. private _applyUserInteraction;
  43002. /**
  43003. * Stops and removes all animations that have been applied to the camera
  43004. */
  43005. stopAllAnimations(): void;
  43006. /**
  43007. * Gets a value indicating if the user is moving the camera
  43008. */
  43009. get isUserIsMoving(): boolean;
  43010. /**
  43011. * The camera can move all the way towards the mesh.
  43012. */
  43013. static IgnoreBoundsSizeMode: number;
  43014. /**
  43015. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43016. */
  43017. static FitFrustumSidesMode: number;
  43018. }
  43019. }
  43020. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43021. import { Nullable } from "babylonjs/types";
  43022. import { Camera } from "babylonjs/Cameras/camera";
  43023. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43024. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43025. /**
  43026. * Base class for Camera Pointer Inputs.
  43027. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43028. * for example usage.
  43029. */
  43030. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43031. /**
  43032. * Defines the camera the input is attached to.
  43033. */
  43034. abstract camera: Camera;
  43035. /**
  43036. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43037. */
  43038. protected _altKey: boolean;
  43039. protected _ctrlKey: boolean;
  43040. protected _metaKey: boolean;
  43041. protected _shiftKey: boolean;
  43042. /**
  43043. * Which mouse buttons were pressed at time of last mouse event.
  43044. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43045. */
  43046. protected _buttonsPressed: number;
  43047. /**
  43048. * Defines the buttons associated with the input to handle camera move.
  43049. */
  43050. buttons: number[];
  43051. /**
  43052. * Attach the input controls to a specific dom element to get the input from.
  43053. * @param element Defines the element the controls should be listened from
  43054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43055. */
  43056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43057. /**
  43058. * Detach the current controls from the specified dom element.
  43059. * @param element Defines the element to stop listening the inputs from
  43060. */
  43061. detachControl(element: Nullable<HTMLElement>): void;
  43062. /**
  43063. * Gets the class name of the current input.
  43064. * @returns the class name
  43065. */
  43066. getClassName(): string;
  43067. /**
  43068. * Get the friendly name associated with the input class.
  43069. * @returns the input friendly name
  43070. */
  43071. getSimpleName(): string;
  43072. /**
  43073. * Called on pointer POINTERDOUBLETAP event.
  43074. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43075. */
  43076. protected onDoubleTap(type: string): void;
  43077. /**
  43078. * Called on pointer POINTERMOVE event if only a single touch is active.
  43079. * Override this method to provide functionality.
  43080. */
  43081. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43082. /**
  43083. * Called on pointer POINTERMOVE event if multiple touches are active.
  43084. * Override this method to provide functionality.
  43085. */
  43086. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43087. /**
  43088. * Called on JS contextmenu event.
  43089. * Override this method to provide functionality.
  43090. */
  43091. protected onContextMenu(evt: PointerEvent): void;
  43092. /**
  43093. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43094. * press.
  43095. * Override this method to provide functionality.
  43096. */
  43097. protected onButtonDown(evt: PointerEvent): void;
  43098. /**
  43099. * Called each time a new POINTERUP event occurs. Ie, for each button
  43100. * release.
  43101. * Override this method to provide functionality.
  43102. */
  43103. protected onButtonUp(evt: PointerEvent): void;
  43104. /**
  43105. * Called when window becomes inactive.
  43106. * Override this method to provide functionality.
  43107. */
  43108. protected onLostFocus(): void;
  43109. private _pointerInput;
  43110. private _observer;
  43111. private _onLostFocus;
  43112. private pointA;
  43113. private pointB;
  43114. }
  43115. }
  43116. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43117. import { Nullable } from "babylonjs/types";
  43118. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43119. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43120. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43121. /**
  43122. * Manage the pointers inputs to control an arc rotate camera.
  43123. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43124. */
  43125. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43126. /**
  43127. * Defines the camera the input is attached to.
  43128. */
  43129. camera: ArcRotateCamera;
  43130. /**
  43131. * Gets the class name of the current input.
  43132. * @returns the class name
  43133. */
  43134. getClassName(): string;
  43135. /**
  43136. * Defines the buttons associated with the input to handle camera move.
  43137. */
  43138. buttons: number[];
  43139. /**
  43140. * Defines the pointer angular sensibility along the X axis or how fast is
  43141. * the camera rotating.
  43142. */
  43143. angularSensibilityX: number;
  43144. /**
  43145. * Defines the pointer angular sensibility along the Y axis or how fast is
  43146. * the camera rotating.
  43147. */
  43148. angularSensibilityY: number;
  43149. /**
  43150. * Defines the pointer pinch precision or how fast is the camera zooming.
  43151. */
  43152. pinchPrecision: number;
  43153. /**
  43154. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43155. * from 0.
  43156. * It defines the percentage of current camera.radius to use as delta when
  43157. * pinch zoom is used.
  43158. */
  43159. pinchDeltaPercentage: number;
  43160. /**
  43161. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43162. * that any object in the plane at the camera's target point will scale
  43163. * perfectly with finger motion.
  43164. * Overrides pinchDeltaPercentage and pinchPrecision.
  43165. */
  43166. useNaturalPinchZoom: boolean;
  43167. /**
  43168. * Defines the pointer panning sensibility or how fast is the camera moving.
  43169. */
  43170. panningSensibility: number;
  43171. /**
  43172. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43173. */
  43174. multiTouchPanning: boolean;
  43175. /**
  43176. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43177. * zoom (pinch) through multitouch.
  43178. */
  43179. multiTouchPanAndZoom: boolean;
  43180. /**
  43181. * Revers pinch action direction.
  43182. */
  43183. pinchInwards: boolean;
  43184. private _isPanClick;
  43185. private _twoFingerActivityCount;
  43186. private _isPinching;
  43187. /**
  43188. * Called on pointer POINTERMOVE event if only a single touch is active.
  43189. */
  43190. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43191. /**
  43192. * Called on pointer POINTERDOUBLETAP event.
  43193. */
  43194. protected onDoubleTap(type: string): void;
  43195. /**
  43196. * Called on pointer POINTERMOVE event if multiple touches are active.
  43197. */
  43198. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43199. /**
  43200. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43201. * press.
  43202. */
  43203. protected onButtonDown(evt: PointerEvent): void;
  43204. /**
  43205. * Called each time a new POINTERUP event occurs. Ie, for each button
  43206. * release.
  43207. */
  43208. protected onButtonUp(evt: PointerEvent): void;
  43209. /**
  43210. * Called when window becomes inactive.
  43211. */
  43212. protected onLostFocus(): void;
  43213. }
  43214. }
  43215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43216. import { Nullable } from "babylonjs/types";
  43217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43219. /**
  43220. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43221. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43222. */
  43223. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43224. /**
  43225. * Defines the camera the input is attached to.
  43226. */
  43227. camera: ArcRotateCamera;
  43228. /**
  43229. * Defines the list of key codes associated with the up action (increase alpha)
  43230. */
  43231. keysUp: number[];
  43232. /**
  43233. * Defines the list of key codes associated with the down action (decrease alpha)
  43234. */
  43235. keysDown: number[];
  43236. /**
  43237. * Defines the list of key codes associated with the left action (increase beta)
  43238. */
  43239. keysLeft: number[];
  43240. /**
  43241. * Defines the list of key codes associated with the right action (decrease beta)
  43242. */
  43243. keysRight: number[];
  43244. /**
  43245. * Defines the list of key codes associated with the reset action.
  43246. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43247. */
  43248. keysReset: number[];
  43249. /**
  43250. * Defines the panning sensibility of the inputs.
  43251. * (How fast is the camera panning)
  43252. */
  43253. panningSensibility: number;
  43254. /**
  43255. * Defines the zooming sensibility of the inputs.
  43256. * (How fast is the camera zooming)
  43257. */
  43258. zoomingSensibility: number;
  43259. /**
  43260. * Defines whether maintaining the alt key down switch the movement mode from
  43261. * orientation to zoom.
  43262. */
  43263. useAltToZoom: boolean;
  43264. /**
  43265. * Rotation speed of the camera
  43266. */
  43267. angularSpeed: number;
  43268. private _keys;
  43269. private _ctrlPressed;
  43270. private _altPressed;
  43271. private _onCanvasBlurObserver;
  43272. private _onKeyboardObserver;
  43273. private _engine;
  43274. private _scene;
  43275. /**
  43276. * Attach the input controls to a specific dom element to get the input from.
  43277. * @param element Defines the element the controls should be listened from
  43278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43279. */
  43280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43281. /**
  43282. * Detach the current controls from the specified dom element.
  43283. * @param element Defines the element to stop listening the inputs from
  43284. */
  43285. detachControl(element: Nullable<HTMLElement>): void;
  43286. /**
  43287. * Update the current camera state depending on the inputs that have been used this frame.
  43288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43289. */
  43290. checkInputs(): void;
  43291. /**
  43292. * Gets the class name of the current intput.
  43293. * @returns the class name
  43294. */
  43295. getClassName(): string;
  43296. /**
  43297. * Get the friendly name associated with the input class.
  43298. * @returns the input friendly name
  43299. */
  43300. getSimpleName(): string;
  43301. }
  43302. }
  43303. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43304. import { Nullable } from "babylonjs/types";
  43305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43306. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43307. /**
  43308. * Manage the mouse wheel inputs to control an arc rotate camera.
  43309. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43310. */
  43311. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43312. /**
  43313. * Defines the camera the input is attached to.
  43314. */
  43315. camera: ArcRotateCamera;
  43316. /**
  43317. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43318. */
  43319. wheelPrecision: number;
  43320. /**
  43321. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43322. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43323. */
  43324. wheelDeltaPercentage: number;
  43325. private _wheel;
  43326. private _observer;
  43327. private computeDeltaFromMouseWheelLegacyEvent;
  43328. /**
  43329. * Attach the input controls to a specific dom element to get the input from.
  43330. * @param element Defines the element the controls should be listened from
  43331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43332. */
  43333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43334. /**
  43335. * Detach the current controls from the specified dom element.
  43336. * @param element Defines the element to stop listening the inputs from
  43337. */
  43338. detachControl(element: Nullable<HTMLElement>): void;
  43339. /**
  43340. * Gets the class name of the current intput.
  43341. * @returns the class name
  43342. */
  43343. getClassName(): string;
  43344. /**
  43345. * Get the friendly name associated with the input class.
  43346. * @returns the input friendly name
  43347. */
  43348. getSimpleName(): string;
  43349. }
  43350. }
  43351. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43352. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43353. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43354. /**
  43355. * Default Inputs manager for the ArcRotateCamera.
  43356. * It groups all the default supported inputs for ease of use.
  43357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43358. */
  43359. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43360. /**
  43361. * Instantiates a new ArcRotateCameraInputsManager.
  43362. * @param camera Defines the camera the inputs belong to
  43363. */
  43364. constructor(camera: ArcRotateCamera);
  43365. /**
  43366. * Add mouse wheel input support to the input manager.
  43367. * @returns the current input manager
  43368. */
  43369. addMouseWheel(): ArcRotateCameraInputsManager;
  43370. /**
  43371. * Add pointers input support to the input manager.
  43372. * @returns the current input manager
  43373. */
  43374. addPointers(): ArcRotateCameraInputsManager;
  43375. /**
  43376. * Add keyboard input support to the input manager.
  43377. * @returns the current input manager
  43378. */
  43379. addKeyboard(): ArcRotateCameraInputsManager;
  43380. }
  43381. }
  43382. declare module "babylonjs/Cameras/arcRotateCamera" {
  43383. import { Observable } from "babylonjs/Misc/observable";
  43384. import { Nullable } from "babylonjs/types";
  43385. import { Scene } from "babylonjs/scene";
  43386. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43388. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43389. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43390. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43391. import { Camera } from "babylonjs/Cameras/camera";
  43392. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43393. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43394. import { Collider } from "babylonjs/Collisions/collider";
  43395. /**
  43396. * This represents an orbital type of camera.
  43397. *
  43398. * 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.
  43399. * 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.
  43400. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43401. */
  43402. export class ArcRotateCamera extends TargetCamera {
  43403. /**
  43404. * Defines the rotation angle of the camera along the longitudinal axis.
  43405. */
  43406. alpha: number;
  43407. /**
  43408. * Defines the rotation angle of the camera along the latitudinal axis.
  43409. */
  43410. beta: number;
  43411. /**
  43412. * Defines the radius of the camera from it s target point.
  43413. */
  43414. radius: number;
  43415. protected _target: Vector3;
  43416. protected _targetHost: Nullable<AbstractMesh>;
  43417. /**
  43418. * Defines the target point of the camera.
  43419. * The camera looks towards it form the radius distance.
  43420. */
  43421. get target(): Vector3;
  43422. set target(value: Vector3);
  43423. /**
  43424. * Define the current local position of the camera in the scene
  43425. */
  43426. get position(): Vector3;
  43427. set position(newPosition: Vector3);
  43428. protected _upVector: Vector3;
  43429. protected _upToYMatrix: Matrix;
  43430. protected _YToUpMatrix: Matrix;
  43431. /**
  43432. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43433. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43434. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43435. */
  43436. set upVector(vec: Vector3);
  43437. get upVector(): Vector3;
  43438. /**
  43439. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43440. */
  43441. setMatUp(): void;
  43442. /**
  43443. * Current inertia value on the longitudinal axis.
  43444. * The bigger this number the longer it will take for the camera to stop.
  43445. */
  43446. inertialAlphaOffset: number;
  43447. /**
  43448. * Current inertia value on the latitudinal axis.
  43449. * The bigger this number the longer it will take for the camera to stop.
  43450. */
  43451. inertialBetaOffset: number;
  43452. /**
  43453. * Current inertia value on the radius axis.
  43454. * The bigger this number the longer it will take for the camera to stop.
  43455. */
  43456. inertialRadiusOffset: number;
  43457. /**
  43458. * Minimum allowed angle on the longitudinal axis.
  43459. * This can help limiting how the Camera is able to move in the scene.
  43460. */
  43461. lowerAlphaLimit: Nullable<number>;
  43462. /**
  43463. * Maximum allowed angle on the longitudinal axis.
  43464. * This can help limiting how the Camera is able to move in the scene.
  43465. */
  43466. upperAlphaLimit: Nullable<number>;
  43467. /**
  43468. * Minimum allowed angle on the latitudinal axis.
  43469. * This can help limiting how the Camera is able to move in the scene.
  43470. */
  43471. lowerBetaLimit: number;
  43472. /**
  43473. * Maximum allowed angle on the latitudinal axis.
  43474. * This can help limiting how the Camera is able to move in the scene.
  43475. */
  43476. upperBetaLimit: number;
  43477. /**
  43478. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43479. * This can help limiting how the Camera is able to move in the scene.
  43480. */
  43481. lowerRadiusLimit: Nullable<number>;
  43482. /**
  43483. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43484. * This can help limiting how the Camera is able to move in the scene.
  43485. */
  43486. upperRadiusLimit: Nullable<number>;
  43487. /**
  43488. * Defines the current inertia value used during panning of the camera along the X axis.
  43489. */
  43490. inertialPanningX: number;
  43491. /**
  43492. * Defines the current inertia value used during panning of the camera along the Y axis.
  43493. */
  43494. inertialPanningY: number;
  43495. /**
  43496. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43497. * Basically if your fingers moves away from more than this distance you will be considered
  43498. * in pinch mode.
  43499. */
  43500. pinchToPanMaxDistance: number;
  43501. /**
  43502. * Defines the maximum distance the camera can pan.
  43503. * This could help keeping the cammera always in your scene.
  43504. */
  43505. panningDistanceLimit: Nullable<number>;
  43506. /**
  43507. * Defines the target of the camera before paning.
  43508. */
  43509. panningOriginTarget: Vector3;
  43510. /**
  43511. * Defines the value of the inertia used during panning.
  43512. * 0 would mean stop inertia and one would mean no decelleration at all.
  43513. */
  43514. panningInertia: number;
  43515. /**
  43516. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43517. */
  43518. get angularSensibilityX(): number;
  43519. set angularSensibilityX(value: number);
  43520. /**
  43521. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43522. */
  43523. get angularSensibilityY(): number;
  43524. set angularSensibilityY(value: number);
  43525. /**
  43526. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43527. */
  43528. get pinchPrecision(): number;
  43529. set pinchPrecision(value: number);
  43530. /**
  43531. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43532. * It will be used instead of pinchDeltaPrecision if different from 0.
  43533. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43534. */
  43535. get pinchDeltaPercentage(): number;
  43536. set pinchDeltaPercentage(value: number);
  43537. /**
  43538. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43539. * and pinch delta percentage.
  43540. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43541. * that any object in the plane at the camera's target point will scale
  43542. * perfectly with finger motion.
  43543. */
  43544. get useNaturalPinchZoom(): boolean;
  43545. set useNaturalPinchZoom(value: boolean);
  43546. /**
  43547. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43548. */
  43549. get panningSensibility(): number;
  43550. set panningSensibility(value: number);
  43551. /**
  43552. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43553. */
  43554. get keysUp(): number[];
  43555. set keysUp(value: number[]);
  43556. /**
  43557. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43558. */
  43559. get keysDown(): number[];
  43560. set keysDown(value: number[]);
  43561. /**
  43562. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43563. */
  43564. get keysLeft(): number[];
  43565. set keysLeft(value: number[]);
  43566. /**
  43567. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43568. */
  43569. get keysRight(): number[];
  43570. set keysRight(value: number[]);
  43571. /**
  43572. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43573. */
  43574. get wheelPrecision(): number;
  43575. set wheelPrecision(value: number);
  43576. /**
  43577. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43578. * It will be used instead of pinchDeltaPrecision if different from 0.
  43579. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43580. */
  43581. get wheelDeltaPercentage(): number;
  43582. set wheelDeltaPercentage(value: number);
  43583. /**
  43584. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43585. */
  43586. zoomOnFactor: number;
  43587. /**
  43588. * Defines a screen offset for the camera position.
  43589. */
  43590. targetScreenOffset: Vector2;
  43591. /**
  43592. * Allows the camera to be completely reversed.
  43593. * If false the camera can not arrive upside down.
  43594. */
  43595. allowUpsideDown: boolean;
  43596. /**
  43597. * Define if double tap/click is used to restore the previously saved state of the camera.
  43598. */
  43599. useInputToRestoreState: boolean;
  43600. /** @hidden */
  43601. _viewMatrix: Matrix;
  43602. /** @hidden */
  43603. _useCtrlForPanning: boolean;
  43604. /** @hidden */
  43605. _panningMouseButton: number;
  43606. /**
  43607. * Defines the input associated to the camera.
  43608. */
  43609. inputs: ArcRotateCameraInputsManager;
  43610. /** @hidden */
  43611. _reset: () => void;
  43612. /**
  43613. * Defines the allowed panning axis.
  43614. */
  43615. panningAxis: Vector3;
  43616. protected _localDirection: Vector3;
  43617. protected _transformedDirection: Vector3;
  43618. private _bouncingBehavior;
  43619. /**
  43620. * Gets the bouncing behavior of the camera if it has been enabled.
  43621. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43622. */
  43623. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43624. /**
  43625. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43626. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43627. */
  43628. get useBouncingBehavior(): boolean;
  43629. set useBouncingBehavior(value: boolean);
  43630. private _framingBehavior;
  43631. /**
  43632. * Gets the framing behavior of the camera if it has been enabled.
  43633. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43634. */
  43635. get framingBehavior(): Nullable<FramingBehavior>;
  43636. /**
  43637. * Defines if the framing behavior of the camera is enabled on the camera.
  43638. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43639. */
  43640. get useFramingBehavior(): boolean;
  43641. set useFramingBehavior(value: boolean);
  43642. private _autoRotationBehavior;
  43643. /**
  43644. * Gets the auto rotation behavior of the camera if it has been enabled.
  43645. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43646. */
  43647. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43648. /**
  43649. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43650. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43651. */
  43652. get useAutoRotationBehavior(): boolean;
  43653. set useAutoRotationBehavior(value: boolean);
  43654. /**
  43655. * Observable triggered when the mesh target has been changed on the camera.
  43656. */
  43657. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43658. /**
  43659. * Event raised when the camera is colliding with a mesh.
  43660. */
  43661. onCollide: (collidedMesh: AbstractMesh) => void;
  43662. /**
  43663. * Defines whether the camera should check collision with the objects oh the scene.
  43664. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43665. */
  43666. checkCollisions: boolean;
  43667. /**
  43668. * Defines the collision radius of the camera.
  43669. * This simulates a sphere around the camera.
  43670. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43671. */
  43672. collisionRadius: Vector3;
  43673. protected _collider: Collider;
  43674. protected _previousPosition: Vector3;
  43675. protected _collisionVelocity: Vector3;
  43676. protected _newPosition: Vector3;
  43677. protected _previousAlpha: number;
  43678. protected _previousBeta: number;
  43679. protected _previousRadius: number;
  43680. protected _collisionTriggered: boolean;
  43681. protected _targetBoundingCenter: Nullable<Vector3>;
  43682. private _computationVector;
  43683. /**
  43684. * Instantiates a new ArcRotateCamera in a given scene
  43685. * @param name Defines the name of the camera
  43686. * @param alpha Defines the camera rotation along the logitudinal axis
  43687. * @param beta Defines the camera rotation along the latitudinal axis
  43688. * @param radius Defines the camera distance from its target
  43689. * @param target Defines the camera target
  43690. * @param scene Defines the scene the camera belongs to
  43691. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43692. */
  43693. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43694. /** @hidden */
  43695. _initCache(): void;
  43696. /** @hidden */
  43697. _updateCache(ignoreParentClass?: boolean): void;
  43698. protected _getTargetPosition(): Vector3;
  43699. private _storedAlpha;
  43700. private _storedBeta;
  43701. private _storedRadius;
  43702. private _storedTarget;
  43703. private _storedTargetScreenOffset;
  43704. /**
  43705. * Stores the current state of the camera (alpha, beta, radius and target)
  43706. * @returns the camera itself
  43707. */
  43708. storeState(): Camera;
  43709. /**
  43710. * @hidden
  43711. * Restored camera state. You must call storeState() first
  43712. */
  43713. _restoreStateValues(): boolean;
  43714. /** @hidden */
  43715. _isSynchronizedViewMatrix(): boolean;
  43716. /**
  43717. * Attached controls to the current camera.
  43718. * @param element Defines the element the controls should be listened from
  43719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43720. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43721. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43722. */
  43723. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43724. /**
  43725. * Detach the current controls from the camera.
  43726. * The camera will stop reacting to inputs.
  43727. * @param element Defines the element to stop listening the inputs from
  43728. */
  43729. detachControl(element: HTMLElement): void;
  43730. /** @hidden */
  43731. _checkInputs(): void;
  43732. protected _checkLimits(): void;
  43733. /**
  43734. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43735. */
  43736. rebuildAnglesAndRadius(): void;
  43737. /**
  43738. * Use a position to define the current camera related information like alpha, beta and radius
  43739. * @param position Defines the position to set the camera at
  43740. */
  43741. setPosition(position: Vector3): void;
  43742. /**
  43743. * Defines the target the camera should look at.
  43744. * This will automatically adapt alpha beta and radius to fit within the new target.
  43745. * @param target Defines the new target as a Vector or a mesh
  43746. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43747. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43748. */
  43749. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43750. /** @hidden */
  43751. _getViewMatrix(): Matrix;
  43752. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43753. /**
  43754. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43755. * @param meshes Defines the mesh to zoom on
  43756. * @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)
  43757. */
  43758. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43759. /**
  43760. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43761. * The target will be changed but the radius
  43762. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43763. * @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)
  43764. */
  43765. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43766. min: Vector3;
  43767. max: Vector3;
  43768. distance: number;
  43769. }, doNotUpdateMaxZ?: boolean): void;
  43770. /**
  43771. * @override
  43772. * Override Camera.createRigCamera
  43773. */
  43774. createRigCamera(name: string, cameraIndex: number): Camera;
  43775. /**
  43776. * @hidden
  43777. * @override
  43778. * Override Camera._updateRigCameras
  43779. */
  43780. _updateRigCameras(): void;
  43781. /**
  43782. * Destroy the camera and release the current resources hold by it.
  43783. */
  43784. dispose(): void;
  43785. /**
  43786. * Gets the current object class name.
  43787. * @return the class name
  43788. */
  43789. getClassName(): string;
  43790. }
  43791. }
  43792. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43793. import { Behavior } from "babylonjs/Behaviors/behavior";
  43794. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43795. /**
  43796. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43797. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43798. */
  43799. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43800. /**
  43801. * Gets the name of the behavior.
  43802. */
  43803. get name(): string;
  43804. private _zoomStopsAnimation;
  43805. private _idleRotationSpeed;
  43806. private _idleRotationWaitTime;
  43807. private _idleRotationSpinupTime;
  43808. /**
  43809. * Sets the flag that indicates if user zooming should stop animation.
  43810. */
  43811. set zoomStopsAnimation(flag: boolean);
  43812. /**
  43813. * Gets the flag that indicates if user zooming should stop animation.
  43814. */
  43815. get zoomStopsAnimation(): boolean;
  43816. /**
  43817. * Sets the default speed at which the camera rotates around the model.
  43818. */
  43819. set idleRotationSpeed(speed: number);
  43820. /**
  43821. * Gets the default speed at which the camera rotates around the model.
  43822. */
  43823. get idleRotationSpeed(): number;
  43824. /**
  43825. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43826. */
  43827. set idleRotationWaitTime(time: number);
  43828. /**
  43829. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43830. */
  43831. get idleRotationWaitTime(): number;
  43832. /**
  43833. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43834. */
  43835. set idleRotationSpinupTime(time: number);
  43836. /**
  43837. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43838. */
  43839. get idleRotationSpinupTime(): number;
  43840. /**
  43841. * Gets a value indicating if the camera is currently rotating because of this behavior
  43842. */
  43843. get rotationInProgress(): boolean;
  43844. private _onPrePointerObservableObserver;
  43845. private _onAfterCheckInputsObserver;
  43846. private _attachedCamera;
  43847. private _isPointerDown;
  43848. private _lastFrameTime;
  43849. private _lastInteractionTime;
  43850. private _cameraRotationSpeed;
  43851. /**
  43852. * Initializes the behavior.
  43853. */
  43854. init(): void;
  43855. /**
  43856. * Attaches the behavior to its arc rotate camera.
  43857. * @param camera Defines the camera to attach the behavior to
  43858. */
  43859. attach(camera: ArcRotateCamera): void;
  43860. /**
  43861. * Detaches the behavior from its current arc rotate camera.
  43862. */
  43863. detach(): void;
  43864. /**
  43865. * Returns true if user is scrolling.
  43866. * @return true if user is scrolling.
  43867. */
  43868. private _userIsZooming;
  43869. private _lastFrameRadius;
  43870. private _shouldAnimationStopForInteraction;
  43871. /**
  43872. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43873. */
  43874. private _applyUserInteraction;
  43875. private _userIsMoving;
  43876. }
  43877. }
  43878. declare module "babylonjs/Behaviors/Cameras/index" {
  43879. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43880. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43881. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43882. }
  43883. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43884. import { Mesh } from "babylonjs/Meshes/mesh";
  43885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43886. import { Behavior } from "babylonjs/Behaviors/behavior";
  43887. /**
  43888. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43889. */
  43890. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43891. private ui;
  43892. /**
  43893. * The name of the behavior
  43894. */
  43895. name: string;
  43896. /**
  43897. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43898. */
  43899. distanceAwayFromFace: number;
  43900. /**
  43901. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43902. */
  43903. distanceAwayFromBottomOfFace: number;
  43904. private _faceVectors;
  43905. private _target;
  43906. private _scene;
  43907. private _onRenderObserver;
  43908. private _tmpMatrix;
  43909. private _tmpVector;
  43910. /**
  43911. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43912. * @param ui The transform node that should be attched to the mesh
  43913. */
  43914. constructor(ui: TransformNode);
  43915. /**
  43916. * Initializes the behavior
  43917. */
  43918. init(): void;
  43919. private _closestFace;
  43920. private _zeroVector;
  43921. private _lookAtTmpMatrix;
  43922. private _lookAtToRef;
  43923. /**
  43924. * Attaches the AttachToBoxBehavior to the passed in mesh
  43925. * @param target The mesh that the specified node will be attached to
  43926. */
  43927. attach(target: Mesh): void;
  43928. /**
  43929. * Detaches the behavior from the mesh
  43930. */
  43931. detach(): void;
  43932. }
  43933. }
  43934. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43935. import { Behavior } from "babylonjs/Behaviors/behavior";
  43936. import { Mesh } from "babylonjs/Meshes/mesh";
  43937. /**
  43938. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43939. */
  43940. export class FadeInOutBehavior implements Behavior<Mesh> {
  43941. /**
  43942. * Time in milliseconds to delay before fading in (Default: 0)
  43943. */
  43944. delay: number;
  43945. /**
  43946. * Time in milliseconds for the mesh to fade in (Default: 300)
  43947. */
  43948. fadeInTime: number;
  43949. private _millisecondsPerFrame;
  43950. private _hovered;
  43951. private _hoverValue;
  43952. private _ownerNode;
  43953. /**
  43954. * Instatiates the FadeInOutBehavior
  43955. */
  43956. constructor();
  43957. /**
  43958. * The name of the behavior
  43959. */
  43960. get name(): string;
  43961. /**
  43962. * Initializes the behavior
  43963. */
  43964. init(): void;
  43965. /**
  43966. * Attaches the fade behavior on the passed in mesh
  43967. * @param ownerNode The mesh that will be faded in/out once attached
  43968. */
  43969. attach(ownerNode: Mesh): void;
  43970. /**
  43971. * Detaches the behavior from the mesh
  43972. */
  43973. detach(): void;
  43974. /**
  43975. * Triggers the mesh to begin fading in or out
  43976. * @param value if the object should fade in or out (true to fade in)
  43977. */
  43978. fadeIn(value: boolean): void;
  43979. private _update;
  43980. private _setAllVisibility;
  43981. }
  43982. }
  43983. declare module "babylonjs/Misc/pivotTools" {
  43984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43985. /**
  43986. * Class containing a set of static utilities functions for managing Pivots
  43987. * @hidden
  43988. */
  43989. export class PivotTools {
  43990. private static _PivotCached;
  43991. private static _OldPivotPoint;
  43992. private static _PivotTranslation;
  43993. private static _PivotTmpVector;
  43994. /** @hidden */
  43995. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43996. /** @hidden */
  43997. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43998. }
  43999. }
  44000. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44001. import { Scene } from "babylonjs/scene";
  44002. import { Vector4 } from "babylonjs/Maths/math.vector";
  44003. import { Mesh } from "babylonjs/Meshes/mesh";
  44004. import { Nullable } from "babylonjs/types";
  44005. import { Plane } from "babylonjs/Maths/math.plane";
  44006. /**
  44007. * Class containing static functions to help procedurally build meshes
  44008. */
  44009. export class PlaneBuilder {
  44010. /**
  44011. * Creates a plane mesh
  44012. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44013. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44014. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44018. * @param name defines the name of the mesh
  44019. * @param options defines the options used to create the mesh
  44020. * @param scene defines the hosting scene
  44021. * @returns the plane mesh
  44022. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44023. */
  44024. static CreatePlane(name: string, options: {
  44025. size?: number;
  44026. width?: number;
  44027. height?: number;
  44028. sideOrientation?: number;
  44029. frontUVs?: Vector4;
  44030. backUVs?: Vector4;
  44031. updatable?: boolean;
  44032. sourcePlane?: Plane;
  44033. }, scene?: Nullable<Scene>): Mesh;
  44034. }
  44035. }
  44036. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44037. import { Behavior } from "babylonjs/Behaviors/behavior";
  44038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44039. import { Observable } from "babylonjs/Misc/observable";
  44040. import { Vector3 } from "babylonjs/Maths/math.vector";
  44041. import { Ray } from "babylonjs/Culling/ray";
  44042. import "babylonjs/Meshes/Builders/planeBuilder";
  44043. /**
  44044. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44045. */
  44046. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44047. private static _AnyMouseID;
  44048. /**
  44049. * Abstract mesh the behavior is set on
  44050. */
  44051. attachedNode: AbstractMesh;
  44052. private _dragPlane;
  44053. private _scene;
  44054. private _pointerObserver;
  44055. private _beforeRenderObserver;
  44056. private static _planeScene;
  44057. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44058. /**
  44059. * 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)
  44060. */
  44061. maxDragAngle: number;
  44062. /**
  44063. * @hidden
  44064. */
  44065. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44066. /**
  44067. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44068. */
  44069. currentDraggingPointerID: number;
  44070. /**
  44071. * The last position where the pointer hit the drag plane in world space
  44072. */
  44073. lastDragPosition: Vector3;
  44074. /**
  44075. * If the behavior is currently in a dragging state
  44076. */
  44077. dragging: boolean;
  44078. /**
  44079. * 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)
  44080. */
  44081. dragDeltaRatio: number;
  44082. /**
  44083. * If the drag plane orientation should be updated during the dragging (Default: true)
  44084. */
  44085. updateDragPlane: boolean;
  44086. private _debugMode;
  44087. private _moving;
  44088. /**
  44089. * Fires each time the attached mesh is dragged with the pointer
  44090. * * delta between last drag position and current drag position in world space
  44091. * * dragDistance along the drag axis
  44092. * * dragPlaneNormal normal of the current drag plane used during the drag
  44093. * * dragPlanePoint in world space where the drag intersects the drag plane
  44094. */
  44095. onDragObservable: Observable<{
  44096. delta: Vector3;
  44097. dragPlanePoint: Vector3;
  44098. dragPlaneNormal: Vector3;
  44099. dragDistance: number;
  44100. pointerId: number;
  44101. }>;
  44102. /**
  44103. * Fires each time a drag begins (eg. mouse down on mesh)
  44104. */
  44105. onDragStartObservable: Observable<{
  44106. dragPlanePoint: Vector3;
  44107. pointerId: number;
  44108. }>;
  44109. /**
  44110. * Fires each time a drag ends (eg. mouse release after drag)
  44111. */
  44112. onDragEndObservable: Observable<{
  44113. dragPlanePoint: Vector3;
  44114. pointerId: number;
  44115. }>;
  44116. /**
  44117. * If the attached mesh should be moved when dragged
  44118. */
  44119. moveAttached: boolean;
  44120. /**
  44121. * If the drag behavior will react to drag events (Default: true)
  44122. */
  44123. enabled: boolean;
  44124. /**
  44125. * If pointer events should start and release the drag (Default: true)
  44126. */
  44127. startAndReleaseDragOnPointerEvents: boolean;
  44128. /**
  44129. * If camera controls should be detached during the drag
  44130. */
  44131. detachCameraControls: boolean;
  44132. /**
  44133. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44134. */
  44135. useObjectOrientationForDragging: boolean;
  44136. private _options;
  44137. /**
  44138. * Gets the options used by the behavior
  44139. */
  44140. get options(): {
  44141. dragAxis?: Vector3;
  44142. dragPlaneNormal?: Vector3;
  44143. };
  44144. /**
  44145. * Sets the options used by the behavior
  44146. */
  44147. set options(options: {
  44148. dragAxis?: Vector3;
  44149. dragPlaneNormal?: Vector3;
  44150. });
  44151. /**
  44152. * Creates a pointer drag behavior that can be attached to a mesh
  44153. * @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)
  44154. */
  44155. constructor(options?: {
  44156. dragAxis?: Vector3;
  44157. dragPlaneNormal?: Vector3;
  44158. });
  44159. /**
  44160. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44161. */
  44162. validateDrag: (targetPosition: Vector3) => boolean;
  44163. /**
  44164. * The name of the behavior
  44165. */
  44166. get name(): string;
  44167. /**
  44168. * Initializes the behavior
  44169. */
  44170. init(): void;
  44171. private _tmpVector;
  44172. private _alternatePickedPoint;
  44173. private _worldDragAxis;
  44174. private _targetPosition;
  44175. private _attachedElement;
  44176. /**
  44177. * Attaches the drag behavior the passed in mesh
  44178. * @param ownerNode The mesh that will be dragged around once attached
  44179. * @param predicate Predicate to use for pick filtering
  44180. */
  44181. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44182. /**
  44183. * Force relase the drag action by code.
  44184. */
  44185. releaseDrag(): void;
  44186. private _startDragRay;
  44187. private _lastPointerRay;
  44188. /**
  44189. * Simulates the start of a pointer drag event on the behavior
  44190. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44191. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44192. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44193. */
  44194. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44195. private _startDrag;
  44196. private _dragDelta;
  44197. private _moveDrag;
  44198. private _pickWithRayOnDragPlane;
  44199. private _pointA;
  44200. private _pointB;
  44201. private _pointC;
  44202. private _lineA;
  44203. private _lineB;
  44204. private _localAxis;
  44205. private _lookAt;
  44206. private _updateDragPlanePosition;
  44207. /**
  44208. * Detaches the behavior from the mesh
  44209. */
  44210. detach(): void;
  44211. }
  44212. }
  44213. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44214. import { Mesh } from "babylonjs/Meshes/mesh";
  44215. import { Behavior } from "babylonjs/Behaviors/behavior";
  44216. /**
  44217. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44218. */
  44219. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44220. private _dragBehaviorA;
  44221. private _dragBehaviorB;
  44222. private _startDistance;
  44223. private _initialScale;
  44224. private _targetScale;
  44225. private _ownerNode;
  44226. private _sceneRenderObserver;
  44227. /**
  44228. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44229. */
  44230. constructor();
  44231. /**
  44232. * The name of the behavior
  44233. */
  44234. get name(): string;
  44235. /**
  44236. * Initializes the behavior
  44237. */
  44238. init(): void;
  44239. private _getCurrentDistance;
  44240. /**
  44241. * Attaches the scale behavior the passed in mesh
  44242. * @param ownerNode The mesh that will be scaled around once attached
  44243. */
  44244. attach(ownerNode: Mesh): void;
  44245. /**
  44246. * Detaches the behavior from the mesh
  44247. */
  44248. detach(): void;
  44249. }
  44250. }
  44251. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44252. import { Behavior } from "babylonjs/Behaviors/behavior";
  44253. import { Mesh } from "babylonjs/Meshes/mesh";
  44254. import { Observable } from "babylonjs/Misc/observable";
  44255. /**
  44256. * 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
  44257. */
  44258. export class SixDofDragBehavior implements Behavior<Mesh> {
  44259. private static _virtualScene;
  44260. private _ownerNode;
  44261. private _sceneRenderObserver;
  44262. private _scene;
  44263. private _targetPosition;
  44264. private _virtualOriginMesh;
  44265. private _virtualDragMesh;
  44266. private _pointerObserver;
  44267. private _moving;
  44268. private _startingOrientation;
  44269. private _attachedElement;
  44270. /**
  44271. * 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)
  44272. */
  44273. private zDragFactor;
  44274. /**
  44275. * If the object should rotate to face the drag origin
  44276. */
  44277. rotateDraggedObject: boolean;
  44278. /**
  44279. * If the behavior is currently in a dragging state
  44280. */
  44281. dragging: boolean;
  44282. /**
  44283. * 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)
  44284. */
  44285. dragDeltaRatio: number;
  44286. /**
  44287. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44288. */
  44289. currentDraggingPointerID: number;
  44290. /**
  44291. * If camera controls should be detached during the drag
  44292. */
  44293. detachCameraControls: boolean;
  44294. /**
  44295. * Fires each time a drag starts
  44296. */
  44297. onDragStartObservable: Observable<{}>;
  44298. /**
  44299. * Fires each time a drag ends (eg. mouse release after drag)
  44300. */
  44301. onDragEndObservable: Observable<{}>;
  44302. /**
  44303. * 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
  44304. */
  44305. constructor();
  44306. /**
  44307. * The name of the behavior
  44308. */
  44309. get name(): string;
  44310. /**
  44311. * Initializes the behavior
  44312. */
  44313. init(): void;
  44314. /**
  44315. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44316. */
  44317. private get _pointerCamera();
  44318. /**
  44319. * Attaches the scale behavior the passed in mesh
  44320. * @param ownerNode The mesh that will be scaled around once attached
  44321. */
  44322. attach(ownerNode: Mesh): void;
  44323. /**
  44324. * Detaches the behavior from the mesh
  44325. */
  44326. detach(): void;
  44327. }
  44328. }
  44329. declare module "babylonjs/Behaviors/Meshes/index" {
  44330. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44331. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44332. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44333. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44334. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44335. }
  44336. declare module "babylonjs/Behaviors/index" {
  44337. export * from "babylonjs/Behaviors/behavior";
  44338. export * from "babylonjs/Behaviors/Cameras/index";
  44339. export * from "babylonjs/Behaviors/Meshes/index";
  44340. }
  44341. declare module "babylonjs/Bones/boneIKController" {
  44342. import { Bone } from "babylonjs/Bones/bone";
  44343. import { Vector3 } from "babylonjs/Maths/math.vector";
  44344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44345. import { Nullable } from "babylonjs/types";
  44346. /**
  44347. * Class used to apply inverse kinematics to bones
  44348. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44349. */
  44350. export class BoneIKController {
  44351. private static _tmpVecs;
  44352. private static _tmpQuat;
  44353. private static _tmpMats;
  44354. /**
  44355. * Gets or sets the target mesh
  44356. */
  44357. targetMesh: AbstractMesh;
  44358. /** Gets or sets the mesh used as pole */
  44359. poleTargetMesh: AbstractMesh;
  44360. /**
  44361. * Gets or sets the bone used as pole
  44362. */
  44363. poleTargetBone: Nullable<Bone>;
  44364. /**
  44365. * Gets or sets the target position
  44366. */
  44367. targetPosition: Vector3;
  44368. /**
  44369. * Gets or sets the pole target position
  44370. */
  44371. poleTargetPosition: Vector3;
  44372. /**
  44373. * Gets or sets the pole target local offset
  44374. */
  44375. poleTargetLocalOffset: Vector3;
  44376. /**
  44377. * Gets or sets the pole angle
  44378. */
  44379. poleAngle: number;
  44380. /**
  44381. * Gets or sets the mesh associated with the controller
  44382. */
  44383. mesh: AbstractMesh;
  44384. /**
  44385. * 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)
  44386. */
  44387. slerpAmount: number;
  44388. private _bone1Quat;
  44389. private _bone1Mat;
  44390. private _bone2Ang;
  44391. private _bone1;
  44392. private _bone2;
  44393. private _bone1Length;
  44394. private _bone2Length;
  44395. private _maxAngle;
  44396. private _maxReach;
  44397. private _rightHandedSystem;
  44398. private _bendAxis;
  44399. private _slerping;
  44400. private _adjustRoll;
  44401. /**
  44402. * Gets or sets maximum allowed angle
  44403. */
  44404. get maxAngle(): number;
  44405. set maxAngle(value: number);
  44406. /**
  44407. * Creates a new BoneIKController
  44408. * @param mesh defines the mesh to control
  44409. * @param bone defines the bone to control
  44410. * @param options defines options to set up the controller
  44411. */
  44412. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44413. targetMesh?: AbstractMesh;
  44414. poleTargetMesh?: AbstractMesh;
  44415. poleTargetBone?: Bone;
  44416. poleTargetLocalOffset?: Vector3;
  44417. poleAngle?: number;
  44418. bendAxis?: Vector3;
  44419. maxAngle?: number;
  44420. slerpAmount?: number;
  44421. });
  44422. private _setMaxAngle;
  44423. /**
  44424. * Force the controller to update the bones
  44425. */
  44426. update(): void;
  44427. }
  44428. }
  44429. declare module "babylonjs/Bones/boneLookController" {
  44430. import { Vector3 } from "babylonjs/Maths/math.vector";
  44431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44432. import { Bone } from "babylonjs/Bones/bone";
  44433. import { Space } from "babylonjs/Maths/math.axis";
  44434. /**
  44435. * Class used to make a bone look toward a point in space
  44436. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44437. */
  44438. export class BoneLookController {
  44439. private static _tmpVecs;
  44440. private static _tmpQuat;
  44441. private static _tmpMats;
  44442. /**
  44443. * The target Vector3 that the bone will look at
  44444. */
  44445. target: Vector3;
  44446. /**
  44447. * The mesh that the bone is attached to
  44448. */
  44449. mesh: AbstractMesh;
  44450. /**
  44451. * The bone that will be looking to the target
  44452. */
  44453. bone: Bone;
  44454. /**
  44455. * The up axis of the coordinate system that is used when the bone is rotated
  44456. */
  44457. upAxis: Vector3;
  44458. /**
  44459. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44460. */
  44461. upAxisSpace: Space;
  44462. /**
  44463. * Used to make an adjustment to the yaw of the bone
  44464. */
  44465. adjustYaw: number;
  44466. /**
  44467. * Used to make an adjustment to the pitch of the bone
  44468. */
  44469. adjustPitch: number;
  44470. /**
  44471. * Used to make an adjustment to the roll of the bone
  44472. */
  44473. adjustRoll: number;
  44474. /**
  44475. * 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)
  44476. */
  44477. slerpAmount: number;
  44478. private _minYaw;
  44479. private _maxYaw;
  44480. private _minPitch;
  44481. private _maxPitch;
  44482. private _minYawSin;
  44483. private _minYawCos;
  44484. private _maxYawSin;
  44485. private _maxYawCos;
  44486. private _midYawConstraint;
  44487. private _minPitchTan;
  44488. private _maxPitchTan;
  44489. private _boneQuat;
  44490. private _slerping;
  44491. private _transformYawPitch;
  44492. private _transformYawPitchInv;
  44493. private _firstFrameSkipped;
  44494. private _yawRange;
  44495. private _fowardAxis;
  44496. /**
  44497. * Gets or sets the minimum yaw angle that the bone can look to
  44498. */
  44499. get minYaw(): number;
  44500. set minYaw(value: number);
  44501. /**
  44502. * Gets or sets the maximum yaw angle that the bone can look to
  44503. */
  44504. get maxYaw(): number;
  44505. set maxYaw(value: number);
  44506. /**
  44507. * Gets or sets the minimum pitch angle that the bone can look to
  44508. */
  44509. get minPitch(): number;
  44510. set minPitch(value: number);
  44511. /**
  44512. * Gets or sets the maximum pitch angle that the bone can look to
  44513. */
  44514. get maxPitch(): number;
  44515. set maxPitch(value: number);
  44516. /**
  44517. * Create a BoneLookController
  44518. * @param mesh the mesh that the bone belongs to
  44519. * @param bone the bone that will be looking to the target
  44520. * @param target the target Vector3 to look at
  44521. * @param options optional settings:
  44522. * * maxYaw: the maximum angle the bone will yaw to
  44523. * * minYaw: the minimum angle the bone will yaw to
  44524. * * maxPitch: the maximum angle the bone will pitch to
  44525. * * minPitch: the minimum angle the bone will yaw to
  44526. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44527. * * upAxis: the up axis of the coordinate system
  44528. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44529. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44530. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44531. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44532. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44533. * * adjustRoll: used to make an adjustment to the roll of the bone
  44534. **/
  44535. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44536. maxYaw?: number;
  44537. minYaw?: number;
  44538. maxPitch?: number;
  44539. minPitch?: number;
  44540. slerpAmount?: number;
  44541. upAxis?: Vector3;
  44542. upAxisSpace?: Space;
  44543. yawAxis?: Vector3;
  44544. pitchAxis?: Vector3;
  44545. adjustYaw?: number;
  44546. adjustPitch?: number;
  44547. adjustRoll?: number;
  44548. });
  44549. /**
  44550. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44551. */
  44552. update(): void;
  44553. private _getAngleDiff;
  44554. private _getAngleBetween;
  44555. private _isAngleBetween;
  44556. }
  44557. }
  44558. declare module "babylonjs/Bones/index" {
  44559. export * from "babylonjs/Bones/bone";
  44560. export * from "babylonjs/Bones/boneIKController";
  44561. export * from "babylonjs/Bones/boneLookController";
  44562. export * from "babylonjs/Bones/skeleton";
  44563. }
  44564. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44565. import { Nullable } from "babylonjs/types";
  44566. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44567. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44568. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44569. /**
  44570. * Manage the gamepad inputs to control an arc rotate camera.
  44571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44572. */
  44573. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44574. /**
  44575. * Defines the camera the input is attached to.
  44576. */
  44577. camera: ArcRotateCamera;
  44578. /**
  44579. * Defines the gamepad the input is gathering event from.
  44580. */
  44581. gamepad: Nullable<Gamepad>;
  44582. /**
  44583. * Defines the gamepad rotation sensiblity.
  44584. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44585. */
  44586. gamepadRotationSensibility: number;
  44587. /**
  44588. * Defines the gamepad move sensiblity.
  44589. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44590. */
  44591. gamepadMoveSensibility: number;
  44592. private _yAxisScale;
  44593. /**
  44594. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44595. */
  44596. get invertYAxis(): boolean;
  44597. set invertYAxis(value: boolean);
  44598. private _onGamepadConnectedObserver;
  44599. private _onGamepadDisconnectedObserver;
  44600. /**
  44601. * Attach the input controls to a specific dom element to get the input from.
  44602. * @param element Defines the element the controls should be listened from
  44603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44604. */
  44605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44606. /**
  44607. * Detach the current controls from the specified dom element.
  44608. * @param element Defines the element to stop listening the inputs from
  44609. */
  44610. detachControl(element: Nullable<HTMLElement>): void;
  44611. /**
  44612. * Update the current camera state depending on the inputs that have been used this frame.
  44613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44614. */
  44615. checkInputs(): void;
  44616. /**
  44617. * Gets the class name of the current intput.
  44618. * @returns the class name
  44619. */
  44620. getClassName(): string;
  44621. /**
  44622. * Get the friendly name associated with the input class.
  44623. * @returns the input friendly name
  44624. */
  44625. getSimpleName(): string;
  44626. }
  44627. }
  44628. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44629. import { Nullable } from "babylonjs/types";
  44630. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44631. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44632. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44633. interface ArcRotateCameraInputsManager {
  44634. /**
  44635. * Add orientation input support to the input manager.
  44636. * @returns the current input manager
  44637. */
  44638. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44639. }
  44640. }
  44641. /**
  44642. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44643. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44644. */
  44645. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44646. /**
  44647. * Defines the camera the input is attached to.
  44648. */
  44649. camera: ArcRotateCamera;
  44650. /**
  44651. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44652. */
  44653. alphaCorrection: number;
  44654. /**
  44655. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44656. */
  44657. gammaCorrection: number;
  44658. private _alpha;
  44659. private _gamma;
  44660. private _dirty;
  44661. private _deviceOrientationHandler;
  44662. /**
  44663. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44664. */
  44665. constructor();
  44666. /**
  44667. * Attach the input controls to a specific dom element to get the input from.
  44668. * @param element Defines the element the controls should be listened from
  44669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44670. */
  44671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44672. /** @hidden */
  44673. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44674. /**
  44675. * Update the current camera state depending on the inputs that have been used this frame.
  44676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44677. */
  44678. checkInputs(): void;
  44679. /**
  44680. * Detach the current controls from the specified dom element.
  44681. * @param element Defines the element to stop listening the inputs from
  44682. */
  44683. detachControl(element: Nullable<HTMLElement>): void;
  44684. /**
  44685. * Gets the class name of the current intput.
  44686. * @returns the class name
  44687. */
  44688. getClassName(): string;
  44689. /**
  44690. * Get the friendly name associated with the input class.
  44691. * @returns the input friendly name
  44692. */
  44693. getSimpleName(): string;
  44694. }
  44695. }
  44696. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44697. import { Nullable } from "babylonjs/types";
  44698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44699. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44700. /**
  44701. * Listen to mouse events to control the camera.
  44702. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44703. */
  44704. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44705. /**
  44706. * Defines the camera the input is attached to.
  44707. */
  44708. camera: FlyCamera;
  44709. /**
  44710. * Defines if touch is enabled. (Default is true.)
  44711. */
  44712. touchEnabled: boolean;
  44713. /**
  44714. * Defines the buttons associated with the input to handle camera rotation.
  44715. */
  44716. buttons: number[];
  44717. /**
  44718. * Assign buttons for Yaw control.
  44719. */
  44720. buttonsYaw: number[];
  44721. /**
  44722. * Assign buttons for Pitch control.
  44723. */
  44724. buttonsPitch: number[];
  44725. /**
  44726. * Assign buttons for Roll control.
  44727. */
  44728. buttonsRoll: number[];
  44729. /**
  44730. * Detect if any button is being pressed while mouse is moved.
  44731. * -1 = Mouse locked.
  44732. * 0 = Left button.
  44733. * 1 = Middle Button.
  44734. * 2 = Right Button.
  44735. */
  44736. activeButton: number;
  44737. /**
  44738. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44739. * Higher values reduce its sensitivity.
  44740. */
  44741. angularSensibility: number;
  44742. private _mousemoveCallback;
  44743. private _observer;
  44744. private _rollObserver;
  44745. private previousPosition;
  44746. private noPreventDefault;
  44747. private element;
  44748. /**
  44749. * Listen to mouse events to control the camera.
  44750. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44752. */
  44753. constructor(touchEnabled?: boolean);
  44754. /**
  44755. * Attach the mouse control to the HTML DOM element.
  44756. * @param element Defines the element that listens to the input events.
  44757. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44758. */
  44759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44760. /**
  44761. * Detach the current controls from the specified dom element.
  44762. * @param element Defines the element to stop listening the inputs from
  44763. */
  44764. detachControl(element: Nullable<HTMLElement>): void;
  44765. /**
  44766. * Gets the class name of the current input.
  44767. * @returns the class name.
  44768. */
  44769. getClassName(): string;
  44770. /**
  44771. * Get the friendly name associated with the input class.
  44772. * @returns the input's friendly name.
  44773. */
  44774. getSimpleName(): string;
  44775. private _pointerInput;
  44776. private _onMouseMove;
  44777. /**
  44778. * Rotate camera by mouse offset.
  44779. */
  44780. private rotateCamera;
  44781. }
  44782. }
  44783. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44784. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44785. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44786. /**
  44787. * Default Inputs manager for the FlyCamera.
  44788. * It groups all the default supported inputs for ease of use.
  44789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44790. */
  44791. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44792. /**
  44793. * Instantiates a new FlyCameraInputsManager.
  44794. * @param camera Defines the camera the inputs belong to.
  44795. */
  44796. constructor(camera: FlyCamera);
  44797. /**
  44798. * Add keyboard input support to the input manager.
  44799. * @returns the new FlyCameraKeyboardMoveInput().
  44800. */
  44801. addKeyboard(): FlyCameraInputsManager;
  44802. /**
  44803. * Add mouse input support to the input manager.
  44804. * @param touchEnabled Enable touch screen support.
  44805. * @returns the new FlyCameraMouseInput().
  44806. */
  44807. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44808. }
  44809. }
  44810. declare module "babylonjs/Cameras/flyCamera" {
  44811. import { Scene } from "babylonjs/scene";
  44812. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44814. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44815. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44816. /**
  44817. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44818. * such as in a 3D Space Shooter or a Flight Simulator.
  44819. */
  44820. export class FlyCamera extends TargetCamera {
  44821. /**
  44822. * Define the collision ellipsoid of the camera.
  44823. * This is helpful for simulating a camera body, like a player's body.
  44824. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44825. */
  44826. ellipsoid: Vector3;
  44827. /**
  44828. * Define an offset for the position of the ellipsoid around the camera.
  44829. * This can be helpful if the camera is attached away from the player's body center,
  44830. * such as at its head.
  44831. */
  44832. ellipsoidOffset: Vector3;
  44833. /**
  44834. * Enable or disable collisions of the camera with the rest of the scene objects.
  44835. */
  44836. checkCollisions: boolean;
  44837. /**
  44838. * Enable or disable gravity on the camera.
  44839. */
  44840. applyGravity: boolean;
  44841. /**
  44842. * Define the current direction the camera is moving to.
  44843. */
  44844. cameraDirection: Vector3;
  44845. /**
  44846. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44847. * This overrides and empties cameraRotation.
  44848. */
  44849. rotationQuaternion: Quaternion;
  44850. /**
  44851. * Track Roll to maintain the wanted Rolling when looking around.
  44852. */
  44853. _trackRoll: number;
  44854. /**
  44855. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44856. */
  44857. rollCorrect: number;
  44858. /**
  44859. * Mimic a banked turn, Rolling the camera when Yawing.
  44860. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44861. */
  44862. bankedTurn: boolean;
  44863. /**
  44864. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44865. */
  44866. bankedTurnLimit: number;
  44867. /**
  44868. * Value of 0 disables the banked Roll.
  44869. * Value of 1 is equal to the Yaw angle in radians.
  44870. */
  44871. bankedTurnMultiplier: number;
  44872. /**
  44873. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44874. */
  44875. inputs: FlyCameraInputsManager;
  44876. /**
  44877. * Gets the input sensibility for mouse input.
  44878. * Higher values reduce sensitivity.
  44879. */
  44880. get angularSensibility(): number;
  44881. /**
  44882. * Sets the input sensibility for a mouse input.
  44883. * Higher values reduce sensitivity.
  44884. */
  44885. set angularSensibility(value: number);
  44886. /**
  44887. * Get the keys for camera movement forward.
  44888. */
  44889. get keysForward(): number[];
  44890. /**
  44891. * Set the keys for camera movement forward.
  44892. */
  44893. set keysForward(value: number[]);
  44894. /**
  44895. * Get the keys for camera movement backward.
  44896. */
  44897. get keysBackward(): number[];
  44898. set keysBackward(value: number[]);
  44899. /**
  44900. * Get the keys for camera movement up.
  44901. */
  44902. get keysUp(): number[];
  44903. /**
  44904. * Set the keys for camera movement up.
  44905. */
  44906. set keysUp(value: number[]);
  44907. /**
  44908. * Get the keys for camera movement down.
  44909. */
  44910. get keysDown(): number[];
  44911. /**
  44912. * Set the keys for camera movement down.
  44913. */
  44914. set keysDown(value: number[]);
  44915. /**
  44916. * Get the keys for camera movement left.
  44917. */
  44918. get keysLeft(): number[];
  44919. /**
  44920. * Set the keys for camera movement left.
  44921. */
  44922. set keysLeft(value: number[]);
  44923. /**
  44924. * Set the keys for camera movement right.
  44925. */
  44926. get keysRight(): number[];
  44927. /**
  44928. * Set the keys for camera movement right.
  44929. */
  44930. set keysRight(value: number[]);
  44931. /**
  44932. * Event raised when the camera collides with a mesh in the scene.
  44933. */
  44934. onCollide: (collidedMesh: AbstractMesh) => void;
  44935. private _collider;
  44936. private _needMoveForGravity;
  44937. private _oldPosition;
  44938. private _diffPosition;
  44939. private _newPosition;
  44940. /** @hidden */
  44941. _localDirection: Vector3;
  44942. /** @hidden */
  44943. _transformedDirection: Vector3;
  44944. /**
  44945. * Instantiates a FlyCamera.
  44946. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44947. * such as in a 3D Space Shooter or a Flight Simulator.
  44948. * @param name Define the name of the camera in the scene.
  44949. * @param position Define the starting position of the camera in the scene.
  44950. * @param scene Define the scene the camera belongs to.
  44951. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44952. */
  44953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44954. /**
  44955. * Attach a control to the HTML DOM element.
  44956. * @param element Defines the element that listens to the input events.
  44957. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44958. */
  44959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44960. /**
  44961. * Detach a control from the HTML DOM element.
  44962. * The camera will stop reacting to that input.
  44963. * @param element Defines the element that listens to the input events.
  44964. */
  44965. detachControl(element: HTMLElement): void;
  44966. private _collisionMask;
  44967. /**
  44968. * Get the mask that the camera ignores in collision events.
  44969. */
  44970. get collisionMask(): number;
  44971. /**
  44972. * Set the mask that the camera ignores in collision events.
  44973. */
  44974. set collisionMask(mask: number);
  44975. /** @hidden */
  44976. _collideWithWorld(displacement: Vector3): void;
  44977. /** @hidden */
  44978. private _onCollisionPositionChange;
  44979. /** @hidden */
  44980. _checkInputs(): void;
  44981. /** @hidden */
  44982. _decideIfNeedsToMove(): boolean;
  44983. /** @hidden */
  44984. _updatePosition(): void;
  44985. /**
  44986. * Restore the Roll to its target value at the rate specified.
  44987. * @param rate - Higher means slower restoring.
  44988. * @hidden
  44989. */
  44990. restoreRoll(rate: number): void;
  44991. /**
  44992. * Destroy the camera and release the current resources held by it.
  44993. */
  44994. dispose(): void;
  44995. /**
  44996. * Get the current object class name.
  44997. * @returns the class name.
  44998. */
  44999. getClassName(): string;
  45000. }
  45001. }
  45002. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45003. import { Nullable } from "babylonjs/types";
  45004. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45005. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45006. /**
  45007. * Listen to keyboard events to control the camera.
  45008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45009. */
  45010. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45011. /**
  45012. * Defines the camera the input is attached to.
  45013. */
  45014. camera: FlyCamera;
  45015. /**
  45016. * The list of keyboard keys used to control the forward move of the camera.
  45017. */
  45018. keysForward: number[];
  45019. /**
  45020. * The list of keyboard keys used to control the backward move of the camera.
  45021. */
  45022. keysBackward: number[];
  45023. /**
  45024. * The list of keyboard keys used to control the forward move of the camera.
  45025. */
  45026. keysUp: number[];
  45027. /**
  45028. * The list of keyboard keys used to control the backward move of the camera.
  45029. */
  45030. keysDown: number[];
  45031. /**
  45032. * The list of keyboard keys used to control the right strafe move of the camera.
  45033. */
  45034. keysRight: number[];
  45035. /**
  45036. * The list of keyboard keys used to control the left strafe move of the camera.
  45037. */
  45038. keysLeft: number[];
  45039. private _keys;
  45040. private _onCanvasBlurObserver;
  45041. private _onKeyboardObserver;
  45042. private _engine;
  45043. private _scene;
  45044. /**
  45045. * Attach the input controls to a specific dom element to get the input from.
  45046. * @param element Defines the element the controls should be listened from
  45047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45048. */
  45049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45050. /**
  45051. * Detach the current controls from the specified dom element.
  45052. * @param element Defines the element to stop listening the inputs from
  45053. */
  45054. detachControl(element: Nullable<HTMLElement>): void;
  45055. /**
  45056. * Gets the class name of the current intput.
  45057. * @returns the class name
  45058. */
  45059. getClassName(): string;
  45060. /** @hidden */
  45061. _onLostFocus(e: FocusEvent): void;
  45062. /**
  45063. * Get the friendly name associated with the input class.
  45064. * @returns the input friendly name
  45065. */
  45066. getSimpleName(): string;
  45067. /**
  45068. * Update the current camera state depending on the inputs that have been used this frame.
  45069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45070. */
  45071. checkInputs(): void;
  45072. }
  45073. }
  45074. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45075. import { Nullable } from "babylonjs/types";
  45076. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45077. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45078. /**
  45079. * Manage the mouse wheel inputs to control a follow camera.
  45080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45081. */
  45082. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45083. /**
  45084. * Defines the camera the input is attached to.
  45085. */
  45086. camera: FollowCamera;
  45087. /**
  45088. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45089. */
  45090. axisControlRadius: boolean;
  45091. /**
  45092. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45093. */
  45094. axisControlHeight: boolean;
  45095. /**
  45096. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45097. */
  45098. axisControlRotation: boolean;
  45099. /**
  45100. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45101. * relation to mouseWheel events.
  45102. */
  45103. wheelPrecision: number;
  45104. /**
  45105. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45106. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45107. */
  45108. wheelDeltaPercentage: number;
  45109. private _wheel;
  45110. private _observer;
  45111. /**
  45112. * Attach the input controls to a specific dom element to get the input from.
  45113. * @param element Defines the element the controls should be listened from
  45114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45115. */
  45116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45117. /**
  45118. * Detach the current controls from the specified dom element.
  45119. * @param element Defines the element to stop listening the inputs from
  45120. */
  45121. detachControl(element: Nullable<HTMLElement>): void;
  45122. /**
  45123. * Gets the class name of the current intput.
  45124. * @returns the class name
  45125. */
  45126. getClassName(): string;
  45127. /**
  45128. * Get the friendly name associated with the input class.
  45129. * @returns the input friendly name
  45130. */
  45131. getSimpleName(): string;
  45132. }
  45133. }
  45134. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45135. import { Nullable } from "babylonjs/types";
  45136. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45137. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45138. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45139. /**
  45140. * Manage the pointers inputs to control an follow camera.
  45141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45142. */
  45143. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45144. /**
  45145. * Defines the camera the input is attached to.
  45146. */
  45147. camera: FollowCamera;
  45148. /**
  45149. * Gets the class name of the current input.
  45150. * @returns the class name
  45151. */
  45152. getClassName(): string;
  45153. /**
  45154. * Defines the pointer angular sensibility along the X axis or how fast is
  45155. * the camera rotating.
  45156. * A negative number will reverse the axis direction.
  45157. */
  45158. angularSensibilityX: number;
  45159. /**
  45160. * Defines the pointer angular sensibility along the Y axis or how fast is
  45161. * the camera rotating.
  45162. * A negative number will reverse the axis direction.
  45163. */
  45164. angularSensibilityY: number;
  45165. /**
  45166. * Defines the pointer pinch precision or how fast is the camera zooming.
  45167. * A negative number will reverse the axis direction.
  45168. */
  45169. pinchPrecision: number;
  45170. /**
  45171. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45172. * from 0.
  45173. * It defines the percentage of current camera.radius to use as delta when
  45174. * pinch zoom is used.
  45175. */
  45176. pinchDeltaPercentage: number;
  45177. /**
  45178. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45179. */
  45180. axisXControlRadius: boolean;
  45181. /**
  45182. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45183. */
  45184. axisXControlHeight: boolean;
  45185. /**
  45186. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45187. */
  45188. axisXControlRotation: boolean;
  45189. /**
  45190. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45191. */
  45192. axisYControlRadius: boolean;
  45193. /**
  45194. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45195. */
  45196. axisYControlHeight: boolean;
  45197. /**
  45198. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45199. */
  45200. axisYControlRotation: boolean;
  45201. /**
  45202. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45203. */
  45204. axisPinchControlRadius: boolean;
  45205. /**
  45206. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45207. */
  45208. axisPinchControlHeight: boolean;
  45209. /**
  45210. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45211. */
  45212. axisPinchControlRotation: boolean;
  45213. /**
  45214. * Log error messages if basic misconfiguration has occurred.
  45215. */
  45216. warningEnable: boolean;
  45217. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45218. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45219. private _warningCounter;
  45220. private _warning;
  45221. }
  45222. }
  45223. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45224. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45225. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45226. /**
  45227. * Default Inputs manager for the FollowCamera.
  45228. * It groups all the default supported inputs for ease of use.
  45229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45230. */
  45231. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45232. /**
  45233. * Instantiates a new FollowCameraInputsManager.
  45234. * @param camera Defines the camera the inputs belong to
  45235. */
  45236. constructor(camera: FollowCamera);
  45237. /**
  45238. * Add keyboard input support to the input manager.
  45239. * @returns the current input manager
  45240. */
  45241. addKeyboard(): FollowCameraInputsManager;
  45242. /**
  45243. * Add mouse wheel input support to the input manager.
  45244. * @returns the current input manager
  45245. */
  45246. addMouseWheel(): FollowCameraInputsManager;
  45247. /**
  45248. * Add pointers input support to the input manager.
  45249. * @returns the current input manager
  45250. */
  45251. addPointers(): FollowCameraInputsManager;
  45252. /**
  45253. * Add orientation input support to the input manager.
  45254. * @returns the current input manager
  45255. */
  45256. addVRDeviceOrientation(): FollowCameraInputsManager;
  45257. }
  45258. }
  45259. declare module "babylonjs/Cameras/followCamera" {
  45260. import { Nullable } from "babylonjs/types";
  45261. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45262. import { Scene } from "babylonjs/scene";
  45263. import { Vector3 } from "babylonjs/Maths/math.vector";
  45264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45265. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45266. /**
  45267. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45268. * an arc rotate version arcFollowCamera are available.
  45269. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45270. */
  45271. export class FollowCamera extends TargetCamera {
  45272. /**
  45273. * Distance the follow camera should follow an object at
  45274. */
  45275. radius: number;
  45276. /**
  45277. * Minimum allowed distance of the camera to the axis of rotation
  45278. * (The camera can not get closer).
  45279. * This can help limiting how the Camera is able to move in the scene.
  45280. */
  45281. lowerRadiusLimit: Nullable<number>;
  45282. /**
  45283. * Maximum allowed distance of the camera to the axis of rotation
  45284. * (The camera can not get further).
  45285. * This can help limiting how the Camera is able to move in the scene.
  45286. */
  45287. upperRadiusLimit: Nullable<number>;
  45288. /**
  45289. * Define a rotation offset between the camera and the object it follows
  45290. */
  45291. rotationOffset: number;
  45292. /**
  45293. * Minimum allowed angle to camera position relative to target object.
  45294. * This can help limiting how the Camera is able to move in the scene.
  45295. */
  45296. lowerRotationOffsetLimit: Nullable<number>;
  45297. /**
  45298. * Maximum allowed angle to camera position relative to target object.
  45299. * This can help limiting how the Camera is able to move in the scene.
  45300. */
  45301. upperRotationOffsetLimit: Nullable<number>;
  45302. /**
  45303. * Define a height offset between the camera and the object it follows.
  45304. * It can help following an object from the top (like a car chaing a plane)
  45305. */
  45306. heightOffset: number;
  45307. /**
  45308. * Minimum allowed height of camera position relative to target object.
  45309. * This can help limiting how the Camera is able to move in the scene.
  45310. */
  45311. lowerHeightOffsetLimit: Nullable<number>;
  45312. /**
  45313. * Maximum allowed height of camera position relative to target object.
  45314. * This can help limiting how the Camera is able to move in the scene.
  45315. */
  45316. upperHeightOffsetLimit: Nullable<number>;
  45317. /**
  45318. * Define how fast the camera can accelerate to follow it s target.
  45319. */
  45320. cameraAcceleration: number;
  45321. /**
  45322. * Define the speed limit of the camera following an object.
  45323. */
  45324. maxCameraSpeed: number;
  45325. /**
  45326. * Define the target of the camera.
  45327. */
  45328. lockedTarget: Nullable<AbstractMesh>;
  45329. /**
  45330. * Defines the input associated with the camera.
  45331. */
  45332. inputs: FollowCameraInputsManager;
  45333. /**
  45334. * Instantiates the follow camera.
  45335. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45336. * @param name Define the name of the camera in the scene
  45337. * @param position Define the position of the camera
  45338. * @param scene Define the scene the camera belong to
  45339. * @param lockedTarget Define the target of the camera
  45340. */
  45341. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45342. private _follow;
  45343. /**
  45344. * Attached controls to the current camera.
  45345. * @param element Defines the element the controls should be listened from
  45346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45347. */
  45348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45349. /**
  45350. * Detach the current controls from the camera.
  45351. * The camera will stop reacting to inputs.
  45352. * @param element Defines the element to stop listening the inputs from
  45353. */
  45354. detachControl(element: HTMLElement): void;
  45355. /** @hidden */
  45356. _checkInputs(): void;
  45357. private _checkLimits;
  45358. /**
  45359. * Gets the camera class name.
  45360. * @returns the class name
  45361. */
  45362. getClassName(): string;
  45363. }
  45364. /**
  45365. * Arc Rotate version of the follow camera.
  45366. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45367. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45368. */
  45369. export class ArcFollowCamera extends TargetCamera {
  45370. /** The longitudinal angle of the camera */
  45371. alpha: number;
  45372. /** The latitudinal angle of the camera */
  45373. beta: number;
  45374. /** The radius of the camera from its target */
  45375. radius: number;
  45376. /** Define the camera target (the mesh it should follow) */
  45377. target: Nullable<AbstractMesh>;
  45378. private _cartesianCoordinates;
  45379. /**
  45380. * Instantiates a new ArcFollowCamera
  45381. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45382. * @param name Define the name of the camera
  45383. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45384. * @param beta Define the rotation angle of the camera around the elevation axis
  45385. * @param radius Define the radius of the camera from its target point
  45386. * @param target Define the target of the camera
  45387. * @param scene Define the scene the camera belongs to
  45388. */
  45389. constructor(name: string,
  45390. /** The longitudinal angle of the camera */
  45391. alpha: number,
  45392. /** The latitudinal angle of the camera */
  45393. beta: number,
  45394. /** The radius of the camera from its target */
  45395. radius: number,
  45396. /** Define the camera target (the mesh it should follow) */
  45397. target: Nullable<AbstractMesh>, scene: Scene);
  45398. private _follow;
  45399. /** @hidden */
  45400. _checkInputs(): void;
  45401. /**
  45402. * Returns the class name of the object.
  45403. * It is mostly used internally for serialization purposes.
  45404. */
  45405. getClassName(): string;
  45406. }
  45407. }
  45408. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45409. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45410. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45411. import { Nullable } from "babylonjs/types";
  45412. /**
  45413. * Manage the keyboard inputs to control the movement of a follow camera.
  45414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45415. */
  45416. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45417. /**
  45418. * Defines the camera the input is attached to.
  45419. */
  45420. camera: FollowCamera;
  45421. /**
  45422. * Defines the list of key codes associated with the up action (increase heightOffset)
  45423. */
  45424. keysHeightOffsetIncr: number[];
  45425. /**
  45426. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45427. */
  45428. keysHeightOffsetDecr: number[];
  45429. /**
  45430. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45431. */
  45432. keysHeightOffsetModifierAlt: boolean;
  45433. /**
  45434. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45435. */
  45436. keysHeightOffsetModifierCtrl: boolean;
  45437. /**
  45438. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45439. */
  45440. keysHeightOffsetModifierShift: boolean;
  45441. /**
  45442. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45443. */
  45444. keysRotationOffsetIncr: number[];
  45445. /**
  45446. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45447. */
  45448. keysRotationOffsetDecr: number[];
  45449. /**
  45450. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45451. */
  45452. keysRotationOffsetModifierAlt: boolean;
  45453. /**
  45454. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45455. */
  45456. keysRotationOffsetModifierCtrl: boolean;
  45457. /**
  45458. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45459. */
  45460. keysRotationOffsetModifierShift: boolean;
  45461. /**
  45462. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45463. */
  45464. keysRadiusIncr: number[];
  45465. /**
  45466. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45467. */
  45468. keysRadiusDecr: number[];
  45469. /**
  45470. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45471. */
  45472. keysRadiusModifierAlt: boolean;
  45473. /**
  45474. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45475. */
  45476. keysRadiusModifierCtrl: boolean;
  45477. /**
  45478. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45479. */
  45480. keysRadiusModifierShift: boolean;
  45481. /**
  45482. * Defines the rate of change of heightOffset.
  45483. */
  45484. heightSensibility: number;
  45485. /**
  45486. * Defines the rate of change of rotationOffset.
  45487. */
  45488. rotationSensibility: number;
  45489. /**
  45490. * Defines the rate of change of radius.
  45491. */
  45492. radiusSensibility: number;
  45493. private _keys;
  45494. private _ctrlPressed;
  45495. private _altPressed;
  45496. private _shiftPressed;
  45497. private _onCanvasBlurObserver;
  45498. private _onKeyboardObserver;
  45499. private _engine;
  45500. private _scene;
  45501. /**
  45502. * Attach the input controls to a specific dom element to get the input from.
  45503. * @param element Defines the element the controls should be listened from
  45504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45505. */
  45506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45507. /**
  45508. * Detach the current controls from the specified dom element.
  45509. * @param element Defines the element to stop listening the inputs from
  45510. */
  45511. detachControl(element: Nullable<HTMLElement>): void;
  45512. /**
  45513. * Update the current camera state depending on the inputs that have been used this frame.
  45514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45515. */
  45516. checkInputs(): void;
  45517. /**
  45518. * Gets the class name of the current input.
  45519. * @returns the class name
  45520. */
  45521. getClassName(): string;
  45522. /**
  45523. * Get the friendly name associated with the input class.
  45524. * @returns the input friendly name
  45525. */
  45526. getSimpleName(): string;
  45527. /**
  45528. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45529. * allow modification of the heightOffset value.
  45530. */
  45531. private _modifierHeightOffset;
  45532. /**
  45533. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45534. * allow modification of the rotationOffset value.
  45535. */
  45536. private _modifierRotationOffset;
  45537. /**
  45538. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45539. * allow modification of the radius value.
  45540. */
  45541. private _modifierRadius;
  45542. }
  45543. }
  45544. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45545. import { Nullable } from "babylonjs/types";
  45546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45547. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45548. import { Observable } from "babylonjs/Misc/observable";
  45549. module "babylonjs/Cameras/freeCameraInputsManager" {
  45550. interface FreeCameraInputsManager {
  45551. /**
  45552. * @hidden
  45553. */
  45554. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45555. /**
  45556. * Add orientation input support to the input manager.
  45557. * @returns the current input manager
  45558. */
  45559. addDeviceOrientation(): FreeCameraInputsManager;
  45560. }
  45561. }
  45562. /**
  45563. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45564. * Screen rotation is taken into account.
  45565. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45566. */
  45567. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45568. private _camera;
  45569. private _screenOrientationAngle;
  45570. private _constantTranform;
  45571. private _screenQuaternion;
  45572. private _alpha;
  45573. private _beta;
  45574. private _gamma;
  45575. /**
  45576. * Can be used to detect if a device orientation sensor is available on a device
  45577. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45578. * @returns a promise that will resolve on orientation change
  45579. */
  45580. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45581. /**
  45582. * @hidden
  45583. */
  45584. _onDeviceOrientationChangedObservable: Observable<void>;
  45585. /**
  45586. * Instantiates a new input
  45587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45588. */
  45589. constructor();
  45590. /**
  45591. * Define the camera controlled by the input.
  45592. */
  45593. get camera(): FreeCamera;
  45594. set camera(camera: FreeCamera);
  45595. /**
  45596. * Attach the input controls to a specific dom element to get the input from.
  45597. * @param element Defines the element the controls should be listened from
  45598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45599. */
  45600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45601. private _orientationChanged;
  45602. private _deviceOrientation;
  45603. /**
  45604. * Detach the current controls from the specified dom element.
  45605. * @param element Defines the element to stop listening the inputs from
  45606. */
  45607. detachControl(element: Nullable<HTMLElement>): void;
  45608. /**
  45609. * Update the current camera state depending on the inputs that have been used this frame.
  45610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45611. */
  45612. checkInputs(): void;
  45613. /**
  45614. * Gets the class name of the current intput.
  45615. * @returns the class name
  45616. */
  45617. getClassName(): string;
  45618. /**
  45619. * Get the friendly name associated with the input class.
  45620. * @returns the input friendly name
  45621. */
  45622. getSimpleName(): string;
  45623. }
  45624. }
  45625. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45626. import { Nullable } from "babylonjs/types";
  45627. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45628. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45629. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45630. /**
  45631. * Manage the gamepad inputs to control a free camera.
  45632. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45633. */
  45634. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45635. /**
  45636. * Define the camera the input is attached to.
  45637. */
  45638. camera: FreeCamera;
  45639. /**
  45640. * Define the Gamepad controlling the input
  45641. */
  45642. gamepad: Nullable<Gamepad>;
  45643. /**
  45644. * Defines the gamepad rotation sensiblity.
  45645. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45646. */
  45647. gamepadAngularSensibility: number;
  45648. /**
  45649. * Defines the gamepad move sensiblity.
  45650. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45651. */
  45652. gamepadMoveSensibility: number;
  45653. private _yAxisScale;
  45654. /**
  45655. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45656. */
  45657. get invertYAxis(): boolean;
  45658. set invertYAxis(value: boolean);
  45659. private _onGamepadConnectedObserver;
  45660. private _onGamepadDisconnectedObserver;
  45661. private _cameraTransform;
  45662. private _deltaTransform;
  45663. private _vector3;
  45664. private _vector2;
  45665. /**
  45666. * Attach the input controls to a specific dom element to get the input from.
  45667. * @param element Defines the element the controls should be listened from
  45668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45669. */
  45670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45671. /**
  45672. * Detach the current controls from the specified dom element.
  45673. * @param element Defines the element to stop listening the inputs from
  45674. */
  45675. detachControl(element: Nullable<HTMLElement>): void;
  45676. /**
  45677. * Update the current camera state depending on the inputs that have been used this frame.
  45678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45679. */
  45680. checkInputs(): void;
  45681. /**
  45682. * Gets the class name of the current intput.
  45683. * @returns the class name
  45684. */
  45685. getClassName(): string;
  45686. /**
  45687. * Get the friendly name associated with the input class.
  45688. * @returns the input friendly name
  45689. */
  45690. getSimpleName(): string;
  45691. }
  45692. }
  45693. declare module "babylonjs/Misc/virtualJoystick" {
  45694. import { Nullable } from "babylonjs/types";
  45695. import { Vector3 } from "babylonjs/Maths/math.vector";
  45696. /**
  45697. * Defines the potential axis of a Joystick
  45698. */
  45699. export enum JoystickAxis {
  45700. /** X axis */
  45701. X = 0,
  45702. /** Y axis */
  45703. Y = 1,
  45704. /** Z axis */
  45705. Z = 2
  45706. }
  45707. /**
  45708. * Represents the different customization options available
  45709. * for VirtualJoystick
  45710. */
  45711. interface VirtualJoystickCustomizations {
  45712. /**
  45713. * Size of the joystick's puck
  45714. */
  45715. puckSize: number;
  45716. /**
  45717. * Size of the joystick's container
  45718. */
  45719. containerSize: number;
  45720. /**
  45721. * Color of the joystick && puck
  45722. */
  45723. color: string;
  45724. /**
  45725. * Image URL for the joystick's puck
  45726. */
  45727. puckImage?: string;
  45728. /**
  45729. * Image URL for the joystick's container
  45730. */
  45731. containerImage?: string;
  45732. /**
  45733. * Defines the unmoving position of the joystick container
  45734. */
  45735. position?: {
  45736. x: number;
  45737. y: number;
  45738. };
  45739. /**
  45740. * Defines whether or not the joystick container is always visible
  45741. */
  45742. alwaysVisible: boolean;
  45743. /**
  45744. * Defines whether or not to limit the movement of the puck to the joystick's container
  45745. */
  45746. limitToContainer: boolean;
  45747. }
  45748. /**
  45749. * Class used to define virtual joystick (used in touch mode)
  45750. */
  45751. export class VirtualJoystick {
  45752. /**
  45753. * Gets or sets a boolean indicating that left and right values must be inverted
  45754. */
  45755. reverseLeftRight: boolean;
  45756. /**
  45757. * Gets or sets a boolean indicating that up and down values must be inverted
  45758. */
  45759. reverseUpDown: boolean;
  45760. /**
  45761. * Gets the offset value for the position (ie. the change of the position value)
  45762. */
  45763. deltaPosition: Vector3;
  45764. /**
  45765. * Gets a boolean indicating if the virtual joystick was pressed
  45766. */
  45767. pressed: boolean;
  45768. /**
  45769. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45770. */
  45771. static Canvas: Nullable<HTMLCanvasElement>;
  45772. /**
  45773. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45774. */
  45775. limitToContainer: boolean;
  45776. private static _globalJoystickIndex;
  45777. private static _alwaysVisibleSticks;
  45778. private static vjCanvasContext;
  45779. private static vjCanvasWidth;
  45780. private static vjCanvasHeight;
  45781. private static halfWidth;
  45782. private static _GetDefaultOptions;
  45783. private _action;
  45784. private _axisTargetedByLeftAndRight;
  45785. private _axisTargetedByUpAndDown;
  45786. private _joystickSensibility;
  45787. private _inversedSensibility;
  45788. private _joystickPointerID;
  45789. private _joystickColor;
  45790. private _joystickPointerPos;
  45791. private _joystickPreviousPointerPos;
  45792. private _joystickPointerStartPos;
  45793. private _deltaJoystickVector;
  45794. private _leftJoystick;
  45795. private _touches;
  45796. private _joystickPosition;
  45797. private _alwaysVisible;
  45798. private _puckImage;
  45799. private _containerImage;
  45800. private _joystickPuckSize;
  45801. private _joystickContainerSize;
  45802. private _clearPuckSize;
  45803. private _clearContainerSize;
  45804. private _clearPuckSizeOffset;
  45805. private _clearContainerSizeOffset;
  45806. private _onPointerDownHandlerRef;
  45807. private _onPointerMoveHandlerRef;
  45808. private _onPointerUpHandlerRef;
  45809. private _onResize;
  45810. /**
  45811. * Creates a new virtual joystick
  45812. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45813. * @param customizations Defines the options we want to customize the VirtualJoystick
  45814. */
  45815. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45816. /**
  45817. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45818. * @param newJoystickSensibility defines the new sensibility
  45819. */
  45820. setJoystickSensibility(newJoystickSensibility: number): void;
  45821. private _onPointerDown;
  45822. private _onPointerMove;
  45823. private _onPointerUp;
  45824. /**
  45825. * Change the color of the virtual joystick
  45826. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45827. */
  45828. setJoystickColor(newColor: string): void;
  45829. /**
  45830. * Size of the joystick's container
  45831. */
  45832. set containerSize(newSize: number);
  45833. get containerSize(): number;
  45834. /**
  45835. * Size of the joystick's puck
  45836. */
  45837. set puckSize(newSize: number);
  45838. get puckSize(): number;
  45839. /**
  45840. * Clears the set position of the joystick
  45841. */
  45842. clearPosition(): void;
  45843. /**
  45844. * Defines whether or not the joystick container is always visible
  45845. */
  45846. set alwaysVisible(value: boolean);
  45847. get alwaysVisible(): boolean;
  45848. /**
  45849. * Sets the constant position of the Joystick container
  45850. * @param x X axis coordinate
  45851. * @param y Y axis coordinate
  45852. */
  45853. setPosition(x: number, y: number): void;
  45854. /**
  45855. * Defines a callback to call when the joystick is touched
  45856. * @param action defines the callback
  45857. */
  45858. setActionOnTouch(action: () => any): void;
  45859. /**
  45860. * Defines which axis you'd like to control for left & right
  45861. * @param axis defines the axis to use
  45862. */
  45863. setAxisForLeftRight(axis: JoystickAxis): void;
  45864. /**
  45865. * Defines which axis you'd like to control for up & down
  45866. * @param axis defines the axis to use
  45867. */
  45868. setAxisForUpDown(axis: JoystickAxis): void;
  45869. /**
  45870. * Clears the canvas from the previous puck / container draw
  45871. */
  45872. private _clearPreviousDraw;
  45873. /**
  45874. * Loads `urlPath` to be used for the container's image
  45875. * @param urlPath defines the urlPath of an image to use
  45876. */
  45877. setContainerImage(urlPath: string): void;
  45878. /**
  45879. * Loads `urlPath` to be used for the puck's image
  45880. * @param urlPath defines the urlPath of an image to use
  45881. */
  45882. setPuckImage(urlPath: string): void;
  45883. /**
  45884. * Draws the Virtual Joystick's container
  45885. */
  45886. private _drawContainer;
  45887. /**
  45888. * Draws the Virtual Joystick's puck
  45889. */
  45890. private _drawPuck;
  45891. private _drawVirtualJoystick;
  45892. /**
  45893. * Release internal HTML canvas
  45894. */
  45895. releaseCanvas(): void;
  45896. }
  45897. }
  45898. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45899. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45900. import { Nullable } from "babylonjs/types";
  45901. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45902. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45903. module "babylonjs/Cameras/freeCameraInputsManager" {
  45904. interface FreeCameraInputsManager {
  45905. /**
  45906. * Add virtual joystick input support to the input manager.
  45907. * @returns the current input manager
  45908. */
  45909. addVirtualJoystick(): FreeCameraInputsManager;
  45910. }
  45911. }
  45912. /**
  45913. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45914. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45915. */
  45916. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45917. /**
  45918. * Defines the camera the input is attached to.
  45919. */
  45920. camera: FreeCamera;
  45921. private _leftjoystick;
  45922. private _rightjoystick;
  45923. /**
  45924. * Gets the left stick of the virtual joystick.
  45925. * @returns The virtual Joystick
  45926. */
  45927. getLeftJoystick(): VirtualJoystick;
  45928. /**
  45929. * Gets the right stick of the virtual joystick.
  45930. * @returns The virtual Joystick
  45931. */
  45932. getRightJoystick(): VirtualJoystick;
  45933. /**
  45934. * Update the current camera state depending on the inputs that have been used this frame.
  45935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45936. */
  45937. checkInputs(): void;
  45938. /**
  45939. * Attach the input controls to a specific dom element to get the input from.
  45940. * @param element Defines the element the controls should be listened from
  45941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45942. */
  45943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45944. /**
  45945. * Detach the current controls from the specified dom element.
  45946. * @param element Defines the element to stop listening the inputs from
  45947. */
  45948. detachControl(element: Nullable<HTMLElement>): void;
  45949. /**
  45950. * Gets the class name of the current intput.
  45951. * @returns the class name
  45952. */
  45953. getClassName(): string;
  45954. /**
  45955. * Get the friendly name associated with the input class.
  45956. * @returns the input friendly name
  45957. */
  45958. getSimpleName(): string;
  45959. }
  45960. }
  45961. declare module "babylonjs/Cameras/Inputs/index" {
  45962. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45963. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45964. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45965. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45966. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45967. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45968. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45969. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45970. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45971. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45972. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45973. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45974. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45975. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45976. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45977. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45978. }
  45979. declare module "babylonjs/Cameras/touchCamera" {
  45980. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45981. import { Scene } from "babylonjs/scene";
  45982. import { Vector3 } from "babylonjs/Maths/math.vector";
  45983. /**
  45984. * This represents a FPS type of camera controlled by touch.
  45985. * This is like a universal camera minus the Gamepad controls.
  45986. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45987. */
  45988. export class TouchCamera extends FreeCamera {
  45989. /**
  45990. * Defines the touch sensibility for rotation.
  45991. * The higher the faster.
  45992. */
  45993. get touchAngularSensibility(): number;
  45994. set touchAngularSensibility(value: number);
  45995. /**
  45996. * Defines the touch sensibility for move.
  45997. * The higher the faster.
  45998. */
  45999. get touchMoveSensibility(): number;
  46000. set touchMoveSensibility(value: number);
  46001. /**
  46002. * Instantiates a new touch camera.
  46003. * This represents a FPS type of camera controlled by touch.
  46004. * This is like a universal camera minus the Gamepad controls.
  46005. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46006. * @param name Define the name of the camera in the scene
  46007. * @param position Define the start position of the camera in the scene
  46008. * @param scene Define the scene the camera belongs to
  46009. */
  46010. constructor(name: string, position: Vector3, scene: Scene);
  46011. /**
  46012. * Gets the current object class name.
  46013. * @return the class name
  46014. */
  46015. getClassName(): string;
  46016. /** @hidden */
  46017. _setupInputs(): void;
  46018. }
  46019. }
  46020. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46021. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46022. import { Scene } from "babylonjs/scene";
  46023. import { Vector3 } from "babylonjs/Maths/math.vector";
  46024. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46025. import { Axis } from "babylonjs/Maths/math.axis";
  46026. /**
  46027. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46028. * being tilted forward or back and left or right.
  46029. */
  46030. export class DeviceOrientationCamera extends FreeCamera {
  46031. private _initialQuaternion;
  46032. private _quaternionCache;
  46033. private _tmpDragQuaternion;
  46034. private _disablePointerInputWhenUsingDeviceOrientation;
  46035. /**
  46036. * Creates a new device orientation camera
  46037. * @param name The name of the camera
  46038. * @param position The start position camera
  46039. * @param scene The scene the camera belongs to
  46040. */
  46041. constructor(name: string, position: Vector3, scene: Scene);
  46042. /**
  46043. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46044. */
  46045. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46046. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46047. private _dragFactor;
  46048. /**
  46049. * Enabled turning on the y axis when the orientation sensor is active
  46050. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46051. */
  46052. enableHorizontalDragging(dragFactor?: number): void;
  46053. /**
  46054. * Gets the current instance class name ("DeviceOrientationCamera").
  46055. * This helps avoiding instanceof at run time.
  46056. * @returns the class name
  46057. */
  46058. getClassName(): string;
  46059. /**
  46060. * @hidden
  46061. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46062. */
  46063. _checkInputs(): void;
  46064. /**
  46065. * Reset the camera to its default orientation on the specified axis only.
  46066. * @param axis The axis to reset
  46067. */
  46068. resetToCurrentRotation(axis?: Axis): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Gamepads/xboxGamepad" {
  46072. import { Observable } from "babylonjs/Misc/observable";
  46073. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46074. /**
  46075. * Defines supported buttons for XBox360 compatible gamepads
  46076. */
  46077. export enum Xbox360Button {
  46078. /** A */
  46079. A = 0,
  46080. /** B */
  46081. B = 1,
  46082. /** X */
  46083. X = 2,
  46084. /** Y */
  46085. Y = 3,
  46086. /** Left button */
  46087. LB = 4,
  46088. /** Right button */
  46089. RB = 5,
  46090. /** Back */
  46091. Back = 8,
  46092. /** Start */
  46093. Start = 9,
  46094. /** Left stick */
  46095. LeftStick = 10,
  46096. /** Right stick */
  46097. RightStick = 11
  46098. }
  46099. /** Defines values for XBox360 DPad */
  46100. export enum Xbox360Dpad {
  46101. /** Up */
  46102. Up = 12,
  46103. /** Down */
  46104. Down = 13,
  46105. /** Left */
  46106. Left = 14,
  46107. /** Right */
  46108. Right = 15
  46109. }
  46110. /**
  46111. * Defines a XBox360 gamepad
  46112. */
  46113. export class Xbox360Pad extends Gamepad {
  46114. private _leftTrigger;
  46115. private _rightTrigger;
  46116. private _onlefttriggerchanged;
  46117. private _onrighttriggerchanged;
  46118. private _onbuttondown;
  46119. private _onbuttonup;
  46120. private _ondpaddown;
  46121. private _ondpadup;
  46122. /** Observable raised when a button is pressed */
  46123. onButtonDownObservable: Observable<Xbox360Button>;
  46124. /** Observable raised when a button is released */
  46125. onButtonUpObservable: Observable<Xbox360Button>;
  46126. /** Observable raised when a pad is pressed */
  46127. onPadDownObservable: Observable<Xbox360Dpad>;
  46128. /** Observable raised when a pad is released */
  46129. onPadUpObservable: Observable<Xbox360Dpad>;
  46130. private _buttonA;
  46131. private _buttonB;
  46132. private _buttonX;
  46133. private _buttonY;
  46134. private _buttonBack;
  46135. private _buttonStart;
  46136. private _buttonLB;
  46137. private _buttonRB;
  46138. private _buttonLeftStick;
  46139. private _buttonRightStick;
  46140. private _dPadUp;
  46141. private _dPadDown;
  46142. private _dPadLeft;
  46143. private _dPadRight;
  46144. private _isXboxOnePad;
  46145. /**
  46146. * Creates a new XBox360 gamepad object
  46147. * @param id defines the id of this gamepad
  46148. * @param index defines its index
  46149. * @param gamepad defines the internal HTML gamepad object
  46150. * @param xboxOne defines if it is a XBox One gamepad
  46151. */
  46152. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46153. /**
  46154. * Defines the callback to call when left trigger is pressed
  46155. * @param callback defines the callback to use
  46156. */
  46157. onlefttriggerchanged(callback: (value: number) => void): void;
  46158. /**
  46159. * Defines the callback to call when right trigger is pressed
  46160. * @param callback defines the callback to use
  46161. */
  46162. onrighttriggerchanged(callback: (value: number) => void): void;
  46163. /**
  46164. * Gets the left trigger value
  46165. */
  46166. get leftTrigger(): number;
  46167. /**
  46168. * Sets the left trigger value
  46169. */
  46170. set leftTrigger(newValue: number);
  46171. /**
  46172. * Gets the right trigger value
  46173. */
  46174. get rightTrigger(): number;
  46175. /**
  46176. * Sets the right trigger value
  46177. */
  46178. set rightTrigger(newValue: number);
  46179. /**
  46180. * Defines the callback to call when a button is pressed
  46181. * @param callback defines the callback to use
  46182. */
  46183. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46184. /**
  46185. * Defines the callback to call when a button is released
  46186. * @param callback defines the callback to use
  46187. */
  46188. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46189. /**
  46190. * Defines the callback to call when a pad is pressed
  46191. * @param callback defines the callback to use
  46192. */
  46193. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46194. /**
  46195. * Defines the callback to call when a pad is released
  46196. * @param callback defines the callback to use
  46197. */
  46198. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46199. private _setButtonValue;
  46200. private _setDPadValue;
  46201. /**
  46202. * Gets the value of the `A` button
  46203. */
  46204. get buttonA(): number;
  46205. /**
  46206. * Sets the value of the `A` button
  46207. */
  46208. set buttonA(value: number);
  46209. /**
  46210. * Gets the value of the `B` button
  46211. */
  46212. get buttonB(): number;
  46213. /**
  46214. * Sets the value of the `B` button
  46215. */
  46216. set buttonB(value: number);
  46217. /**
  46218. * Gets the value of the `X` button
  46219. */
  46220. get buttonX(): number;
  46221. /**
  46222. * Sets the value of the `X` button
  46223. */
  46224. set buttonX(value: number);
  46225. /**
  46226. * Gets the value of the `Y` button
  46227. */
  46228. get buttonY(): number;
  46229. /**
  46230. * Sets the value of the `Y` button
  46231. */
  46232. set buttonY(value: number);
  46233. /**
  46234. * Gets the value of the `Start` button
  46235. */
  46236. get buttonStart(): number;
  46237. /**
  46238. * Sets the value of the `Start` button
  46239. */
  46240. set buttonStart(value: number);
  46241. /**
  46242. * Gets the value of the `Back` button
  46243. */
  46244. get buttonBack(): number;
  46245. /**
  46246. * Sets the value of the `Back` button
  46247. */
  46248. set buttonBack(value: number);
  46249. /**
  46250. * Gets the value of the `Left` button
  46251. */
  46252. get buttonLB(): number;
  46253. /**
  46254. * Sets the value of the `Left` button
  46255. */
  46256. set buttonLB(value: number);
  46257. /**
  46258. * Gets the value of the `Right` button
  46259. */
  46260. get buttonRB(): number;
  46261. /**
  46262. * Sets the value of the `Right` button
  46263. */
  46264. set buttonRB(value: number);
  46265. /**
  46266. * Gets the value of the Left joystick
  46267. */
  46268. get buttonLeftStick(): number;
  46269. /**
  46270. * Sets the value of the Left joystick
  46271. */
  46272. set buttonLeftStick(value: number);
  46273. /**
  46274. * Gets the value of the Right joystick
  46275. */
  46276. get buttonRightStick(): number;
  46277. /**
  46278. * Sets the value of the Right joystick
  46279. */
  46280. set buttonRightStick(value: number);
  46281. /**
  46282. * Gets the value of D-pad up
  46283. */
  46284. get dPadUp(): number;
  46285. /**
  46286. * Sets the value of D-pad up
  46287. */
  46288. set dPadUp(value: number);
  46289. /**
  46290. * Gets the value of D-pad down
  46291. */
  46292. get dPadDown(): number;
  46293. /**
  46294. * Sets the value of D-pad down
  46295. */
  46296. set dPadDown(value: number);
  46297. /**
  46298. * Gets the value of D-pad left
  46299. */
  46300. get dPadLeft(): number;
  46301. /**
  46302. * Sets the value of D-pad left
  46303. */
  46304. set dPadLeft(value: number);
  46305. /**
  46306. * Gets the value of D-pad right
  46307. */
  46308. get dPadRight(): number;
  46309. /**
  46310. * Sets the value of D-pad right
  46311. */
  46312. set dPadRight(value: number);
  46313. /**
  46314. * Force the gamepad to synchronize with device values
  46315. */
  46316. update(): void;
  46317. /**
  46318. * Disposes the gamepad
  46319. */
  46320. dispose(): void;
  46321. }
  46322. }
  46323. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46324. import { Observable } from "babylonjs/Misc/observable";
  46325. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46326. /**
  46327. * Defines supported buttons for DualShock compatible gamepads
  46328. */
  46329. export enum DualShockButton {
  46330. /** Cross */
  46331. Cross = 0,
  46332. /** Circle */
  46333. Circle = 1,
  46334. /** Square */
  46335. Square = 2,
  46336. /** Triangle */
  46337. Triangle = 3,
  46338. /** L1 */
  46339. L1 = 4,
  46340. /** R1 */
  46341. R1 = 5,
  46342. /** Share */
  46343. Share = 8,
  46344. /** Options */
  46345. Options = 9,
  46346. /** Left stick */
  46347. LeftStick = 10,
  46348. /** Right stick */
  46349. RightStick = 11
  46350. }
  46351. /** Defines values for DualShock DPad */
  46352. export enum DualShockDpad {
  46353. /** Up */
  46354. Up = 12,
  46355. /** Down */
  46356. Down = 13,
  46357. /** Left */
  46358. Left = 14,
  46359. /** Right */
  46360. Right = 15
  46361. }
  46362. /**
  46363. * Defines a DualShock gamepad
  46364. */
  46365. export class DualShockPad extends Gamepad {
  46366. private _leftTrigger;
  46367. private _rightTrigger;
  46368. private _onlefttriggerchanged;
  46369. private _onrighttriggerchanged;
  46370. private _onbuttondown;
  46371. private _onbuttonup;
  46372. private _ondpaddown;
  46373. private _ondpadup;
  46374. /** Observable raised when a button is pressed */
  46375. onButtonDownObservable: Observable<DualShockButton>;
  46376. /** Observable raised when a button is released */
  46377. onButtonUpObservable: Observable<DualShockButton>;
  46378. /** Observable raised when a pad is pressed */
  46379. onPadDownObservable: Observable<DualShockDpad>;
  46380. /** Observable raised when a pad is released */
  46381. onPadUpObservable: Observable<DualShockDpad>;
  46382. private _buttonCross;
  46383. private _buttonCircle;
  46384. private _buttonSquare;
  46385. private _buttonTriangle;
  46386. private _buttonShare;
  46387. private _buttonOptions;
  46388. private _buttonL1;
  46389. private _buttonR1;
  46390. private _buttonLeftStick;
  46391. private _buttonRightStick;
  46392. private _dPadUp;
  46393. private _dPadDown;
  46394. private _dPadLeft;
  46395. private _dPadRight;
  46396. /**
  46397. * Creates a new DualShock gamepad object
  46398. * @param id defines the id of this gamepad
  46399. * @param index defines its index
  46400. * @param gamepad defines the internal HTML gamepad object
  46401. */
  46402. constructor(id: string, index: number, gamepad: any);
  46403. /**
  46404. * Defines the callback to call when left trigger is pressed
  46405. * @param callback defines the callback to use
  46406. */
  46407. onlefttriggerchanged(callback: (value: number) => void): void;
  46408. /**
  46409. * Defines the callback to call when right trigger is pressed
  46410. * @param callback defines the callback to use
  46411. */
  46412. onrighttriggerchanged(callback: (value: number) => void): void;
  46413. /**
  46414. * Gets the left trigger value
  46415. */
  46416. get leftTrigger(): number;
  46417. /**
  46418. * Sets the left trigger value
  46419. */
  46420. set leftTrigger(newValue: number);
  46421. /**
  46422. * Gets the right trigger value
  46423. */
  46424. get rightTrigger(): number;
  46425. /**
  46426. * Sets the right trigger value
  46427. */
  46428. set rightTrigger(newValue: number);
  46429. /**
  46430. * Defines the callback to call when a button is pressed
  46431. * @param callback defines the callback to use
  46432. */
  46433. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46434. /**
  46435. * Defines the callback to call when a button is released
  46436. * @param callback defines the callback to use
  46437. */
  46438. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46439. /**
  46440. * Defines the callback to call when a pad is pressed
  46441. * @param callback defines the callback to use
  46442. */
  46443. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46444. /**
  46445. * Defines the callback to call when a pad is released
  46446. * @param callback defines the callback to use
  46447. */
  46448. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46449. private _setButtonValue;
  46450. private _setDPadValue;
  46451. /**
  46452. * Gets the value of the `Cross` button
  46453. */
  46454. get buttonCross(): number;
  46455. /**
  46456. * Sets the value of the `Cross` button
  46457. */
  46458. set buttonCross(value: number);
  46459. /**
  46460. * Gets the value of the `Circle` button
  46461. */
  46462. get buttonCircle(): number;
  46463. /**
  46464. * Sets the value of the `Circle` button
  46465. */
  46466. set buttonCircle(value: number);
  46467. /**
  46468. * Gets the value of the `Square` button
  46469. */
  46470. get buttonSquare(): number;
  46471. /**
  46472. * Sets the value of the `Square` button
  46473. */
  46474. set buttonSquare(value: number);
  46475. /**
  46476. * Gets the value of the `Triangle` button
  46477. */
  46478. get buttonTriangle(): number;
  46479. /**
  46480. * Sets the value of the `Triangle` button
  46481. */
  46482. set buttonTriangle(value: number);
  46483. /**
  46484. * Gets the value of the `Options` button
  46485. */
  46486. get buttonOptions(): number;
  46487. /**
  46488. * Sets the value of the `Options` button
  46489. */
  46490. set buttonOptions(value: number);
  46491. /**
  46492. * Gets the value of the `Share` button
  46493. */
  46494. get buttonShare(): number;
  46495. /**
  46496. * Sets the value of the `Share` button
  46497. */
  46498. set buttonShare(value: number);
  46499. /**
  46500. * Gets the value of the `L1` button
  46501. */
  46502. get buttonL1(): number;
  46503. /**
  46504. * Sets the value of the `L1` button
  46505. */
  46506. set buttonL1(value: number);
  46507. /**
  46508. * Gets the value of the `R1` button
  46509. */
  46510. get buttonR1(): number;
  46511. /**
  46512. * Sets the value of the `R1` button
  46513. */
  46514. set buttonR1(value: number);
  46515. /**
  46516. * Gets the value of the Left joystick
  46517. */
  46518. get buttonLeftStick(): number;
  46519. /**
  46520. * Sets the value of the Left joystick
  46521. */
  46522. set buttonLeftStick(value: number);
  46523. /**
  46524. * Gets the value of the Right joystick
  46525. */
  46526. get buttonRightStick(): number;
  46527. /**
  46528. * Sets the value of the Right joystick
  46529. */
  46530. set buttonRightStick(value: number);
  46531. /**
  46532. * Gets the value of D-pad up
  46533. */
  46534. get dPadUp(): number;
  46535. /**
  46536. * Sets the value of D-pad up
  46537. */
  46538. set dPadUp(value: number);
  46539. /**
  46540. * Gets the value of D-pad down
  46541. */
  46542. get dPadDown(): number;
  46543. /**
  46544. * Sets the value of D-pad down
  46545. */
  46546. set dPadDown(value: number);
  46547. /**
  46548. * Gets the value of D-pad left
  46549. */
  46550. get dPadLeft(): number;
  46551. /**
  46552. * Sets the value of D-pad left
  46553. */
  46554. set dPadLeft(value: number);
  46555. /**
  46556. * Gets the value of D-pad right
  46557. */
  46558. get dPadRight(): number;
  46559. /**
  46560. * Sets the value of D-pad right
  46561. */
  46562. set dPadRight(value: number);
  46563. /**
  46564. * Force the gamepad to synchronize with device values
  46565. */
  46566. update(): void;
  46567. /**
  46568. * Disposes the gamepad
  46569. */
  46570. dispose(): void;
  46571. }
  46572. }
  46573. declare module "babylonjs/Gamepads/gamepadManager" {
  46574. import { Observable } from "babylonjs/Misc/observable";
  46575. import { Nullable } from "babylonjs/types";
  46576. import { Scene } from "babylonjs/scene";
  46577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46578. /**
  46579. * Manager for handling gamepads
  46580. */
  46581. export class GamepadManager {
  46582. private _scene?;
  46583. private _babylonGamepads;
  46584. private _oneGamepadConnected;
  46585. /** @hidden */
  46586. _isMonitoring: boolean;
  46587. private _gamepadEventSupported;
  46588. private _gamepadSupport?;
  46589. /**
  46590. * observable to be triggered when the gamepad controller has been connected
  46591. */
  46592. onGamepadConnectedObservable: Observable<Gamepad>;
  46593. /**
  46594. * observable to be triggered when the gamepad controller has been disconnected
  46595. */
  46596. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46597. private _onGamepadConnectedEvent;
  46598. private _onGamepadDisconnectedEvent;
  46599. /**
  46600. * Initializes the gamepad manager
  46601. * @param _scene BabylonJS scene
  46602. */
  46603. constructor(_scene?: Scene | undefined);
  46604. /**
  46605. * The gamepads in the game pad manager
  46606. */
  46607. get gamepads(): Gamepad[];
  46608. /**
  46609. * Get the gamepad controllers based on type
  46610. * @param type The type of gamepad controller
  46611. * @returns Nullable gamepad
  46612. */
  46613. getGamepadByType(type?: number): Nullable<Gamepad>;
  46614. /**
  46615. * Disposes the gamepad manager
  46616. */
  46617. dispose(): void;
  46618. private _addNewGamepad;
  46619. private _startMonitoringGamepads;
  46620. private _stopMonitoringGamepads;
  46621. /** @hidden */
  46622. _checkGamepadsStatus(): void;
  46623. private _updateGamepadObjects;
  46624. }
  46625. }
  46626. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46627. import { Nullable } from "babylonjs/types";
  46628. import { Scene } from "babylonjs/scene";
  46629. import { ISceneComponent } from "babylonjs/sceneComponent";
  46630. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46631. module "babylonjs/scene" {
  46632. interface Scene {
  46633. /** @hidden */
  46634. _gamepadManager: Nullable<GamepadManager>;
  46635. /**
  46636. * Gets the gamepad manager associated with the scene
  46637. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46638. */
  46639. gamepadManager: GamepadManager;
  46640. }
  46641. }
  46642. module "babylonjs/Cameras/freeCameraInputsManager" {
  46643. /**
  46644. * Interface representing a free camera inputs manager
  46645. */
  46646. interface FreeCameraInputsManager {
  46647. /**
  46648. * Adds gamepad input support to the FreeCameraInputsManager.
  46649. * @returns the FreeCameraInputsManager
  46650. */
  46651. addGamepad(): FreeCameraInputsManager;
  46652. }
  46653. }
  46654. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46655. /**
  46656. * Interface representing an arc rotate camera inputs manager
  46657. */
  46658. interface ArcRotateCameraInputsManager {
  46659. /**
  46660. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46661. * @returns the camera inputs manager
  46662. */
  46663. addGamepad(): ArcRotateCameraInputsManager;
  46664. }
  46665. }
  46666. /**
  46667. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46668. */
  46669. export class GamepadSystemSceneComponent implements ISceneComponent {
  46670. /**
  46671. * The component name helpfull to identify the component in the list of scene components.
  46672. */
  46673. readonly name: string;
  46674. /**
  46675. * The scene the component belongs to.
  46676. */
  46677. scene: Scene;
  46678. /**
  46679. * Creates a new instance of the component for the given scene
  46680. * @param scene Defines the scene to register the component in
  46681. */
  46682. constructor(scene: Scene);
  46683. /**
  46684. * Registers the component in a given scene
  46685. */
  46686. register(): void;
  46687. /**
  46688. * Rebuilds the elements related to this component in case of
  46689. * context lost for instance.
  46690. */
  46691. rebuild(): void;
  46692. /**
  46693. * Disposes the component and the associated ressources
  46694. */
  46695. dispose(): void;
  46696. private _beforeCameraUpdate;
  46697. }
  46698. }
  46699. declare module "babylonjs/Cameras/universalCamera" {
  46700. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46701. import { Scene } from "babylonjs/scene";
  46702. import { Vector3 } from "babylonjs/Maths/math.vector";
  46703. import "babylonjs/Gamepads/gamepadSceneComponent";
  46704. /**
  46705. * 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,
  46706. * which still works and will still be found in many Playgrounds.
  46707. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46708. */
  46709. export class UniversalCamera extends TouchCamera {
  46710. /**
  46711. * Defines the gamepad rotation sensiblity.
  46712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46713. */
  46714. get gamepadAngularSensibility(): number;
  46715. set gamepadAngularSensibility(value: number);
  46716. /**
  46717. * Defines the gamepad move sensiblity.
  46718. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46719. */
  46720. get gamepadMoveSensibility(): number;
  46721. set gamepadMoveSensibility(value: number);
  46722. /**
  46723. * 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,
  46724. * which still works and will still be found in many Playgrounds.
  46725. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46726. * @param name Define the name of the camera in the scene
  46727. * @param position Define the start position of the camera in the scene
  46728. * @param scene Define the scene the camera belongs to
  46729. */
  46730. constructor(name: string, position: Vector3, scene: Scene);
  46731. /**
  46732. * Gets the current object class name.
  46733. * @return the class name
  46734. */
  46735. getClassName(): string;
  46736. }
  46737. }
  46738. declare module "babylonjs/Cameras/gamepadCamera" {
  46739. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46740. import { Scene } from "babylonjs/scene";
  46741. import { Vector3 } from "babylonjs/Maths/math.vector";
  46742. /**
  46743. * This represents a FPS type of camera. This is only here for back compat purpose.
  46744. * Please use the UniversalCamera instead as both are identical.
  46745. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46746. */
  46747. export class GamepadCamera extends UniversalCamera {
  46748. /**
  46749. * Instantiates a new Gamepad Camera
  46750. * This represents a FPS type of camera. This is only here for back compat purpose.
  46751. * Please use the UniversalCamera instead as both are identical.
  46752. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46753. * @param name Define the name of the camera in the scene
  46754. * @param position Define the start position of the camera in the scene
  46755. * @param scene Define the scene the camera belongs to
  46756. */
  46757. constructor(name: string, position: Vector3, scene: Scene);
  46758. /**
  46759. * Gets the current object class name.
  46760. * @return the class name
  46761. */
  46762. getClassName(): string;
  46763. }
  46764. }
  46765. declare module "babylonjs/Shaders/pass.fragment" {
  46766. /** @hidden */
  46767. export var passPixelShader: {
  46768. name: string;
  46769. shader: string;
  46770. };
  46771. }
  46772. declare module "babylonjs/Shaders/passCube.fragment" {
  46773. /** @hidden */
  46774. export var passCubePixelShader: {
  46775. name: string;
  46776. shader: string;
  46777. };
  46778. }
  46779. declare module "babylonjs/PostProcesses/passPostProcess" {
  46780. import { Nullable } from "babylonjs/types";
  46781. import { Camera } from "babylonjs/Cameras/camera";
  46782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46783. import { Engine } from "babylonjs/Engines/engine";
  46784. import "babylonjs/Shaders/pass.fragment";
  46785. import "babylonjs/Shaders/passCube.fragment";
  46786. /**
  46787. * PassPostProcess which produces an output the same as it's input
  46788. */
  46789. export class PassPostProcess extends PostProcess {
  46790. /**
  46791. * Creates the PassPostProcess
  46792. * @param name The name of the effect.
  46793. * @param options The required width/height ratio to downsize to before computing the render pass.
  46794. * @param camera The camera to apply the render pass to.
  46795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46796. * @param engine The engine which the post process will be applied. (default: current engine)
  46797. * @param reusable If the post process can be reused on the same frame. (default: false)
  46798. * @param textureType The type of texture to be used when performing the post processing.
  46799. * @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)
  46800. */
  46801. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46802. }
  46803. /**
  46804. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46805. */
  46806. export class PassCubePostProcess extends PostProcess {
  46807. private _face;
  46808. /**
  46809. * Gets or sets the cube face to display.
  46810. * * 0 is +X
  46811. * * 1 is -X
  46812. * * 2 is +Y
  46813. * * 3 is -Y
  46814. * * 4 is +Z
  46815. * * 5 is -Z
  46816. */
  46817. get face(): number;
  46818. set face(value: number);
  46819. /**
  46820. * Creates the PassCubePostProcess
  46821. * @param name The name of the effect.
  46822. * @param options The required width/height ratio to downsize to before computing the render pass.
  46823. * @param camera The camera to apply the render pass to.
  46824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46825. * @param engine The engine which the post process will be applied. (default: current engine)
  46826. * @param reusable If the post process can be reused on the same frame. (default: false)
  46827. * @param textureType The type of texture to be used when performing the post processing.
  46828. * @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)
  46829. */
  46830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46831. }
  46832. }
  46833. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46834. /** @hidden */
  46835. export var anaglyphPixelShader: {
  46836. name: string;
  46837. shader: string;
  46838. };
  46839. }
  46840. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46841. import { Engine } from "babylonjs/Engines/engine";
  46842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46843. import { Camera } from "babylonjs/Cameras/camera";
  46844. import "babylonjs/Shaders/anaglyph.fragment";
  46845. /**
  46846. * Postprocess used to generate anaglyphic rendering
  46847. */
  46848. export class AnaglyphPostProcess extends PostProcess {
  46849. private _passedProcess;
  46850. /**
  46851. * Creates a new AnaglyphPostProcess
  46852. * @param name defines postprocess name
  46853. * @param options defines creation options or target ratio scale
  46854. * @param rigCameras defines cameras using this postprocess
  46855. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46856. * @param engine defines hosting engine
  46857. * @param reusable defines if the postprocess will be reused multiple times per frame
  46858. */
  46859. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46860. }
  46861. }
  46862. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46863. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46864. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46865. import { Scene } from "babylonjs/scene";
  46866. import { Vector3 } from "babylonjs/Maths/math.vector";
  46867. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46868. /**
  46869. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46870. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46871. */
  46872. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46873. /**
  46874. * Creates a new AnaglyphArcRotateCamera
  46875. * @param name defines camera name
  46876. * @param alpha defines alpha angle (in radians)
  46877. * @param beta defines beta angle (in radians)
  46878. * @param radius defines radius
  46879. * @param target defines camera target
  46880. * @param interaxialDistance defines distance between each color axis
  46881. * @param scene defines the hosting scene
  46882. */
  46883. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46884. /**
  46885. * Gets camera class name
  46886. * @returns AnaglyphArcRotateCamera
  46887. */
  46888. getClassName(): string;
  46889. }
  46890. }
  46891. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46892. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46893. import { Scene } from "babylonjs/scene";
  46894. import { Vector3 } from "babylonjs/Maths/math.vector";
  46895. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46896. /**
  46897. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46898. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46899. */
  46900. export class AnaglyphFreeCamera extends FreeCamera {
  46901. /**
  46902. * Creates a new AnaglyphFreeCamera
  46903. * @param name defines camera name
  46904. * @param position defines initial position
  46905. * @param interaxialDistance defines distance between each color axis
  46906. * @param scene defines the hosting scene
  46907. */
  46908. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46909. /**
  46910. * Gets camera class name
  46911. * @returns AnaglyphFreeCamera
  46912. */
  46913. getClassName(): string;
  46914. }
  46915. }
  46916. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46917. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46918. import { Scene } from "babylonjs/scene";
  46919. import { Vector3 } from "babylonjs/Maths/math.vector";
  46920. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46921. /**
  46922. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46923. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46924. */
  46925. export class AnaglyphGamepadCamera extends GamepadCamera {
  46926. /**
  46927. * Creates a new AnaglyphGamepadCamera
  46928. * @param name defines camera name
  46929. * @param position defines initial position
  46930. * @param interaxialDistance defines distance between each color axis
  46931. * @param scene defines the hosting scene
  46932. */
  46933. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46934. /**
  46935. * Gets camera class name
  46936. * @returns AnaglyphGamepadCamera
  46937. */
  46938. getClassName(): string;
  46939. }
  46940. }
  46941. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46943. import { Scene } from "babylonjs/scene";
  46944. import { Vector3 } from "babylonjs/Maths/math.vector";
  46945. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46946. /**
  46947. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46948. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46949. */
  46950. export class AnaglyphUniversalCamera extends UniversalCamera {
  46951. /**
  46952. * Creates a new AnaglyphUniversalCamera
  46953. * @param name defines camera name
  46954. * @param position defines initial position
  46955. * @param interaxialDistance defines distance between each color axis
  46956. * @param scene defines the hosting scene
  46957. */
  46958. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46959. /**
  46960. * Gets camera class name
  46961. * @returns AnaglyphUniversalCamera
  46962. */
  46963. getClassName(): string;
  46964. }
  46965. }
  46966. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46967. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46968. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46969. import { Scene } from "babylonjs/scene";
  46970. import { Vector3 } from "babylonjs/Maths/math.vector";
  46971. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46972. /**
  46973. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46974. * @see https://doc.babylonjs.com/features/cameras
  46975. */
  46976. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46977. /**
  46978. * Creates a new StereoscopicArcRotateCamera
  46979. * @param name defines camera name
  46980. * @param alpha defines alpha angle (in radians)
  46981. * @param beta defines beta angle (in radians)
  46982. * @param radius defines radius
  46983. * @param target defines camera target
  46984. * @param interaxialDistance defines distance between each color axis
  46985. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46986. * @param scene defines the hosting scene
  46987. */
  46988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46989. /**
  46990. * Gets camera class name
  46991. * @returns StereoscopicArcRotateCamera
  46992. */
  46993. getClassName(): string;
  46994. }
  46995. }
  46996. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46997. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46998. import { Scene } from "babylonjs/scene";
  46999. import { Vector3 } from "babylonjs/Maths/math.vector";
  47000. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47001. /**
  47002. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47003. * @see https://doc.babylonjs.com/features/cameras
  47004. */
  47005. export class StereoscopicFreeCamera extends FreeCamera {
  47006. /**
  47007. * Creates a new StereoscopicFreeCamera
  47008. * @param name defines camera name
  47009. * @param position defines initial position
  47010. * @param interaxialDistance defines distance between each color axis
  47011. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47012. * @param scene defines the hosting scene
  47013. */
  47014. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47015. /**
  47016. * Gets camera class name
  47017. * @returns StereoscopicFreeCamera
  47018. */
  47019. getClassName(): string;
  47020. }
  47021. }
  47022. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47023. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47024. import { Scene } from "babylonjs/scene";
  47025. import { Vector3 } from "babylonjs/Maths/math.vector";
  47026. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47027. /**
  47028. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47029. * @see https://doc.babylonjs.com/features/cameras
  47030. */
  47031. export class StereoscopicGamepadCamera extends GamepadCamera {
  47032. /**
  47033. * Creates a new StereoscopicGamepadCamera
  47034. * @param name defines camera name
  47035. * @param position defines initial position
  47036. * @param interaxialDistance defines distance between each color axis
  47037. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47038. * @param scene defines the hosting scene
  47039. */
  47040. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47041. /**
  47042. * Gets camera class name
  47043. * @returns StereoscopicGamepadCamera
  47044. */
  47045. getClassName(): string;
  47046. }
  47047. }
  47048. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47049. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47050. import { Scene } from "babylonjs/scene";
  47051. import { Vector3 } from "babylonjs/Maths/math.vector";
  47052. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47053. /**
  47054. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47055. * @see https://doc.babylonjs.com/features/cameras
  47056. */
  47057. export class StereoscopicUniversalCamera extends UniversalCamera {
  47058. /**
  47059. * Creates a new StereoscopicUniversalCamera
  47060. * @param name defines camera name
  47061. * @param position defines initial position
  47062. * @param interaxialDistance defines distance between each color axis
  47063. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47064. * @param scene defines the hosting scene
  47065. */
  47066. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47067. /**
  47068. * Gets camera class name
  47069. * @returns StereoscopicUniversalCamera
  47070. */
  47071. getClassName(): string;
  47072. }
  47073. }
  47074. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47075. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47076. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47077. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47078. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47079. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47080. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47081. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47082. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47083. }
  47084. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47085. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47086. import { Scene } from "babylonjs/scene";
  47087. import { Vector3 } from "babylonjs/Maths/math.vector";
  47088. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47089. /**
  47090. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47091. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47092. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47093. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47094. */
  47095. export class VirtualJoysticksCamera extends FreeCamera {
  47096. /**
  47097. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47098. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47099. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47100. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47101. * @param name Define the name of the camera in the scene
  47102. * @param position Define the start position of the camera in the scene
  47103. * @param scene Define the scene the camera belongs to
  47104. */
  47105. constructor(name: string, position: Vector3, scene: Scene);
  47106. /**
  47107. * Gets the current object class name.
  47108. * @return the class name
  47109. */
  47110. getClassName(): string;
  47111. }
  47112. }
  47113. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47114. import { Matrix } from "babylonjs/Maths/math.vector";
  47115. /**
  47116. * This represents all the required metrics to create a VR camera.
  47117. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47118. */
  47119. export class VRCameraMetrics {
  47120. /**
  47121. * Define the horizontal resolution off the screen.
  47122. */
  47123. hResolution: number;
  47124. /**
  47125. * Define the vertical resolution off the screen.
  47126. */
  47127. vResolution: number;
  47128. /**
  47129. * Define the horizontal screen size.
  47130. */
  47131. hScreenSize: number;
  47132. /**
  47133. * Define the vertical screen size.
  47134. */
  47135. vScreenSize: number;
  47136. /**
  47137. * Define the vertical screen center position.
  47138. */
  47139. vScreenCenter: number;
  47140. /**
  47141. * Define the distance of the eyes to the screen.
  47142. */
  47143. eyeToScreenDistance: number;
  47144. /**
  47145. * Define the distance between both lenses
  47146. */
  47147. lensSeparationDistance: number;
  47148. /**
  47149. * Define the distance between both viewer's eyes.
  47150. */
  47151. interpupillaryDistance: number;
  47152. /**
  47153. * Define the distortion factor of the VR postprocess.
  47154. * Please, touch with care.
  47155. */
  47156. distortionK: number[];
  47157. /**
  47158. * Define the chromatic aberration correction factors for the VR post process.
  47159. */
  47160. chromaAbCorrection: number[];
  47161. /**
  47162. * Define the scale factor of the post process.
  47163. * The smaller the better but the slower.
  47164. */
  47165. postProcessScaleFactor: number;
  47166. /**
  47167. * Define an offset for the lens center.
  47168. */
  47169. lensCenterOffset: number;
  47170. /**
  47171. * Define if the current vr camera should compensate the distortion of the lense or not.
  47172. */
  47173. compensateDistortion: boolean;
  47174. /**
  47175. * Defines if multiview should be enabled when rendering (Default: false)
  47176. */
  47177. multiviewEnabled: boolean;
  47178. /**
  47179. * Gets the rendering aspect ratio based on the provided resolutions.
  47180. */
  47181. get aspectRatio(): number;
  47182. /**
  47183. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47184. */
  47185. get aspectRatioFov(): number;
  47186. /**
  47187. * @hidden
  47188. */
  47189. get leftHMatrix(): Matrix;
  47190. /**
  47191. * @hidden
  47192. */
  47193. get rightHMatrix(): Matrix;
  47194. /**
  47195. * @hidden
  47196. */
  47197. get leftPreViewMatrix(): Matrix;
  47198. /**
  47199. * @hidden
  47200. */
  47201. get rightPreViewMatrix(): Matrix;
  47202. /**
  47203. * Get the default VRMetrics based on the most generic setup.
  47204. * @returns the default vr metrics
  47205. */
  47206. static GetDefault(): VRCameraMetrics;
  47207. }
  47208. }
  47209. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47210. /** @hidden */
  47211. export var vrDistortionCorrectionPixelShader: {
  47212. name: string;
  47213. shader: string;
  47214. };
  47215. }
  47216. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47217. import { Camera } from "babylonjs/Cameras/camera";
  47218. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47219. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47220. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47221. /**
  47222. * VRDistortionCorrectionPostProcess used for mobile VR
  47223. */
  47224. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47225. private _isRightEye;
  47226. private _distortionFactors;
  47227. private _postProcessScaleFactor;
  47228. private _lensCenterOffset;
  47229. private _scaleIn;
  47230. private _scaleFactor;
  47231. private _lensCenter;
  47232. /**
  47233. * Initializes the VRDistortionCorrectionPostProcess
  47234. * @param name The name of the effect.
  47235. * @param camera The camera to apply the render pass to.
  47236. * @param isRightEye If this is for the right eye distortion
  47237. * @param vrMetrics All the required metrics for the VR camera
  47238. */
  47239. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47240. }
  47241. }
  47242. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47243. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47244. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47245. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47246. import { Scene } from "babylonjs/scene";
  47247. import { Vector3 } from "babylonjs/Maths/math.vector";
  47248. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47249. import "babylonjs/Cameras/RigModes/vrRigMode";
  47250. /**
  47251. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47252. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47253. */
  47254. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47255. /**
  47256. * Creates a new VRDeviceOrientationArcRotateCamera
  47257. * @param name defines camera name
  47258. * @param alpha defines the camera rotation along the logitudinal axis
  47259. * @param beta defines the camera rotation along the latitudinal axis
  47260. * @param radius defines the camera distance from its target
  47261. * @param target defines the camera target
  47262. * @param scene defines the scene the camera belongs to
  47263. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47264. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47265. */
  47266. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47267. /**
  47268. * Gets camera class name
  47269. * @returns VRDeviceOrientationArcRotateCamera
  47270. */
  47271. getClassName(): string;
  47272. }
  47273. }
  47274. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47275. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47276. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47277. import { Scene } from "babylonjs/scene";
  47278. import { Vector3 } from "babylonjs/Maths/math.vector";
  47279. import "babylonjs/Cameras/RigModes/vrRigMode";
  47280. /**
  47281. * Camera used to simulate VR rendering (based on FreeCamera)
  47282. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47283. */
  47284. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47285. /**
  47286. * Creates a new VRDeviceOrientationFreeCamera
  47287. * @param name defines camera name
  47288. * @param position defines the start position of the camera
  47289. * @param scene defines the scene the camera belongs to
  47290. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47291. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47292. */
  47293. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47294. /**
  47295. * Gets camera class name
  47296. * @returns VRDeviceOrientationFreeCamera
  47297. */
  47298. getClassName(): string;
  47299. }
  47300. }
  47301. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47302. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47303. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47304. import { Scene } from "babylonjs/scene";
  47305. import { Vector3 } from "babylonjs/Maths/math.vector";
  47306. import "babylonjs/Gamepads/gamepadSceneComponent";
  47307. /**
  47308. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47309. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47310. */
  47311. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47312. /**
  47313. * Creates a new VRDeviceOrientationGamepadCamera
  47314. * @param name defines camera name
  47315. * @param position defines the start position of the camera
  47316. * @param scene defines the scene the camera belongs to
  47317. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47318. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47319. */
  47320. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47321. /**
  47322. * Gets camera class name
  47323. * @returns VRDeviceOrientationGamepadCamera
  47324. */
  47325. getClassName(): string;
  47326. }
  47327. }
  47328. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47329. import { Scene } from "babylonjs/scene";
  47330. import { Texture } from "babylonjs/Materials/Textures/texture";
  47331. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47332. /**
  47333. * A class extending Texture allowing drawing on a texture
  47334. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47335. */
  47336. export class DynamicTexture extends Texture {
  47337. private _generateMipMaps;
  47338. private _canvas;
  47339. private _context;
  47340. /**
  47341. * Creates a DynamicTexture
  47342. * @param name defines the name of the texture
  47343. * @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
  47344. * @param scene defines the scene where you want the texture
  47345. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47346. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47347. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47348. */
  47349. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47350. /**
  47351. * Get the current class name of the texture useful for serialization or dynamic coding.
  47352. * @returns "DynamicTexture"
  47353. */
  47354. getClassName(): string;
  47355. /**
  47356. * Gets the current state of canRescale
  47357. */
  47358. get canRescale(): boolean;
  47359. private _recreate;
  47360. /**
  47361. * Scales the texture
  47362. * @param ratio the scale factor to apply to both width and height
  47363. */
  47364. scale(ratio: number): void;
  47365. /**
  47366. * Resizes the texture
  47367. * @param width the new width
  47368. * @param height the new height
  47369. */
  47370. scaleTo(width: number, height: number): void;
  47371. /**
  47372. * Gets the context of the canvas used by the texture
  47373. * @returns the canvas context of the dynamic texture
  47374. */
  47375. getContext(): CanvasRenderingContext2D;
  47376. /**
  47377. * Clears the texture
  47378. */
  47379. clear(): void;
  47380. /**
  47381. * Updates the texture
  47382. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47383. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47384. */
  47385. update(invertY?: boolean, premulAlpha?: boolean): void;
  47386. /**
  47387. * Draws text onto the texture
  47388. * @param text defines the text to be drawn
  47389. * @param x defines the placement of the text from the left
  47390. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47391. * @param font defines the font to be used with font-style, font-size, font-name
  47392. * @param color defines the color used for the text
  47393. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47394. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47395. * @param update defines whether texture is immediately update (default is true)
  47396. */
  47397. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47398. /**
  47399. * Clones the texture
  47400. * @returns the clone of the texture.
  47401. */
  47402. clone(): DynamicTexture;
  47403. /**
  47404. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47405. * @returns a serialized dynamic texture object
  47406. */
  47407. serialize(): any;
  47408. private _IsCanvasElement;
  47409. /** @hidden */
  47410. _rebuild(): void;
  47411. }
  47412. }
  47413. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47414. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47415. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47416. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47417. /** @hidden */
  47418. export var imageProcessingPixelShader: {
  47419. name: string;
  47420. shader: string;
  47421. };
  47422. }
  47423. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47424. import { Nullable } from "babylonjs/types";
  47425. import { Color4 } from "babylonjs/Maths/math.color";
  47426. import { Camera } from "babylonjs/Cameras/camera";
  47427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47428. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47429. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47430. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47431. import { Engine } from "babylonjs/Engines/engine";
  47432. import "babylonjs/Shaders/imageProcessing.fragment";
  47433. import "babylonjs/Shaders/postprocess.vertex";
  47434. /**
  47435. * ImageProcessingPostProcess
  47436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47437. */
  47438. export class ImageProcessingPostProcess extends PostProcess {
  47439. /**
  47440. * Default configuration related to image processing available in the PBR Material.
  47441. */
  47442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47443. /**
  47444. * Gets the image processing configuration used either in this material.
  47445. */
  47446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47447. /**
  47448. * Sets the Default image processing configuration used either in the this material.
  47449. *
  47450. * If sets to null, the scene one is in use.
  47451. */
  47452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47453. /**
  47454. * Keep track of the image processing observer to allow dispose and replace.
  47455. */
  47456. private _imageProcessingObserver;
  47457. /**
  47458. * Attaches a new image processing configuration to the PBR Material.
  47459. * @param configuration
  47460. */
  47461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47462. /**
  47463. * If the post process is supported.
  47464. */
  47465. get isSupported(): boolean;
  47466. /**
  47467. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47468. */
  47469. get colorCurves(): Nullable<ColorCurves>;
  47470. /**
  47471. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47472. */
  47473. set colorCurves(value: Nullable<ColorCurves>);
  47474. /**
  47475. * Gets wether the color curves effect is enabled.
  47476. */
  47477. get colorCurvesEnabled(): boolean;
  47478. /**
  47479. * Sets wether the color curves effect is enabled.
  47480. */
  47481. set colorCurvesEnabled(value: boolean);
  47482. /**
  47483. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47484. */
  47485. get colorGradingTexture(): Nullable<BaseTexture>;
  47486. /**
  47487. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47488. */
  47489. set colorGradingTexture(value: Nullable<BaseTexture>);
  47490. /**
  47491. * Gets wether the color grading effect is enabled.
  47492. */
  47493. get colorGradingEnabled(): boolean;
  47494. /**
  47495. * Gets wether the color grading effect is enabled.
  47496. */
  47497. set colorGradingEnabled(value: boolean);
  47498. /**
  47499. * Gets exposure used in the effect.
  47500. */
  47501. get exposure(): number;
  47502. /**
  47503. * Sets exposure used in the effect.
  47504. */
  47505. set exposure(value: number);
  47506. /**
  47507. * Gets wether tonemapping is enabled or not.
  47508. */
  47509. get toneMappingEnabled(): boolean;
  47510. /**
  47511. * Sets wether tonemapping is enabled or not
  47512. */
  47513. set toneMappingEnabled(value: boolean);
  47514. /**
  47515. * Gets the type of tone mapping effect.
  47516. */
  47517. get toneMappingType(): number;
  47518. /**
  47519. * Sets the type of tone mapping effect.
  47520. */
  47521. set toneMappingType(value: number);
  47522. /**
  47523. * Gets contrast used in the effect.
  47524. */
  47525. get contrast(): number;
  47526. /**
  47527. * Sets contrast used in the effect.
  47528. */
  47529. set contrast(value: number);
  47530. /**
  47531. * Gets Vignette stretch size.
  47532. */
  47533. get vignetteStretch(): number;
  47534. /**
  47535. * Sets Vignette stretch size.
  47536. */
  47537. set vignetteStretch(value: number);
  47538. /**
  47539. * Gets Vignette centre X Offset.
  47540. */
  47541. get vignetteCentreX(): number;
  47542. /**
  47543. * Sets Vignette centre X Offset.
  47544. */
  47545. set vignetteCentreX(value: number);
  47546. /**
  47547. * Gets Vignette centre Y Offset.
  47548. */
  47549. get vignetteCentreY(): number;
  47550. /**
  47551. * Sets Vignette centre Y Offset.
  47552. */
  47553. set vignetteCentreY(value: number);
  47554. /**
  47555. * Gets Vignette weight or intensity of the vignette effect.
  47556. */
  47557. get vignetteWeight(): number;
  47558. /**
  47559. * Sets Vignette weight or intensity of the vignette effect.
  47560. */
  47561. set vignetteWeight(value: number);
  47562. /**
  47563. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47564. * if vignetteEnabled is set to true.
  47565. */
  47566. get vignetteColor(): Color4;
  47567. /**
  47568. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47569. * if vignetteEnabled is set to true.
  47570. */
  47571. set vignetteColor(value: Color4);
  47572. /**
  47573. * Gets Camera field of view used by the Vignette effect.
  47574. */
  47575. get vignetteCameraFov(): number;
  47576. /**
  47577. * Sets Camera field of view used by the Vignette effect.
  47578. */
  47579. set vignetteCameraFov(value: number);
  47580. /**
  47581. * Gets the vignette blend mode allowing different kind of effect.
  47582. */
  47583. get vignetteBlendMode(): number;
  47584. /**
  47585. * Sets the vignette blend mode allowing different kind of effect.
  47586. */
  47587. set vignetteBlendMode(value: number);
  47588. /**
  47589. * Gets wether the vignette effect is enabled.
  47590. */
  47591. get vignetteEnabled(): boolean;
  47592. /**
  47593. * Sets wether the vignette effect is enabled.
  47594. */
  47595. set vignetteEnabled(value: boolean);
  47596. private _fromLinearSpace;
  47597. /**
  47598. * Gets wether the input of the processing is in Gamma or Linear Space.
  47599. */
  47600. get fromLinearSpace(): boolean;
  47601. /**
  47602. * Sets wether the input of the processing is in Gamma or Linear Space.
  47603. */
  47604. set fromLinearSpace(value: boolean);
  47605. /**
  47606. * Defines cache preventing GC.
  47607. */
  47608. private _defines;
  47609. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47610. /**
  47611. * "ImageProcessingPostProcess"
  47612. * @returns "ImageProcessingPostProcess"
  47613. */
  47614. getClassName(): string;
  47615. /**
  47616. * @hidden
  47617. */
  47618. _updateParameters(): void;
  47619. dispose(camera?: Camera): void;
  47620. }
  47621. }
  47622. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47623. import { Scene } from "babylonjs/scene";
  47624. import { Color3 } from "babylonjs/Maths/math.color";
  47625. import { Mesh } from "babylonjs/Meshes/mesh";
  47626. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47627. import { Nullable } from "babylonjs/types";
  47628. /**
  47629. * Class containing static functions to help procedurally build meshes
  47630. */
  47631. export class GroundBuilder {
  47632. /**
  47633. * Creates a ground mesh
  47634. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47635. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47637. * @param name defines the name of the mesh
  47638. * @param options defines the options used to create the mesh
  47639. * @param scene defines the hosting scene
  47640. * @returns the ground mesh
  47641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47642. */
  47643. static CreateGround(name: string, options: {
  47644. width?: number;
  47645. height?: number;
  47646. subdivisions?: number;
  47647. subdivisionsX?: number;
  47648. subdivisionsY?: number;
  47649. updatable?: boolean;
  47650. }, scene: any): Mesh;
  47651. /**
  47652. * Creates a tiled ground mesh
  47653. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47654. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47655. * * 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
  47656. * * 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
  47657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47658. * @param name defines the name of the mesh
  47659. * @param options defines the options used to create the mesh
  47660. * @param scene defines the hosting scene
  47661. * @returns the tiled ground mesh
  47662. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47663. */
  47664. static CreateTiledGround(name: string, options: {
  47665. xmin: number;
  47666. zmin: number;
  47667. xmax: number;
  47668. zmax: number;
  47669. subdivisions?: {
  47670. w: number;
  47671. h: number;
  47672. };
  47673. precision?: {
  47674. w: number;
  47675. h: number;
  47676. };
  47677. updatable?: boolean;
  47678. }, scene?: Nullable<Scene>): Mesh;
  47679. /**
  47680. * Creates a ground mesh from a height map
  47681. * * The parameter `url` sets the URL of the height map image resource.
  47682. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47683. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47684. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47685. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47686. * * 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.
  47687. * * 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).
  47688. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47690. * @param name defines the name of the mesh
  47691. * @param url defines the url to the height map
  47692. * @param options defines the options used to create the mesh
  47693. * @param scene defines the hosting scene
  47694. * @returns the ground mesh
  47695. * @see https://doc.babylonjs.com/babylon101/height_map
  47696. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47697. */
  47698. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47699. width?: number;
  47700. height?: number;
  47701. subdivisions?: number;
  47702. minHeight?: number;
  47703. maxHeight?: number;
  47704. colorFilter?: Color3;
  47705. alphaFilter?: number;
  47706. updatable?: boolean;
  47707. onReady?: (mesh: GroundMesh) => void;
  47708. }, scene?: Nullable<Scene>): GroundMesh;
  47709. }
  47710. }
  47711. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47712. import { Vector4 } from "babylonjs/Maths/math.vector";
  47713. import { Mesh } from "babylonjs/Meshes/mesh";
  47714. /**
  47715. * Class containing static functions to help procedurally build meshes
  47716. */
  47717. export class TorusBuilder {
  47718. /**
  47719. * Creates a torus mesh
  47720. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47721. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47722. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47726. * @param name defines the name of the mesh
  47727. * @param options defines the options used to create the mesh
  47728. * @param scene defines the hosting scene
  47729. * @returns the torus mesh
  47730. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47731. */
  47732. static CreateTorus(name: string, options: {
  47733. diameter?: number;
  47734. thickness?: number;
  47735. tessellation?: number;
  47736. updatable?: boolean;
  47737. sideOrientation?: number;
  47738. frontUVs?: Vector4;
  47739. backUVs?: Vector4;
  47740. }, scene: any): Mesh;
  47741. }
  47742. }
  47743. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47744. import { Vector4 } from "babylonjs/Maths/math.vector";
  47745. import { Color4 } from "babylonjs/Maths/math.color";
  47746. import { Mesh } from "babylonjs/Meshes/mesh";
  47747. /**
  47748. * Class containing static functions to help procedurally build meshes
  47749. */
  47750. export class CylinderBuilder {
  47751. /**
  47752. * Creates a cylinder or a cone mesh
  47753. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47754. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47755. * * 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.
  47756. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47757. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47758. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47759. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47760. * * 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).
  47761. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47762. * * 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).
  47763. * * 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
  47764. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47765. * * 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
  47766. * * 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.
  47767. * * If `enclose` is false, a ring surface is one element.
  47768. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47769. * * 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
  47770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47773. * @param name defines the name of the mesh
  47774. * @param options defines the options used to create the mesh
  47775. * @param scene defines the hosting scene
  47776. * @returns the cylinder mesh
  47777. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47778. */
  47779. static CreateCylinder(name: string, options: {
  47780. height?: number;
  47781. diameterTop?: number;
  47782. diameterBottom?: number;
  47783. diameter?: number;
  47784. tessellation?: number;
  47785. subdivisions?: number;
  47786. arc?: number;
  47787. faceColors?: Color4[];
  47788. faceUV?: Vector4[];
  47789. updatable?: boolean;
  47790. hasRings?: boolean;
  47791. enclose?: boolean;
  47792. cap?: number;
  47793. sideOrientation?: number;
  47794. frontUVs?: Vector4;
  47795. backUVs?: Vector4;
  47796. }, scene: any): Mesh;
  47797. }
  47798. }
  47799. declare module "babylonjs/XR/webXRTypes" {
  47800. import { Nullable } from "babylonjs/types";
  47801. import { IDisposable } from "babylonjs/scene";
  47802. /**
  47803. * States of the webXR experience
  47804. */
  47805. export enum WebXRState {
  47806. /**
  47807. * Transitioning to being in XR mode
  47808. */
  47809. ENTERING_XR = 0,
  47810. /**
  47811. * Transitioning to non XR mode
  47812. */
  47813. EXITING_XR = 1,
  47814. /**
  47815. * In XR mode and presenting
  47816. */
  47817. IN_XR = 2,
  47818. /**
  47819. * Not entered XR mode
  47820. */
  47821. NOT_IN_XR = 3
  47822. }
  47823. /**
  47824. * Abstraction of the XR render target
  47825. */
  47826. export interface WebXRRenderTarget extends IDisposable {
  47827. /**
  47828. * xrpresent context of the canvas which can be used to display/mirror xr content
  47829. */
  47830. canvasContext: WebGLRenderingContext;
  47831. /**
  47832. * xr layer for the canvas
  47833. */
  47834. xrLayer: Nullable<XRWebGLLayer>;
  47835. /**
  47836. * Initializes the xr layer for the session
  47837. * @param xrSession xr session
  47838. * @returns a promise that will resolve once the XR Layer has been created
  47839. */
  47840. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47841. }
  47842. }
  47843. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47844. import { Nullable } from "babylonjs/types";
  47845. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47846. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47847. import { Observable } from "babylonjs/Misc/observable";
  47848. /**
  47849. * COnfiguration object for WebXR output canvas
  47850. */
  47851. export class WebXRManagedOutputCanvasOptions {
  47852. /**
  47853. * An optional canvas in case you wish to create it yourself and provide it here.
  47854. * If not provided, a new canvas will be created
  47855. */
  47856. canvasElement?: HTMLCanvasElement;
  47857. /**
  47858. * Options for this XR Layer output
  47859. */
  47860. canvasOptions?: XRWebGLLayerOptions;
  47861. /**
  47862. * CSS styling for a newly created canvas (if not provided)
  47863. */
  47864. newCanvasCssStyle?: string;
  47865. /**
  47866. * Get the default values of the configuration object
  47867. * @returns default values of this configuration object
  47868. */
  47869. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47870. }
  47871. /**
  47872. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47873. */
  47874. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47875. private _options;
  47876. private _canvas;
  47877. private _engine;
  47878. private _originalCanvasSize;
  47879. /**
  47880. * Rendering context of the canvas which can be used to display/mirror xr content
  47881. */
  47882. canvasContext: WebGLRenderingContext;
  47883. /**
  47884. * xr layer for the canvas
  47885. */
  47886. xrLayer: Nullable<XRWebGLLayer>;
  47887. /**
  47888. * Obseervers registered here will be triggered when the xr layer was initialized
  47889. */
  47890. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47891. /**
  47892. * Initializes the canvas to be added/removed upon entering/exiting xr
  47893. * @param _xrSessionManager The XR Session manager
  47894. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47895. */
  47896. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47897. /**
  47898. * Disposes of the object
  47899. */
  47900. dispose(): void;
  47901. /**
  47902. * Initializes the xr layer for the session
  47903. * @param xrSession xr session
  47904. * @returns a promise that will resolve once the XR Layer has been created
  47905. */
  47906. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47907. private _addCanvas;
  47908. private _removeCanvas;
  47909. private _setCanvasSize;
  47910. private _setManagedOutputCanvas;
  47911. }
  47912. }
  47913. declare module "babylonjs/XR/webXRSessionManager" {
  47914. import { Observable } from "babylonjs/Misc/observable";
  47915. import { Nullable } from "babylonjs/types";
  47916. import { IDisposable, Scene } from "babylonjs/scene";
  47917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47918. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47919. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47920. /**
  47921. * Manages an XRSession to work with Babylon's engine
  47922. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47923. */
  47924. export class WebXRSessionManager implements IDisposable {
  47925. /** The scene which the session should be created for */
  47926. scene: Scene;
  47927. private _referenceSpace;
  47928. private _rttProvider;
  47929. private _sessionEnded;
  47930. private _xrNavigator;
  47931. private baseLayer;
  47932. /**
  47933. * The base reference space from which the session started. good if you want to reset your
  47934. * reference space
  47935. */
  47936. baseReferenceSpace: XRReferenceSpace;
  47937. /**
  47938. * Current XR frame
  47939. */
  47940. currentFrame: Nullable<XRFrame>;
  47941. /** WebXR timestamp updated every frame */
  47942. currentTimestamp: number;
  47943. /**
  47944. * Used just in case of a failure to initialize an immersive session.
  47945. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47946. */
  47947. defaultHeightCompensation: number;
  47948. /**
  47949. * Fires every time a new xrFrame arrives which can be used to update the camera
  47950. */
  47951. onXRFrameObservable: Observable<XRFrame>;
  47952. /**
  47953. * Fires when the reference space changed
  47954. */
  47955. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47956. /**
  47957. * Fires when the xr session is ended either by the device or manually done
  47958. */
  47959. onXRSessionEnded: Observable<any>;
  47960. /**
  47961. * Fires when the xr session is ended either by the device or manually done
  47962. */
  47963. onXRSessionInit: Observable<XRSession>;
  47964. /**
  47965. * Underlying xr session
  47966. */
  47967. session: XRSession;
  47968. /**
  47969. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47970. * or get the offset the player is currently at.
  47971. */
  47972. viewerReferenceSpace: XRReferenceSpace;
  47973. /**
  47974. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47975. * @param scene The scene which the session should be created for
  47976. */
  47977. constructor(
  47978. /** The scene which the session should be created for */
  47979. scene: Scene);
  47980. /**
  47981. * The current reference space used in this session. This reference space can constantly change!
  47982. * It is mainly used to offset the camera's position.
  47983. */
  47984. get referenceSpace(): XRReferenceSpace;
  47985. /**
  47986. * Set a new reference space and triggers the observable
  47987. */
  47988. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47989. /**
  47990. * Disposes of the session manager
  47991. */
  47992. dispose(): void;
  47993. /**
  47994. * Stops the xrSession and restores the render loop
  47995. * @returns Promise which resolves after it exits XR
  47996. */
  47997. exitXRAsync(): Promise<void>;
  47998. /**
  47999. * Gets the correct render target texture to be rendered this frame for this eye
  48000. * @param eye the eye for which to get the render target
  48001. * @returns the render target for the specified eye
  48002. */
  48003. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48004. /**
  48005. * Creates a WebXRRenderTarget object for the XR session
  48006. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48007. * @param options optional options to provide when creating a new render target
  48008. * @returns a WebXR render target to which the session can render
  48009. */
  48010. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48011. /**
  48012. * Initializes the manager
  48013. * After initialization enterXR can be called to start an XR session
  48014. * @returns Promise which resolves after it is initialized
  48015. */
  48016. initializeAsync(): Promise<void>;
  48017. /**
  48018. * Initializes an xr session
  48019. * @param xrSessionMode mode to initialize
  48020. * @param xrSessionInit defines optional and required values to pass to the session builder
  48021. * @returns a promise which will resolve once the session has been initialized
  48022. */
  48023. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48024. /**
  48025. * Checks if a session would be supported for the creation options specified
  48026. * @param sessionMode session mode to check if supported eg. immersive-vr
  48027. * @returns A Promise that resolves to true if supported and false if not
  48028. */
  48029. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48030. /**
  48031. * Resets the reference space to the one started the session
  48032. */
  48033. resetReferenceSpace(): void;
  48034. /**
  48035. * Starts rendering to the xr layer
  48036. */
  48037. runXRRenderLoop(): void;
  48038. /**
  48039. * Sets the reference space on the xr session
  48040. * @param referenceSpaceType space to set
  48041. * @returns a promise that will resolve once the reference space has been set
  48042. */
  48043. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48044. /**
  48045. * Updates the render state of the session
  48046. * @param state state to set
  48047. * @returns a promise that resolves once the render state has been updated
  48048. */
  48049. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48050. /**
  48051. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48052. * @param sessionMode defines the session to test
  48053. * @returns a promise with boolean as final value
  48054. */
  48055. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48056. private _createRenderTargetTexture;
  48057. }
  48058. }
  48059. declare module "babylonjs/XR/webXRCamera" {
  48060. import { Scene } from "babylonjs/scene";
  48061. import { Camera } from "babylonjs/Cameras/camera";
  48062. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48063. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48064. /**
  48065. * WebXR Camera which holds the views for the xrSession
  48066. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48067. */
  48068. export class WebXRCamera extends FreeCamera {
  48069. private _xrSessionManager;
  48070. private _firstFrame;
  48071. private _referenceQuaternion;
  48072. private _referencedPosition;
  48073. private _xrInvPositionCache;
  48074. private _xrInvQuaternionCache;
  48075. /**
  48076. * Should position compensation execute on first frame.
  48077. * This is used when copying the position from a native (non XR) camera
  48078. */
  48079. compensateOnFirstFrame: boolean;
  48080. /**
  48081. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48082. * @param name the name of the camera
  48083. * @param scene the scene to add the camera to
  48084. * @param _xrSessionManager a constructed xr session manager
  48085. */
  48086. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48087. /**
  48088. * Return the user's height, unrelated to the current ground.
  48089. * This will be the y position of this camera, when ground level is 0.
  48090. */
  48091. get realWorldHeight(): number;
  48092. /** @hidden */
  48093. _updateForDualEyeDebugging(): void;
  48094. /**
  48095. * Sets this camera's transformation based on a non-vr camera
  48096. * @param otherCamera the non-vr camera to copy the transformation from
  48097. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48098. */
  48099. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48100. /**
  48101. * Gets the current instance class name ("WebXRCamera").
  48102. * @returns the class name
  48103. */
  48104. getClassName(): string;
  48105. private _rotate180;
  48106. private _updateFromXRSession;
  48107. private _updateNumberOfRigCameras;
  48108. private _updateReferenceSpace;
  48109. private _updateReferenceSpaceOffset;
  48110. }
  48111. }
  48112. declare module "babylonjs/XR/webXRFeaturesManager" {
  48113. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48114. import { IDisposable } from "babylonjs/scene";
  48115. /**
  48116. * Defining the interface required for a (webxr) feature
  48117. */
  48118. export interface IWebXRFeature extends IDisposable {
  48119. /**
  48120. * Is this feature attached
  48121. */
  48122. attached: boolean;
  48123. /**
  48124. * Should auto-attach be disabled?
  48125. */
  48126. disableAutoAttach: boolean;
  48127. /**
  48128. * Attach the feature to the session
  48129. * Will usually be called by the features manager
  48130. *
  48131. * @param force should attachment be forced (even when already attached)
  48132. * @returns true if successful.
  48133. */
  48134. attach(force?: boolean): boolean;
  48135. /**
  48136. * Detach the feature from the session
  48137. * Will usually be called by the features manager
  48138. *
  48139. * @returns true if successful.
  48140. */
  48141. detach(): boolean;
  48142. }
  48143. /**
  48144. * A list of the currently available features without referencing them
  48145. */
  48146. export class WebXRFeatureName {
  48147. /**
  48148. * The name of the anchor system feature
  48149. */
  48150. static ANCHOR_SYSTEM: string;
  48151. /**
  48152. * The name of the background remover feature
  48153. */
  48154. static BACKGROUND_REMOVER: string;
  48155. /**
  48156. * The name of the hit test feature
  48157. */
  48158. static HIT_TEST: string;
  48159. /**
  48160. * physics impostors for xr controllers feature
  48161. */
  48162. static PHYSICS_CONTROLLERS: string;
  48163. /**
  48164. * The name of the plane detection feature
  48165. */
  48166. static PLANE_DETECTION: string;
  48167. /**
  48168. * The name of the pointer selection feature
  48169. */
  48170. static POINTER_SELECTION: string;
  48171. /**
  48172. * The name of the teleportation feature
  48173. */
  48174. static TELEPORTATION: string;
  48175. }
  48176. /**
  48177. * Defining the constructor of a feature. Used to register the modules.
  48178. */
  48179. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48180. /**
  48181. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48182. * It is mainly used in AR sessions.
  48183. *
  48184. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48185. */
  48186. export class WebXRFeaturesManager implements IDisposable {
  48187. private _xrSessionManager;
  48188. private static readonly _AvailableFeatures;
  48189. private _features;
  48190. /**
  48191. * constructs a new features manages.
  48192. *
  48193. * @param _xrSessionManager an instance of WebXRSessionManager
  48194. */
  48195. constructor(_xrSessionManager: WebXRSessionManager);
  48196. /**
  48197. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48198. * Mainly used internally.
  48199. *
  48200. * @param featureName the name of the feature to register
  48201. * @param constructorFunction the function used to construct the module
  48202. * @param version the (babylon) version of the module
  48203. * @param stable is that a stable version of this module
  48204. */
  48205. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48206. /**
  48207. * Returns a constructor of a specific feature.
  48208. *
  48209. * @param featureName the name of the feature to construct
  48210. * @param version the version of the feature to load
  48211. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48212. * @param options optional options provided to the module.
  48213. * @returns a function that, when called, will return a new instance of this feature
  48214. */
  48215. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48216. /**
  48217. * Can be used to return the list of features currently registered
  48218. *
  48219. * @returns an Array of available features
  48220. */
  48221. static GetAvailableFeatures(): string[];
  48222. /**
  48223. * Gets the versions available for a specific feature
  48224. * @param featureName the name of the feature
  48225. * @returns an array with the available versions
  48226. */
  48227. static GetAvailableVersions(featureName: string): string[];
  48228. /**
  48229. * Return the latest unstable version of this feature
  48230. * @param featureName the name of the feature to search
  48231. * @returns the version number. if not found will return -1
  48232. */
  48233. static GetLatestVersionOfFeature(featureName: string): number;
  48234. /**
  48235. * Return the latest stable version of this feature
  48236. * @param featureName the name of the feature to search
  48237. * @returns the version number. if not found will return -1
  48238. */
  48239. static GetStableVersionOfFeature(featureName: string): number;
  48240. /**
  48241. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48242. * Can be used during a session to start a feature
  48243. * @param featureName the name of feature to attach
  48244. */
  48245. attachFeature(featureName: string): void;
  48246. /**
  48247. * Can be used inside a session or when the session ends to detach a specific feature
  48248. * @param featureName the name of the feature to detach
  48249. */
  48250. detachFeature(featureName: string): void;
  48251. /**
  48252. * Used to disable an already-enabled feature
  48253. * The feature will be disposed and will be recreated once enabled.
  48254. * @param featureName the feature to disable
  48255. * @returns true if disable was successful
  48256. */
  48257. disableFeature(featureName: string | {
  48258. Name: string;
  48259. }): boolean;
  48260. /**
  48261. * dispose this features manager
  48262. */
  48263. dispose(): void;
  48264. /**
  48265. * 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.
  48266. * 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.
  48267. *
  48268. * @param featureName the name of the feature to load or the class of the feature
  48269. * @param version optional version to load. if not provided the latest version will be enabled
  48270. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48271. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48272. * @returns a new constructed feature or throws an error if feature not found.
  48273. */
  48274. enableFeature(featureName: string | {
  48275. Name: string;
  48276. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48277. /**
  48278. * get the implementation of an enabled feature.
  48279. * @param featureName the name of the feature to load
  48280. * @returns the feature class, if found
  48281. */
  48282. getEnabledFeature(featureName: string): IWebXRFeature;
  48283. /**
  48284. * Get the list of enabled features
  48285. * @returns an array of enabled features
  48286. */
  48287. getEnabledFeatures(): string[];
  48288. }
  48289. }
  48290. declare module "babylonjs/XR/webXRExperienceHelper" {
  48291. import { Observable } from "babylonjs/Misc/observable";
  48292. import { IDisposable, Scene } from "babylonjs/scene";
  48293. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48294. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48295. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48296. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48297. /**
  48298. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48299. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48300. */
  48301. export class WebXRExperienceHelper implements IDisposable {
  48302. private scene;
  48303. private _nonVRCamera;
  48304. private _originalSceneAutoClear;
  48305. private _supported;
  48306. /**
  48307. * Camera used to render xr content
  48308. */
  48309. camera: WebXRCamera;
  48310. /** A features manager for this xr session */
  48311. featuresManager: WebXRFeaturesManager;
  48312. /**
  48313. * Observers registered here will be triggered after the camera's initial transformation is set
  48314. * This can be used to set a different ground level or an extra rotation.
  48315. *
  48316. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48317. * to the position set after this observable is done executing.
  48318. */
  48319. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48320. /**
  48321. * Fires when the state of the experience helper has changed
  48322. */
  48323. onStateChangedObservable: Observable<WebXRState>;
  48324. /** Session manager used to keep track of xr session */
  48325. sessionManager: WebXRSessionManager;
  48326. /**
  48327. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48328. */
  48329. state: WebXRState;
  48330. /**
  48331. * Creates a WebXRExperienceHelper
  48332. * @param scene The scene the helper should be created in
  48333. */
  48334. private constructor();
  48335. /**
  48336. * Creates the experience helper
  48337. * @param scene the scene to attach the experience helper to
  48338. * @returns a promise for the experience helper
  48339. */
  48340. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48341. /**
  48342. * Disposes of the experience helper
  48343. */
  48344. dispose(): void;
  48345. /**
  48346. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48347. * @param sessionMode options for the XR session
  48348. * @param referenceSpaceType frame of reference of the XR session
  48349. * @param renderTarget the output canvas that will be used to enter XR mode
  48350. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48351. * @returns promise that resolves after xr mode has entered
  48352. */
  48353. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48354. /**
  48355. * Exits XR mode and returns the scene to its original state
  48356. * @returns promise that resolves after xr mode has exited
  48357. */
  48358. exitXRAsync(): Promise<void>;
  48359. private _nonXRToXRCamera;
  48360. private _setState;
  48361. }
  48362. }
  48363. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48364. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48365. import { Observable } from "babylonjs/Misc/observable";
  48366. import { IDisposable } from "babylonjs/scene";
  48367. /**
  48368. * X-Y values for axes in WebXR
  48369. */
  48370. export interface IWebXRMotionControllerAxesValue {
  48371. /**
  48372. * The value of the x axis
  48373. */
  48374. x: number;
  48375. /**
  48376. * The value of the y-axis
  48377. */
  48378. y: number;
  48379. }
  48380. /**
  48381. * changed / previous values for the values of this component
  48382. */
  48383. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48384. /**
  48385. * current (this frame) value
  48386. */
  48387. current: T;
  48388. /**
  48389. * previous (last change) value
  48390. */
  48391. previous: T;
  48392. }
  48393. /**
  48394. * Represents changes in the component between current frame and last values recorded
  48395. */
  48396. export interface IWebXRMotionControllerComponentChanges {
  48397. /**
  48398. * will be populated with previous and current values if axes changed
  48399. */
  48400. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48401. /**
  48402. * will be populated with previous and current values if pressed changed
  48403. */
  48404. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48405. /**
  48406. * will be populated with previous and current values if touched changed
  48407. */
  48408. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48409. /**
  48410. * will be populated with previous and current values if value changed
  48411. */
  48412. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48413. }
  48414. /**
  48415. * This class represents a single component (for example button or thumbstick) of a motion controller
  48416. */
  48417. export class WebXRControllerComponent implements IDisposable {
  48418. /**
  48419. * the id of this component
  48420. */
  48421. id: string;
  48422. /**
  48423. * the type of the component
  48424. */
  48425. type: MotionControllerComponentType;
  48426. private _buttonIndex;
  48427. private _axesIndices;
  48428. private _axes;
  48429. private _changes;
  48430. private _currentValue;
  48431. private _hasChanges;
  48432. private _pressed;
  48433. private _touched;
  48434. /**
  48435. * button component type
  48436. */
  48437. static BUTTON_TYPE: MotionControllerComponentType;
  48438. /**
  48439. * squeeze component type
  48440. */
  48441. static SQUEEZE_TYPE: MotionControllerComponentType;
  48442. /**
  48443. * Thumbstick component type
  48444. */
  48445. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48446. /**
  48447. * Touchpad component type
  48448. */
  48449. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48450. /**
  48451. * trigger component type
  48452. */
  48453. static TRIGGER_TYPE: MotionControllerComponentType;
  48454. /**
  48455. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48456. * the axes data changes
  48457. */
  48458. onAxisValueChangedObservable: Observable<{
  48459. x: number;
  48460. y: number;
  48461. }>;
  48462. /**
  48463. * Observers registered here will be triggered when the state of a button changes
  48464. * State change is either pressed / touched / value
  48465. */
  48466. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48467. /**
  48468. * Creates a new component for a motion controller.
  48469. * It is created by the motion controller itself
  48470. *
  48471. * @param id the id of this component
  48472. * @param type the type of the component
  48473. * @param _buttonIndex index in the buttons array of the gamepad
  48474. * @param _axesIndices indices of the values in the axes array of the gamepad
  48475. */
  48476. constructor(
  48477. /**
  48478. * the id of this component
  48479. */
  48480. id: string,
  48481. /**
  48482. * the type of the component
  48483. */
  48484. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48485. /**
  48486. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48487. */
  48488. get axes(): IWebXRMotionControllerAxesValue;
  48489. /**
  48490. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48491. */
  48492. get changes(): IWebXRMotionControllerComponentChanges;
  48493. /**
  48494. * Return whether or not the component changed the last frame
  48495. */
  48496. get hasChanges(): boolean;
  48497. /**
  48498. * is the button currently pressed
  48499. */
  48500. get pressed(): boolean;
  48501. /**
  48502. * is the button currently touched
  48503. */
  48504. get touched(): boolean;
  48505. /**
  48506. * Get the current value of this component
  48507. */
  48508. get value(): number;
  48509. /**
  48510. * Dispose this component
  48511. */
  48512. dispose(): void;
  48513. /**
  48514. * Are there axes correlating to this component
  48515. * @return true is axes data is available
  48516. */
  48517. isAxes(): boolean;
  48518. /**
  48519. * Is this component a button (hence - pressable)
  48520. * @returns true if can be pressed
  48521. */
  48522. isButton(): boolean;
  48523. /**
  48524. * update this component using the gamepad object it is in. Called on every frame
  48525. * @param nativeController the native gamepad controller object
  48526. */
  48527. update(nativeController: IMinimalMotionControllerObject): void;
  48528. }
  48529. }
  48530. declare module "babylonjs/Loading/sceneLoader" {
  48531. import { Observable } from "babylonjs/Misc/observable";
  48532. import { Nullable } from "babylonjs/types";
  48533. import { Scene } from "babylonjs/scene";
  48534. import { Engine } from "babylonjs/Engines/engine";
  48535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48536. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48537. import { AssetContainer } from "babylonjs/assetContainer";
  48538. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48539. import { Skeleton } from "babylonjs/Bones/skeleton";
  48540. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48541. import { WebRequest } from "babylonjs/Misc/webRequest";
  48542. /**
  48543. * Interface used to represent data loading progression
  48544. */
  48545. export interface ISceneLoaderProgressEvent {
  48546. /**
  48547. * Defines if data length to load can be evaluated
  48548. */
  48549. readonly lengthComputable: boolean;
  48550. /**
  48551. * Defines the loaded data length
  48552. */
  48553. readonly loaded: number;
  48554. /**
  48555. * Defines the data length to load
  48556. */
  48557. readonly total: number;
  48558. }
  48559. /**
  48560. * Interface used by SceneLoader plugins to define supported file extensions
  48561. */
  48562. export interface ISceneLoaderPluginExtensions {
  48563. /**
  48564. * Defines the list of supported extensions
  48565. */
  48566. [extension: string]: {
  48567. isBinary: boolean;
  48568. };
  48569. }
  48570. /**
  48571. * Interface used by SceneLoader plugin factory
  48572. */
  48573. export interface ISceneLoaderPluginFactory {
  48574. /**
  48575. * Defines the name of the factory
  48576. */
  48577. name: string;
  48578. /**
  48579. * Function called to create a new plugin
  48580. * @return the new plugin
  48581. */
  48582. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48583. /**
  48584. * The callback that returns true if the data can be directly loaded.
  48585. * @param data string containing the file data
  48586. * @returns if the data can be loaded directly
  48587. */
  48588. canDirectLoad?(data: string): boolean;
  48589. }
  48590. /**
  48591. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48592. */
  48593. export interface ISceneLoaderPluginBase {
  48594. /**
  48595. * The friendly name of this plugin.
  48596. */
  48597. name: string;
  48598. /**
  48599. * The file extensions supported by this plugin.
  48600. */
  48601. extensions: string | ISceneLoaderPluginExtensions;
  48602. /**
  48603. * The callback called when loading from a url.
  48604. * @param scene scene loading this url
  48605. * @param url url to load
  48606. * @param onSuccess callback called when the file successfully loads
  48607. * @param onProgress callback called while file is loading (if the server supports this mode)
  48608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48609. * @param onError callback called when the file fails to load
  48610. * @returns a file request object
  48611. */
  48612. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48613. /**
  48614. * The callback called when loading from a file object.
  48615. * @param scene scene loading this file
  48616. * @param file defines the file to load
  48617. * @param onSuccess defines the callback to call when data is loaded
  48618. * @param onProgress defines the callback to call during loading process
  48619. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48620. * @param onError defines the callback to call when an error occurs
  48621. * @returns a file request object
  48622. */
  48623. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48624. /**
  48625. * The callback that returns true if the data can be directly loaded.
  48626. * @param data string containing the file data
  48627. * @returns if the data can be loaded directly
  48628. */
  48629. canDirectLoad?(data: string): boolean;
  48630. /**
  48631. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48632. * @param scene scene loading this data
  48633. * @param data string containing the data
  48634. * @returns data to pass to the plugin
  48635. */
  48636. directLoad?(scene: Scene, data: string): any;
  48637. /**
  48638. * The callback that allows custom handling of the root url based on the response url.
  48639. * @param rootUrl the original root url
  48640. * @param responseURL the response url if available
  48641. * @returns the new root url
  48642. */
  48643. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48644. }
  48645. /**
  48646. * Interface used to define a SceneLoader plugin
  48647. */
  48648. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48649. /**
  48650. * Import meshes into a scene.
  48651. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48652. * @param scene The scene to import into
  48653. * @param data The data to import
  48654. * @param rootUrl The root url for scene and resources
  48655. * @param meshes The meshes array to import into
  48656. * @param particleSystems The particle systems array to import into
  48657. * @param skeletons The skeletons array to import into
  48658. * @param onError The callback when import fails
  48659. * @returns True if successful or false otherwise
  48660. */
  48661. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48662. /**
  48663. * Load into a scene.
  48664. * @param scene The scene to load into
  48665. * @param data The data to import
  48666. * @param rootUrl The root url for scene and resources
  48667. * @param onError The callback when import fails
  48668. * @returns True if successful or false otherwise
  48669. */
  48670. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48671. /**
  48672. * Load into an asset container.
  48673. * @param scene The scene to load into
  48674. * @param data The data to import
  48675. * @param rootUrl The root url for scene and resources
  48676. * @param onError The callback when import fails
  48677. * @returns The loaded asset container
  48678. */
  48679. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48680. }
  48681. /**
  48682. * Interface used to define an async SceneLoader plugin
  48683. */
  48684. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48685. /**
  48686. * Import meshes into a scene.
  48687. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48688. * @param scene The scene to import into
  48689. * @param data The data to import
  48690. * @param rootUrl The root url for scene and resources
  48691. * @param onProgress The callback when the load progresses
  48692. * @param fileName Defines the name of the file to load
  48693. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48694. */
  48695. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48696. meshes: AbstractMesh[];
  48697. particleSystems: IParticleSystem[];
  48698. skeletons: Skeleton[];
  48699. animationGroups: AnimationGroup[];
  48700. }>;
  48701. /**
  48702. * Load into a scene.
  48703. * @param scene The scene to load into
  48704. * @param data The data to import
  48705. * @param rootUrl The root url for scene and resources
  48706. * @param onProgress The callback when the load progresses
  48707. * @param fileName Defines the name of the file to load
  48708. * @returns Nothing
  48709. */
  48710. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48711. /**
  48712. * Load into an asset container.
  48713. * @param scene The scene to load into
  48714. * @param data The data to import
  48715. * @param rootUrl The root url for scene and resources
  48716. * @param onProgress The callback when the load progresses
  48717. * @param fileName Defines the name of the file to load
  48718. * @returns The loaded asset container
  48719. */
  48720. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48721. }
  48722. /**
  48723. * Mode that determines how to handle old animation groups before loading new ones.
  48724. */
  48725. export enum SceneLoaderAnimationGroupLoadingMode {
  48726. /**
  48727. * Reset all old animations to initial state then dispose them.
  48728. */
  48729. Clean = 0,
  48730. /**
  48731. * Stop all old animations.
  48732. */
  48733. Stop = 1,
  48734. /**
  48735. * Restart old animations from first frame.
  48736. */
  48737. Sync = 2,
  48738. /**
  48739. * Old animations remains untouched.
  48740. */
  48741. NoSync = 3
  48742. }
  48743. /**
  48744. * Class used to load scene from various file formats using registered plugins
  48745. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48746. */
  48747. export class SceneLoader {
  48748. /**
  48749. * No logging while loading
  48750. */
  48751. static readonly NO_LOGGING: number;
  48752. /**
  48753. * Minimal logging while loading
  48754. */
  48755. static readonly MINIMAL_LOGGING: number;
  48756. /**
  48757. * Summary logging while loading
  48758. */
  48759. static readonly SUMMARY_LOGGING: number;
  48760. /**
  48761. * Detailled logging while loading
  48762. */
  48763. static readonly DETAILED_LOGGING: number;
  48764. /**
  48765. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48766. */
  48767. static get ForceFullSceneLoadingForIncremental(): boolean;
  48768. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48769. /**
  48770. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48771. */
  48772. static get ShowLoadingScreen(): boolean;
  48773. static set ShowLoadingScreen(value: boolean);
  48774. /**
  48775. * Defines the current logging level (while loading the scene)
  48776. * @ignorenaming
  48777. */
  48778. static get loggingLevel(): number;
  48779. static set loggingLevel(value: number);
  48780. /**
  48781. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48782. */
  48783. static get CleanBoneMatrixWeights(): boolean;
  48784. static set CleanBoneMatrixWeights(value: boolean);
  48785. /**
  48786. * Event raised when a plugin is used to load a scene
  48787. */
  48788. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48789. private static _registeredPlugins;
  48790. private static _showingLoadingScreen;
  48791. private static _getDefaultPlugin;
  48792. private static _getPluginForExtension;
  48793. private static _getPluginForDirectLoad;
  48794. private static _getPluginForFilename;
  48795. private static _getDirectLoad;
  48796. private static _loadData;
  48797. private static _getFileInfo;
  48798. /**
  48799. * Gets a plugin that can load the given extension
  48800. * @param extension defines the extension to load
  48801. * @returns a plugin or null if none works
  48802. */
  48803. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48804. /**
  48805. * Gets a boolean indicating that the given extension can be loaded
  48806. * @param extension defines the extension to load
  48807. * @returns true if the extension is supported
  48808. */
  48809. static IsPluginForExtensionAvailable(extension: string): boolean;
  48810. /**
  48811. * Adds a new plugin to the list of registered plugins
  48812. * @param plugin defines the plugin to add
  48813. */
  48814. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48815. /**
  48816. * Import meshes into a scene
  48817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48818. * @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)
  48819. * @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)
  48820. * @param scene the instance of BABYLON.Scene to append to
  48821. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48822. * @param onProgress a callback with a progress event for each file being loaded
  48823. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48824. * @param pluginExtension the extension used to determine the plugin
  48825. * @returns The loaded plugin
  48826. */
  48827. 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>;
  48828. /**
  48829. * Import meshes into a scene
  48830. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48831. * @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)
  48832. * @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)
  48833. * @param scene the instance of BABYLON.Scene to append to
  48834. * @param onProgress a callback with a progress event for each file being loaded
  48835. * @param pluginExtension the extension used to determine the plugin
  48836. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48837. */
  48838. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48839. meshes: AbstractMesh[];
  48840. particleSystems: IParticleSystem[];
  48841. skeletons: Skeleton[];
  48842. animationGroups: AnimationGroup[];
  48843. }>;
  48844. /**
  48845. * Load a scene
  48846. * @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)
  48847. * @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)
  48848. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48849. * @param onSuccess a callback with the scene when import succeeds
  48850. * @param onProgress a callback with a progress event for each file being loaded
  48851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48852. * @param pluginExtension the extension used to determine the plugin
  48853. * @returns The loaded plugin
  48854. */
  48855. 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>;
  48856. /**
  48857. * Load a scene
  48858. * @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)
  48859. * @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)
  48860. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48861. * @param onProgress a callback with a progress event for each file being loaded
  48862. * @param pluginExtension the extension used to determine the plugin
  48863. * @returns The loaded scene
  48864. */
  48865. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48866. /**
  48867. * Append a scene
  48868. * @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)
  48869. * @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)
  48870. * @param scene is the instance of BABYLON.Scene to append to
  48871. * @param onSuccess a callback with the scene when import succeeds
  48872. * @param onProgress a callback with a progress event for each file being loaded
  48873. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48874. * @param pluginExtension the extension used to determine the plugin
  48875. * @returns The loaded plugin
  48876. */
  48877. 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>;
  48878. /**
  48879. * Append a scene
  48880. * @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)
  48881. * @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)
  48882. * @param scene is the instance of BABYLON.Scene to append to
  48883. * @param onProgress a callback with a progress event for each file being loaded
  48884. * @param pluginExtension the extension used to determine the plugin
  48885. * @returns The given scene
  48886. */
  48887. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48888. /**
  48889. * Load a scene into an asset container
  48890. * @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)
  48891. * @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)
  48892. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48893. * @param onSuccess a callback with the scene when import succeeds
  48894. * @param onProgress a callback with a progress event for each file being loaded
  48895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48896. * @param pluginExtension the extension used to determine the plugin
  48897. * @returns The loaded plugin
  48898. */
  48899. 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>;
  48900. /**
  48901. * Load a scene into an asset container
  48902. * @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)
  48903. * @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)
  48904. * @param scene is the instance of Scene to append to
  48905. * @param onProgress a callback with a progress event for each file being loaded
  48906. * @param pluginExtension the extension used to determine the plugin
  48907. * @returns The loaded asset container
  48908. */
  48909. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48910. /**
  48911. * Import animations from a file into a scene
  48912. * @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)
  48913. * @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)
  48914. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48915. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48916. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48917. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48918. * @param onSuccess a callback with the scene when import succeeds
  48919. * @param onProgress a callback with a progress event for each file being loaded
  48920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48921. * @param pluginExtension the extension used to determine the plugin
  48922. */
  48923. 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;
  48924. /**
  48925. * Import animations from a file into a scene
  48926. * @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)
  48927. * @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)
  48928. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48929. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48930. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48931. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48932. * @param onSuccess a callback with the scene when import succeeds
  48933. * @param onProgress a callback with a progress event for each file being loaded
  48934. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48935. * @param pluginExtension the extension used to determine the plugin
  48936. * @returns the updated scene with imported animations
  48937. */
  48938. 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>;
  48939. }
  48940. }
  48941. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48942. import { IDisposable, Scene } from "babylonjs/scene";
  48943. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48944. import { Observable } from "babylonjs/Misc/observable";
  48945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48946. import { Nullable } from "babylonjs/types";
  48947. /**
  48948. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48949. */
  48950. export type MotionControllerHandedness = "none" | "left" | "right";
  48951. /**
  48952. * The type of components available in motion controllers.
  48953. * This is not the name of the component.
  48954. */
  48955. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48956. /**
  48957. * The state of a controller component
  48958. */
  48959. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48960. /**
  48961. * The schema of motion controller layout.
  48962. * No object will be initialized using this interface
  48963. * This is used just to define the profile.
  48964. */
  48965. export interface IMotionControllerLayout {
  48966. /**
  48967. * Path to load the assets. Usually relative to the base path
  48968. */
  48969. assetPath: string;
  48970. /**
  48971. * Available components (unsorted)
  48972. */
  48973. components: {
  48974. /**
  48975. * A map of component Ids
  48976. */
  48977. [componentId: string]: {
  48978. /**
  48979. * The type of input the component outputs
  48980. */
  48981. type: MotionControllerComponentType;
  48982. /**
  48983. * The indices of this component in the gamepad object
  48984. */
  48985. gamepadIndices: {
  48986. /**
  48987. * Index of button
  48988. */
  48989. button?: number;
  48990. /**
  48991. * If available, index of x-axis
  48992. */
  48993. xAxis?: number;
  48994. /**
  48995. * If available, index of y-axis
  48996. */
  48997. yAxis?: number;
  48998. };
  48999. /**
  49000. * The mesh's root node name
  49001. */
  49002. rootNodeName: string;
  49003. /**
  49004. * Animation definitions for this model
  49005. */
  49006. visualResponses: {
  49007. [stateKey: string]: {
  49008. /**
  49009. * What property will be animated
  49010. */
  49011. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49012. /**
  49013. * What states influence this visual response
  49014. */
  49015. states: MotionControllerComponentStateType[];
  49016. /**
  49017. * Type of animation - movement or visibility
  49018. */
  49019. valueNodeProperty: "transform" | "visibility";
  49020. /**
  49021. * Base node name to move. Its position will be calculated according to the min and max nodes
  49022. */
  49023. valueNodeName?: string;
  49024. /**
  49025. * Minimum movement node
  49026. */
  49027. minNodeName?: string;
  49028. /**
  49029. * Max movement node
  49030. */
  49031. maxNodeName?: string;
  49032. };
  49033. };
  49034. /**
  49035. * If touch enabled, what is the name of node to display user feedback
  49036. */
  49037. touchPointNodeName?: string;
  49038. };
  49039. };
  49040. /**
  49041. * Is it xr standard mapping or not
  49042. */
  49043. gamepadMapping: "" | "xr-standard";
  49044. /**
  49045. * Base root node of this entire model
  49046. */
  49047. rootNodeName: string;
  49048. /**
  49049. * Defines the main button component id
  49050. */
  49051. selectComponentId: string;
  49052. }
  49053. /**
  49054. * A definition for the layout map in the input profile
  49055. */
  49056. export interface IMotionControllerLayoutMap {
  49057. /**
  49058. * Layouts with handedness type as a key
  49059. */
  49060. [handedness: string]: IMotionControllerLayout;
  49061. }
  49062. /**
  49063. * The XR Input profile schema
  49064. * Profiles can be found here:
  49065. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49066. */
  49067. export interface IMotionControllerProfile {
  49068. /**
  49069. * fallback profiles for this profileId
  49070. */
  49071. fallbackProfileIds: string[];
  49072. /**
  49073. * The layout map, with handedness as key
  49074. */
  49075. layouts: IMotionControllerLayoutMap;
  49076. /**
  49077. * The id of this profile
  49078. * correlates to the profile(s) in the xrInput.profiles array
  49079. */
  49080. profileId: string;
  49081. }
  49082. /**
  49083. * A helper-interface for the 3 meshes needed for controller button animation
  49084. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49085. */
  49086. export interface IMotionControllerButtonMeshMap {
  49087. /**
  49088. * the mesh that defines the pressed value mesh position.
  49089. * This is used to find the max-position of this button
  49090. */
  49091. pressedMesh: AbstractMesh;
  49092. /**
  49093. * the mesh that defines the unpressed value mesh position.
  49094. * This is used to find the min (or initial) position of this button
  49095. */
  49096. unpressedMesh: AbstractMesh;
  49097. /**
  49098. * The mesh that will be changed when value changes
  49099. */
  49100. valueMesh: AbstractMesh;
  49101. }
  49102. /**
  49103. * A helper-interface for the 3 meshes needed for controller axis animation.
  49104. * This will be expanded when touchpad animations are fully supported
  49105. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49106. */
  49107. export interface IMotionControllerMeshMap {
  49108. /**
  49109. * the mesh that defines the maximum value mesh position.
  49110. */
  49111. maxMesh?: AbstractMesh;
  49112. /**
  49113. * the mesh that defines the minimum value mesh position.
  49114. */
  49115. minMesh?: AbstractMesh;
  49116. /**
  49117. * The mesh that will be changed when axis value changes
  49118. */
  49119. valueMesh: AbstractMesh;
  49120. }
  49121. /**
  49122. * The elements needed for change-detection of the gamepad objects in motion controllers
  49123. */
  49124. export interface IMinimalMotionControllerObject {
  49125. /**
  49126. * Available axes of this controller
  49127. */
  49128. axes: number[];
  49129. /**
  49130. * An array of available buttons
  49131. */
  49132. buttons: Array<{
  49133. /**
  49134. * Value of the button/trigger
  49135. */
  49136. value: number;
  49137. /**
  49138. * If the button/trigger is currently touched
  49139. */
  49140. touched: boolean;
  49141. /**
  49142. * If the button/trigger is currently pressed
  49143. */
  49144. pressed: boolean;
  49145. }>;
  49146. /**
  49147. * EXPERIMENTAL haptic support.
  49148. */
  49149. hapticActuators?: Array<{
  49150. pulse: (value: number, duration: number) => Promise<boolean>;
  49151. }>;
  49152. }
  49153. /**
  49154. * An Abstract Motion controller
  49155. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49156. * Each component has an observable to check for changes in value and state
  49157. */
  49158. export abstract class WebXRAbstractMotionController implements IDisposable {
  49159. protected scene: Scene;
  49160. protected layout: IMotionControllerLayout;
  49161. /**
  49162. * The gamepad object correlating to this controller
  49163. */
  49164. gamepadObject: IMinimalMotionControllerObject;
  49165. /**
  49166. * handedness (left/right/none) of this controller
  49167. */
  49168. handedness: MotionControllerHandedness;
  49169. private _initComponent;
  49170. private _modelReady;
  49171. /**
  49172. * A map of components (WebXRControllerComponent) in this motion controller
  49173. * Components have a ComponentType and can also have both button and axis definitions
  49174. */
  49175. readonly components: {
  49176. [id: string]: WebXRControllerComponent;
  49177. };
  49178. /**
  49179. * Disable the model's animation. Can be set at any time.
  49180. */
  49181. disableAnimation: boolean;
  49182. /**
  49183. * Observers registered here will be triggered when the model of this controller is done loading
  49184. */
  49185. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49186. /**
  49187. * The profile id of this motion controller
  49188. */
  49189. abstract profileId: string;
  49190. /**
  49191. * The root mesh of the model. It is null if the model was not yet initialized
  49192. */
  49193. rootMesh: Nullable<AbstractMesh>;
  49194. /**
  49195. * constructs a new abstract motion controller
  49196. * @param scene the scene to which the model of the controller will be added
  49197. * @param layout The profile layout to load
  49198. * @param gamepadObject The gamepad object correlating to this controller
  49199. * @param handedness handedness (left/right/none) of this controller
  49200. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49201. */
  49202. constructor(scene: Scene, layout: IMotionControllerLayout,
  49203. /**
  49204. * The gamepad object correlating to this controller
  49205. */
  49206. gamepadObject: IMinimalMotionControllerObject,
  49207. /**
  49208. * handedness (left/right/none) of this controller
  49209. */
  49210. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49211. /**
  49212. * Dispose this controller, the model mesh and all its components
  49213. */
  49214. dispose(): void;
  49215. /**
  49216. * Returns all components of specific type
  49217. * @param type the type to search for
  49218. * @return an array of components with this type
  49219. */
  49220. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49221. /**
  49222. * get a component based an its component id as defined in layout.components
  49223. * @param id the id of the component
  49224. * @returns the component correlates to the id or undefined if not found
  49225. */
  49226. getComponent(id: string): WebXRControllerComponent;
  49227. /**
  49228. * Get the list of components available in this motion controller
  49229. * @returns an array of strings correlating to available components
  49230. */
  49231. getComponentIds(): string[];
  49232. /**
  49233. * Get the first component of specific type
  49234. * @param type type of component to find
  49235. * @return a controller component or null if not found
  49236. */
  49237. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49238. /**
  49239. * Get the main (Select) component of this controller as defined in the layout
  49240. * @returns the main component of this controller
  49241. */
  49242. getMainComponent(): WebXRControllerComponent;
  49243. /**
  49244. * Loads the model correlating to this controller
  49245. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49246. * @returns A promise fulfilled with the result of the model loading
  49247. */
  49248. loadModel(): Promise<boolean>;
  49249. /**
  49250. * Update this model using the current XRFrame
  49251. * @param xrFrame the current xr frame to use and update the model
  49252. */
  49253. updateFromXRFrame(xrFrame: XRFrame): void;
  49254. /**
  49255. * Backwards compatibility due to a deeply-integrated typo
  49256. */
  49257. get handness(): XREye;
  49258. /**
  49259. * Pulse (vibrate) this controller
  49260. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49261. * Consecutive calls to this function will cancel the last pulse call
  49262. *
  49263. * @param value the strength of the pulse in 0.0...1.0 range
  49264. * @param duration Duration of the pulse in milliseconds
  49265. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49266. * @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
  49267. */
  49268. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49269. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49270. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49271. /**
  49272. * Moves the axis on the controller mesh based on its current state
  49273. * @param axis the index of the axis
  49274. * @param axisValue the value of the axis which determines the meshes new position
  49275. * @hidden
  49276. */
  49277. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49278. /**
  49279. * Update the model itself with the current frame data
  49280. * @param xrFrame the frame to use for updating the model mesh
  49281. */
  49282. protected updateModel(xrFrame: XRFrame): void;
  49283. /**
  49284. * Get the filename and path for this controller's model
  49285. * @returns a map of filename and path
  49286. */
  49287. protected abstract _getFilenameAndPath(): {
  49288. filename: string;
  49289. path: string;
  49290. };
  49291. /**
  49292. * This function is called before the mesh is loaded. It checks for loading constraints.
  49293. * For example, this function can check if the GLB loader is available
  49294. * If this function returns false, the generic controller will be loaded instead
  49295. * @returns Is the client ready to load the mesh
  49296. */
  49297. protected abstract _getModelLoadingConstraints(): boolean;
  49298. /**
  49299. * This function will be called after the model was successfully loaded and can be used
  49300. * for mesh transformations before it is available for the user
  49301. * @param meshes the loaded meshes
  49302. */
  49303. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49304. /**
  49305. * Set the root mesh for this controller. Important for the WebXR controller class
  49306. * @param meshes the loaded meshes
  49307. */
  49308. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49309. /**
  49310. * A function executed each frame that updates the mesh (if needed)
  49311. * @param xrFrame the current xrFrame
  49312. */
  49313. protected abstract _updateModel(xrFrame: XRFrame): void;
  49314. private _getGenericFilenameAndPath;
  49315. private _getGenericParentMesh;
  49316. }
  49317. }
  49318. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49319. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49321. import { Scene } from "babylonjs/scene";
  49322. /**
  49323. * A generic trigger-only motion controller for WebXR
  49324. */
  49325. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49326. /**
  49327. * Static version of the profile id of this controller
  49328. */
  49329. static ProfileId: string;
  49330. profileId: string;
  49331. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49332. protected _getFilenameAndPath(): {
  49333. filename: string;
  49334. path: string;
  49335. };
  49336. protected _getModelLoadingConstraints(): boolean;
  49337. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49338. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49339. protected _updateModel(): void;
  49340. }
  49341. }
  49342. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49343. import { Vector4 } from "babylonjs/Maths/math.vector";
  49344. import { Mesh } from "babylonjs/Meshes/mesh";
  49345. import { Scene } from "babylonjs/scene";
  49346. import { Nullable } from "babylonjs/types";
  49347. /**
  49348. * Class containing static functions to help procedurally build meshes
  49349. */
  49350. export class SphereBuilder {
  49351. /**
  49352. * Creates a sphere mesh
  49353. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49354. * * 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`)
  49355. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49356. * * 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
  49357. * * 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)
  49358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49361. * @param name defines the name of the mesh
  49362. * @param options defines the options used to create the mesh
  49363. * @param scene defines the hosting scene
  49364. * @returns the sphere mesh
  49365. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49366. */
  49367. static CreateSphere(name: string, options: {
  49368. segments?: number;
  49369. diameter?: number;
  49370. diameterX?: number;
  49371. diameterY?: number;
  49372. diameterZ?: number;
  49373. arc?: number;
  49374. slice?: number;
  49375. sideOrientation?: number;
  49376. frontUVs?: Vector4;
  49377. backUVs?: Vector4;
  49378. updatable?: boolean;
  49379. }, scene?: Nullable<Scene>): Mesh;
  49380. }
  49381. }
  49382. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49384. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49385. import { Scene } from "babylonjs/scene";
  49386. /**
  49387. * A profiled motion controller has its profile loaded from an online repository.
  49388. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49389. */
  49390. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49391. private _repositoryUrl;
  49392. private _buttonMeshMapping;
  49393. private _touchDots;
  49394. /**
  49395. * The profile ID of this controller. Will be populated when the controller initializes.
  49396. */
  49397. profileId: string;
  49398. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49399. dispose(): void;
  49400. protected _getFilenameAndPath(): {
  49401. filename: string;
  49402. path: string;
  49403. };
  49404. protected _getModelLoadingConstraints(): boolean;
  49405. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49406. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49407. protected _updateModel(_xrFrame: XRFrame): void;
  49408. }
  49409. }
  49410. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49411. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49412. import { Scene } from "babylonjs/scene";
  49413. /**
  49414. * A construction function type to create a new controller based on an xrInput object
  49415. */
  49416. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49417. /**
  49418. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49419. *
  49420. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49421. * it should be replaced with auto-loaded controllers.
  49422. *
  49423. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49424. */
  49425. export class WebXRMotionControllerManager {
  49426. private static _AvailableControllers;
  49427. private static _Fallbacks;
  49428. private static _ProfileLoadingPromises;
  49429. private static _ProfilesList;
  49430. /**
  49431. * The base URL of the online controller repository. Can be changed at any time.
  49432. */
  49433. static BaseRepositoryUrl: string;
  49434. /**
  49435. * Which repository gets priority - local or online
  49436. */
  49437. static PrioritizeOnlineRepository: boolean;
  49438. /**
  49439. * Use the online repository, or use only locally-defined controllers
  49440. */
  49441. static UseOnlineRepository: boolean;
  49442. /**
  49443. * Clear the cache used for profile loading and reload when requested again
  49444. */
  49445. static ClearProfilesCache(): void;
  49446. /**
  49447. * Register the default fallbacks.
  49448. * This function is called automatically when this file is imported.
  49449. */
  49450. static DefaultFallbacks(): void;
  49451. /**
  49452. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49453. * @param profileId the profile to which a fallback needs to be found
  49454. * @return an array with corresponding fallback profiles
  49455. */
  49456. static FindFallbackWithProfileId(profileId: string): string[];
  49457. /**
  49458. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49459. * The order of search:
  49460. *
  49461. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49462. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49463. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49464. * 4) return the generic trigger controller if none were found
  49465. *
  49466. * @param xrInput the xrInput to which a new controller is initialized
  49467. * @param scene the scene to which the model will be added
  49468. * @param forceProfile force a certain profile for this controller
  49469. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49470. */
  49471. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49472. /**
  49473. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49474. *
  49475. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49476. *
  49477. * @param type the profile type to register
  49478. * @param constructFunction the function to be called when loading this profile
  49479. */
  49480. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49481. /**
  49482. * Register a fallback to a specific profile.
  49483. * @param profileId the profileId that will receive the fallbacks
  49484. * @param fallbacks A list of fallback profiles
  49485. */
  49486. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49487. /**
  49488. * Will update the list of profiles available in the repository
  49489. * @return a promise that resolves to a map of profiles available online
  49490. */
  49491. static UpdateProfilesList(): Promise<{
  49492. [profile: string]: string;
  49493. }>;
  49494. private static _LoadProfileFromRepository;
  49495. private static _LoadProfilesFromAvailableControllers;
  49496. }
  49497. }
  49498. declare module "babylonjs/XR/webXRInputSource" {
  49499. import { Observable } from "babylonjs/Misc/observable";
  49500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49501. import { Ray } from "babylonjs/Culling/ray";
  49502. import { Scene } from "babylonjs/scene";
  49503. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49504. /**
  49505. * Configuration options for the WebXR controller creation
  49506. */
  49507. export interface IWebXRControllerOptions {
  49508. /**
  49509. * Should the controller mesh be animated when a user interacts with it
  49510. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49511. */
  49512. disableMotionControllerAnimation?: boolean;
  49513. /**
  49514. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49515. */
  49516. doNotLoadControllerMesh?: boolean;
  49517. /**
  49518. * Force a specific controller type for this controller.
  49519. * This can be used when creating your own profile or when testing different controllers
  49520. */
  49521. forceControllerProfile?: string;
  49522. /**
  49523. * Defines a rendering group ID for meshes that will be loaded.
  49524. * This is for the default controllers only.
  49525. */
  49526. renderingGroupId?: number;
  49527. }
  49528. /**
  49529. * Represents an XR controller
  49530. */
  49531. export class WebXRInputSource {
  49532. private _scene;
  49533. /** The underlying input source for the controller */
  49534. inputSource: XRInputSource;
  49535. private _options;
  49536. private _tmpVector;
  49537. private _uniqueId;
  49538. /**
  49539. * 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
  49540. */
  49541. grip?: AbstractMesh;
  49542. /**
  49543. * If available, this is the gamepad object related to this controller.
  49544. * Using this object it is possible to get click events and trackpad changes of the
  49545. * webxr controller that is currently being used.
  49546. */
  49547. motionController?: WebXRAbstractMotionController;
  49548. /**
  49549. * Event that fires when the controller is removed/disposed.
  49550. * The object provided as event data is this controller, after associated assets were disposed.
  49551. * uniqueId is still available.
  49552. */
  49553. onDisposeObservable: Observable<WebXRInputSource>;
  49554. /**
  49555. * Will be triggered when the mesh associated with the motion controller is done loading.
  49556. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49557. * A shortened version of controller -> motion controller -> on mesh loaded.
  49558. */
  49559. onMeshLoadedObservable: Observable<AbstractMesh>;
  49560. /**
  49561. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49562. */
  49563. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49564. /**
  49565. * Pointer which can be used to select objects or attach a visible laser to
  49566. */
  49567. pointer: AbstractMesh;
  49568. /**
  49569. * Creates the input source object
  49570. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49571. * @param _scene the scene which the controller should be associated to
  49572. * @param inputSource the underlying input source for the controller
  49573. * @param _options options for this controller creation
  49574. */
  49575. constructor(_scene: Scene,
  49576. /** The underlying input source for the controller */
  49577. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49578. /**
  49579. * Get this controllers unique id
  49580. */
  49581. get uniqueId(): string;
  49582. /**
  49583. * Disposes of the object
  49584. */
  49585. dispose(): void;
  49586. /**
  49587. * Gets a world space ray coming from the pointer or grip
  49588. * @param result the resulting ray
  49589. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49590. */
  49591. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49592. /**
  49593. * Updates the controller pose based on the given XRFrame
  49594. * @param xrFrame xr frame to update the pose with
  49595. * @param referenceSpace reference space to use
  49596. */
  49597. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49598. }
  49599. }
  49600. declare module "babylonjs/XR/webXRInput" {
  49601. import { Observable } from "babylonjs/Misc/observable";
  49602. import { IDisposable } from "babylonjs/scene";
  49603. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49604. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49605. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49606. /**
  49607. * The schema for initialization options of the XR Input class
  49608. */
  49609. export interface IWebXRInputOptions {
  49610. /**
  49611. * If set to true no model will be automatically loaded
  49612. */
  49613. doNotLoadControllerMeshes?: boolean;
  49614. /**
  49615. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49616. * If not found, the xr input profile data will be used.
  49617. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49618. */
  49619. forceInputProfile?: string;
  49620. /**
  49621. * Do not send a request to the controller repository to load the profile.
  49622. *
  49623. * Instead, use the controllers available in babylon itself.
  49624. */
  49625. disableOnlineControllerRepository?: boolean;
  49626. /**
  49627. * A custom URL for the controllers repository
  49628. */
  49629. customControllersRepositoryURL?: string;
  49630. /**
  49631. * Should the controller model's components not move according to the user input
  49632. */
  49633. disableControllerAnimation?: boolean;
  49634. /**
  49635. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49636. */
  49637. controllerOptions?: IWebXRControllerOptions;
  49638. }
  49639. /**
  49640. * XR input used to track XR inputs such as controllers/rays
  49641. */
  49642. export class WebXRInput implements IDisposable {
  49643. /**
  49644. * the xr session manager for this session
  49645. */
  49646. xrSessionManager: WebXRSessionManager;
  49647. /**
  49648. * the WebXR camera for this session. Mainly used for teleportation
  49649. */
  49650. xrCamera: WebXRCamera;
  49651. private readonly options;
  49652. /**
  49653. * XR controllers being tracked
  49654. */
  49655. controllers: Array<WebXRInputSource>;
  49656. private _frameObserver;
  49657. private _sessionEndedObserver;
  49658. private _sessionInitObserver;
  49659. /**
  49660. * Event when a controller has been connected/added
  49661. */
  49662. onControllerAddedObservable: Observable<WebXRInputSource>;
  49663. /**
  49664. * Event when a controller has been removed/disconnected
  49665. */
  49666. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49667. /**
  49668. * Initializes the WebXRInput
  49669. * @param xrSessionManager the xr session manager for this session
  49670. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49671. * @param options = initialization options for this xr input
  49672. */
  49673. constructor(
  49674. /**
  49675. * the xr session manager for this session
  49676. */
  49677. xrSessionManager: WebXRSessionManager,
  49678. /**
  49679. * the WebXR camera for this session. Mainly used for teleportation
  49680. */
  49681. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49682. private _onInputSourcesChange;
  49683. private _addAndRemoveControllers;
  49684. /**
  49685. * Disposes of the object
  49686. */
  49687. dispose(): void;
  49688. }
  49689. }
  49690. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49691. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49692. import { Observable, EventState } from "babylonjs/Misc/observable";
  49693. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49694. /**
  49695. * This is the base class for all WebXR features.
  49696. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49697. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49698. */
  49699. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49700. protected _xrSessionManager: WebXRSessionManager;
  49701. private _attached;
  49702. private _removeOnDetach;
  49703. /**
  49704. * Should auto-attach be disabled?
  49705. */
  49706. disableAutoAttach: boolean;
  49707. /**
  49708. * Construct a new (abstract) WebXR feature
  49709. * @param _xrSessionManager the xr session manager for this feature
  49710. */
  49711. constructor(_xrSessionManager: WebXRSessionManager);
  49712. /**
  49713. * Is this feature attached
  49714. */
  49715. get attached(): boolean;
  49716. /**
  49717. * attach this feature
  49718. *
  49719. * @param force should attachment be forced (even when already attached)
  49720. * @returns true if successful, false is failed or already attached
  49721. */
  49722. attach(force?: boolean): boolean;
  49723. /**
  49724. * detach this feature.
  49725. *
  49726. * @returns true if successful, false if failed or already detached
  49727. */
  49728. detach(): boolean;
  49729. /**
  49730. * Dispose this feature and all of the resources attached
  49731. */
  49732. dispose(): void;
  49733. /**
  49734. * This is used to register callbacks that will automatically be removed when detach is called.
  49735. * @param observable the observable to which the observer will be attached
  49736. * @param callback the callback to register
  49737. */
  49738. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49739. /**
  49740. * Code in this function will be executed on each xrFrame received from the browser.
  49741. * This function will not execute after the feature is detached.
  49742. * @param _xrFrame the current frame
  49743. */
  49744. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49745. }
  49746. }
  49747. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49748. import { IDisposable, Scene } from "babylonjs/scene";
  49749. import { Nullable } from "babylonjs/types";
  49750. import { Observable } from "babylonjs/Misc/observable";
  49751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49752. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49753. import { Camera } from "babylonjs/Cameras/camera";
  49754. /**
  49755. * Renders a layer on top of an existing scene
  49756. */
  49757. export class UtilityLayerRenderer implements IDisposable {
  49758. /** the original scene that will be rendered on top of */
  49759. originalScene: Scene;
  49760. private _pointerCaptures;
  49761. private _lastPointerEvents;
  49762. private static _DefaultUtilityLayer;
  49763. private static _DefaultKeepDepthUtilityLayer;
  49764. private _sharedGizmoLight;
  49765. private _renderCamera;
  49766. /**
  49767. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49768. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49769. * @returns the camera that is used when rendering the utility layer
  49770. */
  49771. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49772. /**
  49773. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49774. * @param cam the camera that should be used when rendering the utility layer
  49775. */
  49776. setRenderCamera(cam: Nullable<Camera>): void;
  49777. /**
  49778. * @hidden
  49779. * Light which used by gizmos to get light shading
  49780. */
  49781. _getSharedGizmoLight(): HemisphericLight;
  49782. /**
  49783. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49784. */
  49785. pickUtilitySceneFirst: boolean;
  49786. /**
  49787. * 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)
  49788. */
  49789. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49790. /**
  49791. * 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)
  49792. */
  49793. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49794. /**
  49795. * The scene that is rendered on top of the original scene
  49796. */
  49797. utilityLayerScene: Scene;
  49798. /**
  49799. * If the utility layer should automatically be rendered on top of existing scene
  49800. */
  49801. shouldRender: boolean;
  49802. /**
  49803. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49804. */
  49805. onlyCheckPointerDownEvents: boolean;
  49806. /**
  49807. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49808. */
  49809. processAllEvents: boolean;
  49810. /**
  49811. * Observable raised when the pointer move from the utility layer scene to the main scene
  49812. */
  49813. onPointerOutObservable: Observable<number>;
  49814. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49815. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49816. private _afterRenderObserver;
  49817. private _sceneDisposeObserver;
  49818. private _originalPointerObserver;
  49819. /**
  49820. * Instantiates a UtilityLayerRenderer
  49821. * @param originalScene the original scene that will be rendered on top of
  49822. * @param handleEvents boolean indicating if the utility layer should handle events
  49823. */
  49824. constructor(
  49825. /** the original scene that will be rendered on top of */
  49826. originalScene: Scene, handleEvents?: boolean);
  49827. private _notifyObservers;
  49828. /**
  49829. * Renders the utility layers scene on top of the original scene
  49830. */
  49831. render(): void;
  49832. /**
  49833. * Disposes of the renderer
  49834. */
  49835. dispose(): void;
  49836. private _updateCamera;
  49837. }
  49838. }
  49839. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49840. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49842. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49843. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49844. import { Scene } from "babylonjs/scene";
  49845. import { Nullable } from "babylonjs/types";
  49846. import { Color3 } from "babylonjs/Maths/math.color";
  49847. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49848. /**
  49849. * Options interface for the pointer selection module
  49850. */
  49851. export interface IWebXRControllerPointerSelectionOptions {
  49852. /**
  49853. * if provided, this scene will be used to render meshes.
  49854. */
  49855. customUtilityLayerScene?: Scene;
  49856. /**
  49857. * 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)
  49858. * If not disabled, the last picked point will be used to execute a pointer up event
  49859. * If disabled, pointer up event will be triggered right after the pointer down event.
  49860. * Used in screen and gaze target ray mode only
  49861. */
  49862. disablePointerUpOnTouchOut: boolean;
  49863. /**
  49864. * For gaze mode (time to select instead of press)
  49865. */
  49866. forceGazeMode: boolean;
  49867. /**
  49868. * 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
  49869. * to start a new countdown to the pointer down event.
  49870. * Defaults to 1.
  49871. */
  49872. gazeModePointerMovedFactor?: number;
  49873. /**
  49874. * Different button type to use instead of the main component
  49875. */
  49876. overrideButtonId?: string;
  49877. /**
  49878. * use this rendering group id for the meshes (optional)
  49879. */
  49880. renderingGroupId?: number;
  49881. /**
  49882. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49883. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49884. * 3000 means 3 seconds between pointing at something and selecting it
  49885. */
  49886. timeToSelect?: number;
  49887. /**
  49888. * Should meshes created here be added to a utility layer or the main scene
  49889. */
  49890. useUtilityLayer?: boolean;
  49891. /**
  49892. * the xr input to use with this pointer selection
  49893. */
  49894. xrInput: WebXRInput;
  49895. }
  49896. /**
  49897. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49898. */
  49899. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49900. private readonly _options;
  49901. private static _idCounter;
  49902. private _attachController;
  49903. private _controllers;
  49904. private _scene;
  49905. private _tmpVectorForPickCompare;
  49906. /**
  49907. * The module's name
  49908. */
  49909. static readonly Name: string;
  49910. /**
  49911. * The (Babylon) version of this module.
  49912. * This is an integer representing the implementation version.
  49913. * This number does not correspond to the WebXR specs version
  49914. */
  49915. static readonly Version: number;
  49916. /**
  49917. * Disable lighting on the laser pointer (so it will always be visible)
  49918. */
  49919. disablePointerLighting: boolean;
  49920. /**
  49921. * Disable lighting on the selection mesh (so it will always be visible)
  49922. */
  49923. disableSelectionMeshLighting: boolean;
  49924. /**
  49925. * Should the laser pointer be displayed
  49926. */
  49927. displayLaserPointer: boolean;
  49928. /**
  49929. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49930. */
  49931. displaySelectionMesh: boolean;
  49932. /**
  49933. * This color will be set to the laser pointer when selection is triggered
  49934. */
  49935. laserPointerPickedColor: Color3;
  49936. /**
  49937. * Default color of the laser pointer
  49938. */
  49939. laserPointerDefaultColor: Color3;
  49940. /**
  49941. * default color of the selection ring
  49942. */
  49943. selectionMeshDefaultColor: Color3;
  49944. /**
  49945. * This color will be applied to the selection ring when selection is triggered
  49946. */
  49947. selectionMeshPickedColor: Color3;
  49948. /**
  49949. * Optional filter to be used for ray selection. This predicate shares behavior with
  49950. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49951. */
  49952. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49953. /**
  49954. * constructs a new background remover module
  49955. * @param _xrSessionManager the session manager for this module
  49956. * @param _options read-only options to be used in this module
  49957. */
  49958. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49959. /**
  49960. * attach this feature
  49961. * Will usually be called by the features manager
  49962. *
  49963. * @returns true if successful.
  49964. */
  49965. attach(): boolean;
  49966. /**
  49967. * detach this feature.
  49968. * Will usually be called by the features manager
  49969. *
  49970. * @returns true if successful.
  49971. */
  49972. detach(): boolean;
  49973. /**
  49974. * Will get the mesh under a specific pointer.
  49975. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49976. * @param controllerId the controllerId to check
  49977. * @returns The mesh under pointer or null if no mesh is under the pointer
  49978. */
  49979. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49980. /**
  49981. * Get the xr controller that correlates to the pointer id in the pointer event
  49982. *
  49983. * @param id the pointer id to search for
  49984. * @returns the controller that correlates to this id or null if not found
  49985. */
  49986. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49987. protected _onXRFrame(_xrFrame: XRFrame): void;
  49988. private _attachGazeMode;
  49989. private _attachScreenRayMode;
  49990. private _attachTrackedPointerRayMode;
  49991. private _convertNormalToDirectionOfRay;
  49992. private _detachController;
  49993. private _generateNewMeshPair;
  49994. private _pickingMoved;
  49995. private _updatePointerDistance;
  49996. /** @hidden */
  49997. get lasterPointerDefaultColor(): Color3;
  49998. }
  49999. }
  50000. declare module "babylonjs/XR/webXREnterExitUI" {
  50001. import { Nullable } from "babylonjs/types";
  50002. import { Observable } from "babylonjs/Misc/observable";
  50003. import { IDisposable, Scene } from "babylonjs/scene";
  50004. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50005. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50006. /**
  50007. * Button which can be used to enter a different mode of XR
  50008. */
  50009. export class WebXREnterExitUIButton {
  50010. /** button element */
  50011. element: HTMLElement;
  50012. /** XR initialization options for the button */
  50013. sessionMode: XRSessionMode;
  50014. /** Reference space type */
  50015. referenceSpaceType: XRReferenceSpaceType;
  50016. /**
  50017. * Creates a WebXREnterExitUIButton
  50018. * @param element button element
  50019. * @param sessionMode XR initialization session mode
  50020. * @param referenceSpaceType the type of reference space to be used
  50021. */
  50022. constructor(
  50023. /** button element */
  50024. element: HTMLElement,
  50025. /** XR initialization options for the button */
  50026. sessionMode: XRSessionMode,
  50027. /** Reference space type */
  50028. referenceSpaceType: XRReferenceSpaceType);
  50029. /**
  50030. * Extendable function which can be used to update the button's visuals when the state changes
  50031. * @param activeButton the current active button in the UI
  50032. */
  50033. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50034. }
  50035. /**
  50036. * Options to create the webXR UI
  50037. */
  50038. export class WebXREnterExitUIOptions {
  50039. /**
  50040. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50041. */
  50042. customButtons?: Array<WebXREnterExitUIButton>;
  50043. /**
  50044. * A reference space type to use when creating the default button.
  50045. * Default is local-floor
  50046. */
  50047. referenceSpaceType?: XRReferenceSpaceType;
  50048. /**
  50049. * Context to enter xr with
  50050. */
  50051. renderTarget?: Nullable<WebXRRenderTarget>;
  50052. /**
  50053. * A session mode to use when creating the default button.
  50054. * Default is immersive-vr
  50055. */
  50056. sessionMode?: XRSessionMode;
  50057. /**
  50058. * A list of optional features to init the session with
  50059. */
  50060. optionalFeatures?: string[];
  50061. /**
  50062. * A list of optional features to init the session with
  50063. */
  50064. requiredFeatures?: string[];
  50065. }
  50066. /**
  50067. * UI to allow the user to enter/exit XR mode
  50068. */
  50069. export class WebXREnterExitUI implements IDisposable {
  50070. private scene;
  50071. /** version of the options passed to this UI */
  50072. options: WebXREnterExitUIOptions;
  50073. private _activeButton;
  50074. private _buttons;
  50075. private _overlay;
  50076. /**
  50077. * Fired every time the active button is changed.
  50078. *
  50079. * When xr is entered via a button that launches xr that button will be the callback parameter
  50080. *
  50081. * When exiting xr the callback parameter will be null)
  50082. */
  50083. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50084. /**
  50085. *
  50086. * @param scene babylon scene object to use
  50087. * @param options (read-only) version of the options passed to this UI
  50088. */
  50089. private constructor();
  50090. /**
  50091. * Creates UI to allow the user to enter/exit XR mode
  50092. * @param scene the scene to add the ui to
  50093. * @param helper the xr experience helper to enter/exit xr with
  50094. * @param options options to configure the UI
  50095. * @returns the created ui
  50096. */
  50097. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50098. /**
  50099. * Disposes of the XR UI component
  50100. */
  50101. dispose(): void;
  50102. private _updateButtons;
  50103. }
  50104. }
  50105. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50106. import { Vector3 } from "babylonjs/Maths/math.vector";
  50107. import { Color4 } from "babylonjs/Maths/math.color";
  50108. import { Nullable } from "babylonjs/types";
  50109. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50110. import { Scene } from "babylonjs/scene";
  50111. /**
  50112. * Class containing static functions to help procedurally build meshes
  50113. */
  50114. export class LinesBuilder {
  50115. /**
  50116. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50117. * * 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
  50118. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50119. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50120. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50121. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50122. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50123. * * 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
  50124. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50127. * @param name defines the name of the new line system
  50128. * @param options defines the options used to create the line system
  50129. * @param scene defines the hosting scene
  50130. * @returns a new line system mesh
  50131. */
  50132. static CreateLineSystem(name: string, options: {
  50133. lines: Vector3[][];
  50134. updatable?: boolean;
  50135. instance?: Nullable<LinesMesh>;
  50136. colors?: Nullable<Color4[][]>;
  50137. useVertexAlpha?: boolean;
  50138. }, scene: Nullable<Scene>): LinesMesh;
  50139. /**
  50140. * Creates a line mesh
  50141. * 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
  50142. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50143. * * The parameter `points` is an array successive Vector3
  50144. * * 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
  50145. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50146. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50147. * * When updating an instance, remember that only point positions can change, not the number of points
  50148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50150. * @param name defines the name of the new line system
  50151. * @param options defines the options used to create the line system
  50152. * @param scene defines the hosting scene
  50153. * @returns a new line mesh
  50154. */
  50155. static CreateLines(name: string, options: {
  50156. points: Vector3[];
  50157. updatable?: boolean;
  50158. instance?: Nullable<LinesMesh>;
  50159. colors?: Color4[];
  50160. useVertexAlpha?: boolean;
  50161. }, scene?: Nullable<Scene>): LinesMesh;
  50162. /**
  50163. * Creates a dashed line mesh
  50164. * * 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
  50165. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50166. * * The parameter `points` is an array successive Vector3
  50167. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50168. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50169. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50170. * * 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
  50171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50172. * * When updating an instance, remember that only point positions can change, not the number of points
  50173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50174. * @param name defines the name of the mesh
  50175. * @param options defines the options used to create the mesh
  50176. * @param scene defines the hosting scene
  50177. * @returns the dashed line mesh
  50178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50179. */
  50180. static CreateDashedLines(name: string, options: {
  50181. points: Vector3[];
  50182. dashSize?: number;
  50183. gapSize?: number;
  50184. dashNb?: number;
  50185. updatable?: boolean;
  50186. instance?: LinesMesh;
  50187. useVertexAlpha?: boolean;
  50188. }, scene?: Nullable<Scene>): LinesMesh;
  50189. }
  50190. }
  50191. declare module "babylonjs/Misc/timer" {
  50192. import { Observable, Observer } from "babylonjs/Misc/observable";
  50193. import { Nullable } from "babylonjs/types";
  50194. import { IDisposable } from "babylonjs/scene";
  50195. /**
  50196. * Construction options for a timer
  50197. */
  50198. export interface ITimerOptions<T> {
  50199. /**
  50200. * Time-to-end
  50201. */
  50202. timeout: number;
  50203. /**
  50204. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50205. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50206. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50207. */
  50208. contextObservable: Observable<T>;
  50209. /**
  50210. * Optional parameters when adding an observer to the observable
  50211. */
  50212. observableParameters?: {
  50213. mask?: number;
  50214. insertFirst?: boolean;
  50215. scope?: any;
  50216. };
  50217. /**
  50218. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50219. */
  50220. breakCondition?: (data?: ITimerData<T>) => boolean;
  50221. /**
  50222. * Will be triggered when the time condition has met
  50223. */
  50224. onEnded?: (data: ITimerData<any>) => void;
  50225. /**
  50226. * Will be triggered when the break condition has met (prematurely ended)
  50227. */
  50228. onAborted?: (data: ITimerData<any>) => void;
  50229. /**
  50230. * Optional function to execute on each tick (or count)
  50231. */
  50232. onTick?: (data: ITimerData<any>) => void;
  50233. }
  50234. /**
  50235. * An interface defining the data sent by the timer
  50236. */
  50237. export interface ITimerData<T> {
  50238. /**
  50239. * When did it start
  50240. */
  50241. startTime: number;
  50242. /**
  50243. * Time now
  50244. */
  50245. currentTime: number;
  50246. /**
  50247. * Time passed since started
  50248. */
  50249. deltaTime: number;
  50250. /**
  50251. * How much is completed, in [0.0...1.0].
  50252. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50253. */
  50254. completeRate: number;
  50255. /**
  50256. * What the registered observable sent in the last count
  50257. */
  50258. payload: T;
  50259. }
  50260. /**
  50261. * The current state of the timer
  50262. */
  50263. export enum TimerState {
  50264. /**
  50265. * Timer initialized, not yet started
  50266. */
  50267. INIT = 0,
  50268. /**
  50269. * Timer started and counting
  50270. */
  50271. STARTED = 1,
  50272. /**
  50273. * Timer ended (whether aborted or time reached)
  50274. */
  50275. ENDED = 2
  50276. }
  50277. /**
  50278. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50279. *
  50280. * @param options options with which to initialize this timer
  50281. */
  50282. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50283. /**
  50284. * An advanced implementation of a timer class
  50285. */
  50286. export class AdvancedTimer<T = any> implements IDisposable {
  50287. /**
  50288. * Will notify each time the timer calculates the remaining time
  50289. */
  50290. onEachCountObservable: Observable<ITimerData<T>>;
  50291. /**
  50292. * Will trigger when the timer was aborted due to the break condition
  50293. */
  50294. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50295. /**
  50296. * Will trigger when the timer ended successfully
  50297. */
  50298. onTimerEndedObservable: Observable<ITimerData<T>>;
  50299. /**
  50300. * Will trigger when the timer state has changed
  50301. */
  50302. onStateChangedObservable: Observable<TimerState>;
  50303. private _observer;
  50304. private _contextObservable;
  50305. private _observableParameters;
  50306. private _startTime;
  50307. private _timer;
  50308. private _state;
  50309. private _breakCondition;
  50310. private _timeToEnd;
  50311. private _breakOnNextTick;
  50312. /**
  50313. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50314. * @param options construction options for this advanced timer
  50315. */
  50316. constructor(options: ITimerOptions<T>);
  50317. /**
  50318. * set a breaking condition for this timer. Default is to never break during count
  50319. * @param predicate the new break condition. Returns true to break, false otherwise
  50320. */
  50321. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50322. /**
  50323. * Reset ALL associated observables in this advanced timer
  50324. */
  50325. clearObservables(): void;
  50326. /**
  50327. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50328. *
  50329. * @param timeToEnd how much time to measure until timer ended
  50330. */
  50331. start(timeToEnd?: number): void;
  50332. /**
  50333. * Will force a stop on the next tick.
  50334. */
  50335. stop(): void;
  50336. /**
  50337. * Dispose this timer, clearing all resources
  50338. */
  50339. dispose(): void;
  50340. private _setState;
  50341. private _tick;
  50342. private _stop;
  50343. }
  50344. }
  50345. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50346. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50347. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50348. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50350. import { Vector3 } from "babylonjs/Maths/math.vector";
  50351. import { Material } from "babylonjs/Materials/material";
  50352. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50353. import { Scene } from "babylonjs/scene";
  50354. /**
  50355. * The options container for the teleportation module
  50356. */
  50357. export interface IWebXRTeleportationOptions {
  50358. /**
  50359. * if provided, this scene will be used to render meshes.
  50360. */
  50361. customUtilityLayerScene?: Scene;
  50362. /**
  50363. * Values to configure the default target mesh
  50364. */
  50365. defaultTargetMeshOptions?: {
  50366. /**
  50367. * Fill color of the teleportation area
  50368. */
  50369. teleportationFillColor?: string;
  50370. /**
  50371. * Border color for the teleportation area
  50372. */
  50373. teleportationBorderColor?: string;
  50374. /**
  50375. * Disable the mesh's animation sequence
  50376. */
  50377. disableAnimation?: boolean;
  50378. /**
  50379. * Disable lighting on the material or the ring and arrow
  50380. */
  50381. disableLighting?: boolean;
  50382. /**
  50383. * Override the default material of the torus and arrow
  50384. */
  50385. torusArrowMaterial?: Material;
  50386. };
  50387. /**
  50388. * A list of meshes to use as floor meshes.
  50389. * Meshes can be added and removed after initializing the feature using the
  50390. * addFloorMesh and removeFloorMesh functions
  50391. * If empty, rotation will still work
  50392. */
  50393. floorMeshes?: AbstractMesh[];
  50394. /**
  50395. * use this rendering group id for the meshes (optional)
  50396. */
  50397. renderingGroupId?: number;
  50398. /**
  50399. * Should teleportation move only to snap points
  50400. */
  50401. snapPointsOnly?: boolean;
  50402. /**
  50403. * An array of points to which the teleportation will snap to.
  50404. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50405. */
  50406. snapPositions?: Vector3[];
  50407. /**
  50408. * How close should the teleportation ray be in order to snap to position.
  50409. * Default to 0.8 units (meters)
  50410. */
  50411. snapToPositionRadius?: number;
  50412. /**
  50413. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50414. * If you want to support rotation, make sure your mesh has a direction indicator.
  50415. *
  50416. * When left untouched, the default mesh will be initialized.
  50417. */
  50418. teleportationTargetMesh?: AbstractMesh;
  50419. /**
  50420. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50421. */
  50422. timeToTeleport?: number;
  50423. /**
  50424. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50425. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50426. */
  50427. useMainComponentOnly?: boolean;
  50428. /**
  50429. * Should meshes created here be added to a utility layer or the main scene
  50430. */
  50431. useUtilityLayer?: boolean;
  50432. /**
  50433. * Babylon XR Input class for controller
  50434. */
  50435. xrInput: WebXRInput;
  50436. }
  50437. /**
  50438. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50439. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50440. * the input of the attached controllers.
  50441. */
  50442. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50443. private _options;
  50444. private _controllers;
  50445. private _currentTeleportationControllerId;
  50446. private _floorMeshes;
  50447. private _quadraticBezierCurve;
  50448. private _selectionFeature;
  50449. private _snapToPositions;
  50450. private _snappedToPoint;
  50451. private _teleportationRingMaterial?;
  50452. private _tmpRay;
  50453. private _tmpVector;
  50454. /**
  50455. * The module's name
  50456. */
  50457. static readonly Name: string;
  50458. /**
  50459. * The (Babylon) version of this module.
  50460. * This is an integer representing the implementation version.
  50461. * This number does not correspond to the webxr specs version
  50462. */
  50463. static readonly Version: number;
  50464. /**
  50465. * Is movement backwards enabled
  50466. */
  50467. backwardsMovementEnabled: boolean;
  50468. /**
  50469. * Distance to travel when moving backwards
  50470. */
  50471. backwardsTeleportationDistance: number;
  50472. /**
  50473. * The distance from the user to the inspection point in the direction of the controller
  50474. * A higher number will allow the user to move further
  50475. * defaults to 5 (meters, in xr units)
  50476. */
  50477. parabolicCheckRadius: number;
  50478. /**
  50479. * Should the module support parabolic ray on top of direct ray
  50480. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50481. * Very helpful when moving between floors / different heights
  50482. */
  50483. parabolicRayEnabled: boolean;
  50484. /**
  50485. * How much rotation should be applied when rotating right and left
  50486. */
  50487. rotationAngle: number;
  50488. /**
  50489. * Is rotation enabled when moving forward?
  50490. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50491. */
  50492. rotationEnabled: boolean;
  50493. /**
  50494. * constructs a new anchor system
  50495. * @param _xrSessionManager an instance of WebXRSessionManager
  50496. * @param _options configuration object for this feature
  50497. */
  50498. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50499. /**
  50500. * Get the snapPointsOnly flag
  50501. */
  50502. get snapPointsOnly(): boolean;
  50503. /**
  50504. * Sets the snapPointsOnly flag
  50505. * @param snapToPoints should teleportation be exclusively to snap points
  50506. */
  50507. set snapPointsOnly(snapToPoints: boolean);
  50508. /**
  50509. * Add a new mesh to the floor meshes array
  50510. * @param mesh the mesh to use as floor mesh
  50511. */
  50512. addFloorMesh(mesh: AbstractMesh): void;
  50513. /**
  50514. * Add a new snap-to point to fix teleportation to this position
  50515. * @param newSnapPoint The new Snap-To point
  50516. */
  50517. addSnapPoint(newSnapPoint: Vector3): void;
  50518. attach(): boolean;
  50519. detach(): boolean;
  50520. dispose(): void;
  50521. /**
  50522. * Remove a mesh from the floor meshes array
  50523. * @param mesh the mesh to remove
  50524. */
  50525. removeFloorMesh(mesh: AbstractMesh): void;
  50526. /**
  50527. * Remove a mesh from the floor meshes array using its name
  50528. * @param name the mesh name to remove
  50529. */
  50530. removeFloorMeshByName(name: string): void;
  50531. /**
  50532. * 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
  50533. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50534. * @returns was the point found and removed or not
  50535. */
  50536. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50537. /**
  50538. * This function sets a selection feature that will be disabled when
  50539. * the forward ray is shown and will be reattached when hidden.
  50540. * This is used to remove the selection rays when moving.
  50541. * @param selectionFeature the feature to disable when forward movement is enabled
  50542. */
  50543. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50544. protected _onXRFrame(_xrFrame: XRFrame): void;
  50545. private _attachController;
  50546. private _createDefaultTargetMesh;
  50547. private _detachController;
  50548. private _findClosestSnapPointWithRadius;
  50549. private _setTargetMeshPosition;
  50550. private _setTargetMeshVisibility;
  50551. private _showParabolicPath;
  50552. private _teleportForward;
  50553. }
  50554. }
  50555. declare module "babylonjs/XR/webXRDefaultExperience" {
  50556. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50557. import { Scene } from "babylonjs/scene";
  50558. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50559. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50560. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50561. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50563. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50564. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50565. /**
  50566. * Options for the default xr helper
  50567. */
  50568. export class WebXRDefaultExperienceOptions {
  50569. /**
  50570. * Enable or disable default UI to enter XR
  50571. */
  50572. disableDefaultUI?: boolean;
  50573. /**
  50574. * Should teleportation not initialize. defaults to false.
  50575. */
  50576. disableTeleportation?: boolean;
  50577. /**
  50578. * Floor meshes that will be used for teleport
  50579. */
  50580. floorMeshes?: Array<AbstractMesh>;
  50581. /**
  50582. * If set to true, the first frame will not be used to reset position
  50583. * The first frame is mainly used when copying transformation from the old camera
  50584. * Mainly used in AR
  50585. */
  50586. ignoreNativeCameraTransformation?: boolean;
  50587. /**
  50588. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50589. */
  50590. inputOptions?: IWebXRInputOptions;
  50591. /**
  50592. * optional configuration for the output canvas
  50593. */
  50594. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50595. /**
  50596. * optional UI options. This can be used among other to change session mode and reference space type
  50597. */
  50598. uiOptions?: WebXREnterExitUIOptions;
  50599. /**
  50600. * When loading teleportation and pointer select, use stable versions instead of latest.
  50601. */
  50602. useStablePlugins?: boolean;
  50603. /**
  50604. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50605. */
  50606. renderingGroupId?: number;
  50607. /**
  50608. * A list of optional features to init the session with
  50609. * If set to true, all features we support will be added
  50610. */
  50611. optionalFeatures?: boolean | string[];
  50612. }
  50613. /**
  50614. * Default experience which provides a similar setup to the previous webVRExperience
  50615. */
  50616. export class WebXRDefaultExperience {
  50617. /**
  50618. * Base experience
  50619. */
  50620. baseExperience: WebXRExperienceHelper;
  50621. /**
  50622. * Enables ui for entering/exiting xr
  50623. */
  50624. enterExitUI: WebXREnterExitUI;
  50625. /**
  50626. * Input experience extension
  50627. */
  50628. input: WebXRInput;
  50629. /**
  50630. * Enables laser pointer and selection
  50631. */
  50632. pointerSelection: WebXRControllerPointerSelection;
  50633. /**
  50634. * Default target xr should render to
  50635. */
  50636. renderTarget: WebXRRenderTarget;
  50637. /**
  50638. * Enables teleportation
  50639. */
  50640. teleportation: WebXRMotionControllerTeleportation;
  50641. private constructor();
  50642. /**
  50643. * Creates the default xr experience
  50644. * @param scene scene
  50645. * @param options options for basic configuration
  50646. * @returns resulting WebXRDefaultExperience
  50647. */
  50648. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50649. /**
  50650. * DIsposes of the experience helper
  50651. */
  50652. dispose(): void;
  50653. }
  50654. }
  50655. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50656. import { Observable } from "babylonjs/Misc/observable";
  50657. import { Nullable } from "babylonjs/types";
  50658. import { Camera } from "babylonjs/Cameras/camera";
  50659. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50660. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50661. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50662. import { Scene } from "babylonjs/scene";
  50663. import { Vector3 } from "babylonjs/Maths/math.vector";
  50664. import { Color3 } from "babylonjs/Maths/math.color";
  50665. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50667. import { Mesh } from "babylonjs/Meshes/mesh";
  50668. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50669. import { EasingFunction } from "babylonjs/Animations/easing";
  50670. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50671. import "babylonjs/Meshes/Builders/groundBuilder";
  50672. import "babylonjs/Meshes/Builders/torusBuilder";
  50673. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50674. import "babylonjs/Gamepads/gamepadSceneComponent";
  50675. import "babylonjs/Animations/animatable";
  50676. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50677. /**
  50678. * Options to modify the vr teleportation behavior.
  50679. */
  50680. export interface VRTeleportationOptions {
  50681. /**
  50682. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50683. */
  50684. floorMeshName?: string;
  50685. /**
  50686. * A list of meshes to be used as the teleportation floor. (default: empty)
  50687. */
  50688. floorMeshes?: Mesh[];
  50689. /**
  50690. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50691. */
  50692. teleportationMode?: number;
  50693. /**
  50694. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50695. */
  50696. teleportationTime?: number;
  50697. /**
  50698. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50699. */
  50700. teleportationSpeed?: number;
  50701. /**
  50702. * The easing function used in the animation or null for Linear. (default CircleEase)
  50703. */
  50704. easingFunction?: EasingFunction;
  50705. }
  50706. /**
  50707. * Options to modify the vr experience helper's behavior.
  50708. */
  50709. export interface VRExperienceHelperOptions extends WebVROptions {
  50710. /**
  50711. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50712. */
  50713. createDeviceOrientationCamera?: boolean;
  50714. /**
  50715. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50716. */
  50717. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50718. /**
  50719. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50720. */
  50721. laserToggle?: boolean;
  50722. /**
  50723. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50724. */
  50725. floorMeshes?: Mesh[];
  50726. /**
  50727. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50728. */
  50729. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50730. /**
  50731. * Defines if WebXR should be used instead of WebVR (if available)
  50732. */
  50733. useXR?: boolean;
  50734. }
  50735. /**
  50736. * Event containing information after VR has been entered
  50737. */
  50738. export class OnAfterEnteringVRObservableEvent {
  50739. /**
  50740. * If entering vr was successful
  50741. */
  50742. success: boolean;
  50743. }
  50744. /**
  50745. * Helps to quickly add VR support to an existing scene.
  50746. * See https://doc.babylonjs.com/how_to/webvr_helper
  50747. */
  50748. export class VRExperienceHelper {
  50749. /** Options to modify the vr experience helper's behavior. */
  50750. webVROptions: VRExperienceHelperOptions;
  50751. private _scene;
  50752. private _position;
  50753. private _btnVR;
  50754. private _btnVRDisplayed;
  50755. private _webVRsupported;
  50756. private _webVRready;
  50757. private _webVRrequesting;
  50758. private _webVRpresenting;
  50759. private _hasEnteredVR;
  50760. private _fullscreenVRpresenting;
  50761. private _inputElement;
  50762. private _webVRCamera;
  50763. private _vrDeviceOrientationCamera;
  50764. private _deviceOrientationCamera;
  50765. private _existingCamera;
  50766. private _onKeyDown;
  50767. private _onVrDisplayPresentChange;
  50768. private _onVRDisplayChanged;
  50769. private _onVRRequestPresentStart;
  50770. private _onVRRequestPresentComplete;
  50771. /**
  50772. * 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)
  50773. */
  50774. enableGazeEvenWhenNoPointerLock: boolean;
  50775. /**
  50776. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50777. */
  50778. exitVROnDoubleTap: boolean;
  50779. /**
  50780. * Observable raised right before entering VR.
  50781. */
  50782. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50783. /**
  50784. * Observable raised when entering VR has completed.
  50785. */
  50786. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50787. /**
  50788. * Observable raised when exiting VR.
  50789. */
  50790. onExitingVRObservable: Observable<VRExperienceHelper>;
  50791. /**
  50792. * Observable raised when controller mesh is loaded.
  50793. */
  50794. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50795. /** Return this.onEnteringVRObservable
  50796. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50797. */
  50798. get onEnteringVR(): Observable<VRExperienceHelper>;
  50799. /** Return this.onExitingVRObservable
  50800. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50801. */
  50802. get onExitingVR(): Observable<VRExperienceHelper>;
  50803. /** Return this.onControllerMeshLoadedObservable
  50804. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50805. */
  50806. get onControllerMeshLoaded(): Observable<WebVRController>;
  50807. private _rayLength;
  50808. private _useCustomVRButton;
  50809. private _teleportationRequested;
  50810. private _teleportActive;
  50811. private _floorMeshName;
  50812. private _floorMeshesCollection;
  50813. private _teleportationMode;
  50814. private _teleportationTime;
  50815. private _teleportationSpeed;
  50816. private _teleportationEasing;
  50817. private _rotationAllowed;
  50818. private _teleportBackwardsVector;
  50819. private _teleportationTarget;
  50820. private _isDefaultTeleportationTarget;
  50821. private _postProcessMove;
  50822. private _teleportationFillColor;
  50823. private _teleportationBorderColor;
  50824. private _rotationAngle;
  50825. private _haloCenter;
  50826. private _cameraGazer;
  50827. private _padSensibilityUp;
  50828. private _padSensibilityDown;
  50829. private _leftController;
  50830. private _rightController;
  50831. private _gazeColor;
  50832. private _laserColor;
  50833. private _pickedLaserColor;
  50834. private _pickedGazeColor;
  50835. /**
  50836. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50837. */
  50838. onNewMeshSelected: Observable<AbstractMesh>;
  50839. /**
  50840. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50841. * This observable will provide the mesh and the controller used to select the mesh
  50842. */
  50843. onMeshSelectedWithController: Observable<{
  50844. mesh: AbstractMesh;
  50845. controller: WebVRController;
  50846. }>;
  50847. /**
  50848. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50849. */
  50850. onNewMeshPicked: Observable<PickingInfo>;
  50851. private _circleEase;
  50852. /**
  50853. * Observable raised before camera teleportation
  50854. */
  50855. onBeforeCameraTeleport: Observable<Vector3>;
  50856. /**
  50857. * Observable raised after camera teleportation
  50858. */
  50859. onAfterCameraTeleport: Observable<Vector3>;
  50860. /**
  50861. * Observable raised when current selected mesh gets unselected
  50862. */
  50863. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50864. private _raySelectionPredicate;
  50865. /**
  50866. * To be optionaly changed by user to define custom ray selection
  50867. */
  50868. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50869. /**
  50870. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50871. */
  50872. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50873. /**
  50874. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50875. */
  50876. teleportationEnabled: boolean;
  50877. private _defaultHeight;
  50878. private _teleportationInitialized;
  50879. private _interactionsEnabled;
  50880. private _interactionsRequested;
  50881. private _displayGaze;
  50882. private _displayLaserPointer;
  50883. /**
  50884. * The mesh used to display where the user is going to teleport.
  50885. */
  50886. get teleportationTarget(): Mesh;
  50887. /**
  50888. * Sets the mesh to be used to display where the user is going to teleport.
  50889. */
  50890. set teleportationTarget(value: Mesh);
  50891. /**
  50892. * 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
  50893. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50894. * See https://doc.babylonjs.com/resources/baking_transformations
  50895. */
  50896. get gazeTrackerMesh(): Mesh;
  50897. set gazeTrackerMesh(value: Mesh);
  50898. /**
  50899. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50900. */
  50901. updateGazeTrackerScale: boolean;
  50902. /**
  50903. * If the gaze trackers color should be updated when selecting meshes
  50904. */
  50905. updateGazeTrackerColor: boolean;
  50906. /**
  50907. * If the controller laser color should be updated when selecting meshes
  50908. */
  50909. updateControllerLaserColor: boolean;
  50910. /**
  50911. * The gaze tracking mesh corresponding to the left controller
  50912. */
  50913. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50914. /**
  50915. * The gaze tracking mesh corresponding to the right controller
  50916. */
  50917. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50918. /**
  50919. * If the ray of the gaze should be displayed.
  50920. */
  50921. get displayGaze(): boolean;
  50922. /**
  50923. * Sets if the ray of the gaze should be displayed.
  50924. */
  50925. set displayGaze(value: boolean);
  50926. /**
  50927. * If the ray of the LaserPointer should be displayed.
  50928. */
  50929. get displayLaserPointer(): boolean;
  50930. /**
  50931. * Sets if the ray of the LaserPointer should be displayed.
  50932. */
  50933. set displayLaserPointer(value: boolean);
  50934. /**
  50935. * The deviceOrientationCamera used as the camera when not in VR.
  50936. */
  50937. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50938. /**
  50939. * Based on the current WebVR support, returns the current VR camera used.
  50940. */
  50941. get currentVRCamera(): Nullable<Camera>;
  50942. /**
  50943. * The webVRCamera which is used when in VR.
  50944. */
  50945. get webVRCamera(): WebVRFreeCamera;
  50946. /**
  50947. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50948. */
  50949. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50950. /**
  50951. * The html button that is used to trigger entering into VR.
  50952. */
  50953. get vrButton(): Nullable<HTMLButtonElement>;
  50954. private get _teleportationRequestInitiated();
  50955. /**
  50956. * Defines whether or not Pointer lock should be requested when switching to
  50957. * full screen.
  50958. */
  50959. requestPointerLockOnFullScreen: boolean;
  50960. /**
  50961. * If asking to force XR, this will be populated with the default xr experience
  50962. */
  50963. xr: WebXRDefaultExperience;
  50964. /**
  50965. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50966. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50967. */
  50968. xrTestDone: boolean;
  50969. /**
  50970. * Instantiates a VRExperienceHelper.
  50971. * Helps to quickly add VR support to an existing scene.
  50972. * @param scene The scene the VRExperienceHelper belongs to.
  50973. * @param webVROptions Options to modify the vr experience helper's behavior.
  50974. */
  50975. constructor(scene: Scene,
  50976. /** Options to modify the vr experience helper's behavior. */
  50977. webVROptions?: VRExperienceHelperOptions);
  50978. private completeVRInit;
  50979. private _onDefaultMeshLoaded;
  50980. private _onResize;
  50981. private _onFullscreenChange;
  50982. /**
  50983. * Gets a value indicating if we are currently in VR mode.
  50984. */
  50985. get isInVRMode(): boolean;
  50986. private onVrDisplayPresentChange;
  50987. private onVRDisplayChanged;
  50988. private moveButtonToBottomRight;
  50989. private displayVRButton;
  50990. private updateButtonVisibility;
  50991. private _cachedAngularSensibility;
  50992. /**
  50993. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50994. * Otherwise, will use the fullscreen API.
  50995. */
  50996. enterVR(): void;
  50997. /**
  50998. * Attempt to exit VR, or fullscreen.
  50999. */
  51000. exitVR(): void;
  51001. /**
  51002. * The position of the vr experience helper.
  51003. */
  51004. get position(): Vector3;
  51005. /**
  51006. * Sets the position of the vr experience helper.
  51007. */
  51008. set position(value: Vector3);
  51009. /**
  51010. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51011. */
  51012. enableInteractions(): void;
  51013. private get _noControllerIsActive();
  51014. private beforeRender;
  51015. private _isTeleportationFloor;
  51016. /**
  51017. * Adds a floor mesh to be used for teleportation.
  51018. * @param floorMesh the mesh to be used for teleportation.
  51019. */
  51020. addFloorMesh(floorMesh: Mesh): void;
  51021. /**
  51022. * Removes a floor mesh from being used for teleportation.
  51023. * @param floorMesh the mesh to be removed.
  51024. */
  51025. removeFloorMesh(floorMesh: Mesh): void;
  51026. /**
  51027. * Enables interactions and teleportation using the VR controllers and gaze.
  51028. * @param vrTeleportationOptions options to modify teleportation behavior.
  51029. */
  51030. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51031. private _onNewGamepadConnected;
  51032. private _tryEnableInteractionOnController;
  51033. private _onNewGamepadDisconnected;
  51034. private _enableInteractionOnController;
  51035. private _checkTeleportWithRay;
  51036. private _checkRotate;
  51037. private _checkTeleportBackwards;
  51038. private _enableTeleportationOnController;
  51039. private _createTeleportationCircles;
  51040. private _displayTeleportationTarget;
  51041. private _hideTeleportationTarget;
  51042. private _rotateCamera;
  51043. private _moveTeleportationSelectorTo;
  51044. private _workingVector;
  51045. private _workingQuaternion;
  51046. private _workingMatrix;
  51047. /**
  51048. * Time Constant Teleportation Mode
  51049. */
  51050. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51051. /**
  51052. * Speed Constant Teleportation Mode
  51053. */
  51054. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51055. /**
  51056. * Teleports the users feet to the desired location
  51057. * @param location The location where the user's feet should be placed
  51058. */
  51059. teleportCamera(location: Vector3): void;
  51060. private _convertNormalToDirectionOfRay;
  51061. private _castRayAndSelectObject;
  51062. private _notifySelectedMeshUnselected;
  51063. /**
  51064. * Permanently set new colors for the laser pointer
  51065. * @param color the new laser color
  51066. * @param pickedColor the new laser color when picked mesh detected
  51067. */
  51068. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51069. /**
  51070. * Set lighting enabled / disabled on the laser pointer of both controllers
  51071. * @param enabled should the lighting be enabled on the laser pointer
  51072. */
  51073. setLaserLightingState(enabled?: boolean): void;
  51074. /**
  51075. * Permanently set new colors for the gaze pointer
  51076. * @param color the new gaze color
  51077. * @param pickedColor the new gaze color when picked mesh detected
  51078. */
  51079. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51080. /**
  51081. * Sets the color of the laser ray from the vr controllers.
  51082. * @param color new color for the ray.
  51083. */
  51084. changeLaserColor(color: Color3): void;
  51085. /**
  51086. * Sets the color of the ray from the vr headsets gaze.
  51087. * @param color new color for the ray.
  51088. */
  51089. changeGazeColor(color: Color3): void;
  51090. /**
  51091. * Exits VR and disposes of the vr experience helper
  51092. */
  51093. dispose(): void;
  51094. /**
  51095. * Gets the name of the VRExperienceHelper class
  51096. * @returns "VRExperienceHelper"
  51097. */
  51098. getClassName(): string;
  51099. }
  51100. }
  51101. declare module "babylonjs/Cameras/VR/index" {
  51102. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51103. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51104. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51105. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51106. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51107. export * from "babylonjs/Cameras/VR/webVRCamera";
  51108. }
  51109. declare module "babylonjs/Cameras/RigModes/index" {
  51110. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51111. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51112. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51113. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51114. }
  51115. declare module "babylonjs/Cameras/index" {
  51116. export * from "babylonjs/Cameras/Inputs/index";
  51117. export * from "babylonjs/Cameras/cameraInputsManager";
  51118. export * from "babylonjs/Cameras/camera";
  51119. export * from "babylonjs/Cameras/targetCamera";
  51120. export * from "babylonjs/Cameras/freeCamera";
  51121. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51122. export * from "babylonjs/Cameras/touchCamera";
  51123. export * from "babylonjs/Cameras/arcRotateCamera";
  51124. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51125. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51126. export * from "babylonjs/Cameras/flyCamera";
  51127. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51128. export * from "babylonjs/Cameras/followCamera";
  51129. export * from "babylonjs/Cameras/followCameraInputsManager";
  51130. export * from "babylonjs/Cameras/gamepadCamera";
  51131. export * from "babylonjs/Cameras/Stereoscopic/index";
  51132. export * from "babylonjs/Cameras/universalCamera";
  51133. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51134. export * from "babylonjs/Cameras/VR/index";
  51135. export * from "babylonjs/Cameras/RigModes/index";
  51136. }
  51137. declare module "babylonjs/Collisions/index" {
  51138. export * from "babylonjs/Collisions/collider";
  51139. export * from "babylonjs/Collisions/collisionCoordinator";
  51140. export * from "babylonjs/Collisions/pickingInfo";
  51141. export * from "babylonjs/Collisions/intersectionInfo";
  51142. export * from "babylonjs/Collisions/meshCollisionData";
  51143. }
  51144. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51145. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51146. import { Vector3 } from "babylonjs/Maths/math.vector";
  51147. import { Ray } from "babylonjs/Culling/ray";
  51148. import { Plane } from "babylonjs/Maths/math.plane";
  51149. /**
  51150. * Contains an array of blocks representing the octree
  51151. */
  51152. export interface IOctreeContainer<T> {
  51153. /**
  51154. * Blocks within the octree
  51155. */
  51156. blocks: Array<OctreeBlock<T>>;
  51157. }
  51158. /**
  51159. * Class used to store a cell in an octree
  51160. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51161. */
  51162. export class OctreeBlock<T> {
  51163. /**
  51164. * Gets the content of the current block
  51165. */
  51166. entries: T[];
  51167. /**
  51168. * Gets the list of block children
  51169. */
  51170. blocks: Array<OctreeBlock<T>>;
  51171. private _depth;
  51172. private _maxDepth;
  51173. private _capacity;
  51174. private _minPoint;
  51175. private _maxPoint;
  51176. private _boundingVectors;
  51177. private _creationFunc;
  51178. /**
  51179. * Creates a new block
  51180. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51181. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51182. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51183. * @param depth defines the current depth of this block in the octree
  51184. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51185. * @param creationFunc defines a callback to call when an element is added to the block
  51186. */
  51187. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51188. /**
  51189. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51190. */
  51191. get capacity(): number;
  51192. /**
  51193. * Gets the minimum vector (in world space) of the block's bounding box
  51194. */
  51195. get minPoint(): Vector3;
  51196. /**
  51197. * Gets the maximum vector (in world space) of the block's bounding box
  51198. */
  51199. get maxPoint(): Vector3;
  51200. /**
  51201. * Add a new element to this block
  51202. * @param entry defines the element to add
  51203. */
  51204. addEntry(entry: T): void;
  51205. /**
  51206. * Remove an element from this block
  51207. * @param entry defines the element to remove
  51208. */
  51209. removeEntry(entry: T): void;
  51210. /**
  51211. * Add an array of elements to this block
  51212. * @param entries defines the array of elements to add
  51213. */
  51214. addEntries(entries: T[]): void;
  51215. /**
  51216. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51217. * @param frustumPlanes defines the frustum planes to test
  51218. * @param selection defines the array to store current content if selection is positive
  51219. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51220. */
  51221. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51222. /**
  51223. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51224. * @param sphereCenter defines the bounding sphere center
  51225. * @param sphereRadius defines the bounding sphere radius
  51226. * @param selection defines the array to store current content if selection is positive
  51227. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51228. */
  51229. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51230. /**
  51231. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51232. * @param ray defines the ray to test with
  51233. * @param selection defines the array to store current content if selection is positive
  51234. */
  51235. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51236. /**
  51237. * Subdivide the content into child blocks (this block will then be empty)
  51238. */
  51239. createInnerBlocks(): void;
  51240. /**
  51241. * @hidden
  51242. */
  51243. 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;
  51244. }
  51245. }
  51246. declare module "babylonjs/Culling/Octrees/octree" {
  51247. import { SmartArray } from "babylonjs/Misc/smartArray";
  51248. import { Vector3 } from "babylonjs/Maths/math.vector";
  51249. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51251. import { Ray } from "babylonjs/Culling/ray";
  51252. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51253. import { Plane } from "babylonjs/Maths/math.plane";
  51254. /**
  51255. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51257. */
  51258. export class Octree<T> {
  51259. /** 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.) */
  51260. maxDepth: number;
  51261. /**
  51262. * Blocks within the octree containing objects
  51263. */
  51264. blocks: Array<OctreeBlock<T>>;
  51265. /**
  51266. * Content stored in the octree
  51267. */
  51268. dynamicContent: T[];
  51269. private _maxBlockCapacity;
  51270. private _selectionContent;
  51271. private _creationFunc;
  51272. /**
  51273. * Creates a octree
  51274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51275. * @param creationFunc function to be used to instatiate the octree
  51276. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51277. * @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.)
  51278. */
  51279. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51280. /** 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.) */
  51281. maxDepth?: number);
  51282. /**
  51283. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51284. * @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);
  51285. * @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);
  51286. * @param entries meshes to be added to the octree blocks
  51287. */
  51288. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51289. /**
  51290. * Adds a mesh to the octree
  51291. * @param entry Mesh to add to the octree
  51292. */
  51293. addMesh(entry: T): void;
  51294. /**
  51295. * Remove an element from the octree
  51296. * @param entry defines the element to remove
  51297. */
  51298. removeMesh(entry: T): void;
  51299. /**
  51300. * Selects an array of meshes within the frustum
  51301. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51302. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51303. * @returns array of meshes within the frustum
  51304. */
  51305. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51306. /**
  51307. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51308. * @param sphereCenter defines the bounding sphere center
  51309. * @param sphereRadius defines the bounding sphere radius
  51310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51311. * @returns an array of objects that intersect the sphere
  51312. */
  51313. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51314. /**
  51315. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51316. * @param ray defines the ray to test with
  51317. * @returns array of intersected objects
  51318. */
  51319. intersectsRay(ray: Ray): SmartArray<T>;
  51320. /**
  51321. * Adds a mesh into the octree block if it intersects the block
  51322. */
  51323. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51324. /**
  51325. * Adds a submesh into the octree block if it intersects the block
  51326. */
  51327. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51328. }
  51329. }
  51330. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51331. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51332. import { Scene } from "babylonjs/scene";
  51333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51335. import { Ray } from "babylonjs/Culling/ray";
  51336. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51337. import { Collider } from "babylonjs/Collisions/collider";
  51338. module "babylonjs/scene" {
  51339. interface Scene {
  51340. /**
  51341. * @hidden
  51342. * Backing Filed
  51343. */
  51344. _selectionOctree: Octree<AbstractMesh>;
  51345. /**
  51346. * Gets the octree used to boost mesh selection (picking)
  51347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51348. */
  51349. selectionOctree: Octree<AbstractMesh>;
  51350. /**
  51351. * Creates or updates the octree used to boost selection (picking)
  51352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51353. * @param maxCapacity defines the maximum capacity per leaf
  51354. * @param maxDepth defines the maximum depth of the octree
  51355. * @returns an octree of AbstractMesh
  51356. */
  51357. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51358. }
  51359. }
  51360. module "babylonjs/Meshes/abstractMesh" {
  51361. interface AbstractMesh {
  51362. /**
  51363. * @hidden
  51364. * Backing Field
  51365. */
  51366. _submeshesOctree: Octree<SubMesh>;
  51367. /**
  51368. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51369. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51370. * @param maxCapacity defines the maximum size of each block (64 by default)
  51371. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51372. * @returns the new octree
  51373. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51375. */
  51376. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51377. }
  51378. }
  51379. /**
  51380. * Defines the octree scene component responsible to manage any octrees
  51381. * in a given scene.
  51382. */
  51383. export class OctreeSceneComponent {
  51384. /**
  51385. * The component name help to identify the component in the list of scene components.
  51386. */
  51387. readonly name: string;
  51388. /**
  51389. * The scene the component belongs to.
  51390. */
  51391. scene: Scene;
  51392. /**
  51393. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51394. */
  51395. readonly checksIsEnabled: boolean;
  51396. /**
  51397. * Creates a new instance of the component for the given scene
  51398. * @param scene Defines the scene to register the component in
  51399. */
  51400. constructor(scene: Scene);
  51401. /**
  51402. * Registers the component in a given scene
  51403. */
  51404. register(): void;
  51405. /**
  51406. * Return the list of active meshes
  51407. * @returns the list of active meshes
  51408. */
  51409. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51410. /**
  51411. * Return the list of active sub meshes
  51412. * @param mesh The mesh to get the candidates sub meshes from
  51413. * @returns the list of active sub meshes
  51414. */
  51415. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51416. private _tempRay;
  51417. /**
  51418. * Return the list of sub meshes intersecting with a given local ray
  51419. * @param mesh defines the mesh to find the submesh for
  51420. * @param localRay defines the ray in local space
  51421. * @returns the list of intersecting sub meshes
  51422. */
  51423. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51424. /**
  51425. * Return the list of sub meshes colliding with a collider
  51426. * @param mesh defines the mesh to find the submesh for
  51427. * @param collider defines the collider to evaluate the collision against
  51428. * @returns the list of colliding sub meshes
  51429. */
  51430. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51431. /**
  51432. * Rebuilds the elements related to this component in case of
  51433. * context lost for instance.
  51434. */
  51435. rebuild(): void;
  51436. /**
  51437. * Disposes the component and the associated ressources.
  51438. */
  51439. dispose(): void;
  51440. }
  51441. }
  51442. declare module "babylonjs/Culling/Octrees/index" {
  51443. export * from "babylonjs/Culling/Octrees/octree";
  51444. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51445. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51446. }
  51447. declare module "babylonjs/Culling/index" {
  51448. export * from "babylonjs/Culling/boundingBox";
  51449. export * from "babylonjs/Culling/boundingInfo";
  51450. export * from "babylonjs/Culling/boundingSphere";
  51451. export * from "babylonjs/Culling/Octrees/index";
  51452. export * from "babylonjs/Culling/ray";
  51453. }
  51454. declare module "babylonjs/Gizmos/gizmo" {
  51455. import { Nullable } from "babylonjs/types";
  51456. import { IDisposable } from "babylonjs/scene";
  51457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51458. import { Mesh } from "babylonjs/Meshes/mesh";
  51459. import { Node } from "babylonjs/node";
  51460. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51461. /**
  51462. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51463. */
  51464. export class Gizmo implements IDisposable {
  51465. /** The utility layer the gizmo will be added to */
  51466. gizmoLayer: UtilityLayerRenderer;
  51467. /**
  51468. * The root mesh of the gizmo
  51469. */
  51470. _rootMesh: Mesh;
  51471. private _attachedMesh;
  51472. private _attachedNode;
  51473. /**
  51474. * Ratio for the scale of the gizmo (Default: 1)
  51475. */
  51476. scaleRatio: number;
  51477. /**
  51478. * If a custom mesh has been set (Default: false)
  51479. */
  51480. protected _customMeshSet: boolean;
  51481. /**
  51482. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51483. * * When set, interactions will be enabled
  51484. */
  51485. get attachedMesh(): Nullable<AbstractMesh>;
  51486. set attachedMesh(value: Nullable<AbstractMesh>);
  51487. /**
  51488. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  51489. * * When set, interactions will be enabled
  51490. */
  51491. get attachedNode(): Nullable<Node>;
  51492. set attachedNode(value: Nullable<Node>);
  51493. /**
  51494. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51495. * @param mesh The mesh to replace the default mesh of the gizmo
  51496. */
  51497. setCustomMesh(mesh: Mesh): void;
  51498. /**
  51499. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51500. */
  51501. updateGizmoRotationToMatchAttachedMesh: boolean;
  51502. /**
  51503. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51504. */
  51505. updateGizmoPositionToMatchAttachedMesh: boolean;
  51506. /**
  51507. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51508. */
  51509. updateScale: boolean;
  51510. protected _interactionsEnabled: boolean;
  51511. protected _attachedNodeChanged(value: Nullable<Node>): void;
  51512. private _beforeRenderObserver;
  51513. private _tempVector;
  51514. /**
  51515. * Creates a gizmo
  51516. * @param gizmoLayer The utility layer the gizmo will be added to
  51517. */
  51518. constructor(
  51519. /** The utility layer the gizmo will be added to */
  51520. gizmoLayer?: UtilityLayerRenderer);
  51521. /**
  51522. * Updates the gizmo to match the attached mesh's position/rotation
  51523. */
  51524. protected _update(): void;
  51525. /**
  51526. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  51527. * @param value Node, TransformNode or mesh
  51528. */
  51529. protected _matrixChanged(): void;
  51530. /**
  51531. * Disposes of the gizmo
  51532. */
  51533. dispose(): void;
  51534. }
  51535. }
  51536. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51537. import { Observable } from "babylonjs/Misc/observable";
  51538. import { Nullable } from "babylonjs/types";
  51539. import { Vector3 } from "babylonjs/Maths/math.vector";
  51540. import { Color3 } from "babylonjs/Maths/math.color";
  51541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51542. import { Node } from "babylonjs/node";
  51543. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51544. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51545. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51546. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51547. import { Scene } from "babylonjs/scene";
  51548. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51549. /**
  51550. * Single plane drag gizmo
  51551. */
  51552. export class PlaneDragGizmo extends Gizmo {
  51553. /**
  51554. * Drag behavior responsible for the gizmos dragging interactions
  51555. */
  51556. dragBehavior: PointerDragBehavior;
  51557. private _pointerObserver;
  51558. /**
  51559. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51560. */
  51561. snapDistance: number;
  51562. /**
  51563. * Event that fires each time the gizmo snaps to a new location.
  51564. * * snapDistance is the the change in distance
  51565. */
  51566. onSnapObservable: Observable<{
  51567. snapDistance: number;
  51568. }>;
  51569. private _plane;
  51570. private _coloredMaterial;
  51571. private _hoverMaterial;
  51572. private _isEnabled;
  51573. private _parent;
  51574. /** @hidden */
  51575. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51576. /** @hidden */
  51577. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51578. /**
  51579. * Creates a PlaneDragGizmo
  51580. * @param gizmoLayer The utility layer the gizmo will be added to
  51581. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51582. * @param color The color of the gizmo
  51583. */
  51584. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51585. protected _attachedNodeChanged(value: Nullable<Node>): void;
  51586. /**
  51587. * If the gizmo is enabled
  51588. */
  51589. set isEnabled(value: boolean);
  51590. get isEnabled(): boolean;
  51591. /**
  51592. * Disposes of the gizmo
  51593. */
  51594. dispose(): void;
  51595. }
  51596. }
  51597. declare module "babylonjs/Gizmos/positionGizmo" {
  51598. import { Observable } from "babylonjs/Misc/observable";
  51599. import { Nullable } from "babylonjs/types";
  51600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51601. import { Node } from "babylonjs/node";
  51602. import { Mesh } from "babylonjs/Meshes/mesh";
  51603. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51604. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51605. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51606. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51607. /**
  51608. * Gizmo that enables dragging a mesh along 3 axis
  51609. */
  51610. export class PositionGizmo extends Gizmo {
  51611. /**
  51612. * Internal gizmo used for interactions on the x axis
  51613. */
  51614. xGizmo: AxisDragGizmo;
  51615. /**
  51616. * Internal gizmo used for interactions on the y axis
  51617. */
  51618. yGizmo: AxisDragGizmo;
  51619. /**
  51620. * Internal gizmo used for interactions on the z axis
  51621. */
  51622. zGizmo: AxisDragGizmo;
  51623. /**
  51624. * Internal gizmo used for interactions on the yz plane
  51625. */
  51626. xPlaneGizmo: PlaneDragGizmo;
  51627. /**
  51628. * Internal gizmo used for interactions on the xz plane
  51629. */
  51630. yPlaneGizmo: PlaneDragGizmo;
  51631. /**
  51632. * Internal gizmo used for interactions on the xy plane
  51633. */
  51634. zPlaneGizmo: PlaneDragGizmo;
  51635. /**
  51636. * private variables
  51637. */
  51638. private _meshAttached;
  51639. private _nodeAttached;
  51640. private _updateGizmoRotationToMatchAttachedMesh;
  51641. private _snapDistance;
  51642. private _scaleRatio;
  51643. /** Fires an event when any of it's sub gizmos are dragged */
  51644. onDragStartObservable: Observable<unknown>;
  51645. /** Fires an event when any of it's sub gizmos are released from dragging */
  51646. onDragEndObservable: Observable<unknown>;
  51647. /**
  51648. * If set to true, planar drag is enabled
  51649. */
  51650. private _planarGizmoEnabled;
  51651. get attachedMesh(): Nullable<AbstractMesh>;
  51652. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51653. get attachedNode(): Nullable<Node>;
  51654. set attachedNode(node: Nullable<Node>);
  51655. /**
  51656. * Creates a PositionGizmo
  51657. * @param gizmoLayer The utility layer the gizmo will be added to
  51658. */
  51659. constructor(gizmoLayer?: UtilityLayerRenderer);
  51660. /**
  51661. * If the planar drag gizmo is enabled
  51662. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51663. */
  51664. set planarGizmoEnabled(value: boolean);
  51665. get planarGizmoEnabled(): boolean;
  51666. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51667. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51668. /**
  51669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51670. */
  51671. set snapDistance(value: number);
  51672. get snapDistance(): number;
  51673. /**
  51674. * Ratio for the scale of the gizmo (Default: 1)
  51675. */
  51676. set scaleRatio(value: number);
  51677. get scaleRatio(): number;
  51678. /**
  51679. * Disposes of the gizmo
  51680. */
  51681. dispose(): void;
  51682. /**
  51683. * CustomMeshes are not supported by this gizmo
  51684. * @param mesh The mesh to replace the default mesh of the gizmo
  51685. */
  51686. setCustomMesh(mesh: Mesh): void;
  51687. }
  51688. }
  51689. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51690. import { Observable } from "babylonjs/Misc/observable";
  51691. import { Nullable } from "babylonjs/types";
  51692. import { Vector3 } from "babylonjs/Maths/math.vector";
  51693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51694. import { Node } from "babylonjs/node";
  51695. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51696. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51697. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51698. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51699. import { Scene } from "babylonjs/scene";
  51700. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51701. import { Color3 } from "babylonjs/Maths/math.color";
  51702. /**
  51703. * Single axis drag gizmo
  51704. */
  51705. export class AxisDragGizmo extends Gizmo {
  51706. /**
  51707. * Drag behavior responsible for the gizmos dragging interactions
  51708. */
  51709. dragBehavior: PointerDragBehavior;
  51710. private _pointerObserver;
  51711. /**
  51712. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51713. */
  51714. snapDistance: number;
  51715. /**
  51716. * Event that fires each time the gizmo snaps to a new location.
  51717. * * snapDistance is the the change in distance
  51718. */
  51719. onSnapObservable: Observable<{
  51720. snapDistance: number;
  51721. }>;
  51722. private _isEnabled;
  51723. private _parent;
  51724. private _arrow;
  51725. private _coloredMaterial;
  51726. private _hoverMaterial;
  51727. /** @hidden */
  51728. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51729. /** @hidden */
  51730. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51731. /**
  51732. * Creates an AxisDragGizmo
  51733. * @param gizmoLayer The utility layer the gizmo will be added to
  51734. * @param dragAxis The axis which the gizmo will be able to drag on
  51735. * @param color The color of the gizmo
  51736. */
  51737. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51738. protected _attachedNodeChanged(value: Nullable<Node>): void;
  51739. /**
  51740. * If the gizmo is enabled
  51741. */
  51742. set isEnabled(value: boolean);
  51743. get isEnabled(): boolean;
  51744. /**
  51745. * Disposes of the gizmo
  51746. */
  51747. dispose(): void;
  51748. }
  51749. }
  51750. declare module "babylonjs/Debug/axesViewer" {
  51751. import { Vector3 } from "babylonjs/Maths/math.vector";
  51752. import { Nullable } from "babylonjs/types";
  51753. import { Scene } from "babylonjs/scene";
  51754. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51755. /**
  51756. * The Axes viewer will show 3 axes in a specific point in space
  51757. */
  51758. export class AxesViewer {
  51759. private _xAxis;
  51760. private _yAxis;
  51761. private _zAxis;
  51762. private _scaleLinesFactor;
  51763. private _instanced;
  51764. /**
  51765. * Gets the hosting scene
  51766. */
  51767. scene: Scene;
  51768. /**
  51769. * Gets or sets a number used to scale line length
  51770. */
  51771. scaleLines: number;
  51772. /** Gets the node hierarchy used to render x-axis */
  51773. get xAxis(): TransformNode;
  51774. /** Gets the node hierarchy used to render y-axis */
  51775. get yAxis(): TransformNode;
  51776. /** Gets the node hierarchy used to render z-axis */
  51777. get zAxis(): TransformNode;
  51778. /**
  51779. * Creates a new AxesViewer
  51780. * @param scene defines the hosting scene
  51781. * @param scaleLines defines a number used to scale line length (1 by default)
  51782. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51783. * @param xAxis defines the node hierarchy used to render the x-axis
  51784. * @param yAxis defines the node hierarchy used to render the y-axis
  51785. * @param zAxis defines the node hierarchy used to render the z-axis
  51786. */
  51787. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51788. /**
  51789. * Force the viewer to update
  51790. * @param position defines the position of the viewer
  51791. * @param xaxis defines the x axis of the viewer
  51792. * @param yaxis defines the y axis of the viewer
  51793. * @param zaxis defines the z axis of the viewer
  51794. */
  51795. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51796. /**
  51797. * Creates an instance of this axes viewer.
  51798. * @returns a new axes viewer with instanced meshes
  51799. */
  51800. createInstance(): AxesViewer;
  51801. /** Releases resources */
  51802. dispose(): void;
  51803. private static _SetRenderingGroupId;
  51804. }
  51805. }
  51806. declare module "babylonjs/Debug/boneAxesViewer" {
  51807. import { Nullable } from "babylonjs/types";
  51808. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51809. import { Vector3 } from "babylonjs/Maths/math.vector";
  51810. import { Mesh } from "babylonjs/Meshes/mesh";
  51811. import { Bone } from "babylonjs/Bones/bone";
  51812. import { Scene } from "babylonjs/scene";
  51813. /**
  51814. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51815. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51816. */
  51817. export class BoneAxesViewer extends AxesViewer {
  51818. /**
  51819. * Gets or sets the target mesh where to display the axes viewer
  51820. */
  51821. mesh: Nullable<Mesh>;
  51822. /**
  51823. * Gets or sets the target bone where to display the axes viewer
  51824. */
  51825. bone: Nullable<Bone>;
  51826. /** Gets current position */
  51827. pos: Vector3;
  51828. /** Gets direction of X axis */
  51829. xaxis: Vector3;
  51830. /** Gets direction of Y axis */
  51831. yaxis: Vector3;
  51832. /** Gets direction of Z axis */
  51833. zaxis: Vector3;
  51834. /**
  51835. * Creates a new BoneAxesViewer
  51836. * @param scene defines the hosting scene
  51837. * @param bone defines the target bone
  51838. * @param mesh defines the target mesh
  51839. * @param scaleLines defines a scaling factor for line length (1 by default)
  51840. */
  51841. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51842. /**
  51843. * Force the viewer to update
  51844. */
  51845. update(): void;
  51846. /** Releases resources */
  51847. dispose(): void;
  51848. }
  51849. }
  51850. declare module "babylonjs/Debug/debugLayer" {
  51851. import { Scene } from "babylonjs/scene";
  51852. /**
  51853. * Interface used to define scene explorer extensibility option
  51854. */
  51855. export interface IExplorerExtensibilityOption {
  51856. /**
  51857. * Define the option label
  51858. */
  51859. label: string;
  51860. /**
  51861. * Defines the action to execute on click
  51862. */
  51863. action: (entity: any) => void;
  51864. }
  51865. /**
  51866. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51867. */
  51868. export interface IExplorerExtensibilityGroup {
  51869. /**
  51870. * Defines a predicate to test if a given type mut be extended
  51871. */
  51872. predicate: (entity: any) => boolean;
  51873. /**
  51874. * Gets the list of options added to a type
  51875. */
  51876. entries: IExplorerExtensibilityOption[];
  51877. }
  51878. /**
  51879. * Interface used to define the options to use to create the Inspector
  51880. */
  51881. export interface IInspectorOptions {
  51882. /**
  51883. * Display in overlay mode (default: false)
  51884. */
  51885. overlay?: boolean;
  51886. /**
  51887. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51888. */
  51889. globalRoot?: HTMLElement;
  51890. /**
  51891. * Display the Scene explorer
  51892. */
  51893. showExplorer?: boolean;
  51894. /**
  51895. * Display the property inspector
  51896. */
  51897. showInspector?: boolean;
  51898. /**
  51899. * Display in embed mode (both panes on the right)
  51900. */
  51901. embedMode?: boolean;
  51902. /**
  51903. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51904. */
  51905. handleResize?: boolean;
  51906. /**
  51907. * Allow the panes to popup (default: true)
  51908. */
  51909. enablePopup?: boolean;
  51910. /**
  51911. * Allow the panes to be closed by users (default: true)
  51912. */
  51913. enableClose?: boolean;
  51914. /**
  51915. * Optional list of extensibility entries
  51916. */
  51917. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51918. /**
  51919. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51920. */
  51921. inspectorURL?: string;
  51922. /**
  51923. * Optional initial tab (default to DebugLayerTab.Properties)
  51924. */
  51925. initialTab?: DebugLayerTab;
  51926. }
  51927. module "babylonjs/scene" {
  51928. interface Scene {
  51929. /**
  51930. * @hidden
  51931. * Backing field
  51932. */
  51933. _debugLayer: DebugLayer;
  51934. /**
  51935. * Gets the debug layer (aka Inspector) associated with the scene
  51936. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51937. */
  51938. debugLayer: DebugLayer;
  51939. }
  51940. }
  51941. /**
  51942. * Enum of inspector action tab
  51943. */
  51944. export enum DebugLayerTab {
  51945. /**
  51946. * Properties tag (default)
  51947. */
  51948. Properties = 0,
  51949. /**
  51950. * Debug tab
  51951. */
  51952. Debug = 1,
  51953. /**
  51954. * Statistics tab
  51955. */
  51956. Statistics = 2,
  51957. /**
  51958. * Tools tab
  51959. */
  51960. Tools = 3,
  51961. /**
  51962. * Settings tab
  51963. */
  51964. Settings = 4
  51965. }
  51966. /**
  51967. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51968. * what is happening in your scene
  51969. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51970. */
  51971. export class DebugLayer {
  51972. /**
  51973. * Define the url to get the inspector script from.
  51974. * By default it uses the babylonjs CDN.
  51975. * @ignoreNaming
  51976. */
  51977. static InspectorURL: string;
  51978. private _scene;
  51979. private BJSINSPECTOR;
  51980. private _onPropertyChangedObservable?;
  51981. /**
  51982. * Observable triggered when a property is changed through the inspector.
  51983. */
  51984. get onPropertyChangedObservable(): any;
  51985. /**
  51986. * Instantiates a new debug layer.
  51987. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51988. * what is happening in your scene
  51989. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51990. * @param scene Defines the scene to inspect
  51991. */
  51992. constructor(scene: Scene);
  51993. /** Creates the inspector window. */
  51994. private _createInspector;
  51995. /**
  51996. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51997. * @param entity defines the entity to select
  51998. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51999. */
  52000. select(entity: any, lineContainerTitles?: string | string[]): void;
  52001. /** Get the inspector from bundle or global */
  52002. private _getGlobalInspector;
  52003. /**
  52004. * Get if the inspector is visible or not.
  52005. * @returns true if visible otherwise, false
  52006. */
  52007. isVisible(): boolean;
  52008. /**
  52009. * Hide the inspector and close its window.
  52010. */
  52011. hide(): void;
  52012. /**
  52013. * Update the scene in the inspector
  52014. */
  52015. setAsActiveScene(): void;
  52016. /**
  52017. * Launch the debugLayer.
  52018. * @param config Define the configuration of the inspector
  52019. * @return a promise fulfilled when the debug layer is visible
  52020. */
  52021. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52022. }
  52023. }
  52024. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52025. import { Nullable } from "babylonjs/types";
  52026. import { Scene } from "babylonjs/scene";
  52027. import { Vector4 } from "babylonjs/Maths/math.vector";
  52028. import { Color4 } from "babylonjs/Maths/math.color";
  52029. import { Mesh } from "babylonjs/Meshes/mesh";
  52030. /**
  52031. * Class containing static functions to help procedurally build meshes
  52032. */
  52033. export class BoxBuilder {
  52034. /**
  52035. * Creates a box mesh
  52036. * * The parameter `size` sets the size (float) of each box side (default 1)
  52037. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52038. * * 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)
  52039. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52043. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52044. * @param name defines the name of the mesh
  52045. * @param options defines the options used to create the mesh
  52046. * @param scene defines the hosting scene
  52047. * @returns the box mesh
  52048. */
  52049. static CreateBox(name: string, options: {
  52050. size?: number;
  52051. width?: number;
  52052. height?: number;
  52053. depth?: number;
  52054. faceUV?: Vector4[];
  52055. faceColors?: Color4[];
  52056. sideOrientation?: number;
  52057. frontUVs?: Vector4;
  52058. backUVs?: Vector4;
  52059. wrap?: boolean;
  52060. topBaseAt?: number;
  52061. bottomBaseAt?: number;
  52062. updatable?: boolean;
  52063. }, scene?: Nullable<Scene>): Mesh;
  52064. }
  52065. }
  52066. declare module "babylonjs/Debug/physicsViewer" {
  52067. import { Nullable } from "babylonjs/types";
  52068. import { Scene } from "babylonjs/scene";
  52069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52070. import { Mesh } from "babylonjs/Meshes/mesh";
  52071. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52072. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52073. /**
  52074. * Used to show the physics impostor around the specific mesh
  52075. */
  52076. export class PhysicsViewer {
  52077. /** @hidden */
  52078. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52079. /** @hidden */
  52080. protected _meshes: Array<Nullable<AbstractMesh>>;
  52081. /** @hidden */
  52082. protected _scene: Nullable<Scene>;
  52083. /** @hidden */
  52084. protected _numMeshes: number;
  52085. /** @hidden */
  52086. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52087. private _renderFunction;
  52088. private _utilityLayer;
  52089. private _debugBoxMesh;
  52090. private _debugSphereMesh;
  52091. private _debugCylinderMesh;
  52092. private _debugMaterial;
  52093. private _debugMeshMeshes;
  52094. /**
  52095. * Creates a new PhysicsViewer
  52096. * @param scene defines the hosting scene
  52097. */
  52098. constructor(scene: Scene);
  52099. /** @hidden */
  52100. protected _updateDebugMeshes(): void;
  52101. /**
  52102. * Renders a specified physic impostor
  52103. * @param impostor defines the impostor to render
  52104. * @param targetMesh defines the mesh represented by the impostor
  52105. * @returns the new debug mesh used to render the impostor
  52106. */
  52107. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52108. /**
  52109. * Hides a specified physic impostor
  52110. * @param impostor defines the impostor to hide
  52111. */
  52112. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52113. private _getDebugMaterial;
  52114. private _getDebugBoxMesh;
  52115. private _getDebugSphereMesh;
  52116. private _getDebugCylinderMesh;
  52117. private _getDebugMeshMesh;
  52118. private _getDebugMesh;
  52119. /** Releases all resources */
  52120. dispose(): void;
  52121. }
  52122. }
  52123. declare module "babylonjs/Debug/rayHelper" {
  52124. import { Nullable } from "babylonjs/types";
  52125. import { Ray } from "babylonjs/Culling/ray";
  52126. import { Vector3 } from "babylonjs/Maths/math.vector";
  52127. import { Color3 } from "babylonjs/Maths/math.color";
  52128. import { Scene } from "babylonjs/scene";
  52129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52130. import "babylonjs/Meshes/Builders/linesBuilder";
  52131. /**
  52132. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52133. * in order to better appreciate the issue one might have.
  52134. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52135. */
  52136. export class RayHelper {
  52137. /**
  52138. * Defines the ray we are currently tryin to visualize.
  52139. */
  52140. ray: Nullable<Ray>;
  52141. private _renderPoints;
  52142. private _renderLine;
  52143. private _renderFunction;
  52144. private _scene;
  52145. private _updateToMeshFunction;
  52146. private _attachedToMesh;
  52147. private _meshSpaceDirection;
  52148. private _meshSpaceOrigin;
  52149. /**
  52150. * Helper function to create a colored helper in a scene in one line.
  52151. * @param ray Defines the ray we are currently tryin to visualize
  52152. * @param scene Defines the scene the ray is used in
  52153. * @param color Defines the color we want to see the ray in
  52154. * @returns The newly created ray helper.
  52155. */
  52156. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52157. /**
  52158. * Instantiate a new ray helper.
  52159. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52160. * in order to better appreciate the issue one might have.
  52161. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52162. * @param ray Defines the ray we are currently tryin to visualize
  52163. */
  52164. constructor(ray: Ray);
  52165. /**
  52166. * Shows the ray we are willing to debug.
  52167. * @param scene Defines the scene the ray needs to be rendered in
  52168. * @param color Defines the color the ray needs to be rendered in
  52169. */
  52170. show(scene: Scene, color?: Color3): void;
  52171. /**
  52172. * Hides the ray we are debugging.
  52173. */
  52174. hide(): void;
  52175. private _render;
  52176. /**
  52177. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52178. * @param mesh Defines the mesh we want the helper attached to
  52179. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52180. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52181. * @param length Defines the length of the ray
  52182. */
  52183. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52184. /**
  52185. * Detach the ray helper from the mesh it has previously been attached to.
  52186. */
  52187. detachFromMesh(): void;
  52188. private _updateToMesh;
  52189. /**
  52190. * Dispose the helper and release its associated resources.
  52191. */
  52192. dispose(): void;
  52193. }
  52194. }
  52195. declare module "babylonjs/Debug/skeletonViewer" {
  52196. import { Color3 } from "babylonjs/Maths/math.color";
  52197. import { Scene } from "babylonjs/scene";
  52198. import { Nullable } from "babylonjs/types";
  52199. import { Skeleton } from "babylonjs/Bones/skeleton";
  52200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52201. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52202. /**
  52203. * Class used to render a debug view of a given skeleton
  52204. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52205. */
  52206. export class SkeletonViewer {
  52207. /** defines the skeleton to render */
  52208. skeleton: Skeleton;
  52209. /** defines the mesh attached to the skeleton */
  52210. mesh: AbstractMesh;
  52211. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52212. autoUpdateBonesMatrices: boolean;
  52213. /** defines the rendering group id to use with the viewer */
  52214. renderingGroupId: number;
  52215. /** Gets or sets the color used to render the skeleton */
  52216. color: Color3;
  52217. private _scene;
  52218. private _debugLines;
  52219. private _debugMesh;
  52220. private _isEnabled;
  52221. private _renderFunction;
  52222. private _utilityLayer;
  52223. /**
  52224. * Returns the mesh used to render the bones
  52225. */
  52226. get debugMesh(): Nullable<LinesMesh>;
  52227. /**
  52228. * Creates a new SkeletonViewer
  52229. * @param skeleton defines the skeleton to render
  52230. * @param mesh defines the mesh attached to the skeleton
  52231. * @param scene defines the hosting scene
  52232. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52233. * @param renderingGroupId defines the rendering group id to use with the viewer
  52234. */
  52235. constructor(
  52236. /** defines the skeleton to render */
  52237. skeleton: Skeleton,
  52238. /** defines the mesh attached to the skeleton */
  52239. mesh: AbstractMesh, scene: Scene,
  52240. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52241. autoUpdateBonesMatrices?: boolean,
  52242. /** defines the rendering group id to use with the viewer */
  52243. renderingGroupId?: number);
  52244. /** Gets or sets a boolean indicating if the viewer is enabled */
  52245. set isEnabled(value: boolean);
  52246. get isEnabled(): boolean;
  52247. private _getBonePosition;
  52248. private _getLinesForBonesWithLength;
  52249. private _getLinesForBonesNoLength;
  52250. /** Update the viewer to sync with current skeleton state */
  52251. update(): void;
  52252. /** Release associated resources */
  52253. dispose(): void;
  52254. }
  52255. }
  52256. declare module "babylonjs/Debug/index" {
  52257. export * from "babylonjs/Debug/axesViewer";
  52258. export * from "babylonjs/Debug/boneAxesViewer";
  52259. export * from "babylonjs/Debug/debugLayer";
  52260. export * from "babylonjs/Debug/physicsViewer";
  52261. export * from "babylonjs/Debug/rayHelper";
  52262. export * from "babylonjs/Debug/skeletonViewer";
  52263. }
  52264. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52265. /**
  52266. * Enum for Device Types
  52267. */
  52268. export enum DeviceType {
  52269. /** Generic */
  52270. Generic = 0,
  52271. /** Keyboard */
  52272. Keyboard = 1,
  52273. /** Mouse */
  52274. Mouse = 2,
  52275. /** Touch Pointers */
  52276. Touch = 3,
  52277. /** PS4 Dual Shock */
  52278. DualShock = 4,
  52279. /** Xbox */
  52280. Xbox = 5,
  52281. /** Switch Controller */
  52282. Switch = 6
  52283. }
  52284. /**
  52285. * Enum for All Pointers (Touch/Mouse)
  52286. */
  52287. export enum PointerInput {
  52288. /** Horizontal Axis */
  52289. Horizontal = 0,
  52290. /** Vertical Axis */
  52291. Vertical = 1,
  52292. /** Left Click or Touch */
  52293. LeftClick = 2,
  52294. /** Middle Click */
  52295. MiddleClick = 3,
  52296. /** Right Click */
  52297. RightClick = 4,
  52298. /** Browser Back */
  52299. BrowserBack = 5,
  52300. /** Browser Forward */
  52301. BrowserForward = 6
  52302. }
  52303. /**
  52304. * Enum for Dual Shock Gamepad
  52305. */
  52306. export enum DualShockInput {
  52307. /** Cross */
  52308. Cross = 0,
  52309. /** Circle */
  52310. Circle = 1,
  52311. /** Square */
  52312. Square = 2,
  52313. /** Triangle */
  52314. Triangle = 3,
  52315. /** L1 */
  52316. L1 = 4,
  52317. /** R1 */
  52318. R1 = 5,
  52319. /** L2 */
  52320. L2 = 6,
  52321. /** R2 */
  52322. R2 = 7,
  52323. /** Share */
  52324. Share = 8,
  52325. /** Options */
  52326. Options = 9,
  52327. /** L3 */
  52328. L3 = 10,
  52329. /** R3 */
  52330. R3 = 11,
  52331. /** DPadUp */
  52332. DPadUp = 12,
  52333. /** DPadDown */
  52334. DPadDown = 13,
  52335. /** DPadLeft */
  52336. DPadLeft = 14,
  52337. /** DRight */
  52338. DPadRight = 15,
  52339. /** Home */
  52340. Home = 16,
  52341. /** TouchPad */
  52342. TouchPad = 17,
  52343. /** LStickXAxis */
  52344. LStickXAxis = 18,
  52345. /** LStickYAxis */
  52346. LStickYAxis = 19,
  52347. /** RStickXAxis */
  52348. RStickXAxis = 20,
  52349. /** RStickYAxis */
  52350. RStickYAxis = 21
  52351. }
  52352. /**
  52353. * Enum for Xbox Gamepad
  52354. */
  52355. export enum XboxInput {
  52356. /** A */
  52357. A = 0,
  52358. /** B */
  52359. B = 1,
  52360. /** X */
  52361. X = 2,
  52362. /** Y */
  52363. Y = 3,
  52364. /** LB */
  52365. LB = 4,
  52366. /** RB */
  52367. RB = 5,
  52368. /** LT */
  52369. LT = 6,
  52370. /** RT */
  52371. RT = 7,
  52372. /** Back */
  52373. Back = 8,
  52374. /** Start */
  52375. Start = 9,
  52376. /** LS */
  52377. LS = 10,
  52378. /** RS */
  52379. RS = 11,
  52380. /** DPadUp */
  52381. DPadUp = 12,
  52382. /** DPadDown */
  52383. DPadDown = 13,
  52384. /** DPadLeft */
  52385. DPadLeft = 14,
  52386. /** DRight */
  52387. DPadRight = 15,
  52388. /** Home */
  52389. Home = 16,
  52390. /** LStickXAxis */
  52391. LStickXAxis = 17,
  52392. /** LStickYAxis */
  52393. LStickYAxis = 18,
  52394. /** RStickXAxis */
  52395. RStickXAxis = 19,
  52396. /** RStickYAxis */
  52397. RStickYAxis = 20
  52398. }
  52399. /**
  52400. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52401. */
  52402. export enum SwitchInput {
  52403. /** B */
  52404. B = 0,
  52405. /** A */
  52406. A = 1,
  52407. /** Y */
  52408. Y = 2,
  52409. /** X */
  52410. X = 3,
  52411. /** L */
  52412. L = 4,
  52413. /** R */
  52414. R = 5,
  52415. /** ZL */
  52416. ZL = 6,
  52417. /** ZR */
  52418. ZR = 7,
  52419. /** Minus */
  52420. Minus = 8,
  52421. /** Plus */
  52422. Plus = 9,
  52423. /** LS */
  52424. LS = 10,
  52425. /** RS */
  52426. RS = 11,
  52427. /** DPadUp */
  52428. DPadUp = 12,
  52429. /** DPadDown */
  52430. DPadDown = 13,
  52431. /** DPadLeft */
  52432. DPadLeft = 14,
  52433. /** DRight */
  52434. DPadRight = 15,
  52435. /** Home */
  52436. Home = 16,
  52437. /** Capture */
  52438. Capture = 17,
  52439. /** LStickXAxis */
  52440. LStickXAxis = 18,
  52441. /** LStickYAxis */
  52442. LStickYAxis = 19,
  52443. /** RStickXAxis */
  52444. RStickXAxis = 20,
  52445. /** RStickYAxis */
  52446. RStickYAxis = 21
  52447. }
  52448. }
  52449. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52450. import { Engine } from "babylonjs/Engines/engine";
  52451. import { IDisposable } from "babylonjs/scene";
  52452. import { Nullable } from "babylonjs/types";
  52453. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52454. /**
  52455. * This class will take all inputs from Keyboard, Pointer, and
  52456. * any Gamepads and provide a polling system that all devices
  52457. * will use. This class assumes that there will only be one
  52458. * pointer device and one keyboard.
  52459. */
  52460. export class DeviceInputSystem implements IDisposable {
  52461. /**
  52462. * Callback to be triggered when a device is connected
  52463. */
  52464. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52465. /**
  52466. * Callback to be triggered when a device is disconnected
  52467. */
  52468. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52469. /**
  52470. * Callback to be triggered when event driven input is updated
  52471. */
  52472. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52473. private _inputs;
  52474. private _gamepads;
  52475. private _keyboardActive;
  52476. private _pointerActive;
  52477. private _elementToAttachTo;
  52478. private _keyboardDownEvent;
  52479. private _keyboardUpEvent;
  52480. private _pointerMoveEvent;
  52481. private _pointerDownEvent;
  52482. private _pointerUpEvent;
  52483. private _gamepadConnectedEvent;
  52484. private _gamepadDisconnectedEvent;
  52485. private static _MAX_KEYCODES;
  52486. private static _MAX_POINTER_INPUTS;
  52487. private constructor();
  52488. /**
  52489. * Creates a new DeviceInputSystem instance
  52490. * @param engine Engine to pull input element from
  52491. * @returns The new instance
  52492. */
  52493. static Create(engine: Engine): DeviceInputSystem;
  52494. /**
  52495. * Checks for current device input value, given an id and input index
  52496. * @param deviceName Id of connected device
  52497. * @param inputIndex Index of device input
  52498. * @returns Current value of input
  52499. */
  52500. /**
  52501. * Checks for current device input value, given an id and input index
  52502. * @param deviceType Enum specifiying device type
  52503. * @param deviceSlot "Slot" or index that device is referenced in
  52504. * @param inputIndex Id of input to be checked
  52505. * @returns Current value of input
  52506. */
  52507. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52508. /**
  52509. * Dispose of all the eventlisteners
  52510. */
  52511. dispose(): void;
  52512. /**
  52513. * Add device and inputs to device array
  52514. * @param deviceType Enum specifiying device type
  52515. * @param deviceSlot "Slot" or index that device is referenced in
  52516. * @param numberOfInputs Number of input entries to create for given device
  52517. */
  52518. private _registerDevice;
  52519. /**
  52520. * Given a specific device name, remove that device from the device map
  52521. * @param deviceType Enum specifiying device type
  52522. * @param deviceSlot "Slot" or index that device is referenced in
  52523. */
  52524. private _unregisterDevice;
  52525. /**
  52526. * Handle all actions that come from keyboard interaction
  52527. */
  52528. private _handleKeyActions;
  52529. /**
  52530. * Handle all actions that come from pointer interaction
  52531. */
  52532. private _handlePointerActions;
  52533. /**
  52534. * Handle all actions that come from gamepad interaction
  52535. */
  52536. private _handleGamepadActions;
  52537. /**
  52538. * Update all non-event based devices with each frame
  52539. * @param deviceType Enum specifiying device type
  52540. * @param deviceSlot "Slot" or index that device is referenced in
  52541. * @param inputIndex Id of input to be checked
  52542. */
  52543. private _updateDevice;
  52544. /**
  52545. * Gets DeviceType from the device name
  52546. * @param deviceName Name of Device from DeviceInputSystem
  52547. * @returns DeviceType enum value
  52548. */
  52549. private _getGamepadDeviceType;
  52550. }
  52551. }
  52552. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52553. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52554. /**
  52555. * Type to handle enforcement of inputs
  52556. */
  52557. 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;
  52558. }
  52559. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52560. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52561. import { Engine } from "babylonjs/Engines/engine";
  52562. import { IDisposable } from "babylonjs/scene";
  52563. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52564. import { Nullable } from "babylonjs/types";
  52565. import { Observable } from "babylonjs/Misc/observable";
  52566. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52567. /**
  52568. * Class that handles all input for a specific device
  52569. */
  52570. export class DeviceSource<T extends DeviceType> {
  52571. /** Type of device */
  52572. readonly deviceType: DeviceType;
  52573. /** "Slot" or index that device is referenced in */
  52574. readonly deviceSlot: number;
  52575. /**
  52576. * Observable to handle device input changes per device
  52577. */
  52578. readonly onInputChangedObservable: Observable<{
  52579. inputIndex: DeviceInput<T>;
  52580. previousState: Nullable<number>;
  52581. currentState: Nullable<number>;
  52582. }>;
  52583. private readonly _deviceInputSystem;
  52584. /**
  52585. * Default Constructor
  52586. * @param deviceInputSystem Reference to DeviceInputSystem
  52587. * @param deviceType Type of device
  52588. * @param deviceSlot "Slot" or index that device is referenced in
  52589. */
  52590. constructor(deviceInputSystem: DeviceInputSystem,
  52591. /** Type of device */
  52592. deviceType: DeviceType,
  52593. /** "Slot" or index that device is referenced in */
  52594. deviceSlot?: number);
  52595. /**
  52596. * Get input for specific input
  52597. * @param inputIndex index of specific input on device
  52598. * @returns Input value from DeviceInputSystem
  52599. */
  52600. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52601. }
  52602. /**
  52603. * Class to keep track of devices
  52604. */
  52605. export class DeviceSourceManager implements IDisposable {
  52606. /**
  52607. * Observable to be triggered when before a device is connected
  52608. */
  52609. readonly onBeforeDeviceConnectedObservable: Observable<{
  52610. deviceType: DeviceType;
  52611. deviceSlot: number;
  52612. }>;
  52613. /**
  52614. * Observable to be triggered when before a device is disconnected
  52615. */
  52616. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52617. deviceType: DeviceType;
  52618. deviceSlot: number;
  52619. }>;
  52620. /**
  52621. * Observable to be triggered when after a device is connected
  52622. */
  52623. readonly onAfterDeviceConnectedObservable: Observable<{
  52624. deviceType: DeviceType;
  52625. deviceSlot: number;
  52626. }>;
  52627. /**
  52628. * Observable to be triggered when after a device is disconnected
  52629. */
  52630. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52631. deviceType: DeviceType;
  52632. deviceSlot: number;
  52633. }>;
  52634. private readonly _devices;
  52635. private readonly _firstDevice;
  52636. private readonly _deviceInputSystem;
  52637. /**
  52638. * Default Constructor
  52639. * @param engine engine to pull input element from
  52640. */
  52641. constructor(engine: Engine);
  52642. /**
  52643. * Gets a DeviceSource, given a type and slot
  52644. * @param deviceType Enum specifying device type
  52645. * @param deviceSlot "Slot" or index that device is referenced in
  52646. * @returns DeviceSource object
  52647. */
  52648. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52649. /**
  52650. * Gets an array of DeviceSource objects for a given device type
  52651. * @param deviceType Enum specifying device type
  52652. * @returns Array of DeviceSource objects
  52653. */
  52654. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52655. /**
  52656. * Dispose of DeviceInputSystem and other parts
  52657. */
  52658. dispose(): void;
  52659. /**
  52660. * Function to add device name to device list
  52661. * @param deviceType Enum specifying device type
  52662. * @param deviceSlot "Slot" or index that device is referenced in
  52663. */
  52664. private _addDevice;
  52665. /**
  52666. * Function to remove device name to device list
  52667. * @param deviceType Enum specifying device type
  52668. * @param deviceSlot "Slot" or index that device is referenced in
  52669. */
  52670. private _removeDevice;
  52671. /**
  52672. * Updates array storing first connected device of each type
  52673. * @param type Type of Device
  52674. */
  52675. private _updateFirstDevices;
  52676. }
  52677. }
  52678. declare module "babylonjs/DeviceInput/index" {
  52679. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52680. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52681. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52682. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52683. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52684. }
  52685. declare module "babylonjs/Engines/nullEngine" {
  52686. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52687. import { Engine } from "babylonjs/Engines/engine";
  52688. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52689. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52691. import { Effect } from "babylonjs/Materials/effect";
  52692. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52693. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52694. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52695. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52696. /**
  52697. * Options to create the null engine
  52698. */
  52699. export class NullEngineOptions {
  52700. /**
  52701. * Render width (Default: 512)
  52702. */
  52703. renderWidth: number;
  52704. /**
  52705. * Render height (Default: 256)
  52706. */
  52707. renderHeight: number;
  52708. /**
  52709. * Texture size (Default: 512)
  52710. */
  52711. textureSize: number;
  52712. /**
  52713. * If delta time between frames should be constant
  52714. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52715. */
  52716. deterministicLockstep: boolean;
  52717. /**
  52718. * Maximum about of steps between frames (Default: 4)
  52719. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52720. */
  52721. lockstepMaxSteps: number;
  52722. /**
  52723. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  52724. */
  52725. useHighPrecisionMatrix?: boolean;
  52726. }
  52727. /**
  52728. * The null engine class provides support for headless version of babylon.js.
  52729. * This can be used in server side scenario or for testing purposes
  52730. */
  52731. export class NullEngine extends Engine {
  52732. private _options;
  52733. /**
  52734. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52735. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52736. * @returns true if engine is in deterministic lock step mode
  52737. */
  52738. isDeterministicLockStep(): boolean;
  52739. /**
  52740. * Gets the max steps when engine is running in deterministic lock step
  52741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52742. * @returns the max steps
  52743. */
  52744. getLockstepMaxSteps(): number;
  52745. /**
  52746. * Gets the current hardware scaling level.
  52747. * By default the hardware scaling level is computed from the window device ratio.
  52748. * 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.
  52749. * @returns a number indicating the current hardware scaling level
  52750. */
  52751. getHardwareScalingLevel(): number;
  52752. constructor(options?: NullEngineOptions);
  52753. /**
  52754. * Creates a vertex buffer
  52755. * @param vertices the data for the vertex buffer
  52756. * @returns the new WebGL static buffer
  52757. */
  52758. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52759. /**
  52760. * Creates a new index buffer
  52761. * @param indices defines the content of the index buffer
  52762. * @param updatable defines if the index buffer must be updatable
  52763. * @returns a new webGL buffer
  52764. */
  52765. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52766. /**
  52767. * Clear the current render buffer or the current render target (if any is set up)
  52768. * @param color defines the color to use
  52769. * @param backBuffer defines if the back buffer must be cleared
  52770. * @param depth defines if the depth buffer must be cleared
  52771. * @param stencil defines if the stencil buffer must be cleared
  52772. */
  52773. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52774. /**
  52775. * Gets the current render width
  52776. * @param useScreen defines if screen size must be used (or the current render target if any)
  52777. * @returns a number defining the current render width
  52778. */
  52779. getRenderWidth(useScreen?: boolean): number;
  52780. /**
  52781. * Gets the current render height
  52782. * @param useScreen defines if screen size must be used (or the current render target if any)
  52783. * @returns a number defining the current render height
  52784. */
  52785. getRenderHeight(useScreen?: boolean): number;
  52786. /**
  52787. * Set the WebGL's viewport
  52788. * @param viewport defines the viewport element to be used
  52789. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52790. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52791. */
  52792. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52793. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52794. /**
  52795. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52796. * @param pipelineContext defines the pipeline context to use
  52797. * @param uniformsNames defines the list of uniform names
  52798. * @returns an array of webGL uniform locations
  52799. */
  52800. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52801. /**
  52802. * Gets the lsit of active attributes for a given webGL program
  52803. * @param pipelineContext defines the pipeline context to use
  52804. * @param attributesNames defines the list of attribute names to get
  52805. * @returns an array of indices indicating the offset of each attribute
  52806. */
  52807. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52808. /**
  52809. * Binds an effect to the webGL context
  52810. * @param effect defines the effect to bind
  52811. */
  52812. bindSamplers(effect: Effect): void;
  52813. /**
  52814. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52815. * @param effect defines the effect to activate
  52816. */
  52817. enableEffect(effect: Effect): void;
  52818. /**
  52819. * Set various states to the webGL context
  52820. * @param culling defines backface culling state
  52821. * @param zOffset defines the value to apply to zOffset (0 by default)
  52822. * @param force defines if states must be applied even if cache is up to date
  52823. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52824. */
  52825. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52826. /**
  52827. * Set the value of an uniform to an array of int32
  52828. * @param uniform defines the webGL uniform location where to store the value
  52829. * @param array defines the array of int32 to store
  52830. */
  52831. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52832. /**
  52833. * Set the value of an uniform to an array of int32 (stored as vec2)
  52834. * @param uniform defines the webGL uniform location where to store the value
  52835. * @param array defines the array of int32 to store
  52836. */
  52837. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52838. /**
  52839. * Set the value of an uniform to an array of int32 (stored as vec3)
  52840. * @param uniform defines the webGL uniform location where to store the value
  52841. * @param array defines the array of int32 to store
  52842. */
  52843. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52844. /**
  52845. * Set the value of an uniform to an array of int32 (stored as vec4)
  52846. * @param uniform defines the webGL uniform location where to store the value
  52847. * @param array defines the array of int32 to store
  52848. */
  52849. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52850. /**
  52851. * Set the value of an uniform to an array of float32
  52852. * @param uniform defines the webGL uniform location where to store the value
  52853. * @param array defines the array of float32 to store
  52854. */
  52855. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52856. /**
  52857. * Set the value of an uniform to an array of float32 (stored as vec2)
  52858. * @param uniform defines the webGL uniform location where to store the value
  52859. * @param array defines the array of float32 to store
  52860. */
  52861. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52862. /**
  52863. * Set the value of an uniform to an array of float32 (stored as vec3)
  52864. * @param uniform defines the webGL uniform location where to store the value
  52865. * @param array defines the array of float32 to store
  52866. */
  52867. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52868. /**
  52869. * Set the value of an uniform to an array of float32 (stored as vec4)
  52870. * @param uniform defines the webGL uniform location where to store the value
  52871. * @param array defines the array of float32 to store
  52872. */
  52873. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52874. /**
  52875. * Set the value of an uniform to an array of number
  52876. * @param uniform defines the webGL uniform location where to store the value
  52877. * @param array defines the array of number to store
  52878. */
  52879. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52880. /**
  52881. * Set the value of an uniform to an array of number (stored as vec2)
  52882. * @param uniform defines the webGL uniform location where to store the value
  52883. * @param array defines the array of number to store
  52884. */
  52885. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52886. /**
  52887. * Set the value of an uniform to an array of number (stored as vec3)
  52888. * @param uniform defines the webGL uniform location where to store the value
  52889. * @param array defines the array of number to store
  52890. */
  52891. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52892. /**
  52893. * Set the value of an uniform to an array of number (stored as vec4)
  52894. * @param uniform defines the webGL uniform location where to store the value
  52895. * @param array defines the array of number to store
  52896. */
  52897. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52898. /**
  52899. * Set the value of an uniform to an array of float32 (stored as matrices)
  52900. * @param uniform defines the webGL uniform location where to store the value
  52901. * @param matrices defines the array of float32 to store
  52902. */
  52903. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52904. /**
  52905. * Set the value of an uniform to a matrix (3x3)
  52906. * @param uniform defines the webGL uniform location where to store the value
  52907. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52908. */
  52909. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52910. /**
  52911. * Set the value of an uniform to a matrix (2x2)
  52912. * @param uniform defines the webGL uniform location where to store the value
  52913. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52914. */
  52915. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52916. /**
  52917. * Set the value of an uniform to a number (float)
  52918. * @param uniform defines the webGL uniform location where to store the value
  52919. * @param value defines the float number to store
  52920. */
  52921. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52922. /**
  52923. * Set the value of an uniform to a vec2
  52924. * @param uniform defines the webGL uniform location where to store the value
  52925. * @param x defines the 1st component of the value
  52926. * @param y defines the 2nd component of the value
  52927. */
  52928. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52929. /**
  52930. * Set the value of an uniform to a vec3
  52931. * @param uniform defines the webGL uniform location where to store the value
  52932. * @param x defines the 1st component of the value
  52933. * @param y defines the 2nd component of the value
  52934. * @param z defines the 3rd component of the value
  52935. */
  52936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52937. /**
  52938. * Set the value of an uniform to a boolean
  52939. * @param uniform defines the webGL uniform location where to store the value
  52940. * @param bool defines the boolean to store
  52941. */
  52942. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52943. /**
  52944. * Set the value of an uniform to a vec4
  52945. * @param uniform defines the webGL uniform location where to store the value
  52946. * @param x defines the 1st component of the value
  52947. * @param y defines the 2nd component of the value
  52948. * @param z defines the 3rd component of the value
  52949. * @param w defines the 4th component of the value
  52950. */
  52951. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52952. /**
  52953. * Sets the current alpha mode
  52954. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52955. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52956. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52957. */
  52958. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52959. /**
  52960. * Bind webGl buffers directly to the webGL context
  52961. * @param vertexBuffers defines the vertex buffer to bind
  52962. * @param indexBuffer defines the index buffer to bind
  52963. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52964. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52965. * @param effect defines the effect associated with the vertex buffer
  52966. */
  52967. bindBuffers(vertexBuffers: {
  52968. [key: string]: VertexBuffer;
  52969. }, indexBuffer: DataBuffer, effect: Effect): void;
  52970. /**
  52971. * Force the entire cache to be cleared
  52972. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52973. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52974. */
  52975. wipeCaches(bruteForce?: boolean): void;
  52976. /**
  52977. * Send a draw order
  52978. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52979. * @param indexStart defines the starting index
  52980. * @param indexCount defines the number of index to draw
  52981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52982. */
  52983. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52984. /**
  52985. * Draw a list of indexed primitives
  52986. * @param fillMode defines the primitive to use
  52987. * @param indexStart defines the starting index
  52988. * @param indexCount defines the number of index to draw
  52989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52990. */
  52991. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52992. /**
  52993. * Draw a list of unindexed primitives
  52994. * @param fillMode defines the primitive to use
  52995. * @param verticesStart defines the index of first vertex to draw
  52996. * @param verticesCount defines the count of vertices to draw
  52997. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52998. */
  52999. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53000. /** @hidden */
  53001. _createTexture(): WebGLTexture;
  53002. /** @hidden */
  53003. _releaseTexture(texture: InternalTexture): void;
  53004. /**
  53005. * Usually called from Texture.ts.
  53006. * Passed information to create a WebGLTexture
  53007. * @param urlArg defines a value which contains one of the following:
  53008. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53009. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53010. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53012. * @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)
  53013. * @param scene needed for loading to the correct scene
  53014. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53015. * @param onLoad optional callback to be called upon successful completion
  53016. * @param onError optional callback to be called upon failure
  53017. * @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
  53018. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53019. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53020. * @param forcedExtension defines the extension to use to pick the right loader
  53021. * @param mimeType defines an optional mime type
  53022. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53023. */
  53024. 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;
  53025. /**
  53026. * Creates a new render target texture
  53027. * @param size defines the size of the texture
  53028. * @param options defines the options used to create the texture
  53029. * @returns a new render target texture stored in an InternalTexture
  53030. */
  53031. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53032. /**
  53033. * Update the sampling mode of a given texture
  53034. * @param samplingMode defines the required sampling mode
  53035. * @param texture defines the texture to update
  53036. */
  53037. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53038. /**
  53039. * Binds the frame buffer to the specified texture.
  53040. * @param texture The texture to render to or null for the default canvas
  53041. * @param faceIndex The face of the texture to render to in case of cube texture
  53042. * @param requiredWidth The width of the target to render to
  53043. * @param requiredHeight The height of the target to render to
  53044. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53045. * @param lodLevel defines le lod level to bind to the frame buffer
  53046. */
  53047. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53048. /**
  53049. * Unbind the current render target texture from the webGL context
  53050. * @param texture defines the render target texture to unbind
  53051. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53052. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53053. */
  53054. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53055. /**
  53056. * Creates a dynamic vertex buffer
  53057. * @param vertices the data for the dynamic vertex buffer
  53058. * @returns the new WebGL dynamic buffer
  53059. */
  53060. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53061. /**
  53062. * Update the content of a dynamic texture
  53063. * @param texture defines the texture to update
  53064. * @param canvas defines the canvas containing the source
  53065. * @param invertY defines if data must be stored with Y axis inverted
  53066. * @param premulAlpha defines if alpha is stored as premultiplied
  53067. * @param format defines the format of the data
  53068. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53069. */
  53070. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53071. /**
  53072. * Gets a boolean indicating if all created effects are ready
  53073. * @returns true if all effects are ready
  53074. */
  53075. areAllEffectsReady(): boolean;
  53076. /**
  53077. * @hidden
  53078. * Get the current error code of the webGL context
  53079. * @returns the error code
  53080. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53081. */
  53082. getError(): number;
  53083. /** @hidden */
  53084. _getUnpackAlignement(): number;
  53085. /** @hidden */
  53086. _unpackFlipY(value: boolean): void;
  53087. /**
  53088. * Update a dynamic index buffer
  53089. * @param indexBuffer defines the target index buffer
  53090. * @param indices defines the data to update
  53091. * @param offset defines the offset in the target index buffer where update should start
  53092. */
  53093. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53094. /**
  53095. * Updates a dynamic vertex buffer.
  53096. * @param vertexBuffer the vertex buffer to update
  53097. * @param vertices the data used to update the vertex buffer
  53098. * @param byteOffset the byte offset of the data (optional)
  53099. * @param byteLength the byte length of the data (optional)
  53100. */
  53101. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53102. /** @hidden */
  53103. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53104. /** @hidden */
  53105. _bindTexture(channel: number, texture: InternalTexture): void;
  53106. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53107. /**
  53108. * 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
  53109. */
  53110. releaseEffects(): void;
  53111. displayLoadingUI(): void;
  53112. hideLoadingUI(): void;
  53113. /** @hidden */
  53114. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53115. /** @hidden */
  53116. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53117. /** @hidden */
  53118. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53119. /** @hidden */
  53120. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53121. }
  53122. }
  53123. declare module "babylonjs/Instrumentation/timeToken" {
  53124. import { Nullable } from "babylonjs/types";
  53125. /**
  53126. * @hidden
  53127. **/
  53128. export class _TimeToken {
  53129. _startTimeQuery: Nullable<WebGLQuery>;
  53130. _endTimeQuery: Nullable<WebGLQuery>;
  53131. _timeElapsedQuery: Nullable<WebGLQuery>;
  53132. _timeElapsedQueryEnded: boolean;
  53133. }
  53134. }
  53135. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53136. import { Nullable, int } from "babylonjs/types";
  53137. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53138. /** @hidden */
  53139. export class _OcclusionDataStorage {
  53140. /** @hidden */
  53141. occlusionInternalRetryCounter: number;
  53142. /** @hidden */
  53143. isOcclusionQueryInProgress: boolean;
  53144. /** @hidden */
  53145. isOccluded: boolean;
  53146. /** @hidden */
  53147. occlusionRetryCount: number;
  53148. /** @hidden */
  53149. occlusionType: number;
  53150. /** @hidden */
  53151. occlusionQueryAlgorithmType: number;
  53152. }
  53153. module "babylonjs/Engines/engine" {
  53154. interface Engine {
  53155. /**
  53156. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53157. * @return the new query
  53158. */
  53159. createQuery(): WebGLQuery;
  53160. /**
  53161. * Delete and release a webGL query
  53162. * @param query defines the query to delete
  53163. * @return the current engine
  53164. */
  53165. deleteQuery(query: WebGLQuery): Engine;
  53166. /**
  53167. * Check if a given query has resolved and got its value
  53168. * @param query defines the query to check
  53169. * @returns true if the query got its value
  53170. */
  53171. isQueryResultAvailable(query: WebGLQuery): boolean;
  53172. /**
  53173. * Gets the value of a given query
  53174. * @param query defines the query to check
  53175. * @returns the value of the query
  53176. */
  53177. getQueryResult(query: WebGLQuery): number;
  53178. /**
  53179. * Initiates an occlusion query
  53180. * @param algorithmType defines the algorithm to use
  53181. * @param query defines the query to use
  53182. * @returns the current engine
  53183. * @see https://doc.babylonjs.com/features/occlusionquery
  53184. */
  53185. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53186. /**
  53187. * Ends an occlusion query
  53188. * @see https://doc.babylonjs.com/features/occlusionquery
  53189. * @param algorithmType defines the algorithm to use
  53190. * @returns the current engine
  53191. */
  53192. endOcclusionQuery(algorithmType: number): Engine;
  53193. /**
  53194. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53195. * Please note that only one query can be issued at a time
  53196. * @returns a time token used to track the time span
  53197. */
  53198. startTimeQuery(): Nullable<_TimeToken>;
  53199. /**
  53200. * Ends a time query
  53201. * @param token defines the token used to measure the time span
  53202. * @returns the time spent (in ns)
  53203. */
  53204. endTimeQuery(token: _TimeToken): int;
  53205. /** @hidden */
  53206. _currentNonTimestampToken: Nullable<_TimeToken>;
  53207. /** @hidden */
  53208. _createTimeQuery(): WebGLQuery;
  53209. /** @hidden */
  53210. _deleteTimeQuery(query: WebGLQuery): void;
  53211. /** @hidden */
  53212. _getGlAlgorithmType(algorithmType: number): number;
  53213. /** @hidden */
  53214. _getTimeQueryResult(query: WebGLQuery): any;
  53215. /** @hidden */
  53216. _getTimeQueryAvailability(query: WebGLQuery): any;
  53217. }
  53218. }
  53219. module "babylonjs/Meshes/abstractMesh" {
  53220. interface AbstractMesh {
  53221. /**
  53222. * Backing filed
  53223. * @hidden
  53224. */
  53225. __occlusionDataStorage: _OcclusionDataStorage;
  53226. /**
  53227. * Access property
  53228. * @hidden
  53229. */
  53230. _occlusionDataStorage: _OcclusionDataStorage;
  53231. /**
  53232. * 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.
  53233. * The default value is -1 which means don't break the query and wait till the result
  53234. * @see https://doc.babylonjs.com/features/occlusionquery
  53235. */
  53236. occlusionRetryCount: number;
  53237. /**
  53238. * 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:
  53239. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53240. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53241. * * 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.
  53242. * @see https://doc.babylonjs.com/features/occlusionquery
  53243. */
  53244. occlusionType: number;
  53245. /**
  53246. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53247. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53248. * * 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.
  53249. * @see https://doc.babylonjs.com/features/occlusionquery
  53250. */
  53251. occlusionQueryAlgorithmType: number;
  53252. /**
  53253. * 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
  53254. * @see https://doc.babylonjs.com/features/occlusionquery
  53255. */
  53256. isOccluded: boolean;
  53257. /**
  53258. * Flag to check the progress status of the query
  53259. * @see https://doc.babylonjs.com/features/occlusionquery
  53260. */
  53261. isOcclusionQueryInProgress: boolean;
  53262. }
  53263. }
  53264. }
  53265. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53266. import { Nullable } from "babylonjs/types";
  53267. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53268. /** @hidden */
  53269. export var _forceTransformFeedbackToBundle: boolean;
  53270. module "babylonjs/Engines/engine" {
  53271. interface Engine {
  53272. /**
  53273. * Creates a webGL transform feedback object
  53274. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53275. * @returns the webGL transform feedback object
  53276. */
  53277. createTransformFeedback(): WebGLTransformFeedback;
  53278. /**
  53279. * Delete a webGL transform feedback object
  53280. * @param value defines the webGL transform feedback object to delete
  53281. */
  53282. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53283. /**
  53284. * Bind a webGL transform feedback object to the webgl context
  53285. * @param value defines the webGL transform feedback object to bind
  53286. */
  53287. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53288. /**
  53289. * Begins a transform feedback operation
  53290. * @param usePoints defines if points or triangles must be used
  53291. */
  53292. beginTransformFeedback(usePoints: boolean): void;
  53293. /**
  53294. * Ends a transform feedback operation
  53295. */
  53296. endTransformFeedback(): void;
  53297. /**
  53298. * Specify the varyings to use with transform feedback
  53299. * @param program defines the associated webGL program
  53300. * @param value defines the list of strings representing the varying names
  53301. */
  53302. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53303. /**
  53304. * Bind a webGL buffer for a transform feedback operation
  53305. * @param value defines the webGL buffer to bind
  53306. */
  53307. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53308. }
  53309. }
  53310. }
  53311. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53312. import { Scene } from "babylonjs/scene";
  53313. import { Engine } from "babylonjs/Engines/engine";
  53314. import { Texture } from "babylonjs/Materials/Textures/texture";
  53315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53316. import "babylonjs/Engines/Extensions/engine.multiRender";
  53317. /**
  53318. * Creation options of the multi render target texture.
  53319. */
  53320. export interface IMultiRenderTargetOptions {
  53321. /**
  53322. * Define if the texture needs to create mip maps after render.
  53323. */
  53324. generateMipMaps?: boolean;
  53325. /**
  53326. * Define the types of all the draw buffers we want to create
  53327. */
  53328. types?: number[];
  53329. /**
  53330. * Define the sampling modes of all the draw buffers we want to create
  53331. */
  53332. samplingModes?: number[];
  53333. /**
  53334. * Define if a depth buffer is required
  53335. */
  53336. generateDepthBuffer?: boolean;
  53337. /**
  53338. * Define if a stencil buffer is required
  53339. */
  53340. generateStencilBuffer?: boolean;
  53341. /**
  53342. * Define if a depth texture is required instead of a depth buffer
  53343. */
  53344. generateDepthTexture?: boolean;
  53345. /**
  53346. * Define the number of desired draw buffers
  53347. */
  53348. textureCount?: number;
  53349. /**
  53350. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53351. */
  53352. doNotChangeAspectRatio?: boolean;
  53353. /**
  53354. * Define the default type of the buffers we are creating
  53355. */
  53356. defaultType?: number;
  53357. }
  53358. /**
  53359. * A multi render target, like a render target provides the ability to render to a texture.
  53360. * Unlike the render target, it can render to several draw buffers in one draw.
  53361. * This is specially interesting in deferred rendering or for any effects requiring more than
  53362. * just one color from a single pass.
  53363. */
  53364. export class MultiRenderTarget extends RenderTargetTexture {
  53365. private _internalTextures;
  53366. private _textures;
  53367. private _multiRenderTargetOptions;
  53368. private _count;
  53369. /**
  53370. * Get if draw buffers are currently supported by the used hardware and browser.
  53371. */
  53372. get isSupported(): boolean;
  53373. /**
  53374. * Get the list of textures generated by the multi render target.
  53375. */
  53376. get textures(): Texture[];
  53377. /**
  53378. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53379. */
  53380. get count(): number;
  53381. /**
  53382. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53383. */
  53384. get depthTexture(): Texture;
  53385. /**
  53386. * Set the wrapping mode on U of all the textures we are rendering to.
  53387. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53388. */
  53389. set wrapU(wrap: number);
  53390. /**
  53391. * Set the wrapping mode on V of all the textures we are rendering to.
  53392. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53393. */
  53394. set wrapV(wrap: number);
  53395. /**
  53396. * Instantiate a new multi render target texture.
  53397. * A multi render target, like a render target provides the ability to render to a texture.
  53398. * Unlike the render target, it can render to several draw buffers in one draw.
  53399. * This is specially interesting in deferred rendering or for any effects requiring more than
  53400. * just one color from a single pass.
  53401. * @param name Define the name of the texture
  53402. * @param size Define the size of the buffers to render to
  53403. * @param count Define the number of target we are rendering into
  53404. * @param scene Define the scene the texture belongs to
  53405. * @param options Define the options used to create the multi render target
  53406. */
  53407. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53408. /** @hidden */
  53409. _rebuild(): void;
  53410. private _createInternalTextures;
  53411. private _createTextures;
  53412. /**
  53413. * Define the number of samples used if MSAA is enabled.
  53414. */
  53415. get samples(): number;
  53416. set samples(value: number);
  53417. /**
  53418. * Resize all the textures in the multi render target.
  53419. * Be carrefull as it will recreate all the data in the new texture.
  53420. * @param size Define the new size
  53421. */
  53422. resize(size: any): void;
  53423. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53424. /**
  53425. * Dispose the render targets and their associated resources
  53426. */
  53427. dispose(): void;
  53428. /**
  53429. * Release all the underlying texture used as draw buffers.
  53430. */
  53431. releaseInternalTextures(): void;
  53432. }
  53433. }
  53434. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53436. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53437. import { Nullable } from "babylonjs/types";
  53438. module "babylonjs/Engines/thinEngine" {
  53439. interface ThinEngine {
  53440. /**
  53441. * Unbind a list of render target textures from the webGL context
  53442. * This is used only when drawBuffer extension or webGL2 are active
  53443. * @param textures defines the render target textures to unbind
  53444. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53445. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53446. */
  53447. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53448. /**
  53449. * Create a multi render target texture
  53450. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53451. * @param size defines the size of the texture
  53452. * @param options defines the creation options
  53453. * @returns the cube texture as an InternalTexture
  53454. */
  53455. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53456. /**
  53457. * Update the sample count for a given multiple render target texture
  53458. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53459. * @param textures defines the textures to update
  53460. * @param samples defines the sample count to set
  53461. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53462. */
  53463. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53464. /**
  53465. * Select a subsets of attachments to draw to.
  53466. * @param attachments gl attachments
  53467. */
  53468. bindAttachments(attachments: number[]): void;
  53469. }
  53470. }
  53471. }
  53472. declare module "babylonjs/Engines/Extensions/engine.views" {
  53473. import { Camera } from "babylonjs/Cameras/camera";
  53474. import { Nullable } from "babylonjs/types";
  53475. /**
  53476. * Class used to define an additional view for the engine
  53477. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53478. */
  53479. export class EngineView {
  53480. /** Defines the canvas where to render the view */
  53481. target: HTMLCanvasElement;
  53482. /** Defines an optional camera used to render the view (will use active camera else) */
  53483. camera?: Camera;
  53484. }
  53485. module "babylonjs/Engines/engine" {
  53486. interface Engine {
  53487. /**
  53488. * Gets or sets the HTML element to use for attaching events
  53489. */
  53490. inputElement: Nullable<HTMLElement>;
  53491. /**
  53492. * Gets the current engine view
  53493. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53494. */
  53495. activeView: Nullable<EngineView>;
  53496. /** Gets or sets the list of views */
  53497. views: EngineView[];
  53498. /**
  53499. * Register a new child canvas
  53500. * @param canvas defines the canvas to register
  53501. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53502. * @returns the associated view
  53503. */
  53504. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53505. /**
  53506. * Remove a registered child canvas
  53507. * @param canvas defines the canvas to remove
  53508. * @returns the current engine
  53509. */
  53510. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53511. }
  53512. }
  53513. }
  53514. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53515. import { Nullable } from "babylonjs/types";
  53516. module "babylonjs/Engines/engine" {
  53517. interface Engine {
  53518. /** @hidden */
  53519. _excludedCompressedTextures: string[];
  53520. /** @hidden */
  53521. _textureFormatInUse: string;
  53522. /**
  53523. * Gets the list of texture formats supported
  53524. */
  53525. readonly texturesSupported: Array<string>;
  53526. /**
  53527. * Gets the texture format in use
  53528. */
  53529. readonly textureFormatInUse: Nullable<string>;
  53530. /**
  53531. * Set the compressed texture extensions or file names to skip.
  53532. *
  53533. * @param skippedFiles defines the list of those texture files you want to skip
  53534. * Example: [".dds", ".env", "myfile.png"]
  53535. */
  53536. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53537. /**
  53538. * Set the compressed texture format to use, based on the formats you have, and the formats
  53539. * supported by the hardware / browser.
  53540. *
  53541. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53542. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53543. * to API arguments needed to compressed textures. This puts the burden on the container
  53544. * generator to house the arcane code for determining these for current & future formats.
  53545. *
  53546. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53547. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53548. *
  53549. * Note: The result of this call is not taken into account when a texture is base64.
  53550. *
  53551. * @param formatsAvailable defines the list of those format families you have created
  53552. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53553. *
  53554. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53555. * @returns The extension selected.
  53556. */
  53557. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53558. }
  53559. }
  53560. }
  53561. declare module "babylonjs/Engines/Extensions/index" {
  53562. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53563. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53564. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53565. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53566. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53567. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53568. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53569. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53570. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53571. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53572. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53573. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53574. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53575. export * from "babylonjs/Engines/Extensions/engine.views";
  53576. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53577. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53578. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53579. }
  53580. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53581. import { Nullable } from "babylonjs/types";
  53582. /**
  53583. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53584. */
  53585. export interface CubeMapInfo {
  53586. /**
  53587. * The pixel array for the front face.
  53588. * This is stored in format, left to right, up to down format.
  53589. */
  53590. front: Nullable<ArrayBufferView>;
  53591. /**
  53592. * The pixel array for the back face.
  53593. * This is stored in format, left to right, up to down format.
  53594. */
  53595. back: Nullable<ArrayBufferView>;
  53596. /**
  53597. * The pixel array for the left face.
  53598. * This is stored in format, left to right, up to down format.
  53599. */
  53600. left: Nullable<ArrayBufferView>;
  53601. /**
  53602. * The pixel array for the right face.
  53603. * This is stored in format, left to right, up to down format.
  53604. */
  53605. right: Nullable<ArrayBufferView>;
  53606. /**
  53607. * The pixel array for the up face.
  53608. * This is stored in format, left to right, up to down format.
  53609. */
  53610. up: Nullable<ArrayBufferView>;
  53611. /**
  53612. * The pixel array for the down face.
  53613. * This is stored in format, left to right, up to down format.
  53614. */
  53615. down: Nullable<ArrayBufferView>;
  53616. /**
  53617. * The size of the cubemap stored.
  53618. *
  53619. * Each faces will be size * size pixels.
  53620. */
  53621. size: number;
  53622. /**
  53623. * The format of the texture.
  53624. *
  53625. * RGBA, RGB.
  53626. */
  53627. format: number;
  53628. /**
  53629. * The type of the texture data.
  53630. *
  53631. * UNSIGNED_INT, FLOAT.
  53632. */
  53633. type: number;
  53634. /**
  53635. * Specifies whether the texture is in gamma space.
  53636. */
  53637. gammaSpace: boolean;
  53638. }
  53639. /**
  53640. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53641. */
  53642. export class PanoramaToCubeMapTools {
  53643. private static FACE_LEFT;
  53644. private static FACE_RIGHT;
  53645. private static FACE_FRONT;
  53646. private static FACE_BACK;
  53647. private static FACE_DOWN;
  53648. private static FACE_UP;
  53649. /**
  53650. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53651. *
  53652. * @param float32Array The source data.
  53653. * @param inputWidth The width of the input panorama.
  53654. * @param inputHeight The height of the input panorama.
  53655. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53656. * @return The cubemap data
  53657. */
  53658. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53659. private static CreateCubemapTexture;
  53660. private static CalcProjectionSpherical;
  53661. }
  53662. }
  53663. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53664. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53666. import { Nullable } from "babylonjs/types";
  53667. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53668. /**
  53669. * Helper class dealing with the extraction of spherical polynomial dataArray
  53670. * from a cube map.
  53671. */
  53672. export class CubeMapToSphericalPolynomialTools {
  53673. private static FileFaces;
  53674. /**
  53675. * Converts a texture to the according Spherical Polynomial data.
  53676. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53677. *
  53678. * @param texture The texture to extract the information from.
  53679. * @return The Spherical Polynomial data.
  53680. */
  53681. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53682. /**
  53683. * Converts a cubemap to the according Spherical Polynomial data.
  53684. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53685. *
  53686. * @param cubeInfo The Cube map to extract the information from.
  53687. * @return The Spherical Polynomial data.
  53688. */
  53689. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53690. }
  53691. }
  53692. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53693. import { Nullable } from "babylonjs/types";
  53694. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53695. module "babylonjs/Materials/Textures/baseTexture" {
  53696. interface BaseTexture {
  53697. /**
  53698. * Get the polynomial representation of the texture data.
  53699. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53700. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53701. */
  53702. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53703. }
  53704. }
  53705. }
  53706. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53708. /** @hidden */
  53709. export var rgbdEncodePixelShader: {
  53710. name: string;
  53711. shader: string;
  53712. };
  53713. }
  53714. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53716. /** @hidden */
  53717. export var rgbdDecodePixelShader: {
  53718. name: string;
  53719. shader: string;
  53720. };
  53721. }
  53722. declare module "babylonjs/Misc/environmentTextureTools" {
  53723. import { Nullable } from "babylonjs/types";
  53724. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53725. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53727. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53728. import "babylonjs/Engines/Extensions/engine.readTexture";
  53729. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53730. import "babylonjs/Shaders/rgbdEncode.fragment";
  53731. import "babylonjs/Shaders/rgbdDecode.fragment";
  53732. /**
  53733. * Raw texture data and descriptor sufficient for WebGL texture upload
  53734. */
  53735. export interface EnvironmentTextureInfo {
  53736. /**
  53737. * Version of the environment map
  53738. */
  53739. version: number;
  53740. /**
  53741. * Width of image
  53742. */
  53743. width: number;
  53744. /**
  53745. * Irradiance information stored in the file.
  53746. */
  53747. irradiance: any;
  53748. /**
  53749. * Specular information stored in the file.
  53750. */
  53751. specular: any;
  53752. }
  53753. /**
  53754. * Defines One Image in the file. It requires only the position in the file
  53755. * as well as the length.
  53756. */
  53757. interface BufferImageData {
  53758. /**
  53759. * Length of the image data.
  53760. */
  53761. length: number;
  53762. /**
  53763. * Position of the data from the null terminator delimiting the end of the JSON.
  53764. */
  53765. position: number;
  53766. }
  53767. /**
  53768. * Defines the specular data enclosed in the file.
  53769. * This corresponds to the version 1 of the data.
  53770. */
  53771. export interface EnvironmentTextureSpecularInfoV1 {
  53772. /**
  53773. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53774. */
  53775. specularDataPosition?: number;
  53776. /**
  53777. * This contains all the images data needed to reconstruct the cubemap.
  53778. */
  53779. mipmaps: Array<BufferImageData>;
  53780. /**
  53781. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53782. */
  53783. lodGenerationScale: number;
  53784. }
  53785. /**
  53786. * Sets of helpers addressing the serialization and deserialization of environment texture
  53787. * stored in a BabylonJS env file.
  53788. * Those files are usually stored as .env files.
  53789. */
  53790. export class EnvironmentTextureTools {
  53791. /**
  53792. * Magic number identifying the env file.
  53793. */
  53794. private static _MagicBytes;
  53795. /**
  53796. * Gets the environment info from an env file.
  53797. * @param data The array buffer containing the .env bytes.
  53798. * @returns the environment file info (the json header) if successfully parsed.
  53799. */
  53800. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53801. /**
  53802. * Creates an environment texture from a loaded cube texture.
  53803. * @param texture defines the cube texture to convert in env file
  53804. * @return a promise containing the environment data if succesfull.
  53805. */
  53806. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53807. /**
  53808. * Creates a JSON representation of the spherical data.
  53809. * @param texture defines the texture containing the polynomials
  53810. * @return the JSON representation of the spherical info
  53811. */
  53812. private static _CreateEnvTextureIrradiance;
  53813. /**
  53814. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53815. * @param data the image data
  53816. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53817. * @return the views described by info providing access to the underlying buffer
  53818. */
  53819. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53820. /**
  53821. * Uploads the texture info contained in the env file to the GPU.
  53822. * @param texture defines the internal texture to upload to
  53823. * @param data defines the data to load
  53824. * @param info defines the texture info retrieved through the GetEnvInfo method
  53825. * @returns a promise
  53826. */
  53827. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53828. private static _OnImageReadyAsync;
  53829. /**
  53830. * Uploads the levels of image data to the GPU.
  53831. * @param texture defines the internal texture to upload to
  53832. * @param imageData defines the array buffer views of image data [mipmap][face]
  53833. * @returns a promise
  53834. */
  53835. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53836. /**
  53837. * Uploads spherical polynomials information to the texture.
  53838. * @param texture defines the texture we are trying to upload the information to
  53839. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53840. */
  53841. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53842. /** @hidden */
  53843. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53844. }
  53845. }
  53846. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53847. /**
  53848. * Class used to inline functions in shader code
  53849. */
  53850. export class ShaderCodeInliner {
  53851. private static readonly _RegexpFindFunctionNameAndType;
  53852. private _sourceCode;
  53853. private _functionDescr;
  53854. private _numMaxIterations;
  53855. /** Gets or sets the token used to mark the functions to inline */
  53856. inlineToken: string;
  53857. /** Gets or sets the debug mode */
  53858. debug: boolean;
  53859. /** Gets the code after the inlining process */
  53860. get code(): string;
  53861. /**
  53862. * Initializes the inliner
  53863. * @param sourceCode shader code source to inline
  53864. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53865. */
  53866. constructor(sourceCode: string, numMaxIterations?: number);
  53867. /**
  53868. * Start the processing of the shader code
  53869. */
  53870. processCode(): void;
  53871. private _collectFunctions;
  53872. private _processInlining;
  53873. private _extractBetweenMarkers;
  53874. private _skipWhitespaces;
  53875. private _removeComments;
  53876. private _replaceFunctionCallsByCode;
  53877. private _findBackward;
  53878. private _escapeRegExp;
  53879. private _replaceNames;
  53880. }
  53881. }
  53882. declare module "babylonjs/Engines/nativeEngine" {
  53883. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53884. import { Engine } from "babylonjs/Engines/engine";
  53885. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53886. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53888. import { Effect } from "babylonjs/Materials/effect";
  53889. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53890. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53891. import { IColor4Like } from "babylonjs/Maths/math.like";
  53892. import { Scene } from "babylonjs/scene";
  53893. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53894. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53895. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53896. /**
  53897. * Container for accessors for natively-stored mesh data buffers.
  53898. */
  53899. class NativeDataBuffer extends DataBuffer {
  53900. /**
  53901. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53902. */
  53903. nativeIndexBuffer?: any;
  53904. /**
  53905. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53906. */
  53907. nativeVertexBuffer?: any;
  53908. }
  53909. /** @hidden */
  53910. class NativeTexture extends InternalTexture {
  53911. getInternalTexture(): InternalTexture;
  53912. getViewCount(): number;
  53913. }
  53914. /** @hidden */
  53915. export class NativeEngine extends Engine {
  53916. private readonly _native;
  53917. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53918. private readonly INVALID_HANDLE;
  53919. getHardwareScalingLevel(): number;
  53920. constructor();
  53921. dispose(): void;
  53922. /**
  53923. * Can be used to override the current requestAnimationFrame requester.
  53924. * @hidden
  53925. */
  53926. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53927. /**
  53928. * Override default engine behavior.
  53929. * @param color
  53930. * @param backBuffer
  53931. * @param depth
  53932. * @param stencil
  53933. */
  53934. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53935. /**
  53936. * Gets host document
  53937. * @returns the host document object
  53938. */
  53939. getHostDocument(): Nullable<Document>;
  53940. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53941. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53942. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53943. recordVertexArrayObject(vertexBuffers: {
  53944. [key: string]: VertexBuffer;
  53945. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53946. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53947. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53948. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53949. /**
  53950. * Draw a list of indexed primitives
  53951. * @param fillMode defines the primitive to use
  53952. * @param indexStart defines the starting index
  53953. * @param indexCount defines the number of index to draw
  53954. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53955. */
  53956. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53957. /**
  53958. * Draw a list of unindexed primitives
  53959. * @param fillMode defines the primitive to use
  53960. * @param verticesStart defines the index of first vertex to draw
  53961. * @param verticesCount defines the count of vertices to draw
  53962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53963. */
  53964. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53965. createPipelineContext(): IPipelineContext;
  53966. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53967. /** @hidden */
  53968. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53969. /** @hidden */
  53970. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53971. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53972. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53973. protected _setProgram(program: WebGLProgram): void;
  53974. _releaseEffect(effect: Effect): void;
  53975. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53976. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53977. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53978. bindSamplers(effect: Effect): void;
  53979. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53980. getRenderWidth(useScreen?: boolean): number;
  53981. getRenderHeight(useScreen?: boolean): number;
  53982. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53984. /**
  53985. * Set the z offset to apply to current rendering
  53986. * @param value defines the offset to apply
  53987. */
  53988. setZOffset(value: number): void;
  53989. /**
  53990. * Gets the current value of the zOffset
  53991. * @returns the current zOffset state
  53992. */
  53993. getZOffset(): number;
  53994. /**
  53995. * Enable or disable depth buffering
  53996. * @param enable defines the state to set
  53997. */
  53998. setDepthBuffer(enable: boolean): void;
  53999. /**
  54000. * Gets a boolean indicating if depth writing is enabled
  54001. * @returns the current depth writing state
  54002. */
  54003. getDepthWrite(): boolean;
  54004. /**
  54005. * Enable or disable depth writing
  54006. * @param enable defines the state to set
  54007. */
  54008. setDepthWrite(enable: boolean): void;
  54009. /**
  54010. * Enable or disable color writing
  54011. * @param enable defines the state to set
  54012. */
  54013. setColorWrite(enable: boolean): void;
  54014. /**
  54015. * Gets a boolean indicating if color writing is enabled
  54016. * @returns the current color writing state
  54017. */
  54018. getColorWrite(): boolean;
  54019. /**
  54020. * Sets alpha constants used by some alpha blending modes
  54021. * @param r defines the red component
  54022. * @param g defines the green component
  54023. * @param b defines the blue component
  54024. * @param a defines the alpha component
  54025. */
  54026. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54027. /**
  54028. * Sets the current alpha mode
  54029. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54030. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54031. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54032. */
  54033. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54034. /**
  54035. * Gets the current alpha mode
  54036. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54037. * @returns the current alpha mode
  54038. */
  54039. getAlphaMode(): number;
  54040. setInt(uniform: WebGLUniformLocation, int: number): void;
  54041. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54042. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54043. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54044. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54045. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54046. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54047. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54048. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54049. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54050. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54051. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54052. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54053. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54054. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54055. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54056. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54057. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54058. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54059. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54060. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54061. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54062. wipeCaches(bruteForce?: boolean): void;
  54063. _createTexture(): WebGLTexture;
  54064. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54065. /**
  54066. * Usually called from Texture.ts.
  54067. * Passed information to create a WebGLTexture
  54068. * @param url defines a value which contains one of the following:
  54069. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54070. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54071. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54072. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54073. * @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)
  54074. * @param scene needed for loading to the correct scene
  54075. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54076. * @param onLoad optional callback to be called upon successful completion
  54077. * @param onError optional callback to be called upon failure
  54078. * @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
  54079. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54080. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54081. * @param forcedExtension defines the extension to use to pick the right loader
  54082. * @param mimeType defines an optional mime type
  54083. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54084. */
  54085. 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;
  54086. /**
  54087. * Creates a cube texture
  54088. * @param rootUrl defines the url where the files to load is located
  54089. * @param scene defines the current scene
  54090. * @param files defines the list of files to load (1 per face)
  54091. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54092. * @param onLoad defines an optional callback raised when the texture is loaded
  54093. * @param onError defines an optional callback raised if there is an issue to load the texture
  54094. * @param format defines the format of the data
  54095. * @param forcedExtension defines the extension to use to pick the right loader
  54096. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54097. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54098. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54099. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54100. * @returns the cube texture as an InternalTexture
  54101. */
  54102. 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;
  54103. private _getSamplingFilter;
  54104. private static _GetNativeTextureFormat;
  54105. createRenderTargetTexture(size: number | {
  54106. width: number;
  54107. height: number;
  54108. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54109. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54110. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54111. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54112. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54113. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54114. /**
  54115. * Updates a dynamic vertex buffer.
  54116. * @param vertexBuffer the vertex buffer to update
  54117. * @param data the data used to update the vertex buffer
  54118. * @param byteOffset the byte offset of the data (optional)
  54119. * @param byteLength the byte length of the data (optional)
  54120. */
  54121. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54122. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54123. private _updateAnisotropicLevel;
  54124. private _getAddressMode;
  54125. /** @hidden */
  54126. _bindTexture(channel: number, texture: InternalTexture): void;
  54127. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54128. releaseEffects(): void;
  54129. /** @hidden */
  54130. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54131. /** @hidden */
  54132. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54133. /** @hidden */
  54134. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54135. /** @hidden */
  54136. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54137. }
  54138. }
  54139. declare module "babylonjs/Engines/index" {
  54140. export * from "babylonjs/Engines/constants";
  54141. export * from "babylonjs/Engines/engineCapabilities";
  54142. export * from "babylonjs/Engines/instancingAttributeInfo";
  54143. export * from "babylonjs/Engines/thinEngine";
  54144. export * from "babylonjs/Engines/engine";
  54145. export * from "babylonjs/Engines/engineStore";
  54146. export * from "babylonjs/Engines/nullEngine";
  54147. export * from "babylonjs/Engines/Extensions/index";
  54148. export * from "babylonjs/Engines/IPipelineContext";
  54149. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54150. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54151. export * from "babylonjs/Engines/nativeEngine";
  54152. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54153. export * from "babylonjs/Engines/performanceConfigurator";
  54154. }
  54155. declare module "babylonjs/Events/clipboardEvents" {
  54156. /**
  54157. * Gather the list of clipboard event types as constants.
  54158. */
  54159. export class ClipboardEventTypes {
  54160. /**
  54161. * The clipboard event is fired when a copy command is active (pressed).
  54162. */
  54163. static readonly COPY: number;
  54164. /**
  54165. * The clipboard event is fired when a cut command is active (pressed).
  54166. */
  54167. static readonly CUT: number;
  54168. /**
  54169. * The clipboard event is fired when a paste command is active (pressed).
  54170. */
  54171. static readonly PASTE: number;
  54172. }
  54173. /**
  54174. * This class is used to store clipboard related info for the onClipboardObservable event.
  54175. */
  54176. export class ClipboardInfo {
  54177. /**
  54178. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54179. */
  54180. type: number;
  54181. /**
  54182. * Defines the related dom event
  54183. */
  54184. event: ClipboardEvent;
  54185. /**
  54186. *Creates an instance of ClipboardInfo.
  54187. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54188. * @param event Defines the related dom event
  54189. */
  54190. constructor(
  54191. /**
  54192. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54193. */
  54194. type: number,
  54195. /**
  54196. * Defines the related dom event
  54197. */
  54198. event: ClipboardEvent);
  54199. /**
  54200. * Get the clipboard event's type from the keycode.
  54201. * @param keyCode Defines the keyCode for the current keyboard event.
  54202. * @return {number}
  54203. */
  54204. static GetTypeFromCharacter(keyCode: number): number;
  54205. }
  54206. }
  54207. declare module "babylonjs/Events/index" {
  54208. export * from "babylonjs/Events/keyboardEvents";
  54209. export * from "babylonjs/Events/pointerEvents";
  54210. export * from "babylonjs/Events/clipboardEvents";
  54211. }
  54212. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54213. import { Scene } from "babylonjs/scene";
  54214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54215. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54216. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54217. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54218. /**
  54219. * Google Daydream controller
  54220. */
  54221. export class DaydreamController extends WebVRController {
  54222. /**
  54223. * Base Url for the controller model.
  54224. */
  54225. static MODEL_BASE_URL: string;
  54226. /**
  54227. * File name for the controller model.
  54228. */
  54229. static MODEL_FILENAME: string;
  54230. /**
  54231. * Gamepad Id prefix used to identify Daydream Controller.
  54232. */
  54233. static readonly GAMEPAD_ID_PREFIX: string;
  54234. /**
  54235. * Creates a new DaydreamController from a gamepad
  54236. * @param vrGamepad the gamepad that the controller should be created from
  54237. */
  54238. constructor(vrGamepad: any);
  54239. /**
  54240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54241. * @param scene scene in which to add meshes
  54242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54243. */
  54244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54245. /**
  54246. * Called once for each button that changed state since the last frame
  54247. * @param buttonIdx Which button index changed
  54248. * @param state New state of the button
  54249. * @param changes Which properties on the state changed since last frame
  54250. */
  54251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54252. }
  54253. }
  54254. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54255. import { Scene } from "babylonjs/scene";
  54256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54257. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54258. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54259. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54260. /**
  54261. * Gear VR Controller
  54262. */
  54263. export class GearVRController extends WebVRController {
  54264. /**
  54265. * Base Url for the controller model.
  54266. */
  54267. static MODEL_BASE_URL: string;
  54268. /**
  54269. * File name for the controller model.
  54270. */
  54271. static MODEL_FILENAME: string;
  54272. /**
  54273. * Gamepad Id prefix used to identify this controller.
  54274. */
  54275. static readonly GAMEPAD_ID_PREFIX: string;
  54276. private readonly _buttonIndexToObservableNameMap;
  54277. /**
  54278. * Creates a new GearVRController from a gamepad
  54279. * @param vrGamepad the gamepad that the controller should be created from
  54280. */
  54281. constructor(vrGamepad: any);
  54282. /**
  54283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54284. * @param scene scene in which to add meshes
  54285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54286. */
  54287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54288. /**
  54289. * Called once for each button that changed state since the last frame
  54290. * @param buttonIdx Which button index changed
  54291. * @param state New state of the button
  54292. * @param changes Which properties on the state changed since last frame
  54293. */
  54294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54295. }
  54296. }
  54297. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54298. import { Scene } from "babylonjs/scene";
  54299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54300. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54301. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54302. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54303. /**
  54304. * Generic Controller
  54305. */
  54306. export class GenericController extends WebVRController {
  54307. /**
  54308. * Base Url for the controller model.
  54309. */
  54310. static readonly MODEL_BASE_URL: string;
  54311. /**
  54312. * File name for the controller model.
  54313. */
  54314. static readonly MODEL_FILENAME: string;
  54315. /**
  54316. * Creates a new GenericController from a gamepad
  54317. * @param vrGamepad the gamepad that the controller should be created from
  54318. */
  54319. constructor(vrGamepad: any);
  54320. /**
  54321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54322. * @param scene scene in which to add meshes
  54323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54324. */
  54325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54326. /**
  54327. * Called once for each button that changed state since the last frame
  54328. * @param buttonIdx Which button index changed
  54329. * @param state New state of the button
  54330. * @param changes Which properties on the state changed since last frame
  54331. */
  54332. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54333. }
  54334. }
  54335. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54336. import { Observable } from "babylonjs/Misc/observable";
  54337. import { Scene } from "babylonjs/scene";
  54338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54339. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54340. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54341. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54342. /**
  54343. * Oculus Touch Controller
  54344. */
  54345. export class OculusTouchController extends WebVRController {
  54346. /**
  54347. * Base Url for the controller model.
  54348. */
  54349. static MODEL_BASE_URL: string;
  54350. /**
  54351. * File name for the left controller model.
  54352. */
  54353. static MODEL_LEFT_FILENAME: string;
  54354. /**
  54355. * File name for the right controller model.
  54356. */
  54357. static MODEL_RIGHT_FILENAME: string;
  54358. /**
  54359. * Base Url for the Quest controller model.
  54360. */
  54361. static QUEST_MODEL_BASE_URL: string;
  54362. /**
  54363. * @hidden
  54364. * If the controllers are running on a device that needs the updated Quest controller models
  54365. */
  54366. static _IsQuest: boolean;
  54367. /**
  54368. * Fired when the secondary trigger on this controller is modified
  54369. */
  54370. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54371. /**
  54372. * Fired when the thumb rest on this controller is modified
  54373. */
  54374. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54375. /**
  54376. * Creates a new OculusTouchController from a gamepad
  54377. * @param vrGamepad the gamepad that the controller should be created from
  54378. */
  54379. constructor(vrGamepad: any);
  54380. /**
  54381. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54382. * @param scene scene in which to add meshes
  54383. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54384. */
  54385. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54386. /**
  54387. * Fired when the A button on this controller is modified
  54388. */
  54389. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54390. /**
  54391. * Fired when the B button on this controller is modified
  54392. */
  54393. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54394. /**
  54395. * Fired when the X button on this controller is modified
  54396. */
  54397. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54398. /**
  54399. * Fired when the Y button on this controller is modified
  54400. */
  54401. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54402. /**
  54403. * Called once for each button that changed state since the last frame
  54404. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54405. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54406. * 2) secondary trigger (same)
  54407. * 3) A (right) X (left), touch, pressed = value
  54408. * 4) B / Y
  54409. * 5) thumb rest
  54410. * @param buttonIdx Which button index changed
  54411. * @param state New state of the button
  54412. * @param changes Which properties on the state changed since last frame
  54413. */
  54414. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54415. }
  54416. }
  54417. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54418. import { Scene } from "babylonjs/scene";
  54419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54420. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54421. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54422. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54423. import { Observable } from "babylonjs/Misc/observable";
  54424. /**
  54425. * Vive Controller
  54426. */
  54427. export class ViveController extends WebVRController {
  54428. /**
  54429. * Base Url for the controller model.
  54430. */
  54431. static MODEL_BASE_URL: string;
  54432. /**
  54433. * File name for the controller model.
  54434. */
  54435. static MODEL_FILENAME: string;
  54436. /**
  54437. * Creates a new ViveController from a gamepad
  54438. * @param vrGamepad the gamepad that the controller should be created from
  54439. */
  54440. constructor(vrGamepad: any);
  54441. /**
  54442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54443. * @param scene scene in which to add meshes
  54444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54445. */
  54446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54447. /**
  54448. * Fired when the left button on this controller is modified
  54449. */
  54450. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54451. /**
  54452. * Fired when the right button on this controller is modified
  54453. */
  54454. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54455. /**
  54456. * Fired when the menu button on this controller is modified
  54457. */
  54458. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54459. /**
  54460. * Called once for each button that changed state since the last frame
  54461. * Vive mapping:
  54462. * 0: touchpad
  54463. * 1: trigger
  54464. * 2: left AND right buttons
  54465. * 3: menu button
  54466. * @param buttonIdx Which button index changed
  54467. * @param state New state of the button
  54468. * @param changes Which properties on the state changed since last frame
  54469. */
  54470. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54471. }
  54472. }
  54473. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54474. import { Observable } from "babylonjs/Misc/observable";
  54475. import { Scene } from "babylonjs/scene";
  54476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54477. import { Ray } from "babylonjs/Culling/ray";
  54478. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54479. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54480. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54481. /**
  54482. * Defines the WindowsMotionController object that the state of the windows motion controller
  54483. */
  54484. export class WindowsMotionController extends WebVRController {
  54485. /**
  54486. * The base url used to load the left and right controller models
  54487. */
  54488. static MODEL_BASE_URL: string;
  54489. /**
  54490. * The name of the left controller model file
  54491. */
  54492. static MODEL_LEFT_FILENAME: string;
  54493. /**
  54494. * The name of the right controller model file
  54495. */
  54496. static MODEL_RIGHT_FILENAME: string;
  54497. /**
  54498. * The controller name prefix for this controller type
  54499. */
  54500. static readonly GAMEPAD_ID_PREFIX: string;
  54501. /**
  54502. * The controller id pattern for this controller type
  54503. */
  54504. private static readonly GAMEPAD_ID_PATTERN;
  54505. private _loadedMeshInfo;
  54506. protected readonly _mapping: {
  54507. buttons: string[];
  54508. buttonMeshNames: {
  54509. trigger: string;
  54510. menu: string;
  54511. grip: string;
  54512. thumbstick: string;
  54513. trackpad: string;
  54514. };
  54515. buttonObservableNames: {
  54516. trigger: string;
  54517. menu: string;
  54518. grip: string;
  54519. thumbstick: string;
  54520. trackpad: string;
  54521. };
  54522. axisMeshNames: string[];
  54523. pointingPoseMeshName: string;
  54524. };
  54525. /**
  54526. * Fired when the trackpad on this controller is clicked
  54527. */
  54528. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54529. /**
  54530. * Fired when the trackpad on this controller is modified
  54531. */
  54532. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54533. /**
  54534. * The current x and y values of this controller's trackpad
  54535. */
  54536. trackpad: StickValues;
  54537. /**
  54538. * Creates a new WindowsMotionController from a gamepad
  54539. * @param vrGamepad the gamepad that the controller should be created from
  54540. */
  54541. constructor(vrGamepad: any);
  54542. /**
  54543. * Fired when the trigger on this controller is modified
  54544. */
  54545. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54546. /**
  54547. * Fired when the menu button on this controller is modified
  54548. */
  54549. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54550. /**
  54551. * Fired when the grip button on this controller is modified
  54552. */
  54553. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54554. /**
  54555. * Fired when the thumbstick button on this controller is modified
  54556. */
  54557. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54558. /**
  54559. * Fired when the touchpad button on this controller is modified
  54560. */
  54561. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54562. /**
  54563. * Fired when the touchpad values on this controller are modified
  54564. */
  54565. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54566. protected _updateTrackpad(): void;
  54567. /**
  54568. * Called once per frame by the engine.
  54569. */
  54570. update(): void;
  54571. /**
  54572. * Called once for each button that changed state since the last frame
  54573. * @param buttonIdx Which button index changed
  54574. * @param state New state of the button
  54575. * @param changes Which properties on the state changed since last frame
  54576. */
  54577. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54578. /**
  54579. * Moves the buttons on the controller mesh based on their current state
  54580. * @param buttonName the name of the button to move
  54581. * @param buttonValue the value of the button which determines the buttons new position
  54582. */
  54583. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54584. /**
  54585. * Moves the axis on the controller mesh based on its current state
  54586. * @param axis the index of the axis
  54587. * @param axisValue the value of the axis which determines the meshes new position
  54588. * @hidden
  54589. */
  54590. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54591. /**
  54592. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54593. * @param scene scene in which to add meshes
  54594. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54595. */
  54596. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54597. /**
  54598. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54599. * can be transformed by button presses and axes values, based on this._mapping.
  54600. *
  54601. * @param scene scene in which the meshes exist
  54602. * @param meshes list of meshes that make up the controller model to process
  54603. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54604. */
  54605. private processModel;
  54606. private createMeshInfo;
  54607. /**
  54608. * Gets the ray of the controller in the direction the controller is pointing
  54609. * @param length the length the resulting ray should be
  54610. * @returns a ray in the direction the controller is pointing
  54611. */
  54612. getForwardRay(length?: number): Ray;
  54613. /**
  54614. * Disposes of the controller
  54615. */
  54616. dispose(): void;
  54617. }
  54618. /**
  54619. * This class represents a new windows motion controller in XR.
  54620. */
  54621. export class XRWindowsMotionController extends WindowsMotionController {
  54622. /**
  54623. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54624. */
  54625. protected readonly _mapping: {
  54626. buttons: string[];
  54627. buttonMeshNames: {
  54628. trigger: string;
  54629. menu: string;
  54630. grip: string;
  54631. thumbstick: string;
  54632. trackpad: string;
  54633. };
  54634. buttonObservableNames: {
  54635. trigger: string;
  54636. menu: string;
  54637. grip: string;
  54638. thumbstick: string;
  54639. trackpad: string;
  54640. };
  54641. axisMeshNames: string[];
  54642. pointingPoseMeshName: string;
  54643. };
  54644. /**
  54645. * Construct a new XR-Based windows motion controller
  54646. *
  54647. * @param gamepadInfo the gamepad object from the browser
  54648. */
  54649. constructor(gamepadInfo: any);
  54650. /**
  54651. * holds the thumbstick values (X,Y)
  54652. */
  54653. thumbstickValues: StickValues;
  54654. /**
  54655. * Fired when the thumbstick on this controller is clicked
  54656. */
  54657. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54658. /**
  54659. * Fired when the thumbstick on this controller is modified
  54660. */
  54661. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54662. /**
  54663. * Fired when the touchpad button on this controller is modified
  54664. */
  54665. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54666. /**
  54667. * Fired when the touchpad values on this controller are modified
  54668. */
  54669. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54670. /**
  54671. * Fired when the thumbstick button on this controller is modified
  54672. * here to prevent breaking changes
  54673. */
  54674. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54675. /**
  54676. * updating the thumbstick(!) and not the trackpad.
  54677. * This is named this way due to the difference between WebVR and XR and to avoid
  54678. * changing the parent class.
  54679. */
  54680. protected _updateTrackpad(): void;
  54681. /**
  54682. * Disposes the class with joy
  54683. */
  54684. dispose(): void;
  54685. }
  54686. }
  54687. declare module "babylonjs/Gamepads/Controllers/index" {
  54688. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54689. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54690. export * from "babylonjs/Gamepads/Controllers/genericController";
  54691. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54692. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54693. export * from "babylonjs/Gamepads/Controllers/viveController";
  54694. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54695. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54696. }
  54697. declare module "babylonjs/Gamepads/index" {
  54698. export * from "babylonjs/Gamepads/Controllers/index";
  54699. export * from "babylonjs/Gamepads/gamepad";
  54700. export * from "babylonjs/Gamepads/gamepadManager";
  54701. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54702. export * from "babylonjs/Gamepads/xboxGamepad";
  54703. export * from "babylonjs/Gamepads/dualShockGamepad";
  54704. }
  54705. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54706. import { Scene } from "babylonjs/scene";
  54707. import { Vector4 } from "babylonjs/Maths/math.vector";
  54708. import { Color4 } from "babylonjs/Maths/math.color";
  54709. import { Mesh } from "babylonjs/Meshes/mesh";
  54710. import { Nullable } from "babylonjs/types";
  54711. /**
  54712. * Class containing static functions to help procedurally build meshes
  54713. */
  54714. export class PolyhedronBuilder {
  54715. /**
  54716. * Creates a polyhedron mesh
  54717. * * 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
  54718. * * The parameter `size` (positive float, default 1) sets the polygon size
  54719. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54720. * * 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`
  54721. * * 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
  54722. * * 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)`)
  54723. * * 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
  54724. * * 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
  54725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54728. * @param name defines the name of the mesh
  54729. * @param options defines the options used to create the mesh
  54730. * @param scene defines the hosting scene
  54731. * @returns the polyhedron mesh
  54732. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54733. */
  54734. static CreatePolyhedron(name: string, options: {
  54735. type?: number;
  54736. size?: number;
  54737. sizeX?: number;
  54738. sizeY?: number;
  54739. sizeZ?: number;
  54740. custom?: any;
  54741. faceUV?: Vector4[];
  54742. faceColors?: Color4[];
  54743. flat?: boolean;
  54744. updatable?: boolean;
  54745. sideOrientation?: number;
  54746. frontUVs?: Vector4;
  54747. backUVs?: Vector4;
  54748. }, scene?: Nullable<Scene>): Mesh;
  54749. }
  54750. }
  54751. declare module "babylonjs/Gizmos/scaleGizmo" {
  54752. import { Observable } from "babylonjs/Misc/observable";
  54753. import { Nullable } from "babylonjs/types";
  54754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54755. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54756. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54757. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54758. import { Node } from "babylonjs/node";
  54759. /**
  54760. * Gizmo that enables scaling a mesh along 3 axis
  54761. */
  54762. export class ScaleGizmo extends Gizmo {
  54763. /**
  54764. * Internal gizmo used for interactions on the x axis
  54765. */
  54766. xGizmo: AxisScaleGizmo;
  54767. /**
  54768. * Internal gizmo used for interactions on the y axis
  54769. */
  54770. yGizmo: AxisScaleGizmo;
  54771. /**
  54772. * Internal gizmo used for interactions on the z axis
  54773. */
  54774. zGizmo: AxisScaleGizmo;
  54775. /**
  54776. * Internal gizmo used to scale all axis equally
  54777. */
  54778. uniformScaleGizmo: AxisScaleGizmo;
  54779. private _meshAttached;
  54780. private _nodeAttached;
  54781. private _updateGizmoRotationToMatchAttachedMesh;
  54782. private _snapDistance;
  54783. private _scaleRatio;
  54784. private _uniformScalingMesh;
  54785. private _octahedron;
  54786. private _sensitivity;
  54787. /** Fires an event when any of it's sub gizmos are dragged */
  54788. onDragStartObservable: Observable<unknown>;
  54789. /** Fires an event when any of it's sub gizmos are released from dragging */
  54790. onDragEndObservable: Observable<unknown>;
  54791. get attachedMesh(): Nullable<AbstractMesh>;
  54792. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54793. get attachedNode(): Nullable<Node>;
  54794. set attachedNode(node: Nullable<Node>);
  54795. /**
  54796. * Creates a ScaleGizmo
  54797. * @param gizmoLayer The utility layer the gizmo will be added to
  54798. */
  54799. constructor(gizmoLayer?: UtilityLayerRenderer);
  54800. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54801. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54802. /**
  54803. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54804. */
  54805. set snapDistance(value: number);
  54806. get snapDistance(): number;
  54807. /**
  54808. * Ratio for the scale of the gizmo (Default: 1)
  54809. */
  54810. set scaleRatio(value: number);
  54811. get scaleRatio(): number;
  54812. /**
  54813. * Sensitivity factor for dragging (Default: 1)
  54814. */
  54815. set sensitivity(value: number);
  54816. get sensitivity(): number;
  54817. /**
  54818. * Disposes of the gizmo
  54819. */
  54820. dispose(): void;
  54821. }
  54822. }
  54823. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54824. import { Observable } from "babylonjs/Misc/observable";
  54825. import { Nullable } from "babylonjs/types";
  54826. import { Vector3 } from "babylonjs/Maths/math.vector";
  54827. import { Node } from "babylonjs/node";
  54828. import { Mesh } from "babylonjs/Meshes/mesh";
  54829. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54830. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54831. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54832. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54833. import { Color3 } from "babylonjs/Maths/math.color";
  54834. /**
  54835. * Single axis scale gizmo
  54836. */
  54837. export class AxisScaleGizmo extends Gizmo {
  54838. /**
  54839. * Drag behavior responsible for the gizmos dragging interactions
  54840. */
  54841. dragBehavior: PointerDragBehavior;
  54842. private _pointerObserver;
  54843. /**
  54844. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54845. */
  54846. snapDistance: number;
  54847. /**
  54848. * Event that fires each time the gizmo snaps to a new location.
  54849. * * snapDistance is the the change in distance
  54850. */
  54851. onSnapObservable: Observable<{
  54852. snapDistance: number;
  54853. }>;
  54854. /**
  54855. * If the scaling operation should be done on all axis (default: false)
  54856. */
  54857. uniformScaling: boolean;
  54858. /**
  54859. * Custom sensitivity value for the drag strength
  54860. */
  54861. sensitivity: number;
  54862. private _isEnabled;
  54863. private _parent;
  54864. private _arrow;
  54865. private _coloredMaterial;
  54866. private _hoverMaterial;
  54867. /**
  54868. * Creates an AxisScaleGizmo
  54869. * @param gizmoLayer The utility layer the gizmo will be added to
  54870. * @param dragAxis The axis which the gizmo will be able to scale on
  54871. * @param color The color of the gizmo
  54872. */
  54873. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54874. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54875. /**
  54876. * If the gizmo is enabled
  54877. */
  54878. set isEnabled(value: boolean);
  54879. get isEnabled(): boolean;
  54880. /**
  54881. * Disposes of the gizmo
  54882. */
  54883. dispose(): void;
  54884. /**
  54885. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54886. * @param mesh The mesh to replace the default mesh of the gizmo
  54887. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54888. */
  54889. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54890. }
  54891. }
  54892. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54893. import { Observable } from "babylonjs/Misc/observable";
  54894. import { Nullable } from "babylonjs/types";
  54895. import { Vector3 } from "babylonjs/Maths/math.vector";
  54896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54897. import { Mesh } from "babylonjs/Meshes/mesh";
  54898. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54899. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54900. import { Color3 } from "babylonjs/Maths/math.color";
  54901. import "babylonjs/Meshes/Builders/boxBuilder";
  54902. /**
  54903. * Bounding box gizmo
  54904. */
  54905. export class BoundingBoxGizmo extends Gizmo {
  54906. private _lineBoundingBox;
  54907. private _rotateSpheresParent;
  54908. private _scaleBoxesParent;
  54909. private _boundingDimensions;
  54910. private _renderObserver;
  54911. private _pointerObserver;
  54912. private _scaleDragSpeed;
  54913. private _tmpQuaternion;
  54914. private _tmpVector;
  54915. private _tmpRotationMatrix;
  54916. /**
  54917. * 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)
  54918. */
  54919. ignoreChildren: boolean;
  54920. /**
  54921. * 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)
  54922. */
  54923. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54924. /**
  54925. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54926. */
  54927. rotationSphereSize: number;
  54928. /**
  54929. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54930. */
  54931. scaleBoxSize: number;
  54932. /**
  54933. * 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)
  54934. */
  54935. fixedDragMeshScreenSize: boolean;
  54936. /**
  54937. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54938. */
  54939. fixedDragMeshScreenSizeDistanceFactor: number;
  54940. /**
  54941. * Fired when a rotation sphere or scale box is dragged
  54942. */
  54943. onDragStartObservable: Observable<{}>;
  54944. /**
  54945. * Fired when a scale box is dragged
  54946. */
  54947. onScaleBoxDragObservable: Observable<{}>;
  54948. /**
  54949. * Fired when a scale box drag is ended
  54950. */
  54951. onScaleBoxDragEndObservable: Observable<{}>;
  54952. /**
  54953. * Fired when a rotation sphere is dragged
  54954. */
  54955. onRotationSphereDragObservable: Observable<{}>;
  54956. /**
  54957. * Fired when a rotation sphere drag is ended
  54958. */
  54959. onRotationSphereDragEndObservable: Observable<{}>;
  54960. /**
  54961. * 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)
  54962. */
  54963. scalePivot: Nullable<Vector3>;
  54964. /**
  54965. * Mesh used as a pivot to rotate the attached node
  54966. */
  54967. private _anchorMesh;
  54968. private _existingMeshScale;
  54969. private _dragMesh;
  54970. private pointerDragBehavior;
  54971. private coloredMaterial;
  54972. private hoverColoredMaterial;
  54973. /**
  54974. * Sets the color of the bounding box gizmo
  54975. * @param color the color to set
  54976. */
  54977. setColor(color: Color3): void;
  54978. /**
  54979. * Creates an BoundingBoxGizmo
  54980. * @param gizmoLayer The utility layer the gizmo will be added to
  54981. * @param color The color of the gizmo
  54982. */
  54983. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54984. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54985. private _selectNode;
  54986. /**
  54987. * Updates the bounding box information for the Gizmo
  54988. */
  54989. updateBoundingBox(): void;
  54990. private _updateRotationSpheres;
  54991. private _updateScaleBoxes;
  54992. /**
  54993. * Enables rotation on the specified axis and disables rotation on the others
  54994. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54995. */
  54996. setEnabledRotationAxis(axis: string): void;
  54997. /**
  54998. * Enables/disables scaling
  54999. * @param enable if scaling should be enabled
  55000. * @param homogeneousScaling defines if scaling should only be homogeneous
  55001. */
  55002. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55003. private _updateDummy;
  55004. /**
  55005. * Enables a pointer drag behavior on the bounding box of the gizmo
  55006. */
  55007. enableDragBehavior(): void;
  55008. /**
  55009. * Disposes of the gizmo
  55010. */
  55011. dispose(): void;
  55012. /**
  55013. * 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)
  55014. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55015. * @returns the bounding box mesh with the passed in mesh as a child
  55016. */
  55017. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55018. /**
  55019. * CustomMeshes are not supported by this gizmo
  55020. * @param mesh The mesh to replace the default mesh of the gizmo
  55021. */
  55022. setCustomMesh(mesh: Mesh): void;
  55023. }
  55024. }
  55025. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55026. import { Observable } from "babylonjs/Misc/observable";
  55027. import { Nullable } from "babylonjs/types";
  55028. import { Vector3 } from "babylonjs/Maths/math.vector";
  55029. import { Color3 } from "babylonjs/Maths/math.color";
  55030. import { Node } from "babylonjs/node";
  55031. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55032. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55034. import "babylonjs/Meshes/Builders/linesBuilder";
  55035. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55036. /**
  55037. * Single plane rotation gizmo
  55038. */
  55039. export class PlaneRotationGizmo extends Gizmo {
  55040. /**
  55041. * Drag behavior responsible for the gizmos dragging interactions
  55042. */
  55043. dragBehavior: PointerDragBehavior;
  55044. private _pointerObserver;
  55045. /**
  55046. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55047. */
  55048. snapDistance: number;
  55049. /**
  55050. * Event that fires each time the gizmo snaps to a new location.
  55051. * * snapDistance is the the change in distance
  55052. */
  55053. onSnapObservable: Observable<{
  55054. snapDistance: number;
  55055. }>;
  55056. private _isEnabled;
  55057. private _parent;
  55058. /**
  55059. * Creates a PlaneRotationGizmo
  55060. * @param gizmoLayer The utility layer the gizmo will be added to
  55061. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55062. * @param color The color of the gizmo
  55063. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55064. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55065. */
  55066. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  55067. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55068. /**
  55069. * If the gizmo is enabled
  55070. */
  55071. set isEnabled(value: boolean);
  55072. get isEnabled(): boolean;
  55073. /**
  55074. * Disposes of the gizmo
  55075. */
  55076. dispose(): void;
  55077. }
  55078. }
  55079. declare module "babylonjs/Gizmos/rotationGizmo" {
  55080. import { Observable } from "babylonjs/Misc/observable";
  55081. import { Nullable } from "babylonjs/types";
  55082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55083. import { Mesh } from "babylonjs/Meshes/mesh";
  55084. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55085. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55086. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55087. import { Node } from "babylonjs/node";
  55088. /**
  55089. * Gizmo that enables rotating a mesh along 3 axis
  55090. */
  55091. export class RotationGizmo extends Gizmo {
  55092. /**
  55093. * Internal gizmo used for interactions on the x axis
  55094. */
  55095. xGizmo: PlaneRotationGizmo;
  55096. /**
  55097. * Internal gizmo used for interactions on the y axis
  55098. */
  55099. yGizmo: PlaneRotationGizmo;
  55100. /**
  55101. * Internal gizmo used for interactions on the z axis
  55102. */
  55103. zGizmo: PlaneRotationGizmo;
  55104. /** Fires an event when any of it's sub gizmos are dragged */
  55105. onDragStartObservable: Observable<unknown>;
  55106. /** Fires an event when any of it's sub gizmos are released from dragging */
  55107. onDragEndObservable: Observable<unknown>;
  55108. private _meshAttached;
  55109. private _nodeAttached;
  55110. get attachedMesh(): Nullable<AbstractMesh>;
  55111. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55112. get attachedNode(): Nullable<Node>;
  55113. set attachedNode(node: Nullable<Node>);
  55114. /**
  55115. * Creates a RotationGizmo
  55116. * @param gizmoLayer The utility layer the gizmo will be added to
  55117. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55118. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55119. */
  55120. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  55121. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55122. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55123. /**
  55124. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55125. */
  55126. set snapDistance(value: number);
  55127. get snapDistance(): number;
  55128. /**
  55129. * Ratio for the scale of the gizmo (Default: 1)
  55130. */
  55131. set scaleRatio(value: number);
  55132. get scaleRatio(): number;
  55133. /**
  55134. * Disposes of the gizmo
  55135. */
  55136. dispose(): void;
  55137. /**
  55138. * CustomMeshes are not supported by this gizmo
  55139. * @param mesh The mesh to replace the default mesh of the gizmo
  55140. */
  55141. setCustomMesh(mesh: Mesh): void;
  55142. }
  55143. }
  55144. declare module "babylonjs/Gizmos/gizmoManager" {
  55145. import { Observable } from "babylonjs/Misc/observable";
  55146. import { Nullable } from "babylonjs/types";
  55147. import { Scene, IDisposable } from "babylonjs/scene";
  55148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55149. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55150. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55151. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55152. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55153. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55154. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55155. /**
  55156. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55157. */
  55158. export class GizmoManager implements IDisposable {
  55159. private scene;
  55160. /**
  55161. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55162. */
  55163. gizmos: {
  55164. positionGizmo: Nullable<PositionGizmo>;
  55165. rotationGizmo: Nullable<RotationGizmo>;
  55166. scaleGizmo: Nullable<ScaleGizmo>;
  55167. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55168. };
  55169. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55170. clearGizmoOnEmptyPointerEvent: boolean;
  55171. /** Fires an event when the manager is attached to a mesh */
  55172. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55173. private _gizmosEnabled;
  55174. private _pointerObserver;
  55175. private _attachedMesh;
  55176. private _boundingBoxColor;
  55177. private _defaultUtilityLayer;
  55178. private _defaultKeepDepthUtilityLayer;
  55179. /**
  55180. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55181. */
  55182. boundingBoxDragBehavior: SixDofDragBehavior;
  55183. /**
  55184. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55185. */
  55186. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55187. /**
  55188. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55189. */
  55190. usePointerToAttachGizmos: boolean;
  55191. /**
  55192. * Utility layer that the bounding box gizmo belongs to
  55193. */
  55194. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55195. /**
  55196. * Utility layer that all gizmos besides bounding box belong to
  55197. */
  55198. get utilityLayer(): UtilityLayerRenderer;
  55199. /**
  55200. * Instatiates a gizmo manager
  55201. * @param scene the scene to overlay the gizmos on top of
  55202. */
  55203. constructor(scene: Scene);
  55204. /**
  55205. * Attaches a set of gizmos to the specified mesh
  55206. * @param mesh The mesh the gizmo's should be attached to
  55207. */
  55208. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55209. /**
  55210. * If the position gizmo is enabled
  55211. */
  55212. set positionGizmoEnabled(value: boolean);
  55213. get positionGizmoEnabled(): boolean;
  55214. /**
  55215. * If the rotation gizmo is enabled
  55216. */
  55217. set rotationGizmoEnabled(value: boolean);
  55218. get rotationGizmoEnabled(): boolean;
  55219. /**
  55220. * If the scale gizmo is enabled
  55221. */
  55222. set scaleGizmoEnabled(value: boolean);
  55223. get scaleGizmoEnabled(): boolean;
  55224. /**
  55225. * If the boundingBox gizmo is enabled
  55226. */
  55227. set boundingBoxGizmoEnabled(value: boolean);
  55228. get boundingBoxGizmoEnabled(): boolean;
  55229. /**
  55230. * Disposes of the gizmo manager
  55231. */
  55232. dispose(): void;
  55233. }
  55234. }
  55235. declare module "babylonjs/Lights/directionalLight" {
  55236. import { Camera } from "babylonjs/Cameras/camera";
  55237. import { Scene } from "babylonjs/scene";
  55238. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55240. import { Light } from "babylonjs/Lights/light";
  55241. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55242. import { Effect } from "babylonjs/Materials/effect";
  55243. /**
  55244. * A directional light is defined by a direction (what a surprise!).
  55245. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55246. * 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.
  55247. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55248. */
  55249. export class DirectionalLight extends ShadowLight {
  55250. private _shadowFrustumSize;
  55251. /**
  55252. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55253. */
  55254. get shadowFrustumSize(): number;
  55255. /**
  55256. * Specifies a fix frustum size for the shadow generation.
  55257. */
  55258. set shadowFrustumSize(value: number);
  55259. private _shadowOrthoScale;
  55260. /**
  55261. * Gets the shadow projection scale against the optimal computed one.
  55262. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55263. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55264. */
  55265. get shadowOrthoScale(): number;
  55266. /**
  55267. * Sets the shadow projection scale against the optimal computed one.
  55268. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55269. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55270. */
  55271. set shadowOrthoScale(value: number);
  55272. /**
  55273. * Automatically compute the projection matrix to best fit (including all the casters)
  55274. * on each frame.
  55275. */
  55276. autoUpdateExtends: boolean;
  55277. /**
  55278. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55279. * on each frame. autoUpdateExtends must be set to true for this to work
  55280. */
  55281. autoCalcShadowZBounds: boolean;
  55282. private _orthoLeft;
  55283. private _orthoRight;
  55284. private _orthoTop;
  55285. private _orthoBottom;
  55286. /**
  55287. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55288. * The directional light is emitted from everywhere in the given direction.
  55289. * It can cast shadows.
  55290. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55291. * @param name The friendly name of the light
  55292. * @param direction The direction of the light
  55293. * @param scene The scene the light belongs to
  55294. */
  55295. constructor(name: string, direction: Vector3, scene: Scene);
  55296. /**
  55297. * Returns the string "DirectionalLight".
  55298. * @return The class name
  55299. */
  55300. getClassName(): string;
  55301. /**
  55302. * Returns the integer 1.
  55303. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55304. */
  55305. getTypeID(): number;
  55306. /**
  55307. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55308. * Returns the DirectionalLight Shadow projection matrix.
  55309. */
  55310. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55311. /**
  55312. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55313. * Returns the DirectionalLight Shadow projection matrix.
  55314. */
  55315. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55316. /**
  55317. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55318. * Returns the DirectionalLight Shadow projection matrix.
  55319. */
  55320. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55321. protected _buildUniformLayout(): void;
  55322. /**
  55323. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55324. * @param effect The effect to update
  55325. * @param lightIndex The index of the light in the effect to update
  55326. * @returns The directional light
  55327. */
  55328. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55329. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55330. /**
  55331. * Gets the minZ used for shadow according to both the scene and the light.
  55332. *
  55333. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55334. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55335. * @param activeCamera The camera we are returning the min for
  55336. * @returns the depth min z
  55337. */
  55338. getDepthMinZ(activeCamera: Camera): number;
  55339. /**
  55340. * Gets the maxZ used for shadow according to both the scene and the light.
  55341. *
  55342. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55343. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55344. * @param activeCamera The camera we are returning the max for
  55345. * @returns the depth max z
  55346. */
  55347. getDepthMaxZ(activeCamera: Camera): number;
  55348. /**
  55349. * Prepares the list of defines specific to the light type.
  55350. * @param defines the list of defines
  55351. * @param lightIndex defines the index of the light for the effect
  55352. */
  55353. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55354. }
  55355. }
  55356. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55357. import { Mesh } from "babylonjs/Meshes/mesh";
  55358. /**
  55359. * Class containing static functions to help procedurally build meshes
  55360. */
  55361. export class HemisphereBuilder {
  55362. /**
  55363. * Creates a hemisphere mesh
  55364. * @param name defines the name of the mesh
  55365. * @param options defines the options used to create the mesh
  55366. * @param scene defines the hosting scene
  55367. * @returns the hemisphere mesh
  55368. */
  55369. static CreateHemisphere(name: string, options: {
  55370. segments?: number;
  55371. diameter?: number;
  55372. sideOrientation?: number;
  55373. }, scene: any): Mesh;
  55374. }
  55375. }
  55376. declare module "babylonjs/Lights/spotLight" {
  55377. import { Nullable } from "babylonjs/types";
  55378. import { Scene } from "babylonjs/scene";
  55379. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55381. import { Effect } from "babylonjs/Materials/effect";
  55382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55383. import { Light } from "babylonjs/Lights/light";
  55384. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55385. /**
  55386. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55387. * These values define a cone of light starting from the position, emitting toward the direction.
  55388. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55389. * and the exponent defines the speed of the decay of the light with distance (reach).
  55390. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55391. */
  55392. export class SpotLight extends ShadowLight {
  55393. private _angle;
  55394. private _innerAngle;
  55395. private _cosHalfAngle;
  55396. private _lightAngleScale;
  55397. private _lightAngleOffset;
  55398. /**
  55399. * Gets the cone angle of the spot light in Radians.
  55400. */
  55401. get angle(): number;
  55402. /**
  55403. * Sets the cone angle of the spot light in Radians.
  55404. */
  55405. set angle(value: number);
  55406. /**
  55407. * Only used in gltf falloff mode, this defines the angle where
  55408. * the directional falloff will start before cutting at angle which could be seen
  55409. * as outer angle.
  55410. */
  55411. get innerAngle(): number;
  55412. /**
  55413. * Only used in gltf falloff mode, this defines the angle where
  55414. * the directional falloff will start before cutting at angle which could be seen
  55415. * as outer angle.
  55416. */
  55417. set innerAngle(value: number);
  55418. private _shadowAngleScale;
  55419. /**
  55420. * Allows scaling the angle of the light for shadow generation only.
  55421. */
  55422. get shadowAngleScale(): number;
  55423. /**
  55424. * Allows scaling the angle of the light for shadow generation only.
  55425. */
  55426. set shadowAngleScale(value: number);
  55427. /**
  55428. * The light decay speed with the distance from the emission spot.
  55429. */
  55430. exponent: number;
  55431. private _projectionTextureMatrix;
  55432. /**
  55433. * Allows reading the projecton texture
  55434. */
  55435. get projectionTextureMatrix(): Matrix;
  55436. protected _projectionTextureLightNear: number;
  55437. /**
  55438. * Gets the near clip of the Spotlight for texture projection.
  55439. */
  55440. get projectionTextureLightNear(): number;
  55441. /**
  55442. * Sets the near clip of the Spotlight for texture projection.
  55443. */
  55444. set projectionTextureLightNear(value: number);
  55445. protected _projectionTextureLightFar: number;
  55446. /**
  55447. * Gets the far clip of the Spotlight for texture projection.
  55448. */
  55449. get projectionTextureLightFar(): number;
  55450. /**
  55451. * Sets the far clip of the Spotlight for texture projection.
  55452. */
  55453. set projectionTextureLightFar(value: number);
  55454. protected _projectionTextureUpDirection: Vector3;
  55455. /**
  55456. * Gets the Up vector of the Spotlight for texture projection.
  55457. */
  55458. get projectionTextureUpDirection(): Vector3;
  55459. /**
  55460. * Sets the Up vector of the Spotlight for texture projection.
  55461. */
  55462. set projectionTextureUpDirection(value: Vector3);
  55463. private _projectionTexture;
  55464. /**
  55465. * Gets the projection texture of the light.
  55466. */
  55467. get projectionTexture(): Nullable<BaseTexture>;
  55468. /**
  55469. * Sets the projection texture of the light.
  55470. */
  55471. set projectionTexture(value: Nullable<BaseTexture>);
  55472. private _projectionTextureViewLightDirty;
  55473. private _projectionTextureProjectionLightDirty;
  55474. private _projectionTextureDirty;
  55475. private _projectionTextureViewTargetVector;
  55476. private _projectionTextureViewLightMatrix;
  55477. private _projectionTextureProjectionLightMatrix;
  55478. private _projectionTextureScalingMatrix;
  55479. /**
  55480. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55481. * It can cast shadows.
  55482. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55483. * @param name The light friendly name
  55484. * @param position The position of the spot light in the scene
  55485. * @param direction The direction of the light in the scene
  55486. * @param angle The cone angle of the light in Radians
  55487. * @param exponent The light decay speed with the distance from the emission spot
  55488. * @param scene The scene the lights belongs to
  55489. */
  55490. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55491. /**
  55492. * Returns the string "SpotLight".
  55493. * @returns the class name
  55494. */
  55495. getClassName(): string;
  55496. /**
  55497. * Returns the integer 2.
  55498. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55499. */
  55500. getTypeID(): number;
  55501. /**
  55502. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55503. */
  55504. protected _setDirection(value: Vector3): void;
  55505. /**
  55506. * Overrides the position setter to recompute the projection texture view light Matrix.
  55507. */
  55508. protected _setPosition(value: Vector3): void;
  55509. /**
  55510. * 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.
  55511. * Returns the SpotLight.
  55512. */
  55513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55514. protected _computeProjectionTextureViewLightMatrix(): void;
  55515. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55516. /**
  55517. * Main function for light texture projection matrix computing.
  55518. */
  55519. protected _computeProjectionTextureMatrix(): void;
  55520. protected _buildUniformLayout(): void;
  55521. private _computeAngleValues;
  55522. /**
  55523. * Sets the passed Effect "effect" with the Light textures.
  55524. * @param effect The effect to update
  55525. * @param lightIndex The index of the light in the effect to update
  55526. * @returns The light
  55527. */
  55528. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55529. /**
  55530. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55531. * @param effect The effect to update
  55532. * @param lightIndex The index of the light in the effect to update
  55533. * @returns The spot light
  55534. */
  55535. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55536. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55537. /**
  55538. * Disposes the light and the associated resources.
  55539. */
  55540. dispose(): void;
  55541. /**
  55542. * Prepares the list of defines specific to the light type.
  55543. * @param defines the list of defines
  55544. * @param lightIndex defines the index of the light for the effect
  55545. */
  55546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55547. }
  55548. }
  55549. declare module "babylonjs/Gizmos/lightGizmo" {
  55550. import { Nullable } from "babylonjs/types";
  55551. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55552. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55553. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55554. import { Light } from "babylonjs/Lights/light";
  55555. /**
  55556. * Gizmo that enables viewing a light
  55557. */
  55558. export class LightGizmo extends Gizmo {
  55559. private _lightMesh;
  55560. private _material;
  55561. private _cachedPosition;
  55562. private _cachedForward;
  55563. private _attachedMeshParent;
  55564. /**
  55565. * Creates a LightGizmo
  55566. * @param gizmoLayer The utility layer the gizmo will be added to
  55567. */
  55568. constructor(gizmoLayer?: UtilityLayerRenderer);
  55569. private _light;
  55570. /**
  55571. * The light that the gizmo is attached to
  55572. */
  55573. set light(light: Nullable<Light>);
  55574. get light(): Nullable<Light>;
  55575. /**
  55576. * Gets the material used to render the light gizmo
  55577. */
  55578. get material(): StandardMaterial;
  55579. /**
  55580. * @hidden
  55581. * Updates the gizmo to match the attached mesh's position/rotation
  55582. */
  55583. protected _update(): void;
  55584. private static _Scale;
  55585. /**
  55586. * Creates the lines for a light mesh
  55587. */
  55588. private static _CreateLightLines;
  55589. /**
  55590. * Disposes of the light gizmo
  55591. */
  55592. dispose(): void;
  55593. private static _CreateHemisphericLightMesh;
  55594. private static _CreatePointLightMesh;
  55595. private static _CreateSpotLightMesh;
  55596. private static _CreateDirectionalLightMesh;
  55597. }
  55598. }
  55599. declare module "babylonjs/Gizmos/index" {
  55600. export * from "babylonjs/Gizmos/axisDragGizmo";
  55601. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55602. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55603. export * from "babylonjs/Gizmos/gizmo";
  55604. export * from "babylonjs/Gizmos/gizmoManager";
  55605. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55606. export * from "babylonjs/Gizmos/positionGizmo";
  55607. export * from "babylonjs/Gizmos/rotationGizmo";
  55608. export * from "babylonjs/Gizmos/scaleGizmo";
  55609. export * from "babylonjs/Gizmos/lightGizmo";
  55610. export * from "babylonjs/Gizmos/planeDragGizmo";
  55611. }
  55612. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55613. /** @hidden */
  55614. export var backgroundFragmentDeclaration: {
  55615. name: string;
  55616. shader: string;
  55617. };
  55618. }
  55619. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55620. /** @hidden */
  55621. export var backgroundUboDeclaration: {
  55622. name: string;
  55623. shader: string;
  55624. };
  55625. }
  55626. declare module "babylonjs/Shaders/background.fragment" {
  55627. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55628. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55629. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55630. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55631. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55632. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55634. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55635. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55636. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55637. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55638. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55639. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55640. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55641. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55642. /** @hidden */
  55643. export var backgroundPixelShader: {
  55644. name: string;
  55645. shader: string;
  55646. };
  55647. }
  55648. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55649. /** @hidden */
  55650. export var backgroundVertexDeclaration: {
  55651. name: string;
  55652. shader: string;
  55653. };
  55654. }
  55655. declare module "babylonjs/Shaders/background.vertex" {
  55656. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55657. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55658. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55659. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55660. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55661. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55662. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55663. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55664. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55665. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55666. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55667. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55668. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55669. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55670. /** @hidden */
  55671. export var backgroundVertexShader: {
  55672. name: string;
  55673. shader: string;
  55674. };
  55675. }
  55676. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55677. import { Nullable, int, float } from "babylonjs/types";
  55678. import { Scene } from "babylonjs/scene";
  55679. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55680. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55682. import { Mesh } from "babylonjs/Meshes/mesh";
  55683. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55684. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55685. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55687. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55688. import { Color3 } from "babylonjs/Maths/math.color";
  55689. import "babylonjs/Shaders/background.fragment";
  55690. import "babylonjs/Shaders/background.vertex";
  55691. /**
  55692. * Background material used to create an efficient environement around your scene.
  55693. */
  55694. export class BackgroundMaterial extends PushMaterial {
  55695. /**
  55696. * Standard reflectance value at parallel view angle.
  55697. */
  55698. static StandardReflectance0: number;
  55699. /**
  55700. * Standard reflectance value at grazing angle.
  55701. */
  55702. static StandardReflectance90: number;
  55703. protected _primaryColor: Color3;
  55704. /**
  55705. * Key light Color (multiply against the environement texture)
  55706. */
  55707. primaryColor: Color3;
  55708. protected __perceptualColor: Nullable<Color3>;
  55709. /**
  55710. * Experimental Internal Use Only.
  55711. *
  55712. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55713. * This acts as a helper to set the primary color to a more "human friendly" value.
  55714. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55715. * output color as close as possible from the chosen value.
  55716. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55717. * part of lighting setup.)
  55718. */
  55719. get _perceptualColor(): Nullable<Color3>;
  55720. set _perceptualColor(value: Nullable<Color3>);
  55721. protected _primaryColorShadowLevel: float;
  55722. /**
  55723. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55724. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55725. */
  55726. get primaryColorShadowLevel(): float;
  55727. set primaryColorShadowLevel(value: float);
  55728. protected _primaryColorHighlightLevel: float;
  55729. /**
  55730. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55731. * The primary color is used at the level chosen to define what the white area would look.
  55732. */
  55733. get primaryColorHighlightLevel(): float;
  55734. set primaryColorHighlightLevel(value: float);
  55735. protected _reflectionTexture: Nullable<BaseTexture>;
  55736. /**
  55737. * Reflection Texture used in the material.
  55738. * Should be author in a specific way for the best result (refer to the documentation).
  55739. */
  55740. reflectionTexture: Nullable<BaseTexture>;
  55741. protected _reflectionBlur: float;
  55742. /**
  55743. * Reflection Texture level of blur.
  55744. *
  55745. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55746. * texture twice.
  55747. */
  55748. reflectionBlur: float;
  55749. protected _diffuseTexture: Nullable<BaseTexture>;
  55750. /**
  55751. * Diffuse Texture used in the material.
  55752. * Should be author in a specific way for the best result (refer to the documentation).
  55753. */
  55754. diffuseTexture: Nullable<BaseTexture>;
  55755. protected _shadowLights: Nullable<IShadowLight[]>;
  55756. /**
  55757. * Specify the list of lights casting shadow on the material.
  55758. * All scene shadow lights will be included if null.
  55759. */
  55760. shadowLights: Nullable<IShadowLight[]>;
  55761. protected _shadowLevel: float;
  55762. /**
  55763. * Helps adjusting the shadow to a softer level if required.
  55764. * 0 means black shadows and 1 means no shadows.
  55765. */
  55766. shadowLevel: float;
  55767. protected _sceneCenter: Vector3;
  55768. /**
  55769. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55770. * It is usually zero but might be interesting to modify according to your setup.
  55771. */
  55772. sceneCenter: Vector3;
  55773. protected _opacityFresnel: boolean;
  55774. /**
  55775. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55776. * This helps ensuring a nice transition when the camera goes under the ground.
  55777. */
  55778. opacityFresnel: boolean;
  55779. protected _reflectionFresnel: boolean;
  55780. /**
  55781. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55782. * This helps adding a mirror texture on the ground.
  55783. */
  55784. reflectionFresnel: boolean;
  55785. protected _reflectionFalloffDistance: number;
  55786. /**
  55787. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55788. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55789. */
  55790. reflectionFalloffDistance: number;
  55791. protected _reflectionAmount: number;
  55792. /**
  55793. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55794. */
  55795. reflectionAmount: number;
  55796. protected _reflectionReflectance0: number;
  55797. /**
  55798. * This specifies the weight of the reflection at grazing angle.
  55799. */
  55800. reflectionReflectance0: number;
  55801. protected _reflectionReflectance90: number;
  55802. /**
  55803. * This specifies the weight of the reflection at a perpendicular point of view.
  55804. */
  55805. reflectionReflectance90: number;
  55806. /**
  55807. * Sets the reflection reflectance fresnel values according to the default standard
  55808. * empirically know to work well :-)
  55809. */
  55810. set reflectionStandardFresnelWeight(value: number);
  55811. protected _useRGBColor: boolean;
  55812. /**
  55813. * Helps to directly use the maps channels instead of their level.
  55814. */
  55815. useRGBColor: boolean;
  55816. protected _enableNoise: boolean;
  55817. /**
  55818. * This helps reducing the banding effect that could occur on the background.
  55819. */
  55820. enableNoise: boolean;
  55821. /**
  55822. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55823. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55824. * Recommended to be keep at 1.0 except for special cases.
  55825. */
  55826. get fovMultiplier(): number;
  55827. set fovMultiplier(value: number);
  55828. private _fovMultiplier;
  55829. /**
  55830. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55831. */
  55832. useEquirectangularFOV: boolean;
  55833. private _maxSimultaneousLights;
  55834. /**
  55835. * Number of Simultaneous lights allowed on the material.
  55836. */
  55837. maxSimultaneousLights: int;
  55838. private _shadowOnly;
  55839. /**
  55840. * Make the material only render shadows
  55841. */
  55842. shadowOnly: boolean;
  55843. /**
  55844. * Default configuration related to image processing available in the Background Material.
  55845. */
  55846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55847. /**
  55848. * Keep track of the image processing observer to allow dispose and replace.
  55849. */
  55850. private _imageProcessingObserver;
  55851. /**
  55852. * Attaches a new image processing configuration to the PBR Material.
  55853. * @param configuration (if null the scene configuration will be use)
  55854. */
  55855. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55856. /**
  55857. * Gets the image processing configuration used either in this material.
  55858. */
  55859. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55860. /**
  55861. * Sets the Default image processing configuration used either in the this material.
  55862. *
  55863. * If sets to null, the scene one is in use.
  55864. */
  55865. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55866. /**
  55867. * Gets wether the color curves effect is enabled.
  55868. */
  55869. get cameraColorCurvesEnabled(): boolean;
  55870. /**
  55871. * Sets wether the color curves effect is enabled.
  55872. */
  55873. set cameraColorCurvesEnabled(value: boolean);
  55874. /**
  55875. * Gets wether the color grading effect is enabled.
  55876. */
  55877. get cameraColorGradingEnabled(): boolean;
  55878. /**
  55879. * Gets wether the color grading effect is enabled.
  55880. */
  55881. set cameraColorGradingEnabled(value: boolean);
  55882. /**
  55883. * Gets wether tonemapping is enabled or not.
  55884. */
  55885. get cameraToneMappingEnabled(): boolean;
  55886. /**
  55887. * Sets wether tonemapping is enabled or not
  55888. */
  55889. set cameraToneMappingEnabled(value: boolean);
  55890. /**
  55891. * The camera exposure used on this material.
  55892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55893. * This corresponds to a photographic exposure.
  55894. */
  55895. get cameraExposure(): float;
  55896. /**
  55897. * The camera exposure used on this material.
  55898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55899. * This corresponds to a photographic exposure.
  55900. */
  55901. set cameraExposure(value: float);
  55902. /**
  55903. * Gets The camera contrast used on this material.
  55904. */
  55905. get cameraContrast(): float;
  55906. /**
  55907. * Sets The camera contrast used on this material.
  55908. */
  55909. set cameraContrast(value: float);
  55910. /**
  55911. * Gets the Color Grading 2D Lookup Texture.
  55912. */
  55913. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55914. /**
  55915. * Sets the Color Grading 2D Lookup Texture.
  55916. */
  55917. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55918. /**
  55919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55921. * 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;
  55922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55923. */
  55924. get cameraColorCurves(): Nullable<ColorCurves>;
  55925. /**
  55926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55928. * 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;
  55929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55930. */
  55931. set cameraColorCurves(value: Nullable<ColorCurves>);
  55932. /**
  55933. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55934. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55935. */
  55936. switchToBGR: boolean;
  55937. private _renderTargets;
  55938. private _reflectionControls;
  55939. private _white;
  55940. private _primaryShadowColor;
  55941. private _primaryHighlightColor;
  55942. /**
  55943. * Instantiates a Background Material in the given scene
  55944. * @param name The friendly name of the material
  55945. * @param scene The scene to add the material to
  55946. */
  55947. constructor(name: string, scene: Scene);
  55948. /**
  55949. * Gets a boolean indicating that current material needs to register RTT
  55950. */
  55951. get hasRenderTargetTextures(): boolean;
  55952. /**
  55953. * The entire material has been created in order to prevent overdraw.
  55954. * @returns false
  55955. */
  55956. needAlphaTesting(): boolean;
  55957. /**
  55958. * The entire material has been created in order to prevent overdraw.
  55959. * @returns true if blending is enable
  55960. */
  55961. needAlphaBlending(): boolean;
  55962. /**
  55963. * Checks wether the material is ready to be rendered for a given mesh.
  55964. * @param mesh The mesh to render
  55965. * @param subMesh The submesh to check against
  55966. * @param useInstances Specify wether or not the material is used with instances
  55967. * @returns true if all the dependencies are ready (Textures, Effects...)
  55968. */
  55969. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55970. /**
  55971. * Compute the primary color according to the chosen perceptual color.
  55972. */
  55973. private _computePrimaryColorFromPerceptualColor;
  55974. /**
  55975. * Compute the highlights and shadow colors according to their chosen levels.
  55976. */
  55977. private _computePrimaryColors;
  55978. /**
  55979. * Build the uniform buffer used in the material.
  55980. */
  55981. buildUniformLayout(): void;
  55982. /**
  55983. * Unbind the material.
  55984. */
  55985. unbind(): void;
  55986. /**
  55987. * Bind only the world matrix to the material.
  55988. * @param world The world matrix to bind.
  55989. */
  55990. bindOnlyWorldMatrix(world: Matrix): void;
  55991. /**
  55992. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55993. * @param world The world matrix to bind.
  55994. * @param subMesh The submesh to bind for.
  55995. */
  55996. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55997. /**
  55998. * Checks to see if a texture is used in the material.
  55999. * @param texture - Base texture to use.
  56000. * @returns - Boolean specifying if a texture is used in the material.
  56001. */
  56002. hasTexture(texture: BaseTexture): boolean;
  56003. /**
  56004. * Dispose the material.
  56005. * @param forceDisposeEffect Force disposal of the associated effect.
  56006. * @param forceDisposeTextures Force disposal of the associated textures.
  56007. */
  56008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56009. /**
  56010. * Clones the material.
  56011. * @param name The cloned name.
  56012. * @returns The cloned material.
  56013. */
  56014. clone(name: string): BackgroundMaterial;
  56015. /**
  56016. * Serializes the current material to its JSON representation.
  56017. * @returns The JSON representation.
  56018. */
  56019. serialize(): any;
  56020. /**
  56021. * Gets the class name of the material
  56022. * @returns "BackgroundMaterial"
  56023. */
  56024. getClassName(): string;
  56025. /**
  56026. * Parse a JSON input to create back a background material.
  56027. * @param source The JSON data to parse
  56028. * @param scene The scene to create the parsed material in
  56029. * @param rootUrl The root url of the assets the material depends upon
  56030. * @returns the instantiated BackgroundMaterial.
  56031. */
  56032. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56033. }
  56034. }
  56035. declare module "babylonjs/Helpers/environmentHelper" {
  56036. import { Observable } from "babylonjs/Misc/observable";
  56037. import { Nullable } from "babylonjs/types";
  56038. import { Scene } from "babylonjs/scene";
  56039. import { Vector3 } from "babylonjs/Maths/math.vector";
  56040. import { Color3 } from "babylonjs/Maths/math.color";
  56041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56042. import { Mesh } from "babylonjs/Meshes/mesh";
  56043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56044. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56045. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56046. import "babylonjs/Meshes/Builders/planeBuilder";
  56047. import "babylonjs/Meshes/Builders/boxBuilder";
  56048. /**
  56049. * Represents the different options available during the creation of
  56050. * a Environment helper.
  56051. *
  56052. * This can control the default ground, skybox and image processing setup of your scene.
  56053. */
  56054. export interface IEnvironmentHelperOptions {
  56055. /**
  56056. * Specifies whether or not to create a ground.
  56057. * True by default.
  56058. */
  56059. createGround: boolean;
  56060. /**
  56061. * Specifies the ground size.
  56062. * 15 by default.
  56063. */
  56064. groundSize: number;
  56065. /**
  56066. * The texture used on the ground for the main color.
  56067. * Comes from the BabylonJS CDN by default.
  56068. *
  56069. * Remarks: Can be either a texture or a url.
  56070. */
  56071. groundTexture: string | BaseTexture;
  56072. /**
  56073. * The color mixed in the ground texture by default.
  56074. * BabylonJS clearColor by default.
  56075. */
  56076. groundColor: Color3;
  56077. /**
  56078. * Specifies the ground opacity.
  56079. * 1 by default.
  56080. */
  56081. groundOpacity: number;
  56082. /**
  56083. * Enables the ground to receive shadows.
  56084. * True by default.
  56085. */
  56086. enableGroundShadow: boolean;
  56087. /**
  56088. * Helps preventing the shadow to be fully black on the ground.
  56089. * 0.5 by default.
  56090. */
  56091. groundShadowLevel: number;
  56092. /**
  56093. * Creates a mirror texture attach to the ground.
  56094. * false by default.
  56095. */
  56096. enableGroundMirror: boolean;
  56097. /**
  56098. * Specifies the ground mirror size ratio.
  56099. * 0.3 by default as the default kernel is 64.
  56100. */
  56101. groundMirrorSizeRatio: number;
  56102. /**
  56103. * Specifies the ground mirror blur kernel size.
  56104. * 64 by default.
  56105. */
  56106. groundMirrorBlurKernel: number;
  56107. /**
  56108. * Specifies the ground mirror visibility amount.
  56109. * 1 by default
  56110. */
  56111. groundMirrorAmount: number;
  56112. /**
  56113. * Specifies the ground mirror reflectance weight.
  56114. * This uses the standard weight of the background material to setup the fresnel effect
  56115. * of the mirror.
  56116. * 1 by default.
  56117. */
  56118. groundMirrorFresnelWeight: number;
  56119. /**
  56120. * Specifies the ground mirror Falloff distance.
  56121. * This can helps reducing the size of the reflection.
  56122. * 0 by Default.
  56123. */
  56124. groundMirrorFallOffDistance: number;
  56125. /**
  56126. * Specifies the ground mirror texture type.
  56127. * Unsigned Int by Default.
  56128. */
  56129. groundMirrorTextureType: number;
  56130. /**
  56131. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56132. * the shown objects.
  56133. */
  56134. groundYBias: number;
  56135. /**
  56136. * Specifies whether or not to create a skybox.
  56137. * True by default.
  56138. */
  56139. createSkybox: boolean;
  56140. /**
  56141. * Specifies the skybox size.
  56142. * 20 by default.
  56143. */
  56144. skyboxSize: number;
  56145. /**
  56146. * The texture used on the skybox for the main color.
  56147. * Comes from the BabylonJS CDN by default.
  56148. *
  56149. * Remarks: Can be either a texture or a url.
  56150. */
  56151. skyboxTexture: string | BaseTexture;
  56152. /**
  56153. * The color mixed in the skybox texture by default.
  56154. * BabylonJS clearColor by default.
  56155. */
  56156. skyboxColor: Color3;
  56157. /**
  56158. * The background rotation around the Y axis of the scene.
  56159. * This helps aligning the key lights of your scene with the background.
  56160. * 0 by default.
  56161. */
  56162. backgroundYRotation: number;
  56163. /**
  56164. * Compute automatically the size of the elements to best fit with the scene.
  56165. */
  56166. sizeAuto: boolean;
  56167. /**
  56168. * Default position of the rootMesh if autoSize is not true.
  56169. */
  56170. rootPosition: Vector3;
  56171. /**
  56172. * Sets up the image processing in the scene.
  56173. * true by default.
  56174. */
  56175. setupImageProcessing: boolean;
  56176. /**
  56177. * The texture used as your environment texture in the scene.
  56178. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56179. *
  56180. * Remarks: Can be either a texture or a url.
  56181. */
  56182. environmentTexture: string | BaseTexture;
  56183. /**
  56184. * The value of the exposure to apply to the scene.
  56185. * 0.6 by default if setupImageProcessing is true.
  56186. */
  56187. cameraExposure: number;
  56188. /**
  56189. * The value of the contrast to apply to the scene.
  56190. * 1.6 by default if setupImageProcessing is true.
  56191. */
  56192. cameraContrast: number;
  56193. /**
  56194. * Specifies whether or not tonemapping should be enabled in the scene.
  56195. * true by default if setupImageProcessing is true.
  56196. */
  56197. toneMappingEnabled: boolean;
  56198. }
  56199. /**
  56200. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56201. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56202. * It also helps with the default setup of your imageProcessing configuration.
  56203. */
  56204. export class EnvironmentHelper {
  56205. /**
  56206. * Default ground texture URL.
  56207. */
  56208. private static _groundTextureCDNUrl;
  56209. /**
  56210. * Default skybox texture URL.
  56211. */
  56212. private static _skyboxTextureCDNUrl;
  56213. /**
  56214. * Default environment texture URL.
  56215. */
  56216. private static _environmentTextureCDNUrl;
  56217. /**
  56218. * Creates the default options for the helper.
  56219. */
  56220. private static _getDefaultOptions;
  56221. private _rootMesh;
  56222. /**
  56223. * Gets the root mesh created by the helper.
  56224. */
  56225. get rootMesh(): Mesh;
  56226. private _skybox;
  56227. /**
  56228. * Gets the skybox created by the helper.
  56229. */
  56230. get skybox(): Nullable<Mesh>;
  56231. private _skyboxTexture;
  56232. /**
  56233. * Gets the skybox texture created by the helper.
  56234. */
  56235. get skyboxTexture(): Nullable<BaseTexture>;
  56236. private _skyboxMaterial;
  56237. /**
  56238. * Gets the skybox material created by the helper.
  56239. */
  56240. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56241. private _ground;
  56242. /**
  56243. * Gets the ground mesh created by the helper.
  56244. */
  56245. get ground(): Nullable<Mesh>;
  56246. private _groundTexture;
  56247. /**
  56248. * Gets the ground texture created by the helper.
  56249. */
  56250. get groundTexture(): Nullable<BaseTexture>;
  56251. private _groundMirror;
  56252. /**
  56253. * Gets the ground mirror created by the helper.
  56254. */
  56255. get groundMirror(): Nullable<MirrorTexture>;
  56256. /**
  56257. * Gets the ground mirror render list to helps pushing the meshes
  56258. * you wish in the ground reflection.
  56259. */
  56260. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56261. private _groundMaterial;
  56262. /**
  56263. * Gets the ground material created by the helper.
  56264. */
  56265. get groundMaterial(): Nullable<BackgroundMaterial>;
  56266. /**
  56267. * Stores the creation options.
  56268. */
  56269. private readonly _scene;
  56270. private _options;
  56271. /**
  56272. * This observable will be notified with any error during the creation of the environment,
  56273. * mainly texture creation errors.
  56274. */
  56275. onErrorObservable: Observable<{
  56276. message?: string;
  56277. exception?: any;
  56278. }>;
  56279. /**
  56280. * constructor
  56281. * @param options Defines the options we want to customize the helper
  56282. * @param scene The scene to add the material to
  56283. */
  56284. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56285. /**
  56286. * Updates the background according to the new options
  56287. * @param options
  56288. */
  56289. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56290. /**
  56291. * Sets the primary color of all the available elements.
  56292. * @param color the main color to affect to the ground and the background
  56293. */
  56294. setMainColor(color: Color3): void;
  56295. /**
  56296. * Setup the image processing according to the specified options.
  56297. */
  56298. private _setupImageProcessing;
  56299. /**
  56300. * Setup the environment texture according to the specified options.
  56301. */
  56302. private _setupEnvironmentTexture;
  56303. /**
  56304. * Setup the background according to the specified options.
  56305. */
  56306. private _setupBackground;
  56307. /**
  56308. * Get the scene sizes according to the setup.
  56309. */
  56310. private _getSceneSize;
  56311. /**
  56312. * Setup the ground according to the specified options.
  56313. */
  56314. private _setupGround;
  56315. /**
  56316. * Setup the ground material according to the specified options.
  56317. */
  56318. private _setupGroundMaterial;
  56319. /**
  56320. * Setup the ground diffuse texture according to the specified options.
  56321. */
  56322. private _setupGroundDiffuseTexture;
  56323. /**
  56324. * Setup the ground mirror texture according to the specified options.
  56325. */
  56326. private _setupGroundMirrorTexture;
  56327. /**
  56328. * Setup the ground to receive the mirror texture.
  56329. */
  56330. private _setupMirrorInGroundMaterial;
  56331. /**
  56332. * Setup the skybox according to the specified options.
  56333. */
  56334. private _setupSkybox;
  56335. /**
  56336. * Setup the skybox material according to the specified options.
  56337. */
  56338. private _setupSkyboxMaterial;
  56339. /**
  56340. * Setup the skybox reflection texture according to the specified options.
  56341. */
  56342. private _setupSkyboxReflectionTexture;
  56343. private _errorHandler;
  56344. /**
  56345. * Dispose all the elements created by the Helper.
  56346. */
  56347. dispose(): void;
  56348. }
  56349. }
  56350. declare module "babylonjs/Helpers/photoDome" {
  56351. import { Observable } from "babylonjs/Misc/observable";
  56352. import { Nullable } from "babylonjs/types";
  56353. import { Scene } from "babylonjs/scene";
  56354. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56355. import { Mesh } from "babylonjs/Meshes/mesh";
  56356. import { Texture } from "babylonjs/Materials/Textures/texture";
  56357. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56358. import "babylonjs/Meshes/Builders/sphereBuilder";
  56359. /**
  56360. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56361. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56362. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56363. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56364. */
  56365. export class PhotoDome extends TransformNode {
  56366. /**
  56367. * Define the image as a Monoscopic panoramic 360 image.
  56368. */
  56369. static readonly MODE_MONOSCOPIC: number;
  56370. /**
  56371. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56372. */
  56373. static readonly MODE_TOPBOTTOM: number;
  56374. /**
  56375. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56376. */
  56377. static readonly MODE_SIDEBYSIDE: number;
  56378. private _useDirectMapping;
  56379. /**
  56380. * The texture being displayed on the sphere
  56381. */
  56382. protected _photoTexture: Texture;
  56383. /**
  56384. * Gets or sets the texture being displayed on the sphere
  56385. */
  56386. get photoTexture(): Texture;
  56387. set photoTexture(value: Texture);
  56388. /**
  56389. * Observable raised when an error occured while loading the 360 image
  56390. */
  56391. onLoadErrorObservable: Observable<string>;
  56392. /**
  56393. * The skybox material
  56394. */
  56395. protected _material: BackgroundMaterial;
  56396. /**
  56397. * The surface used for the skybox
  56398. */
  56399. protected _mesh: Mesh;
  56400. /**
  56401. * Gets the mesh used for the skybox.
  56402. */
  56403. get mesh(): Mesh;
  56404. /**
  56405. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56406. * Also see the options.resolution property.
  56407. */
  56408. get fovMultiplier(): number;
  56409. set fovMultiplier(value: number);
  56410. private _imageMode;
  56411. /**
  56412. * Gets or set the current video mode for the video. It can be:
  56413. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56414. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56415. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56416. */
  56417. get imageMode(): number;
  56418. set imageMode(value: number);
  56419. /**
  56420. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56421. * @param name Element's name, child elements will append suffixes for their own names.
  56422. * @param urlsOfPhoto defines the url of the photo to display
  56423. * @param options defines an object containing optional or exposed sub element properties
  56424. * @param onError defines a callback called when an error occured while loading the texture
  56425. */
  56426. constructor(name: string, urlOfPhoto: string, options: {
  56427. resolution?: number;
  56428. size?: number;
  56429. useDirectMapping?: boolean;
  56430. faceForward?: boolean;
  56431. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56432. private _onBeforeCameraRenderObserver;
  56433. private _changeImageMode;
  56434. /**
  56435. * Releases resources associated with this node.
  56436. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56437. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56438. */
  56439. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56440. }
  56441. }
  56442. declare module "babylonjs/Misc/rgbdTextureTools" {
  56443. import "babylonjs/Shaders/rgbdDecode.fragment";
  56444. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56445. import { Texture } from "babylonjs/Materials/Textures/texture";
  56446. /**
  56447. * Class used to host RGBD texture specific utilities
  56448. */
  56449. export class RGBDTextureTools {
  56450. /**
  56451. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56452. * @param texture the texture to expand.
  56453. */
  56454. static ExpandRGBDTexture(texture: Texture): void;
  56455. }
  56456. }
  56457. declare module "babylonjs/Misc/brdfTextureTools" {
  56458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56459. import { Scene } from "babylonjs/scene";
  56460. /**
  56461. * Class used to host texture specific utilities
  56462. */
  56463. export class BRDFTextureTools {
  56464. /**
  56465. * Prevents texture cache collision
  56466. */
  56467. private static _instanceNumber;
  56468. /**
  56469. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56470. * @param scene defines the hosting scene
  56471. * @returns the environment BRDF texture
  56472. */
  56473. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56474. private static _environmentBRDFBase64Texture;
  56475. }
  56476. }
  56477. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56478. import { Nullable } from "babylonjs/types";
  56479. import { Color3 } from "babylonjs/Maths/math.color";
  56480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56483. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56484. import { Engine } from "babylonjs/Engines/engine";
  56485. import { Scene } from "babylonjs/scene";
  56486. /**
  56487. * @hidden
  56488. */
  56489. export interface IMaterialClearCoatDefines {
  56490. CLEARCOAT: boolean;
  56491. CLEARCOAT_DEFAULTIOR: boolean;
  56492. CLEARCOAT_TEXTURE: boolean;
  56493. CLEARCOAT_TEXTUREDIRECTUV: number;
  56494. CLEARCOAT_BUMP: boolean;
  56495. CLEARCOAT_BUMPDIRECTUV: number;
  56496. CLEARCOAT_TINT: boolean;
  56497. CLEARCOAT_TINT_TEXTURE: boolean;
  56498. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56499. /** @hidden */
  56500. _areTexturesDirty: boolean;
  56501. }
  56502. /**
  56503. * Define the code related to the clear coat parameters of the pbr material.
  56504. */
  56505. export class PBRClearCoatConfiguration {
  56506. /**
  56507. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56508. * The default fits with a polyurethane material.
  56509. */
  56510. private static readonly _DefaultIndexOfRefraction;
  56511. private _isEnabled;
  56512. /**
  56513. * Defines if the clear coat is enabled in the material.
  56514. */
  56515. isEnabled: boolean;
  56516. /**
  56517. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56518. */
  56519. intensity: number;
  56520. /**
  56521. * Defines the clear coat layer roughness.
  56522. */
  56523. roughness: number;
  56524. private _indexOfRefraction;
  56525. /**
  56526. * Defines the index of refraction of the clear coat.
  56527. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56528. * The default fits with a polyurethane material.
  56529. * Changing the default value is more performance intensive.
  56530. */
  56531. indexOfRefraction: number;
  56532. private _texture;
  56533. /**
  56534. * Stores the clear coat values in a texture.
  56535. */
  56536. texture: Nullable<BaseTexture>;
  56537. private _bumpTexture;
  56538. /**
  56539. * Define the clear coat specific bump texture.
  56540. */
  56541. bumpTexture: Nullable<BaseTexture>;
  56542. private _isTintEnabled;
  56543. /**
  56544. * Defines if the clear coat tint is enabled in the material.
  56545. */
  56546. isTintEnabled: boolean;
  56547. /**
  56548. * Defines the clear coat tint of the material.
  56549. * This is only use if tint is enabled
  56550. */
  56551. tintColor: Color3;
  56552. /**
  56553. * Defines the distance at which the tint color should be found in the
  56554. * clear coat media.
  56555. * This is only use if tint is enabled
  56556. */
  56557. tintColorAtDistance: number;
  56558. /**
  56559. * Defines the clear coat layer thickness.
  56560. * This is only use if tint is enabled
  56561. */
  56562. tintThickness: number;
  56563. private _tintTexture;
  56564. /**
  56565. * Stores the clear tint values in a texture.
  56566. * rgb is tint
  56567. * a is a thickness factor
  56568. */
  56569. tintTexture: Nullable<BaseTexture>;
  56570. /** @hidden */
  56571. private _internalMarkAllSubMeshesAsTexturesDirty;
  56572. /** @hidden */
  56573. _markAllSubMeshesAsTexturesDirty(): void;
  56574. /**
  56575. * Instantiate a new istance of clear coat configuration.
  56576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56577. */
  56578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56579. /**
  56580. * Gets wehter the submesh is ready to be used or not.
  56581. * @param defines the list of "defines" to update.
  56582. * @param scene defines the scene the material belongs to.
  56583. * @param engine defines the engine the material belongs to.
  56584. * @param disableBumpMap defines wether the material disables bump or not.
  56585. * @returns - boolean indicating that the submesh is ready or not.
  56586. */
  56587. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56588. /**
  56589. * Checks to see if a texture is used in the material.
  56590. * @param defines the list of "defines" to update.
  56591. * @param scene defines the scene to the material belongs to.
  56592. */
  56593. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56594. /**
  56595. * Binds the material data.
  56596. * @param uniformBuffer defines the Uniform buffer to fill in.
  56597. * @param scene defines the scene the material belongs to.
  56598. * @param engine defines the engine the material belongs to.
  56599. * @param disableBumpMap defines wether the material disables bump or not.
  56600. * @param isFrozen defines wether the material is frozen or not.
  56601. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56602. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56603. */
  56604. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56605. /**
  56606. * Checks to see if a texture is used in the material.
  56607. * @param texture - Base texture to use.
  56608. * @returns - Boolean specifying if a texture is used in the material.
  56609. */
  56610. hasTexture(texture: BaseTexture): boolean;
  56611. /**
  56612. * Returns an array of the actively used textures.
  56613. * @param activeTextures Array of BaseTextures
  56614. */
  56615. getActiveTextures(activeTextures: BaseTexture[]): void;
  56616. /**
  56617. * Returns the animatable textures.
  56618. * @param animatables Array of animatable textures.
  56619. */
  56620. getAnimatables(animatables: IAnimatable[]): void;
  56621. /**
  56622. * Disposes the resources of the material.
  56623. * @param forceDisposeTextures - Forces the disposal of all textures.
  56624. */
  56625. dispose(forceDisposeTextures?: boolean): void;
  56626. /**
  56627. * Get the current class name of the texture useful for serialization or dynamic coding.
  56628. * @returns "PBRClearCoatConfiguration"
  56629. */
  56630. getClassName(): string;
  56631. /**
  56632. * Add fallbacks to the effect fallbacks list.
  56633. * @param defines defines the Base texture to use.
  56634. * @param fallbacks defines the current fallback list.
  56635. * @param currentRank defines the current fallback rank.
  56636. * @returns the new fallback rank.
  56637. */
  56638. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56639. /**
  56640. * Add the required uniforms to the current list.
  56641. * @param uniforms defines the current uniform list.
  56642. */
  56643. static AddUniforms(uniforms: string[]): void;
  56644. /**
  56645. * Add the required samplers to the current list.
  56646. * @param samplers defines the current sampler list.
  56647. */
  56648. static AddSamplers(samplers: string[]): void;
  56649. /**
  56650. * Add the required uniforms to the current buffer.
  56651. * @param uniformBuffer defines the current uniform buffer.
  56652. */
  56653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56654. /**
  56655. * Makes a duplicate of the current configuration into another one.
  56656. * @param clearCoatConfiguration define the config where to copy the info
  56657. */
  56658. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56659. /**
  56660. * Serializes this clear coat configuration.
  56661. * @returns - An object with the serialized config.
  56662. */
  56663. serialize(): any;
  56664. /**
  56665. * Parses a anisotropy Configuration from a serialized object.
  56666. * @param source - Serialized object.
  56667. * @param scene Defines the scene we are parsing for
  56668. * @param rootUrl Defines the rootUrl to load from
  56669. */
  56670. parse(source: any, scene: Scene, rootUrl: string): void;
  56671. }
  56672. }
  56673. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56674. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56676. import { Vector2 } from "babylonjs/Maths/math.vector";
  56677. import { Scene } from "babylonjs/scene";
  56678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56679. import { Nullable } from "babylonjs/types";
  56680. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56681. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56682. /**
  56683. * @hidden
  56684. */
  56685. export interface IMaterialAnisotropicDefines {
  56686. ANISOTROPIC: boolean;
  56687. ANISOTROPIC_TEXTURE: boolean;
  56688. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56689. MAINUV1: boolean;
  56690. _areTexturesDirty: boolean;
  56691. _needUVs: boolean;
  56692. }
  56693. /**
  56694. * Define the code related to the anisotropic parameters of the pbr material.
  56695. */
  56696. export class PBRAnisotropicConfiguration {
  56697. private _isEnabled;
  56698. /**
  56699. * Defines if the anisotropy is enabled in the material.
  56700. */
  56701. isEnabled: boolean;
  56702. /**
  56703. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56704. */
  56705. intensity: number;
  56706. /**
  56707. * Defines if the effect is along the tangents, bitangents or in between.
  56708. * By default, the effect is "strectching" the highlights along the tangents.
  56709. */
  56710. direction: Vector2;
  56711. private _texture;
  56712. /**
  56713. * Stores the anisotropy values in a texture.
  56714. * rg is direction (like normal from -1 to 1)
  56715. * b is a intensity
  56716. */
  56717. texture: Nullable<BaseTexture>;
  56718. /** @hidden */
  56719. private _internalMarkAllSubMeshesAsTexturesDirty;
  56720. /** @hidden */
  56721. _markAllSubMeshesAsTexturesDirty(): void;
  56722. /**
  56723. * Instantiate a new istance of anisotropy configuration.
  56724. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56725. */
  56726. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56727. /**
  56728. * Specifies that the submesh is ready to be used.
  56729. * @param defines the list of "defines" to update.
  56730. * @param scene defines the scene the material belongs to.
  56731. * @returns - boolean indicating that the submesh is ready or not.
  56732. */
  56733. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56734. /**
  56735. * Checks to see if a texture is used in the material.
  56736. * @param defines the list of "defines" to update.
  56737. * @param mesh the mesh we are preparing the defines for.
  56738. * @param scene defines the scene the material belongs to.
  56739. */
  56740. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56741. /**
  56742. * Binds the material data.
  56743. * @param uniformBuffer defines the Uniform buffer to fill in.
  56744. * @param scene defines the scene the material belongs to.
  56745. * @param isFrozen defines wether the material is frozen or not.
  56746. */
  56747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56748. /**
  56749. * Checks to see if a texture is used in the material.
  56750. * @param texture - Base texture to use.
  56751. * @returns - Boolean specifying if a texture is used in the material.
  56752. */
  56753. hasTexture(texture: BaseTexture): boolean;
  56754. /**
  56755. * Returns an array of the actively used textures.
  56756. * @param activeTextures Array of BaseTextures
  56757. */
  56758. getActiveTextures(activeTextures: BaseTexture[]): void;
  56759. /**
  56760. * Returns the animatable textures.
  56761. * @param animatables Array of animatable textures.
  56762. */
  56763. getAnimatables(animatables: IAnimatable[]): void;
  56764. /**
  56765. * Disposes the resources of the material.
  56766. * @param forceDisposeTextures - Forces the disposal of all textures.
  56767. */
  56768. dispose(forceDisposeTextures?: boolean): void;
  56769. /**
  56770. * Get the current class name of the texture useful for serialization or dynamic coding.
  56771. * @returns "PBRAnisotropicConfiguration"
  56772. */
  56773. getClassName(): string;
  56774. /**
  56775. * Add fallbacks to the effect fallbacks list.
  56776. * @param defines defines the Base texture to use.
  56777. * @param fallbacks defines the current fallback list.
  56778. * @param currentRank defines the current fallback rank.
  56779. * @returns the new fallback rank.
  56780. */
  56781. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56782. /**
  56783. * Add the required uniforms to the current list.
  56784. * @param uniforms defines the current uniform list.
  56785. */
  56786. static AddUniforms(uniforms: string[]): void;
  56787. /**
  56788. * Add the required uniforms to the current buffer.
  56789. * @param uniformBuffer defines the current uniform buffer.
  56790. */
  56791. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56792. /**
  56793. * Add the required samplers to the current list.
  56794. * @param samplers defines the current sampler list.
  56795. */
  56796. static AddSamplers(samplers: string[]): void;
  56797. /**
  56798. * Makes a duplicate of the current configuration into another one.
  56799. * @param anisotropicConfiguration define the config where to copy the info
  56800. */
  56801. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56802. /**
  56803. * Serializes this anisotropy configuration.
  56804. * @returns - An object with the serialized config.
  56805. */
  56806. serialize(): any;
  56807. /**
  56808. * Parses a anisotropy Configuration from a serialized object.
  56809. * @param source - Serialized object.
  56810. * @param scene Defines the scene we are parsing for
  56811. * @param rootUrl Defines the rootUrl to load from
  56812. */
  56813. parse(source: any, scene: Scene, rootUrl: string): void;
  56814. }
  56815. }
  56816. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56817. import { Scene } from "babylonjs/scene";
  56818. /**
  56819. * @hidden
  56820. */
  56821. export interface IMaterialBRDFDefines {
  56822. BRDF_V_HEIGHT_CORRELATED: boolean;
  56823. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56824. SPHERICAL_HARMONICS: boolean;
  56825. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56826. /** @hidden */
  56827. _areMiscDirty: boolean;
  56828. }
  56829. /**
  56830. * Define the code related to the BRDF parameters of the pbr material.
  56831. */
  56832. export class PBRBRDFConfiguration {
  56833. /**
  56834. * Default value used for the energy conservation.
  56835. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56836. */
  56837. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56838. /**
  56839. * Default value used for the Smith Visibility Height Correlated mode.
  56840. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56841. */
  56842. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56843. /**
  56844. * Default value used for the IBL diffuse part.
  56845. * This can help switching back to the polynomials mode globally which is a tiny bit
  56846. * less GPU intensive at the drawback of a lower quality.
  56847. */
  56848. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56849. /**
  56850. * Default value used for activating energy conservation for the specular workflow.
  56851. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56852. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56853. */
  56854. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56855. private _useEnergyConservation;
  56856. /**
  56857. * Defines if the material uses energy conservation.
  56858. */
  56859. useEnergyConservation: boolean;
  56860. private _useSmithVisibilityHeightCorrelated;
  56861. /**
  56862. * LEGACY Mode set to false
  56863. * Defines if the material uses height smith correlated visibility term.
  56864. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56865. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56866. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56867. * Not relying on height correlated will also disable energy conservation.
  56868. */
  56869. useSmithVisibilityHeightCorrelated: boolean;
  56870. private _useSphericalHarmonics;
  56871. /**
  56872. * LEGACY Mode set to false
  56873. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56874. * diffuse part of the IBL.
  56875. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56876. * to the ground truth.
  56877. */
  56878. useSphericalHarmonics: boolean;
  56879. private _useSpecularGlossinessInputEnergyConservation;
  56880. /**
  56881. * Defines if the material uses energy conservation, when the specular workflow is active.
  56882. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56883. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56884. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56885. */
  56886. useSpecularGlossinessInputEnergyConservation: boolean;
  56887. /** @hidden */
  56888. private _internalMarkAllSubMeshesAsMiscDirty;
  56889. /** @hidden */
  56890. _markAllSubMeshesAsMiscDirty(): void;
  56891. /**
  56892. * Instantiate a new istance of clear coat configuration.
  56893. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56894. */
  56895. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56896. /**
  56897. * Checks to see if a texture is used in the material.
  56898. * @param defines the list of "defines" to update.
  56899. */
  56900. prepareDefines(defines: IMaterialBRDFDefines): void;
  56901. /**
  56902. * Get the current class name of the texture useful for serialization or dynamic coding.
  56903. * @returns "PBRClearCoatConfiguration"
  56904. */
  56905. getClassName(): string;
  56906. /**
  56907. * Makes a duplicate of the current configuration into another one.
  56908. * @param brdfConfiguration define the config where to copy the info
  56909. */
  56910. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56911. /**
  56912. * Serializes this BRDF configuration.
  56913. * @returns - An object with the serialized config.
  56914. */
  56915. serialize(): any;
  56916. /**
  56917. * Parses a anisotropy Configuration from a serialized object.
  56918. * @param source - Serialized object.
  56919. * @param scene Defines the scene we are parsing for
  56920. * @param rootUrl Defines the rootUrl to load from
  56921. */
  56922. parse(source: any, scene: Scene, rootUrl: string): void;
  56923. }
  56924. }
  56925. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56926. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56927. import { Color3 } from "babylonjs/Maths/math.color";
  56928. import { Scene } from "babylonjs/scene";
  56929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56930. import { Nullable } from "babylonjs/types";
  56931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56932. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56933. /**
  56934. * @hidden
  56935. */
  56936. export interface IMaterialSheenDefines {
  56937. SHEEN: boolean;
  56938. SHEEN_TEXTURE: boolean;
  56939. SHEEN_TEXTUREDIRECTUV: number;
  56940. SHEEN_LINKWITHALBEDO: boolean;
  56941. SHEEN_ROUGHNESS: boolean;
  56942. SHEEN_ALBEDOSCALING: boolean;
  56943. /** @hidden */
  56944. _areTexturesDirty: boolean;
  56945. }
  56946. /**
  56947. * Define the code related to the Sheen parameters of the pbr material.
  56948. */
  56949. export class PBRSheenConfiguration {
  56950. private _isEnabled;
  56951. /**
  56952. * Defines if the material uses sheen.
  56953. */
  56954. isEnabled: boolean;
  56955. private _linkSheenWithAlbedo;
  56956. /**
  56957. * Defines if the sheen is linked to the sheen color.
  56958. */
  56959. linkSheenWithAlbedo: boolean;
  56960. /**
  56961. * Defines the sheen intensity.
  56962. */
  56963. intensity: number;
  56964. /**
  56965. * Defines the sheen color.
  56966. */
  56967. color: Color3;
  56968. private _texture;
  56969. /**
  56970. * Stores the sheen tint values in a texture.
  56971. * rgb is tint
  56972. * a is a intensity or roughness if roughness has been defined
  56973. */
  56974. texture: Nullable<BaseTexture>;
  56975. private _roughness;
  56976. /**
  56977. * Defines the sheen roughness.
  56978. * It is not taken into account if linkSheenWithAlbedo is true.
  56979. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56980. */
  56981. roughness: Nullable<number>;
  56982. private _albedoScaling;
  56983. /**
  56984. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56985. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56986. * making it easier to setup and tweak the effect
  56987. */
  56988. albedoScaling: boolean;
  56989. /** @hidden */
  56990. private _internalMarkAllSubMeshesAsTexturesDirty;
  56991. /** @hidden */
  56992. _markAllSubMeshesAsTexturesDirty(): void;
  56993. /**
  56994. * Instantiate a new istance of clear coat configuration.
  56995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56996. */
  56997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56998. /**
  56999. * Specifies that the submesh is ready to be used.
  57000. * @param defines the list of "defines" to update.
  57001. * @param scene defines the scene the material belongs to.
  57002. * @returns - boolean indicating that the submesh is ready or not.
  57003. */
  57004. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57005. /**
  57006. * Checks to see if a texture is used in the material.
  57007. * @param defines the list of "defines" to update.
  57008. * @param scene defines the scene the material belongs to.
  57009. */
  57010. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57011. /**
  57012. * Binds the material data.
  57013. * @param uniformBuffer defines the Uniform buffer to fill in.
  57014. * @param scene defines the scene the material belongs to.
  57015. * @param isFrozen defines wether the material is frozen or not.
  57016. */
  57017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57018. /**
  57019. * Checks to see if a texture is used in the material.
  57020. * @param texture - Base texture to use.
  57021. * @returns - Boolean specifying if a texture is used in the material.
  57022. */
  57023. hasTexture(texture: BaseTexture): boolean;
  57024. /**
  57025. * Returns an array of the actively used textures.
  57026. * @param activeTextures Array of BaseTextures
  57027. */
  57028. getActiveTextures(activeTextures: BaseTexture[]): void;
  57029. /**
  57030. * Returns the animatable textures.
  57031. * @param animatables Array of animatable textures.
  57032. */
  57033. getAnimatables(animatables: IAnimatable[]): void;
  57034. /**
  57035. * Disposes the resources of the material.
  57036. * @param forceDisposeTextures - Forces the disposal of all textures.
  57037. */
  57038. dispose(forceDisposeTextures?: boolean): void;
  57039. /**
  57040. * Get the current class name of the texture useful for serialization or dynamic coding.
  57041. * @returns "PBRSheenConfiguration"
  57042. */
  57043. getClassName(): string;
  57044. /**
  57045. * Add fallbacks to the effect fallbacks list.
  57046. * @param defines defines the Base texture to use.
  57047. * @param fallbacks defines the current fallback list.
  57048. * @param currentRank defines the current fallback rank.
  57049. * @returns the new fallback rank.
  57050. */
  57051. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57052. /**
  57053. * Add the required uniforms to the current list.
  57054. * @param uniforms defines the current uniform list.
  57055. */
  57056. static AddUniforms(uniforms: string[]): void;
  57057. /**
  57058. * Add the required uniforms to the current buffer.
  57059. * @param uniformBuffer defines the current uniform buffer.
  57060. */
  57061. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57062. /**
  57063. * Add the required samplers to the current list.
  57064. * @param samplers defines the current sampler list.
  57065. */
  57066. static AddSamplers(samplers: string[]): void;
  57067. /**
  57068. * Makes a duplicate of the current configuration into another one.
  57069. * @param sheenConfiguration define the config where to copy the info
  57070. */
  57071. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57072. /**
  57073. * Serializes this BRDF configuration.
  57074. * @returns - An object with the serialized config.
  57075. */
  57076. serialize(): any;
  57077. /**
  57078. * Parses a anisotropy Configuration from a serialized object.
  57079. * @param source - Serialized object.
  57080. * @param scene Defines the scene we are parsing for
  57081. * @param rootUrl Defines the rootUrl to load from
  57082. */
  57083. parse(source: any, scene: Scene, rootUrl: string): void;
  57084. }
  57085. }
  57086. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57087. import { Nullable } from "babylonjs/types";
  57088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57089. import { Color3 } from "babylonjs/Maths/math.color";
  57090. import { SmartArray } from "babylonjs/Misc/smartArray";
  57091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57092. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57093. import { Effect } from "babylonjs/Materials/effect";
  57094. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57095. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57096. import { Engine } from "babylonjs/Engines/engine";
  57097. import { Scene } from "babylonjs/scene";
  57098. /**
  57099. * @hidden
  57100. */
  57101. export interface IMaterialSubSurfaceDefines {
  57102. SUBSURFACE: boolean;
  57103. SS_REFRACTION: boolean;
  57104. SS_TRANSLUCENCY: boolean;
  57105. SS_SCATTERING: boolean;
  57106. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57107. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57108. SS_REFRACTIONMAP_3D: boolean;
  57109. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57110. SS_LODINREFRACTIONALPHA: boolean;
  57111. SS_GAMMAREFRACTION: boolean;
  57112. SS_RGBDREFRACTION: boolean;
  57113. SS_LINEARSPECULARREFRACTION: boolean;
  57114. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57115. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57116. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57117. /** @hidden */
  57118. _areTexturesDirty: boolean;
  57119. }
  57120. /**
  57121. * Define the code related to the sub surface parameters of the pbr material.
  57122. */
  57123. export class PBRSubSurfaceConfiguration {
  57124. private _isRefractionEnabled;
  57125. /**
  57126. * Defines if the refraction is enabled in the material.
  57127. */
  57128. isRefractionEnabled: boolean;
  57129. private _isTranslucencyEnabled;
  57130. /**
  57131. * Defines if the translucency is enabled in the material.
  57132. */
  57133. isTranslucencyEnabled: boolean;
  57134. private _isScatteringEnabled;
  57135. /**
  57136. * Defines if the sub surface scattering is enabled in the material.
  57137. */
  57138. isScatteringEnabled: boolean;
  57139. private _scatteringDiffusionProfileIndex;
  57140. /**
  57141. * Diffusion profile for subsurface scattering.
  57142. * Useful for better scattering in the skins or foliages.
  57143. */
  57144. get scatteringDiffusionProfile(): Nullable<Color3>;
  57145. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57146. /**
  57147. * Defines the refraction intensity of the material.
  57148. * The refraction when enabled replaces the Diffuse part of the material.
  57149. * The intensity helps transitionning between diffuse and refraction.
  57150. */
  57151. refractionIntensity: number;
  57152. /**
  57153. * Defines the translucency intensity of the material.
  57154. * When translucency has been enabled, this defines how much of the "translucency"
  57155. * is addded to the diffuse part of the material.
  57156. */
  57157. translucencyIntensity: number;
  57158. /**
  57159. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57160. */
  57161. useAlbedoToTintRefraction: boolean;
  57162. private _thicknessTexture;
  57163. /**
  57164. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57165. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57166. * 0 would mean minimumThickness
  57167. * 1 would mean maximumThickness
  57168. * The other channels might be use as a mask to vary the different effects intensity.
  57169. */
  57170. thicknessTexture: Nullable<BaseTexture>;
  57171. private _refractionTexture;
  57172. /**
  57173. * Defines the texture to use for refraction.
  57174. */
  57175. refractionTexture: Nullable<BaseTexture>;
  57176. private _indexOfRefraction;
  57177. /**
  57178. * Index of refraction of the material base layer.
  57179. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57180. *
  57181. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57182. *
  57183. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57184. */
  57185. indexOfRefraction: number;
  57186. private _volumeIndexOfRefraction;
  57187. /**
  57188. * Index of refraction of the material's volume.
  57189. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57190. *
  57191. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57192. * the volume will use the same IOR as the surface.
  57193. */
  57194. get volumeIndexOfRefraction(): number;
  57195. set volumeIndexOfRefraction(value: number);
  57196. private _invertRefractionY;
  57197. /**
  57198. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57199. */
  57200. invertRefractionY: boolean;
  57201. private _linkRefractionWithTransparency;
  57202. /**
  57203. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57204. * Materials half opaque for instance using refraction could benefit from this control.
  57205. */
  57206. linkRefractionWithTransparency: boolean;
  57207. /**
  57208. * Defines the minimum thickness stored in the thickness map.
  57209. * If no thickness map is defined, this value will be used to simulate thickness.
  57210. */
  57211. minimumThickness: number;
  57212. /**
  57213. * Defines the maximum thickness stored in the thickness map.
  57214. */
  57215. maximumThickness: number;
  57216. /**
  57217. * Defines the volume tint of the material.
  57218. * This is used for both translucency and scattering.
  57219. */
  57220. tintColor: Color3;
  57221. /**
  57222. * Defines the distance at which the tint color should be found in the media.
  57223. * This is used for refraction only.
  57224. */
  57225. tintColorAtDistance: number;
  57226. /**
  57227. * Defines how far each channel transmit through the media.
  57228. * It is defined as a color to simplify it selection.
  57229. */
  57230. diffusionDistance: Color3;
  57231. private _useMaskFromThicknessTexture;
  57232. /**
  57233. * Stores the intensity of the different subsurface effects in the thickness texture.
  57234. * * the green channel is the translucency intensity.
  57235. * * the blue channel is the scattering intensity.
  57236. * * the alpha channel is the refraction intensity.
  57237. */
  57238. useMaskFromThicknessTexture: boolean;
  57239. private _scene;
  57240. /** @hidden */
  57241. private _internalMarkAllSubMeshesAsTexturesDirty;
  57242. private _internalMarkScenePrePassDirty;
  57243. /** @hidden */
  57244. _markAllSubMeshesAsTexturesDirty(): void;
  57245. /** @hidden */
  57246. _markScenePrePassDirty(): void;
  57247. /**
  57248. * Instantiate a new istance of sub surface configuration.
  57249. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57250. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57251. * @param scene The scene
  57252. */
  57253. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57254. /**
  57255. * Gets wehter the submesh is ready to be used or not.
  57256. * @param defines the list of "defines" to update.
  57257. * @param scene defines the scene the material belongs to.
  57258. * @returns - boolean indicating that the submesh is ready or not.
  57259. */
  57260. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57261. /**
  57262. * Checks to see if a texture is used in the material.
  57263. * @param defines the list of "defines" to update.
  57264. * @param scene defines the scene to the material belongs to.
  57265. */
  57266. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57267. /**
  57268. * Binds the material data.
  57269. * @param uniformBuffer defines the Uniform buffer to fill in.
  57270. * @param scene defines the scene the material belongs to.
  57271. * @param engine defines the engine the material belongs to.
  57272. * @param isFrozen defines whether the material is frozen or not.
  57273. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57274. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57275. */
  57276. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57277. /**
  57278. * Unbinds the material from the mesh.
  57279. * @param activeEffect defines the effect that should be unbound from.
  57280. * @returns true if unbound, otherwise false
  57281. */
  57282. unbind(activeEffect: Effect): boolean;
  57283. /**
  57284. * Returns the texture used for refraction or null if none is used.
  57285. * @param scene defines the scene the material belongs to.
  57286. * @returns - Refraction texture if present. If no refraction texture and refraction
  57287. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57288. */
  57289. private _getRefractionTexture;
  57290. /**
  57291. * Returns true if alpha blending should be disabled.
  57292. */
  57293. get disableAlphaBlending(): boolean;
  57294. /**
  57295. * Fills the list of render target textures.
  57296. * @param renderTargets the list of render targets to update
  57297. */
  57298. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57299. /**
  57300. * Checks to see if a texture is used in the material.
  57301. * @param texture - Base texture to use.
  57302. * @returns - Boolean specifying if a texture is used in the material.
  57303. */
  57304. hasTexture(texture: BaseTexture): boolean;
  57305. /**
  57306. * Gets a boolean indicating that current material needs to register RTT
  57307. * @returns true if this uses a render target otherwise false.
  57308. */
  57309. hasRenderTargetTextures(): boolean;
  57310. /**
  57311. * Returns an array of the actively used textures.
  57312. * @param activeTextures Array of BaseTextures
  57313. */
  57314. getActiveTextures(activeTextures: BaseTexture[]): void;
  57315. /**
  57316. * Returns the animatable textures.
  57317. * @param animatables Array of animatable textures.
  57318. */
  57319. getAnimatables(animatables: IAnimatable[]): void;
  57320. /**
  57321. * Disposes the resources of the material.
  57322. * @param forceDisposeTextures - Forces the disposal of all textures.
  57323. */
  57324. dispose(forceDisposeTextures?: boolean): void;
  57325. /**
  57326. * Get the current class name of the texture useful for serialization or dynamic coding.
  57327. * @returns "PBRSubSurfaceConfiguration"
  57328. */
  57329. getClassName(): string;
  57330. /**
  57331. * Add fallbacks to the effect fallbacks list.
  57332. * @param defines defines the Base texture to use.
  57333. * @param fallbacks defines the current fallback list.
  57334. * @param currentRank defines the current fallback rank.
  57335. * @returns the new fallback rank.
  57336. */
  57337. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57338. /**
  57339. * Add the required uniforms to the current list.
  57340. * @param uniforms defines the current uniform list.
  57341. */
  57342. static AddUniforms(uniforms: string[]): void;
  57343. /**
  57344. * Add the required samplers to the current list.
  57345. * @param samplers defines the current sampler list.
  57346. */
  57347. static AddSamplers(samplers: string[]): void;
  57348. /**
  57349. * Add the required uniforms to the current buffer.
  57350. * @param uniformBuffer defines the current uniform buffer.
  57351. */
  57352. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57353. /**
  57354. * Makes a duplicate of the current configuration into another one.
  57355. * @param configuration define the config where to copy the info
  57356. */
  57357. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57358. /**
  57359. * Serializes this Sub Surface configuration.
  57360. * @returns - An object with the serialized config.
  57361. */
  57362. serialize(): any;
  57363. /**
  57364. * Parses a anisotropy Configuration from a serialized object.
  57365. * @param source - Serialized object.
  57366. * @param scene Defines the scene we are parsing for
  57367. * @param rootUrl Defines the rootUrl to load from
  57368. */
  57369. parse(source: any, scene: Scene, rootUrl: string): void;
  57370. }
  57371. }
  57372. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57373. /** @hidden */
  57374. export var pbrFragmentDeclaration: {
  57375. name: string;
  57376. shader: string;
  57377. };
  57378. }
  57379. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57380. /** @hidden */
  57381. export var pbrUboDeclaration: {
  57382. name: string;
  57383. shader: string;
  57384. };
  57385. }
  57386. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57387. /** @hidden */
  57388. export var pbrFragmentExtraDeclaration: {
  57389. name: string;
  57390. shader: string;
  57391. };
  57392. }
  57393. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57394. /** @hidden */
  57395. export var pbrFragmentSamplersDeclaration: {
  57396. name: string;
  57397. shader: string;
  57398. };
  57399. }
  57400. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57401. /** @hidden */
  57402. export var subSurfaceScatteringFunctions: {
  57403. name: string;
  57404. shader: string;
  57405. };
  57406. }
  57407. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57408. /** @hidden */
  57409. export var importanceSampling: {
  57410. name: string;
  57411. shader: string;
  57412. };
  57413. }
  57414. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57415. /** @hidden */
  57416. export var pbrHelperFunctions: {
  57417. name: string;
  57418. shader: string;
  57419. };
  57420. }
  57421. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57422. /** @hidden */
  57423. export var harmonicsFunctions: {
  57424. name: string;
  57425. shader: string;
  57426. };
  57427. }
  57428. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57429. /** @hidden */
  57430. export var pbrDirectLightingSetupFunctions: {
  57431. name: string;
  57432. shader: string;
  57433. };
  57434. }
  57435. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57436. /** @hidden */
  57437. export var pbrDirectLightingFalloffFunctions: {
  57438. name: string;
  57439. shader: string;
  57440. };
  57441. }
  57442. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57443. /** @hidden */
  57444. export var pbrBRDFFunctions: {
  57445. name: string;
  57446. shader: string;
  57447. };
  57448. }
  57449. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57450. /** @hidden */
  57451. export var hdrFilteringFunctions: {
  57452. name: string;
  57453. shader: string;
  57454. };
  57455. }
  57456. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57457. /** @hidden */
  57458. export var pbrDirectLightingFunctions: {
  57459. name: string;
  57460. shader: string;
  57461. };
  57462. }
  57463. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57464. /** @hidden */
  57465. export var pbrIBLFunctions: {
  57466. name: string;
  57467. shader: string;
  57468. };
  57469. }
  57470. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57471. /** @hidden */
  57472. export var pbrBlockAlbedoOpacity: {
  57473. name: string;
  57474. shader: string;
  57475. };
  57476. }
  57477. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57478. /** @hidden */
  57479. export var pbrBlockReflectivity: {
  57480. name: string;
  57481. shader: string;
  57482. };
  57483. }
  57484. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57485. /** @hidden */
  57486. export var pbrBlockAmbientOcclusion: {
  57487. name: string;
  57488. shader: string;
  57489. };
  57490. }
  57491. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57492. /** @hidden */
  57493. export var pbrBlockAlphaFresnel: {
  57494. name: string;
  57495. shader: string;
  57496. };
  57497. }
  57498. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57499. /** @hidden */
  57500. export var pbrBlockAnisotropic: {
  57501. name: string;
  57502. shader: string;
  57503. };
  57504. }
  57505. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57506. /** @hidden */
  57507. export var pbrBlockReflection: {
  57508. name: string;
  57509. shader: string;
  57510. };
  57511. }
  57512. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57513. /** @hidden */
  57514. export var pbrBlockSheen: {
  57515. name: string;
  57516. shader: string;
  57517. };
  57518. }
  57519. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57520. /** @hidden */
  57521. export var pbrBlockClearcoat: {
  57522. name: string;
  57523. shader: string;
  57524. };
  57525. }
  57526. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57527. /** @hidden */
  57528. export var pbrBlockSubSurface: {
  57529. name: string;
  57530. shader: string;
  57531. };
  57532. }
  57533. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57534. /** @hidden */
  57535. export var pbrBlockNormalGeometric: {
  57536. name: string;
  57537. shader: string;
  57538. };
  57539. }
  57540. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57541. /** @hidden */
  57542. export var pbrBlockNormalFinal: {
  57543. name: string;
  57544. shader: string;
  57545. };
  57546. }
  57547. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57548. /** @hidden */
  57549. export var pbrBlockGeometryInfo: {
  57550. name: string;
  57551. shader: string;
  57552. };
  57553. }
  57554. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57555. /** @hidden */
  57556. export var pbrBlockReflectance0: {
  57557. name: string;
  57558. shader: string;
  57559. };
  57560. }
  57561. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57562. /** @hidden */
  57563. export var pbrBlockReflectance: {
  57564. name: string;
  57565. shader: string;
  57566. };
  57567. }
  57568. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57569. /** @hidden */
  57570. export var pbrBlockDirectLighting: {
  57571. name: string;
  57572. shader: string;
  57573. };
  57574. }
  57575. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57576. /** @hidden */
  57577. export var pbrBlockFinalLitComponents: {
  57578. name: string;
  57579. shader: string;
  57580. };
  57581. }
  57582. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57583. /** @hidden */
  57584. export var pbrBlockFinalUnlitComponents: {
  57585. name: string;
  57586. shader: string;
  57587. };
  57588. }
  57589. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57590. /** @hidden */
  57591. export var pbrBlockFinalColorComposition: {
  57592. name: string;
  57593. shader: string;
  57594. };
  57595. }
  57596. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57597. /** @hidden */
  57598. export var pbrBlockImageProcessing: {
  57599. name: string;
  57600. shader: string;
  57601. };
  57602. }
  57603. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57604. /** @hidden */
  57605. export var pbrDebug: {
  57606. name: string;
  57607. shader: string;
  57608. };
  57609. }
  57610. declare module "babylonjs/Shaders/pbr.fragment" {
  57611. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57612. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57613. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57614. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57615. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57616. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57617. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57618. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57620. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57621. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57622. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57623. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57624. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57625. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57626. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57627. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57628. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57629. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57630. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57631. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57632. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57633. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57634. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57635. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57636. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57637. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57638. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57639. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57640. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57641. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57642. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57643. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57644. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57645. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57646. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57647. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57648. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57649. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57650. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57651. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57652. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57653. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57654. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57655. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57656. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57657. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57658. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57659. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57660. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57661. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57662. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57663. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57664. /** @hidden */
  57665. export var pbrPixelShader: {
  57666. name: string;
  57667. shader: string;
  57668. };
  57669. }
  57670. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57671. /** @hidden */
  57672. export var pbrVertexDeclaration: {
  57673. name: string;
  57674. shader: string;
  57675. };
  57676. }
  57677. declare module "babylonjs/Shaders/pbr.vertex" {
  57678. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57679. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57680. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57681. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57682. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57683. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57684. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57685. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57687. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57688. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57689. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57690. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57691. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57693. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57694. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57695. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57697. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57698. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57699. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57700. /** @hidden */
  57701. export var pbrVertexShader: {
  57702. name: string;
  57703. shader: string;
  57704. };
  57705. }
  57706. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57707. import { Nullable } from "babylonjs/types";
  57708. import { Scene } from "babylonjs/scene";
  57709. import { Matrix } from "babylonjs/Maths/math.vector";
  57710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57712. import { Mesh } from "babylonjs/Meshes/mesh";
  57713. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57714. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57715. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57716. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57717. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57718. import { Color3 } from "babylonjs/Maths/math.color";
  57719. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57720. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57721. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57722. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57724. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57725. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57726. import "babylonjs/Shaders/pbr.fragment";
  57727. import "babylonjs/Shaders/pbr.vertex";
  57728. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57729. /**
  57730. * Manages the defines for the PBR Material.
  57731. * @hidden
  57732. */
  57733. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57734. PBR: boolean;
  57735. NUM_SAMPLES: string;
  57736. REALTIME_FILTERING: boolean;
  57737. MAINUV1: boolean;
  57738. MAINUV2: boolean;
  57739. UV1: boolean;
  57740. UV2: boolean;
  57741. ALBEDO: boolean;
  57742. GAMMAALBEDO: boolean;
  57743. ALBEDODIRECTUV: number;
  57744. VERTEXCOLOR: boolean;
  57745. DETAIL: boolean;
  57746. DETAILDIRECTUV: number;
  57747. DETAIL_NORMALBLENDMETHOD: number;
  57748. AMBIENT: boolean;
  57749. AMBIENTDIRECTUV: number;
  57750. AMBIENTINGRAYSCALE: boolean;
  57751. OPACITY: boolean;
  57752. VERTEXALPHA: boolean;
  57753. OPACITYDIRECTUV: number;
  57754. OPACITYRGB: boolean;
  57755. ALPHATEST: boolean;
  57756. DEPTHPREPASS: boolean;
  57757. ALPHABLEND: boolean;
  57758. ALPHAFROMALBEDO: boolean;
  57759. ALPHATESTVALUE: string;
  57760. SPECULAROVERALPHA: boolean;
  57761. RADIANCEOVERALPHA: boolean;
  57762. ALPHAFRESNEL: boolean;
  57763. LINEARALPHAFRESNEL: boolean;
  57764. PREMULTIPLYALPHA: boolean;
  57765. EMISSIVE: boolean;
  57766. EMISSIVEDIRECTUV: number;
  57767. REFLECTIVITY: boolean;
  57768. REFLECTIVITYDIRECTUV: number;
  57769. SPECULARTERM: boolean;
  57770. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57771. MICROSURFACEAUTOMATIC: boolean;
  57772. LODBASEDMICROSFURACE: boolean;
  57773. MICROSURFACEMAP: boolean;
  57774. MICROSURFACEMAPDIRECTUV: number;
  57775. METALLICWORKFLOW: boolean;
  57776. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57777. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57778. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57779. AOSTOREINMETALMAPRED: boolean;
  57780. METALLIC_REFLECTANCE: boolean;
  57781. METALLIC_REFLECTANCEDIRECTUV: number;
  57782. ENVIRONMENTBRDF: boolean;
  57783. ENVIRONMENTBRDF_RGBD: boolean;
  57784. NORMAL: boolean;
  57785. TANGENT: boolean;
  57786. BUMP: boolean;
  57787. BUMPDIRECTUV: number;
  57788. OBJECTSPACE_NORMALMAP: boolean;
  57789. PARALLAX: boolean;
  57790. PARALLAXOCCLUSION: boolean;
  57791. NORMALXYSCALE: boolean;
  57792. LIGHTMAP: boolean;
  57793. LIGHTMAPDIRECTUV: number;
  57794. USELIGHTMAPASSHADOWMAP: boolean;
  57795. GAMMALIGHTMAP: boolean;
  57796. RGBDLIGHTMAP: boolean;
  57797. REFLECTION: boolean;
  57798. REFLECTIONMAP_3D: boolean;
  57799. REFLECTIONMAP_SPHERICAL: boolean;
  57800. REFLECTIONMAP_PLANAR: boolean;
  57801. REFLECTIONMAP_CUBIC: boolean;
  57802. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57803. REFLECTIONMAP_PROJECTION: boolean;
  57804. REFLECTIONMAP_SKYBOX: boolean;
  57805. REFLECTIONMAP_EXPLICIT: boolean;
  57806. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57807. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57808. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57809. INVERTCUBICMAP: boolean;
  57810. USESPHERICALFROMREFLECTIONMAP: boolean;
  57811. USEIRRADIANCEMAP: boolean;
  57812. SPHERICAL_HARMONICS: boolean;
  57813. USESPHERICALINVERTEX: boolean;
  57814. REFLECTIONMAP_OPPOSITEZ: boolean;
  57815. LODINREFLECTIONALPHA: boolean;
  57816. GAMMAREFLECTION: boolean;
  57817. RGBDREFLECTION: boolean;
  57818. LINEARSPECULARREFLECTION: boolean;
  57819. RADIANCEOCCLUSION: boolean;
  57820. HORIZONOCCLUSION: boolean;
  57821. INSTANCES: boolean;
  57822. THIN_INSTANCES: boolean;
  57823. PREPASS: boolean;
  57824. SCENE_MRT_COUNT: number;
  57825. NUM_BONE_INFLUENCERS: number;
  57826. BonesPerMesh: number;
  57827. BONETEXTURE: boolean;
  57828. NONUNIFORMSCALING: boolean;
  57829. MORPHTARGETS: boolean;
  57830. MORPHTARGETS_NORMAL: boolean;
  57831. MORPHTARGETS_TANGENT: boolean;
  57832. MORPHTARGETS_UV: boolean;
  57833. NUM_MORPH_INFLUENCERS: number;
  57834. IMAGEPROCESSING: boolean;
  57835. VIGNETTE: boolean;
  57836. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57837. VIGNETTEBLENDMODEOPAQUE: boolean;
  57838. TONEMAPPING: boolean;
  57839. TONEMAPPING_ACES: boolean;
  57840. CONTRAST: boolean;
  57841. COLORCURVES: boolean;
  57842. COLORGRADING: boolean;
  57843. COLORGRADING3D: boolean;
  57844. SAMPLER3DGREENDEPTH: boolean;
  57845. SAMPLER3DBGRMAP: boolean;
  57846. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57847. EXPOSURE: boolean;
  57848. MULTIVIEW: boolean;
  57849. USEPHYSICALLIGHTFALLOFF: boolean;
  57850. USEGLTFLIGHTFALLOFF: boolean;
  57851. TWOSIDEDLIGHTING: boolean;
  57852. SHADOWFLOAT: boolean;
  57853. CLIPPLANE: boolean;
  57854. CLIPPLANE2: boolean;
  57855. CLIPPLANE3: boolean;
  57856. CLIPPLANE4: boolean;
  57857. CLIPPLANE5: boolean;
  57858. CLIPPLANE6: boolean;
  57859. POINTSIZE: boolean;
  57860. FOG: boolean;
  57861. LOGARITHMICDEPTH: boolean;
  57862. FORCENORMALFORWARD: boolean;
  57863. SPECULARAA: boolean;
  57864. CLEARCOAT: boolean;
  57865. CLEARCOAT_DEFAULTIOR: boolean;
  57866. CLEARCOAT_TEXTURE: boolean;
  57867. CLEARCOAT_TEXTUREDIRECTUV: number;
  57868. CLEARCOAT_BUMP: boolean;
  57869. CLEARCOAT_BUMPDIRECTUV: number;
  57870. CLEARCOAT_TINT: boolean;
  57871. CLEARCOAT_TINT_TEXTURE: boolean;
  57872. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57873. ANISOTROPIC: boolean;
  57874. ANISOTROPIC_TEXTURE: boolean;
  57875. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57876. BRDF_V_HEIGHT_CORRELATED: boolean;
  57877. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57878. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57879. SHEEN: boolean;
  57880. SHEEN_TEXTURE: boolean;
  57881. SHEEN_TEXTUREDIRECTUV: number;
  57882. SHEEN_LINKWITHALBEDO: boolean;
  57883. SHEEN_ROUGHNESS: boolean;
  57884. SHEEN_ALBEDOSCALING: boolean;
  57885. SUBSURFACE: boolean;
  57886. SS_REFRACTION: boolean;
  57887. SS_TRANSLUCENCY: boolean;
  57888. SS_SCATTERING: boolean;
  57889. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57890. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57891. SS_REFRACTIONMAP_3D: boolean;
  57892. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57893. SS_LODINREFRACTIONALPHA: boolean;
  57894. SS_GAMMAREFRACTION: boolean;
  57895. SS_RGBDREFRACTION: boolean;
  57896. SS_LINEARSPECULARREFRACTION: boolean;
  57897. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57898. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57899. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57900. UNLIT: boolean;
  57901. DEBUGMODE: number;
  57902. /**
  57903. * Initializes the PBR Material defines.
  57904. */
  57905. constructor();
  57906. /**
  57907. * Resets the PBR Material defines.
  57908. */
  57909. reset(): void;
  57910. }
  57911. /**
  57912. * The Physically based material base class of BJS.
  57913. *
  57914. * This offers the main features of a standard PBR material.
  57915. * For more information, please refer to the documentation :
  57916. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57917. */
  57918. export abstract class PBRBaseMaterial extends PushMaterial {
  57919. /**
  57920. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57921. */
  57922. static readonly PBRMATERIAL_OPAQUE: number;
  57923. /**
  57924. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57925. */
  57926. static readonly PBRMATERIAL_ALPHATEST: number;
  57927. /**
  57928. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57929. */
  57930. static readonly PBRMATERIAL_ALPHABLEND: number;
  57931. /**
  57932. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57933. * They are also discarded below the alpha cutoff threshold to improve performances.
  57934. */
  57935. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57936. /**
  57937. * Defines the default value of how much AO map is occluding the analytical lights
  57938. * (point spot...).
  57939. */
  57940. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57941. /**
  57942. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57943. */
  57944. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57945. /**
  57946. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57947. * to enhance interoperability with other engines.
  57948. */
  57949. static readonly LIGHTFALLOFF_GLTF: number;
  57950. /**
  57951. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57952. * to enhance interoperability with other materials.
  57953. */
  57954. static readonly LIGHTFALLOFF_STANDARD: number;
  57955. /**
  57956. * Intensity of the direct lights e.g. the four lights available in your scene.
  57957. * This impacts both the direct diffuse and specular highlights.
  57958. */
  57959. protected _directIntensity: number;
  57960. /**
  57961. * Intensity of the emissive part of the material.
  57962. * This helps controlling the emissive effect without modifying the emissive color.
  57963. */
  57964. protected _emissiveIntensity: number;
  57965. /**
  57966. * Intensity of the environment e.g. how much the environment will light the object
  57967. * either through harmonics for rough material or through the refelction for shiny ones.
  57968. */
  57969. protected _environmentIntensity: number;
  57970. /**
  57971. * This is a special control allowing the reduction of the specular highlights coming from the
  57972. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57973. */
  57974. protected _specularIntensity: number;
  57975. /**
  57976. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57977. */
  57978. private _lightingInfos;
  57979. /**
  57980. * Debug Control allowing disabling the bump map on this material.
  57981. */
  57982. protected _disableBumpMap: boolean;
  57983. /**
  57984. * AKA Diffuse Texture in standard nomenclature.
  57985. */
  57986. protected _albedoTexture: Nullable<BaseTexture>;
  57987. /**
  57988. * AKA Occlusion Texture in other nomenclature.
  57989. */
  57990. protected _ambientTexture: Nullable<BaseTexture>;
  57991. /**
  57992. * AKA Occlusion Texture Intensity in other nomenclature.
  57993. */
  57994. protected _ambientTextureStrength: number;
  57995. /**
  57996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57997. * 1 means it completely occludes it
  57998. * 0 mean it has no impact
  57999. */
  58000. protected _ambientTextureImpactOnAnalyticalLights: number;
  58001. /**
  58002. * Stores the alpha values in a texture.
  58003. */
  58004. protected _opacityTexture: Nullable<BaseTexture>;
  58005. /**
  58006. * Stores the reflection values in a texture.
  58007. */
  58008. protected _reflectionTexture: Nullable<BaseTexture>;
  58009. /**
  58010. * Stores the emissive values in a texture.
  58011. */
  58012. protected _emissiveTexture: Nullable<BaseTexture>;
  58013. /**
  58014. * AKA Specular texture in other nomenclature.
  58015. */
  58016. protected _reflectivityTexture: Nullable<BaseTexture>;
  58017. /**
  58018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58019. */
  58020. protected _metallicTexture: Nullable<BaseTexture>;
  58021. /**
  58022. * Specifies the metallic scalar of the metallic/roughness workflow.
  58023. * Can also be used to scale the metalness values of the metallic texture.
  58024. */
  58025. protected _metallic: Nullable<number>;
  58026. /**
  58027. * Specifies the roughness scalar of the metallic/roughness workflow.
  58028. * Can also be used to scale the roughness values of the metallic texture.
  58029. */
  58030. protected _roughness: Nullable<number>;
  58031. /**
  58032. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58033. * By default the indexOfrefraction is used to compute F0;
  58034. *
  58035. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58036. *
  58037. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58038. * F90 = metallicReflectanceColor;
  58039. */
  58040. protected _metallicF0Factor: number;
  58041. /**
  58042. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58043. * By default the F90 is always 1;
  58044. *
  58045. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58046. *
  58047. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58048. * F90 = metallicReflectanceColor;
  58049. */
  58050. protected _metallicReflectanceColor: Color3;
  58051. /**
  58052. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58053. * This is multiply against the scalar values defined in the material.
  58054. */
  58055. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58056. /**
  58057. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58058. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58059. */
  58060. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58061. /**
  58062. * Stores surface normal data used to displace a mesh in a texture.
  58063. */
  58064. protected _bumpTexture: Nullable<BaseTexture>;
  58065. /**
  58066. * Stores the pre-calculated light information of a mesh in a texture.
  58067. */
  58068. protected _lightmapTexture: Nullable<BaseTexture>;
  58069. /**
  58070. * The color of a material in ambient lighting.
  58071. */
  58072. protected _ambientColor: Color3;
  58073. /**
  58074. * AKA Diffuse Color in other nomenclature.
  58075. */
  58076. protected _albedoColor: Color3;
  58077. /**
  58078. * AKA Specular Color in other nomenclature.
  58079. */
  58080. protected _reflectivityColor: Color3;
  58081. /**
  58082. * The color applied when light is reflected from a material.
  58083. */
  58084. protected _reflectionColor: Color3;
  58085. /**
  58086. * The color applied when light is emitted from a material.
  58087. */
  58088. protected _emissiveColor: Color3;
  58089. /**
  58090. * AKA Glossiness in other nomenclature.
  58091. */
  58092. protected _microSurface: number;
  58093. /**
  58094. * Specifies that the material will use the light map as a show map.
  58095. */
  58096. protected _useLightmapAsShadowmap: boolean;
  58097. /**
  58098. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58099. * makes the reflect vector face the model (under horizon).
  58100. */
  58101. protected _useHorizonOcclusion: boolean;
  58102. /**
  58103. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58104. * too much the area relying on ambient texture to define their ambient occlusion.
  58105. */
  58106. protected _useRadianceOcclusion: boolean;
  58107. /**
  58108. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58109. */
  58110. protected _useAlphaFromAlbedoTexture: boolean;
  58111. /**
  58112. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58113. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58114. */
  58115. protected _useSpecularOverAlpha: boolean;
  58116. /**
  58117. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58118. */
  58119. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58120. /**
  58121. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58122. */
  58123. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58124. /**
  58125. * Specifies if the metallic texture contains the roughness information in its green channel.
  58126. */
  58127. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58128. /**
  58129. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58130. */
  58131. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58132. /**
  58133. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58134. */
  58135. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58136. /**
  58137. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58138. */
  58139. protected _useAmbientInGrayScale: boolean;
  58140. /**
  58141. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58142. * The material will try to infer what glossiness each pixel should be.
  58143. */
  58144. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58145. /**
  58146. * Defines the falloff type used in this material.
  58147. * It by default is Physical.
  58148. */
  58149. protected _lightFalloff: number;
  58150. /**
  58151. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58152. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58153. */
  58154. protected _useRadianceOverAlpha: boolean;
  58155. /**
  58156. * Allows using an object space normal map (instead of tangent space).
  58157. */
  58158. protected _useObjectSpaceNormalMap: boolean;
  58159. /**
  58160. * Allows using the bump map in parallax mode.
  58161. */
  58162. protected _useParallax: boolean;
  58163. /**
  58164. * Allows using the bump map in parallax occlusion mode.
  58165. */
  58166. protected _useParallaxOcclusion: boolean;
  58167. /**
  58168. * Controls the scale bias of the parallax mode.
  58169. */
  58170. protected _parallaxScaleBias: number;
  58171. /**
  58172. * If sets to true, disables all the lights affecting the material.
  58173. */
  58174. protected _disableLighting: boolean;
  58175. /**
  58176. * Number of Simultaneous lights allowed on the material.
  58177. */
  58178. protected _maxSimultaneousLights: number;
  58179. /**
  58180. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58181. */
  58182. protected _invertNormalMapX: boolean;
  58183. /**
  58184. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58185. */
  58186. protected _invertNormalMapY: boolean;
  58187. /**
  58188. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58189. */
  58190. protected _twoSidedLighting: boolean;
  58191. /**
  58192. * Defines the alpha limits in alpha test mode.
  58193. */
  58194. protected _alphaCutOff: number;
  58195. /**
  58196. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58197. */
  58198. protected _forceAlphaTest: boolean;
  58199. /**
  58200. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58201. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58202. */
  58203. protected _useAlphaFresnel: boolean;
  58204. /**
  58205. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58206. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58207. */
  58208. protected _useLinearAlphaFresnel: boolean;
  58209. /**
  58210. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58211. * from cos thetav and roughness:
  58212. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58213. */
  58214. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58215. /**
  58216. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58217. */
  58218. protected _forceIrradianceInFragment: boolean;
  58219. private _realTimeFiltering;
  58220. /**
  58221. * Enables realtime filtering on the texture.
  58222. */
  58223. get realTimeFiltering(): boolean;
  58224. set realTimeFiltering(b: boolean);
  58225. private _realTimeFilteringQuality;
  58226. /**
  58227. * Quality switch for realtime filtering
  58228. */
  58229. get realTimeFilteringQuality(): number;
  58230. set realTimeFilteringQuality(n: number);
  58231. /**
  58232. * Should this material render to several textures at once
  58233. */
  58234. get shouldRenderToMRT(): boolean;
  58235. /**
  58236. * Force normal to face away from face.
  58237. */
  58238. protected _forceNormalForward: boolean;
  58239. /**
  58240. * Enables specular anti aliasing in the PBR shader.
  58241. * It will both interacts on the Geometry for analytical and IBL lighting.
  58242. * It also prefilter the roughness map based on the bump values.
  58243. */
  58244. protected _enableSpecularAntiAliasing: boolean;
  58245. /**
  58246. * Default configuration related to image processing available in the PBR Material.
  58247. */
  58248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58249. /**
  58250. * Keep track of the image processing observer to allow dispose and replace.
  58251. */
  58252. private _imageProcessingObserver;
  58253. /**
  58254. * Attaches a new image processing configuration to the PBR Material.
  58255. * @param configuration
  58256. */
  58257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58258. /**
  58259. * Stores the available render targets.
  58260. */
  58261. private _renderTargets;
  58262. /**
  58263. * Sets the global ambient color for the material used in lighting calculations.
  58264. */
  58265. private _globalAmbientColor;
  58266. /**
  58267. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58268. */
  58269. private _useLogarithmicDepth;
  58270. /**
  58271. * If set to true, no lighting calculations will be applied.
  58272. */
  58273. private _unlit;
  58274. private _debugMode;
  58275. /**
  58276. * @hidden
  58277. * This is reserved for the inspector.
  58278. * Defines the material debug mode.
  58279. * It helps seeing only some components of the material while troubleshooting.
  58280. */
  58281. debugMode: number;
  58282. /**
  58283. * @hidden
  58284. * This is reserved for the inspector.
  58285. * Specify from where on screen the debug mode should start.
  58286. * The value goes from -1 (full screen) to 1 (not visible)
  58287. * It helps with side by side comparison against the final render
  58288. * This defaults to -1
  58289. */
  58290. private debugLimit;
  58291. /**
  58292. * @hidden
  58293. * This is reserved for the inspector.
  58294. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58295. * You can use the factor to better multiply the final value.
  58296. */
  58297. private debugFactor;
  58298. /**
  58299. * Defines the clear coat layer parameters for the material.
  58300. */
  58301. readonly clearCoat: PBRClearCoatConfiguration;
  58302. /**
  58303. * Defines the anisotropic parameters for the material.
  58304. */
  58305. readonly anisotropy: PBRAnisotropicConfiguration;
  58306. /**
  58307. * Defines the BRDF parameters for the material.
  58308. */
  58309. readonly brdf: PBRBRDFConfiguration;
  58310. /**
  58311. * Defines the Sheen parameters for the material.
  58312. */
  58313. readonly sheen: PBRSheenConfiguration;
  58314. /**
  58315. * Defines the SubSurface parameters for the material.
  58316. */
  58317. readonly subSurface: PBRSubSurfaceConfiguration;
  58318. /**
  58319. * Defines the detail map parameters for the material.
  58320. */
  58321. readonly detailMap: DetailMapConfiguration;
  58322. protected _rebuildInParallel: boolean;
  58323. /**
  58324. * Instantiates a new PBRMaterial instance.
  58325. *
  58326. * @param name The material name
  58327. * @param scene The scene the material will be use in.
  58328. */
  58329. constructor(name: string, scene: Scene);
  58330. /**
  58331. * Gets a boolean indicating that current material needs to register RTT
  58332. */
  58333. get hasRenderTargetTextures(): boolean;
  58334. /**
  58335. * Gets the name of the material class.
  58336. */
  58337. getClassName(): string;
  58338. /**
  58339. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58340. */
  58341. get useLogarithmicDepth(): boolean;
  58342. /**
  58343. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58344. */
  58345. set useLogarithmicDepth(value: boolean);
  58346. /**
  58347. * Returns true if alpha blending should be disabled.
  58348. */
  58349. protected get _disableAlphaBlending(): boolean;
  58350. /**
  58351. * Specifies whether or not this material should be rendered in alpha blend mode.
  58352. */
  58353. needAlphaBlending(): boolean;
  58354. /**
  58355. * Specifies whether or not this material should be rendered in alpha test mode.
  58356. */
  58357. needAlphaTesting(): boolean;
  58358. /**
  58359. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58360. */
  58361. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58362. /**
  58363. * Gets the texture used for the alpha test.
  58364. */
  58365. getAlphaTestTexture(): Nullable<BaseTexture>;
  58366. /**
  58367. * Specifies that the submesh is ready to be used.
  58368. * @param mesh - BJS mesh.
  58369. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58370. * @param useInstances - Specifies that instances should be used.
  58371. * @returns - boolean indicating that the submesh is ready or not.
  58372. */
  58373. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58374. /**
  58375. * Specifies if the material uses metallic roughness workflow.
  58376. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58377. */
  58378. isMetallicWorkflow(): boolean;
  58379. private _prepareEffect;
  58380. private _prepareDefines;
  58381. /**
  58382. * Force shader compilation
  58383. */
  58384. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58385. /**
  58386. * Initializes the uniform buffer layout for the shader.
  58387. */
  58388. buildUniformLayout(): void;
  58389. /**
  58390. * Unbinds the material from the mesh
  58391. */
  58392. unbind(): void;
  58393. /**
  58394. * Binds the submesh data.
  58395. * @param world - The world matrix.
  58396. * @param mesh - The BJS mesh.
  58397. * @param subMesh - A submesh of the BJS mesh.
  58398. */
  58399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58400. /**
  58401. * Returns the animatable textures.
  58402. * @returns - Array of animatable textures.
  58403. */
  58404. getAnimatables(): IAnimatable[];
  58405. /**
  58406. * Returns the texture used for reflections.
  58407. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58408. */
  58409. private _getReflectionTexture;
  58410. /**
  58411. * Returns an array of the actively used textures.
  58412. * @returns - Array of BaseTextures
  58413. */
  58414. getActiveTextures(): BaseTexture[];
  58415. /**
  58416. * Checks to see if a texture is used in the material.
  58417. * @param texture - Base texture to use.
  58418. * @returns - Boolean specifying if a texture is used in the material.
  58419. */
  58420. hasTexture(texture: BaseTexture): boolean;
  58421. /**
  58422. * Disposes the resources of the material.
  58423. * @param forceDisposeEffect - Forces the disposal of effects.
  58424. * @param forceDisposeTextures - Forces the disposal of all textures.
  58425. */
  58426. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58427. }
  58428. }
  58429. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58430. import { Nullable } from "babylonjs/types";
  58431. import { Scene } from "babylonjs/scene";
  58432. import { Color3 } from "babylonjs/Maths/math.color";
  58433. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58434. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58435. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58436. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58437. /**
  58438. * The Physically based material of BJS.
  58439. *
  58440. * This offers the main features of a standard PBR material.
  58441. * For more information, please refer to the documentation :
  58442. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58443. */
  58444. export class PBRMaterial extends PBRBaseMaterial {
  58445. /**
  58446. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58447. */
  58448. static readonly PBRMATERIAL_OPAQUE: number;
  58449. /**
  58450. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58451. */
  58452. static readonly PBRMATERIAL_ALPHATEST: number;
  58453. /**
  58454. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58455. */
  58456. static readonly PBRMATERIAL_ALPHABLEND: number;
  58457. /**
  58458. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58459. * They are also discarded below the alpha cutoff threshold to improve performances.
  58460. */
  58461. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58462. /**
  58463. * Defines the default value of how much AO map is occluding the analytical lights
  58464. * (point spot...).
  58465. */
  58466. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58467. /**
  58468. * Intensity of the direct lights e.g. the four lights available in your scene.
  58469. * This impacts both the direct diffuse and specular highlights.
  58470. */
  58471. directIntensity: number;
  58472. /**
  58473. * Intensity of the emissive part of the material.
  58474. * This helps controlling the emissive effect without modifying the emissive color.
  58475. */
  58476. emissiveIntensity: number;
  58477. /**
  58478. * Intensity of the environment e.g. how much the environment will light the object
  58479. * either through harmonics for rough material or through the refelction for shiny ones.
  58480. */
  58481. environmentIntensity: number;
  58482. /**
  58483. * This is a special control allowing the reduction of the specular highlights coming from the
  58484. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58485. */
  58486. specularIntensity: number;
  58487. /**
  58488. * Debug Control allowing disabling the bump map on this material.
  58489. */
  58490. disableBumpMap: boolean;
  58491. /**
  58492. * AKA Diffuse Texture in standard nomenclature.
  58493. */
  58494. albedoTexture: BaseTexture;
  58495. /**
  58496. * AKA Occlusion Texture in other nomenclature.
  58497. */
  58498. ambientTexture: BaseTexture;
  58499. /**
  58500. * AKA Occlusion Texture Intensity in other nomenclature.
  58501. */
  58502. ambientTextureStrength: number;
  58503. /**
  58504. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58505. * 1 means it completely occludes it
  58506. * 0 mean it has no impact
  58507. */
  58508. ambientTextureImpactOnAnalyticalLights: number;
  58509. /**
  58510. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58511. */
  58512. opacityTexture: BaseTexture;
  58513. /**
  58514. * Stores the reflection values in a texture.
  58515. */
  58516. reflectionTexture: Nullable<BaseTexture>;
  58517. /**
  58518. * Stores the emissive values in a texture.
  58519. */
  58520. emissiveTexture: BaseTexture;
  58521. /**
  58522. * AKA Specular texture in other nomenclature.
  58523. */
  58524. reflectivityTexture: BaseTexture;
  58525. /**
  58526. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58527. */
  58528. metallicTexture: BaseTexture;
  58529. /**
  58530. * Specifies the metallic scalar of the metallic/roughness workflow.
  58531. * Can also be used to scale the metalness values of the metallic texture.
  58532. */
  58533. metallic: Nullable<number>;
  58534. /**
  58535. * Specifies the roughness scalar of the metallic/roughness workflow.
  58536. * Can also be used to scale the roughness values of the metallic texture.
  58537. */
  58538. roughness: Nullable<number>;
  58539. /**
  58540. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58541. * By default the indexOfrefraction is used to compute F0;
  58542. *
  58543. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58544. *
  58545. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58546. * F90 = metallicReflectanceColor;
  58547. */
  58548. metallicF0Factor: number;
  58549. /**
  58550. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58551. * By default the F90 is always 1;
  58552. *
  58553. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58554. *
  58555. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58556. * F90 = metallicReflectanceColor;
  58557. */
  58558. metallicReflectanceColor: Color3;
  58559. /**
  58560. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58561. * This is multiply against the scalar values defined in the material.
  58562. */
  58563. metallicReflectanceTexture: Nullable<BaseTexture>;
  58564. /**
  58565. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58566. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58567. */
  58568. microSurfaceTexture: BaseTexture;
  58569. /**
  58570. * Stores surface normal data used to displace a mesh in a texture.
  58571. */
  58572. bumpTexture: BaseTexture;
  58573. /**
  58574. * Stores the pre-calculated light information of a mesh in a texture.
  58575. */
  58576. lightmapTexture: BaseTexture;
  58577. /**
  58578. * Stores the refracted light information in a texture.
  58579. */
  58580. get refractionTexture(): Nullable<BaseTexture>;
  58581. set refractionTexture(value: Nullable<BaseTexture>);
  58582. /**
  58583. * The color of a material in ambient lighting.
  58584. */
  58585. ambientColor: Color3;
  58586. /**
  58587. * AKA Diffuse Color in other nomenclature.
  58588. */
  58589. albedoColor: Color3;
  58590. /**
  58591. * AKA Specular Color in other nomenclature.
  58592. */
  58593. reflectivityColor: Color3;
  58594. /**
  58595. * The color reflected from the material.
  58596. */
  58597. reflectionColor: Color3;
  58598. /**
  58599. * The color emitted from the material.
  58600. */
  58601. emissiveColor: Color3;
  58602. /**
  58603. * AKA Glossiness in other nomenclature.
  58604. */
  58605. microSurface: number;
  58606. /**
  58607. * Index of refraction of the material base layer.
  58608. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58609. *
  58610. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58611. *
  58612. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58613. */
  58614. get indexOfRefraction(): number;
  58615. set indexOfRefraction(value: number);
  58616. /**
  58617. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58618. */
  58619. get invertRefractionY(): boolean;
  58620. set invertRefractionY(value: boolean);
  58621. /**
  58622. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58623. * Materials half opaque for instance using refraction could benefit from this control.
  58624. */
  58625. get linkRefractionWithTransparency(): boolean;
  58626. set linkRefractionWithTransparency(value: boolean);
  58627. /**
  58628. * If true, the light map contains occlusion information instead of lighting info.
  58629. */
  58630. useLightmapAsShadowmap: boolean;
  58631. /**
  58632. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58633. */
  58634. useAlphaFromAlbedoTexture: boolean;
  58635. /**
  58636. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58637. */
  58638. forceAlphaTest: boolean;
  58639. /**
  58640. * Defines the alpha limits in alpha test mode.
  58641. */
  58642. alphaCutOff: number;
  58643. /**
  58644. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58645. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58646. */
  58647. useSpecularOverAlpha: boolean;
  58648. /**
  58649. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58650. */
  58651. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58652. /**
  58653. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58654. */
  58655. useRoughnessFromMetallicTextureAlpha: boolean;
  58656. /**
  58657. * Specifies if the metallic texture contains the roughness information in its green channel.
  58658. */
  58659. useRoughnessFromMetallicTextureGreen: boolean;
  58660. /**
  58661. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58662. */
  58663. useMetallnessFromMetallicTextureBlue: boolean;
  58664. /**
  58665. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58666. */
  58667. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58668. /**
  58669. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58670. */
  58671. useAmbientInGrayScale: boolean;
  58672. /**
  58673. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58674. * The material will try to infer what glossiness each pixel should be.
  58675. */
  58676. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58677. /**
  58678. * BJS is using an harcoded light falloff based on a manually sets up range.
  58679. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58680. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58681. */
  58682. get usePhysicalLightFalloff(): boolean;
  58683. /**
  58684. * BJS is using an harcoded light falloff based on a manually sets up range.
  58685. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58686. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58687. */
  58688. set usePhysicalLightFalloff(value: boolean);
  58689. /**
  58690. * In order to support the falloff compatibility with gltf, a special mode has been added
  58691. * to reproduce the gltf light falloff.
  58692. */
  58693. get useGLTFLightFalloff(): boolean;
  58694. /**
  58695. * In order to support the falloff compatibility with gltf, a special mode has been added
  58696. * to reproduce the gltf light falloff.
  58697. */
  58698. set useGLTFLightFalloff(value: boolean);
  58699. /**
  58700. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58701. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58702. */
  58703. useRadianceOverAlpha: boolean;
  58704. /**
  58705. * Allows using an object space normal map (instead of tangent space).
  58706. */
  58707. useObjectSpaceNormalMap: boolean;
  58708. /**
  58709. * Allows using the bump map in parallax mode.
  58710. */
  58711. useParallax: boolean;
  58712. /**
  58713. * Allows using the bump map in parallax occlusion mode.
  58714. */
  58715. useParallaxOcclusion: boolean;
  58716. /**
  58717. * Controls the scale bias of the parallax mode.
  58718. */
  58719. parallaxScaleBias: number;
  58720. /**
  58721. * If sets to true, disables all the lights affecting the material.
  58722. */
  58723. disableLighting: boolean;
  58724. /**
  58725. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58726. */
  58727. forceIrradianceInFragment: boolean;
  58728. /**
  58729. * Number of Simultaneous lights allowed on the material.
  58730. */
  58731. maxSimultaneousLights: number;
  58732. /**
  58733. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58734. */
  58735. invertNormalMapX: boolean;
  58736. /**
  58737. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58738. */
  58739. invertNormalMapY: boolean;
  58740. /**
  58741. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58742. */
  58743. twoSidedLighting: boolean;
  58744. /**
  58745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58746. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58747. */
  58748. useAlphaFresnel: boolean;
  58749. /**
  58750. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58751. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58752. */
  58753. useLinearAlphaFresnel: boolean;
  58754. /**
  58755. * Let user defines the brdf lookup texture used for IBL.
  58756. * A default 8bit version is embedded but you could point at :
  58757. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58758. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58759. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58760. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58761. */
  58762. environmentBRDFTexture: Nullable<BaseTexture>;
  58763. /**
  58764. * Force normal to face away from face.
  58765. */
  58766. forceNormalForward: boolean;
  58767. /**
  58768. * Enables specular anti aliasing in the PBR shader.
  58769. * It will both interacts on the Geometry for analytical and IBL lighting.
  58770. * It also prefilter the roughness map based on the bump values.
  58771. */
  58772. enableSpecularAntiAliasing: boolean;
  58773. /**
  58774. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58775. * makes the reflect vector face the model (under horizon).
  58776. */
  58777. useHorizonOcclusion: boolean;
  58778. /**
  58779. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58780. * too much the area relying on ambient texture to define their ambient occlusion.
  58781. */
  58782. useRadianceOcclusion: boolean;
  58783. /**
  58784. * If set to true, no lighting calculations will be applied.
  58785. */
  58786. unlit: boolean;
  58787. /**
  58788. * Gets the image processing configuration used either in this material.
  58789. */
  58790. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58791. /**
  58792. * Sets the Default image processing configuration used either in the this material.
  58793. *
  58794. * If sets to null, the scene one is in use.
  58795. */
  58796. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58797. /**
  58798. * Gets wether the color curves effect is enabled.
  58799. */
  58800. get cameraColorCurvesEnabled(): boolean;
  58801. /**
  58802. * Sets wether the color curves effect is enabled.
  58803. */
  58804. set cameraColorCurvesEnabled(value: boolean);
  58805. /**
  58806. * Gets wether the color grading effect is enabled.
  58807. */
  58808. get cameraColorGradingEnabled(): boolean;
  58809. /**
  58810. * Gets wether the color grading effect is enabled.
  58811. */
  58812. set cameraColorGradingEnabled(value: boolean);
  58813. /**
  58814. * Gets wether tonemapping is enabled or not.
  58815. */
  58816. get cameraToneMappingEnabled(): boolean;
  58817. /**
  58818. * Sets wether tonemapping is enabled or not
  58819. */
  58820. set cameraToneMappingEnabled(value: boolean);
  58821. /**
  58822. * The camera exposure used on this material.
  58823. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58824. * This corresponds to a photographic exposure.
  58825. */
  58826. get cameraExposure(): number;
  58827. /**
  58828. * The camera exposure used on this material.
  58829. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58830. * This corresponds to a photographic exposure.
  58831. */
  58832. set cameraExposure(value: number);
  58833. /**
  58834. * Gets The camera contrast used on this material.
  58835. */
  58836. get cameraContrast(): number;
  58837. /**
  58838. * Sets The camera contrast used on this material.
  58839. */
  58840. set cameraContrast(value: number);
  58841. /**
  58842. * Gets the Color Grading 2D Lookup Texture.
  58843. */
  58844. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58845. /**
  58846. * Sets the Color Grading 2D Lookup Texture.
  58847. */
  58848. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58849. /**
  58850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58852. * 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;
  58853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58854. */
  58855. get cameraColorCurves(): Nullable<ColorCurves>;
  58856. /**
  58857. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58858. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58859. * 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;
  58860. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58861. */
  58862. set cameraColorCurves(value: Nullable<ColorCurves>);
  58863. /**
  58864. * Instantiates a new PBRMaterial instance.
  58865. *
  58866. * @param name The material name
  58867. * @param scene The scene the material will be use in.
  58868. */
  58869. constructor(name: string, scene: Scene);
  58870. /**
  58871. * Returns the name of this material class.
  58872. */
  58873. getClassName(): string;
  58874. /**
  58875. * Makes a duplicate of the current material.
  58876. * @param name - name to use for the new material.
  58877. */
  58878. clone(name: string): PBRMaterial;
  58879. /**
  58880. * Serializes this PBR Material.
  58881. * @returns - An object with the serialized material.
  58882. */
  58883. serialize(): any;
  58884. /**
  58885. * Parses a PBR Material from a serialized object.
  58886. * @param source - Serialized object.
  58887. * @param scene - BJS scene instance.
  58888. * @param rootUrl - url for the scene object
  58889. * @returns - PBRMaterial
  58890. */
  58891. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58892. }
  58893. }
  58894. declare module "babylonjs/Misc/dds" {
  58895. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58897. import { Nullable } from "babylonjs/types";
  58898. import { Scene } from "babylonjs/scene";
  58899. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58900. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58901. /**
  58902. * Direct draw surface info
  58903. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58904. */
  58905. export interface DDSInfo {
  58906. /**
  58907. * Width of the texture
  58908. */
  58909. width: number;
  58910. /**
  58911. * Width of the texture
  58912. */
  58913. height: number;
  58914. /**
  58915. * Number of Mipmaps for the texture
  58916. * @see https://en.wikipedia.org/wiki/Mipmap
  58917. */
  58918. mipmapCount: number;
  58919. /**
  58920. * If the textures format is a known fourCC format
  58921. * @see https://www.fourcc.org/
  58922. */
  58923. isFourCC: boolean;
  58924. /**
  58925. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58926. */
  58927. isRGB: boolean;
  58928. /**
  58929. * If the texture is a lumincance format
  58930. */
  58931. isLuminance: boolean;
  58932. /**
  58933. * If this is a cube texture
  58934. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58935. */
  58936. isCube: boolean;
  58937. /**
  58938. * If the texture is a compressed format eg. FOURCC_DXT1
  58939. */
  58940. isCompressed: boolean;
  58941. /**
  58942. * The dxgiFormat of the texture
  58943. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58944. */
  58945. dxgiFormat: number;
  58946. /**
  58947. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58948. */
  58949. textureType: number;
  58950. /**
  58951. * Sphericle polynomial created for the dds texture
  58952. */
  58953. sphericalPolynomial?: SphericalPolynomial;
  58954. }
  58955. /**
  58956. * Class used to provide DDS decompression tools
  58957. */
  58958. export class DDSTools {
  58959. /**
  58960. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58961. */
  58962. static StoreLODInAlphaChannel: boolean;
  58963. /**
  58964. * Gets DDS information from an array buffer
  58965. * @param data defines the array buffer view to read data from
  58966. * @returns the DDS information
  58967. */
  58968. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58969. private static _FloatView;
  58970. private static _Int32View;
  58971. private static _ToHalfFloat;
  58972. private static _FromHalfFloat;
  58973. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58974. private static _GetHalfFloatRGBAArrayBuffer;
  58975. private static _GetFloatRGBAArrayBuffer;
  58976. private static _GetFloatAsUIntRGBAArrayBuffer;
  58977. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58978. private static _GetRGBAArrayBuffer;
  58979. private static _ExtractLongWordOrder;
  58980. private static _GetRGBArrayBuffer;
  58981. private static _GetLuminanceArrayBuffer;
  58982. /**
  58983. * Uploads DDS Levels to a Babylon Texture
  58984. * @hidden
  58985. */
  58986. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58987. }
  58988. module "babylonjs/Engines/thinEngine" {
  58989. interface ThinEngine {
  58990. /**
  58991. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58992. * @param rootUrl defines the url where the file to load is located
  58993. * @param scene defines the current scene
  58994. * @param lodScale defines scale to apply to the mip map selection
  58995. * @param lodOffset defines offset to apply to the mip map selection
  58996. * @param onLoad defines an optional callback raised when the texture is loaded
  58997. * @param onError defines an optional callback raised if there is an issue to load the texture
  58998. * @param format defines the format of the data
  58999. * @param forcedExtension defines the extension to use to pick the right loader
  59000. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59001. * @returns the cube texture as an InternalTexture
  59002. */
  59003. 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;
  59004. }
  59005. }
  59006. }
  59007. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59008. import { Nullable } from "babylonjs/types";
  59009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59010. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59011. /**
  59012. * Implementation of the DDS Texture Loader.
  59013. * @hidden
  59014. */
  59015. export class _DDSTextureLoader implements IInternalTextureLoader {
  59016. /**
  59017. * Defines wether the loader supports cascade loading the different faces.
  59018. */
  59019. readonly supportCascades: boolean;
  59020. /**
  59021. * This returns if the loader support the current file information.
  59022. * @param extension defines the file extension of the file being loaded
  59023. * @returns true if the loader can load the specified file
  59024. */
  59025. canLoad(extension: string): boolean;
  59026. /**
  59027. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59028. * @param data contains the texture data
  59029. * @param texture defines the BabylonJS internal texture
  59030. * @param createPolynomials will be true if polynomials have been requested
  59031. * @param onLoad defines the callback to trigger once the texture is ready
  59032. * @param onError defines the callback to trigger in case of error
  59033. */
  59034. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59035. /**
  59036. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59037. * @param data contains the texture data
  59038. * @param texture defines the BabylonJS internal texture
  59039. * @param callback defines the method to call once ready to upload
  59040. */
  59041. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59042. }
  59043. }
  59044. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59045. import { Nullable } from "babylonjs/types";
  59046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59047. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59048. /**
  59049. * Implementation of the ENV Texture Loader.
  59050. * @hidden
  59051. */
  59052. export class _ENVTextureLoader implements IInternalTextureLoader {
  59053. /**
  59054. * Defines wether the loader supports cascade loading the different faces.
  59055. */
  59056. readonly supportCascades: boolean;
  59057. /**
  59058. * This returns if the loader support the current file information.
  59059. * @param extension defines the file extension of the file being loaded
  59060. * @returns true if the loader can load the specified file
  59061. */
  59062. canLoad(extension: string): boolean;
  59063. /**
  59064. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59065. * @param data contains the texture data
  59066. * @param texture defines the BabylonJS internal texture
  59067. * @param createPolynomials will be true if polynomials have been requested
  59068. * @param onLoad defines the callback to trigger once the texture is ready
  59069. * @param onError defines the callback to trigger in case of error
  59070. */
  59071. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59072. /**
  59073. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59074. * @param data contains the texture data
  59075. * @param texture defines the BabylonJS internal texture
  59076. * @param callback defines the method to call once ready to upload
  59077. */
  59078. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59079. }
  59080. }
  59081. declare module "babylonjs/Misc/khronosTextureContainer" {
  59082. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59083. /**
  59084. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59085. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59086. */
  59087. export class KhronosTextureContainer {
  59088. /** contents of the KTX container file */
  59089. data: ArrayBufferView;
  59090. private static HEADER_LEN;
  59091. private static COMPRESSED_2D;
  59092. private static COMPRESSED_3D;
  59093. private static TEX_2D;
  59094. private static TEX_3D;
  59095. /**
  59096. * Gets the openGL type
  59097. */
  59098. glType: number;
  59099. /**
  59100. * Gets the openGL type size
  59101. */
  59102. glTypeSize: number;
  59103. /**
  59104. * Gets the openGL format
  59105. */
  59106. glFormat: number;
  59107. /**
  59108. * Gets the openGL internal format
  59109. */
  59110. glInternalFormat: number;
  59111. /**
  59112. * Gets the base internal format
  59113. */
  59114. glBaseInternalFormat: number;
  59115. /**
  59116. * Gets image width in pixel
  59117. */
  59118. pixelWidth: number;
  59119. /**
  59120. * Gets image height in pixel
  59121. */
  59122. pixelHeight: number;
  59123. /**
  59124. * Gets image depth in pixels
  59125. */
  59126. pixelDepth: number;
  59127. /**
  59128. * Gets the number of array elements
  59129. */
  59130. numberOfArrayElements: number;
  59131. /**
  59132. * Gets the number of faces
  59133. */
  59134. numberOfFaces: number;
  59135. /**
  59136. * Gets the number of mipmap levels
  59137. */
  59138. numberOfMipmapLevels: number;
  59139. /**
  59140. * Gets the bytes of key value data
  59141. */
  59142. bytesOfKeyValueData: number;
  59143. /**
  59144. * Gets the load type
  59145. */
  59146. loadType: number;
  59147. /**
  59148. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59149. */
  59150. isInvalid: boolean;
  59151. /**
  59152. * Creates a new KhronosTextureContainer
  59153. * @param data contents of the KTX container file
  59154. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59155. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59156. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59157. */
  59158. constructor(
  59159. /** contents of the KTX container file */
  59160. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59161. /**
  59162. * Uploads KTX content to a Babylon Texture.
  59163. * It is assumed that the texture has already been created & is currently bound
  59164. * @hidden
  59165. */
  59166. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59167. private _upload2DCompressedLevels;
  59168. /**
  59169. * Checks if the given data starts with a KTX file identifier.
  59170. * @param data the data to check
  59171. * @returns true if the data is a KTX file or false otherwise
  59172. */
  59173. static IsValid(data: ArrayBufferView): boolean;
  59174. }
  59175. }
  59176. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59178. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59179. /**
  59180. * Class for loading KTX2 files
  59181. * !!! Experimental Extension Subject to Changes !!!
  59182. * @hidden
  59183. */
  59184. export class KhronosTextureContainer2 {
  59185. private static _ModulePromise;
  59186. private static _TranscodeFormat;
  59187. constructor(engine: ThinEngine);
  59188. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59189. private _determineTranscodeFormat;
  59190. /**
  59191. * Checks if the given data starts with a KTX2 file identifier.
  59192. * @param data the data to check
  59193. * @returns true if the data is a KTX2 file or false otherwise
  59194. */
  59195. static IsValid(data: ArrayBufferView): boolean;
  59196. }
  59197. }
  59198. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59199. import { Nullable } from "babylonjs/types";
  59200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59201. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59202. /**
  59203. * Implementation of the KTX Texture Loader.
  59204. * @hidden
  59205. */
  59206. export class _KTXTextureLoader implements IInternalTextureLoader {
  59207. /**
  59208. * Defines wether the loader supports cascade loading the different faces.
  59209. */
  59210. readonly supportCascades: boolean;
  59211. /**
  59212. * This returns if the loader support the current file information.
  59213. * @param extension defines the file extension of the file being loaded
  59214. * @param mimeType defines the optional mime type of the file being loaded
  59215. * @returns true if the loader can load the specified file
  59216. */
  59217. canLoad(extension: string, mimeType?: string): boolean;
  59218. /**
  59219. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59220. * @param data contains the texture data
  59221. * @param texture defines the BabylonJS internal texture
  59222. * @param createPolynomials will be true if polynomials have been requested
  59223. * @param onLoad defines the callback to trigger once the texture is ready
  59224. * @param onError defines the callback to trigger in case of error
  59225. */
  59226. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59227. /**
  59228. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59229. * @param data contains the texture data
  59230. * @param texture defines the BabylonJS internal texture
  59231. * @param callback defines the method to call once ready to upload
  59232. */
  59233. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59234. }
  59235. }
  59236. declare module "babylonjs/Helpers/sceneHelpers" {
  59237. import { Nullable } from "babylonjs/types";
  59238. import { Mesh } from "babylonjs/Meshes/mesh";
  59239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59240. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59241. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59242. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59243. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59244. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59245. import "babylonjs/Meshes/Builders/boxBuilder";
  59246. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59247. /** @hidden */
  59248. export var _forceSceneHelpersToBundle: boolean;
  59249. module "babylonjs/scene" {
  59250. interface Scene {
  59251. /**
  59252. * Creates a default light for the scene.
  59253. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59254. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59255. */
  59256. createDefaultLight(replace?: boolean): void;
  59257. /**
  59258. * Creates a default camera for the scene.
  59259. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59260. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59261. * @param replace has default false, when true replaces the active camera in the scene
  59262. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59263. */
  59264. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59265. /**
  59266. * Creates a default camera and a default light.
  59267. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59268. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59269. * @param replace has the default false, when true replaces the active camera/light in the scene
  59270. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59271. */
  59272. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59273. /**
  59274. * Creates a new sky box
  59275. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59276. * @param environmentTexture defines the texture to use as environment texture
  59277. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59278. * @param scale defines the overall scale of the skybox
  59279. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59280. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59281. * @returns a new mesh holding the sky box
  59282. */
  59283. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59284. /**
  59285. * Creates a new environment
  59286. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59287. * @param options defines the options you can use to configure the environment
  59288. * @returns the new EnvironmentHelper
  59289. */
  59290. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59291. /**
  59292. * Creates a new VREXperienceHelper
  59293. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59294. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59295. * @returns a new VREXperienceHelper
  59296. */
  59297. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59298. /**
  59299. * Creates a new WebXRDefaultExperience
  59300. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59301. * @param options experience options
  59302. * @returns a promise for a new WebXRDefaultExperience
  59303. */
  59304. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59305. }
  59306. }
  59307. }
  59308. declare module "babylonjs/Helpers/videoDome" {
  59309. import { Scene } from "babylonjs/scene";
  59310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59311. import { Mesh } from "babylonjs/Meshes/mesh";
  59312. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59313. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59314. import "babylonjs/Meshes/Builders/sphereBuilder";
  59315. /**
  59316. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59317. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59318. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59319. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59320. */
  59321. export class VideoDome extends TransformNode {
  59322. /**
  59323. * Define the video source as a Monoscopic panoramic 360 video.
  59324. */
  59325. static readonly MODE_MONOSCOPIC: number;
  59326. /**
  59327. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59328. */
  59329. static readonly MODE_TOPBOTTOM: number;
  59330. /**
  59331. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59332. */
  59333. static readonly MODE_SIDEBYSIDE: number;
  59334. private _halfDome;
  59335. private _useDirectMapping;
  59336. /**
  59337. * The video texture being displayed on the sphere
  59338. */
  59339. protected _videoTexture: VideoTexture;
  59340. /**
  59341. * Gets the video texture being displayed on the sphere
  59342. */
  59343. get videoTexture(): VideoTexture;
  59344. /**
  59345. * The skybox material
  59346. */
  59347. protected _material: BackgroundMaterial;
  59348. /**
  59349. * The surface used for the video dome
  59350. */
  59351. protected _mesh: Mesh;
  59352. /**
  59353. * Gets the mesh used for the video dome.
  59354. */
  59355. get mesh(): Mesh;
  59356. /**
  59357. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59358. */
  59359. private _halfDomeMask;
  59360. /**
  59361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59362. * Also see the options.resolution property.
  59363. */
  59364. get fovMultiplier(): number;
  59365. set fovMultiplier(value: number);
  59366. private _videoMode;
  59367. /**
  59368. * Gets or set the current video mode for the video. It can be:
  59369. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59370. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59371. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59372. */
  59373. get videoMode(): number;
  59374. set videoMode(value: number);
  59375. /**
  59376. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59377. *
  59378. */
  59379. get halfDome(): boolean;
  59380. /**
  59381. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59382. */
  59383. set halfDome(enabled: boolean);
  59384. /**
  59385. * Oberserver used in Stereoscopic VR Mode.
  59386. */
  59387. private _onBeforeCameraRenderObserver;
  59388. /**
  59389. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59390. * @param name Element's name, child elements will append suffixes for their own names.
  59391. * @param urlsOrVideo defines the url(s) or the video element to use
  59392. * @param options An object containing optional or exposed sub element properties
  59393. */
  59394. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59395. resolution?: number;
  59396. clickToPlay?: boolean;
  59397. autoPlay?: boolean;
  59398. loop?: boolean;
  59399. size?: number;
  59400. poster?: string;
  59401. faceForward?: boolean;
  59402. useDirectMapping?: boolean;
  59403. halfDomeMode?: boolean;
  59404. }, scene: Scene);
  59405. private _changeVideoMode;
  59406. /**
  59407. * Releases resources associated with this node.
  59408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59410. */
  59411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59412. }
  59413. }
  59414. declare module "babylonjs/Helpers/index" {
  59415. export * from "babylonjs/Helpers/environmentHelper";
  59416. export * from "babylonjs/Helpers/photoDome";
  59417. export * from "babylonjs/Helpers/sceneHelpers";
  59418. export * from "babylonjs/Helpers/videoDome";
  59419. }
  59420. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59421. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59422. import { IDisposable } from "babylonjs/scene";
  59423. import { Engine } from "babylonjs/Engines/engine";
  59424. /**
  59425. * This class can be used to get instrumentation data from a Babylon engine
  59426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59427. */
  59428. export class EngineInstrumentation implements IDisposable {
  59429. /**
  59430. * Define the instrumented engine.
  59431. */
  59432. engine: Engine;
  59433. private _captureGPUFrameTime;
  59434. private _gpuFrameTimeToken;
  59435. private _gpuFrameTime;
  59436. private _captureShaderCompilationTime;
  59437. private _shaderCompilationTime;
  59438. private _onBeginFrameObserver;
  59439. private _onEndFrameObserver;
  59440. private _onBeforeShaderCompilationObserver;
  59441. private _onAfterShaderCompilationObserver;
  59442. /**
  59443. * Gets the perf counter used for GPU frame time
  59444. */
  59445. get gpuFrameTimeCounter(): PerfCounter;
  59446. /**
  59447. * Gets the GPU frame time capture status
  59448. */
  59449. get captureGPUFrameTime(): boolean;
  59450. /**
  59451. * Enable or disable the GPU frame time capture
  59452. */
  59453. set captureGPUFrameTime(value: boolean);
  59454. /**
  59455. * Gets the perf counter used for shader compilation time
  59456. */
  59457. get shaderCompilationTimeCounter(): PerfCounter;
  59458. /**
  59459. * Gets the shader compilation time capture status
  59460. */
  59461. get captureShaderCompilationTime(): boolean;
  59462. /**
  59463. * Enable or disable the shader compilation time capture
  59464. */
  59465. set captureShaderCompilationTime(value: boolean);
  59466. /**
  59467. * Instantiates a new engine instrumentation.
  59468. * This class can be used to get instrumentation data from a Babylon engine
  59469. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59470. * @param engine Defines the engine to instrument
  59471. */
  59472. constructor(
  59473. /**
  59474. * Define the instrumented engine.
  59475. */
  59476. engine: Engine);
  59477. /**
  59478. * Dispose and release associated resources.
  59479. */
  59480. dispose(): void;
  59481. }
  59482. }
  59483. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59484. import { Scene, IDisposable } from "babylonjs/scene";
  59485. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59486. /**
  59487. * This class can be used to get instrumentation data from a Babylon engine
  59488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59489. */
  59490. export class SceneInstrumentation implements IDisposable {
  59491. /**
  59492. * Defines the scene to instrument
  59493. */
  59494. scene: Scene;
  59495. private _captureActiveMeshesEvaluationTime;
  59496. private _activeMeshesEvaluationTime;
  59497. private _captureRenderTargetsRenderTime;
  59498. private _renderTargetsRenderTime;
  59499. private _captureFrameTime;
  59500. private _frameTime;
  59501. private _captureRenderTime;
  59502. private _renderTime;
  59503. private _captureInterFrameTime;
  59504. private _interFrameTime;
  59505. private _captureParticlesRenderTime;
  59506. private _particlesRenderTime;
  59507. private _captureSpritesRenderTime;
  59508. private _spritesRenderTime;
  59509. private _capturePhysicsTime;
  59510. private _physicsTime;
  59511. private _captureAnimationsTime;
  59512. private _animationsTime;
  59513. private _captureCameraRenderTime;
  59514. private _cameraRenderTime;
  59515. private _onBeforeActiveMeshesEvaluationObserver;
  59516. private _onAfterActiveMeshesEvaluationObserver;
  59517. private _onBeforeRenderTargetsRenderObserver;
  59518. private _onAfterRenderTargetsRenderObserver;
  59519. private _onAfterRenderObserver;
  59520. private _onBeforeDrawPhaseObserver;
  59521. private _onAfterDrawPhaseObserver;
  59522. private _onBeforeAnimationsObserver;
  59523. private _onBeforeParticlesRenderingObserver;
  59524. private _onAfterParticlesRenderingObserver;
  59525. private _onBeforeSpritesRenderingObserver;
  59526. private _onAfterSpritesRenderingObserver;
  59527. private _onBeforePhysicsObserver;
  59528. private _onAfterPhysicsObserver;
  59529. private _onAfterAnimationsObserver;
  59530. private _onBeforeCameraRenderObserver;
  59531. private _onAfterCameraRenderObserver;
  59532. /**
  59533. * Gets the perf counter used for active meshes evaluation time
  59534. */
  59535. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59536. /**
  59537. * Gets the active meshes evaluation time capture status
  59538. */
  59539. get captureActiveMeshesEvaluationTime(): boolean;
  59540. /**
  59541. * Enable or disable the active meshes evaluation time capture
  59542. */
  59543. set captureActiveMeshesEvaluationTime(value: boolean);
  59544. /**
  59545. * Gets the perf counter used for render targets render time
  59546. */
  59547. get renderTargetsRenderTimeCounter(): PerfCounter;
  59548. /**
  59549. * Gets the render targets render time capture status
  59550. */
  59551. get captureRenderTargetsRenderTime(): boolean;
  59552. /**
  59553. * Enable or disable the render targets render time capture
  59554. */
  59555. set captureRenderTargetsRenderTime(value: boolean);
  59556. /**
  59557. * Gets the perf counter used for particles render time
  59558. */
  59559. get particlesRenderTimeCounter(): PerfCounter;
  59560. /**
  59561. * Gets the particles render time capture status
  59562. */
  59563. get captureParticlesRenderTime(): boolean;
  59564. /**
  59565. * Enable or disable the particles render time capture
  59566. */
  59567. set captureParticlesRenderTime(value: boolean);
  59568. /**
  59569. * Gets the perf counter used for sprites render time
  59570. */
  59571. get spritesRenderTimeCounter(): PerfCounter;
  59572. /**
  59573. * Gets the sprites render time capture status
  59574. */
  59575. get captureSpritesRenderTime(): boolean;
  59576. /**
  59577. * Enable or disable the sprites render time capture
  59578. */
  59579. set captureSpritesRenderTime(value: boolean);
  59580. /**
  59581. * Gets the perf counter used for physics time
  59582. */
  59583. get physicsTimeCounter(): PerfCounter;
  59584. /**
  59585. * Gets the physics time capture status
  59586. */
  59587. get capturePhysicsTime(): boolean;
  59588. /**
  59589. * Enable or disable the physics time capture
  59590. */
  59591. set capturePhysicsTime(value: boolean);
  59592. /**
  59593. * Gets the perf counter used for animations time
  59594. */
  59595. get animationsTimeCounter(): PerfCounter;
  59596. /**
  59597. * Gets the animations time capture status
  59598. */
  59599. get captureAnimationsTime(): boolean;
  59600. /**
  59601. * Enable or disable the animations time capture
  59602. */
  59603. set captureAnimationsTime(value: boolean);
  59604. /**
  59605. * Gets the perf counter used for frame time capture
  59606. */
  59607. get frameTimeCounter(): PerfCounter;
  59608. /**
  59609. * Gets the frame time capture status
  59610. */
  59611. get captureFrameTime(): boolean;
  59612. /**
  59613. * Enable or disable the frame time capture
  59614. */
  59615. set captureFrameTime(value: boolean);
  59616. /**
  59617. * Gets the perf counter used for inter-frames time capture
  59618. */
  59619. get interFrameTimeCounter(): PerfCounter;
  59620. /**
  59621. * Gets the inter-frames time capture status
  59622. */
  59623. get captureInterFrameTime(): boolean;
  59624. /**
  59625. * Enable or disable the inter-frames time capture
  59626. */
  59627. set captureInterFrameTime(value: boolean);
  59628. /**
  59629. * Gets the perf counter used for render time capture
  59630. */
  59631. get renderTimeCounter(): PerfCounter;
  59632. /**
  59633. * Gets the render time capture status
  59634. */
  59635. get captureRenderTime(): boolean;
  59636. /**
  59637. * Enable or disable the render time capture
  59638. */
  59639. set captureRenderTime(value: boolean);
  59640. /**
  59641. * Gets the perf counter used for camera render time capture
  59642. */
  59643. get cameraRenderTimeCounter(): PerfCounter;
  59644. /**
  59645. * Gets the camera render time capture status
  59646. */
  59647. get captureCameraRenderTime(): boolean;
  59648. /**
  59649. * Enable or disable the camera render time capture
  59650. */
  59651. set captureCameraRenderTime(value: boolean);
  59652. /**
  59653. * Gets the perf counter used for draw calls
  59654. */
  59655. get drawCallsCounter(): PerfCounter;
  59656. /**
  59657. * Instantiates a new scene instrumentation.
  59658. * This class can be used to get instrumentation data from a Babylon engine
  59659. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59660. * @param scene Defines the scene to instrument
  59661. */
  59662. constructor(
  59663. /**
  59664. * Defines the scene to instrument
  59665. */
  59666. scene: Scene);
  59667. /**
  59668. * Dispose and release associated resources.
  59669. */
  59670. dispose(): void;
  59671. }
  59672. }
  59673. declare module "babylonjs/Instrumentation/index" {
  59674. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59675. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59676. export * from "babylonjs/Instrumentation/timeToken";
  59677. }
  59678. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59679. /** @hidden */
  59680. export var glowMapGenerationPixelShader: {
  59681. name: string;
  59682. shader: string;
  59683. };
  59684. }
  59685. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59686. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59687. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59690. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59691. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59692. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59693. /** @hidden */
  59694. export var glowMapGenerationVertexShader: {
  59695. name: string;
  59696. shader: string;
  59697. };
  59698. }
  59699. declare module "babylonjs/Layers/effectLayer" {
  59700. import { Observable } from "babylonjs/Misc/observable";
  59701. import { Nullable } from "babylonjs/types";
  59702. import { Camera } from "babylonjs/Cameras/camera";
  59703. import { Scene } from "babylonjs/scene";
  59704. import { ISize } from "babylonjs/Maths/math.size";
  59705. import { Color4 } from "babylonjs/Maths/math.color";
  59706. import { Engine } from "babylonjs/Engines/engine";
  59707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59709. import { Mesh } from "babylonjs/Meshes/mesh";
  59710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59713. import { Effect } from "babylonjs/Materials/effect";
  59714. import { Material } from "babylonjs/Materials/material";
  59715. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59716. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59717. /**
  59718. * Effect layer options. This helps customizing the behaviour
  59719. * of the effect layer.
  59720. */
  59721. export interface IEffectLayerOptions {
  59722. /**
  59723. * Multiplication factor apply to the canvas size to compute the render target size
  59724. * used to generated the objects (the smaller the faster).
  59725. */
  59726. mainTextureRatio: number;
  59727. /**
  59728. * Enforces a fixed size texture to ensure effect stability across devices.
  59729. */
  59730. mainTextureFixedSize?: number;
  59731. /**
  59732. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59733. */
  59734. alphaBlendingMode: number;
  59735. /**
  59736. * The camera attached to the layer.
  59737. */
  59738. camera: Nullable<Camera>;
  59739. /**
  59740. * The rendering group to draw the layer in.
  59741. */
  59742. renderingGroupId: number;
  59743. }
  59744. /**
  59745. * The effect layer Helps adding post process effect blended with the main pass.
  59746. *
  59747. * This can be for instance use to generate glow or higlight effects on the scene.
  59748. *
  59749. * The effect layer class can not be used directly and is intented to inherited from to be
  59750. * customized per effects.
  59751. */
  59752. export abstract class EffectLayer {
  59753. private _vertexBuffers;
  59754. private _indexBuffer;
  59755. private _cachedDefines;
  59756. private _effectLayerMapGenerationEffect;
  59757. private _effectLayerOptions;
  59758. private _mergeEffect;
  59759. protected _scene: Scene;
  59760. protected _engine: Engine;
  59761. protected _maxSize: number;
  59762. protected _mainTextureDesiredSize: ISize;
  59763. protected _mainTexture: RenderTargetTexture;
  59764. protected _shouldRender: boolean;
  59765. protected _postProcesses: PostProcess[];
  59766. protected _textures: BaseTexture[];
  59767. protected _emissiveTextureAndColor: {
  59768. texture: Nullable<BaseTexture>;
  59769. color: Color4;
  59770. };
  59771. /**
  59772. * The name of the layer
  59773. */
  59774. name: string;
  59775. /**
  59776. * The clear color of the texture used to generate the glow map.
  59777. */
  59778. neutralColor: Color4;
  59779. /**
  59780. * Specifies whether the highlight layer is enabled or not.
  59781. */
  59782. isEnabled: boolean;
  59783. /**
  59784. * Gets the camera attached to the layer.
  59785. */
  59786. get camera(): Nullable<Camera>;
  59787. /**
  59788. * Gets the rendering group id the layer should render in.
  59789. */
  59790. get renderingGroupId(): number;
  59791. set renderingGroupId(renderingGroupId: number);
  59792. /**
  59793. * An event triggered when the effect layer has been disposed.
  59794. */
  59795. onDisposeObservable: Observable<EffectLayer>;
  59796. /**
  59797. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59798. */
  59799. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59800. /**
  59801. * An event triggered when the generated texture is being merged in the scene.
  59802. */
  59803. onBeforeComposeObservable: Observable<EffectLayer>;
  59804. /**
  59805. * An event triggered when the mesh is rendered into the effect render target.
  59806. */
  59807. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59808. /**
  59809. * An event triggered after the mesh has been rendered into the effect render target.
  59810. */
  59811. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59812. /**
  59813. * An event triggered when the generated texture has been merged in the scene.
  59814. */
  59815. onAfterComposeObservable: Observable<EffectLayer>;
  59816. /**
  59817. * An event triggered when the efffect layer changes its size.
  59818. */
  59819. onSizeChangedObservable: Observable<EffectLayer>;
  59820. /** @hidden */
  59821. static _SceneComponentInitialization: (scene: Scene) => void;
  59822. /**
  59823. * Instantiates a new effect Layer and references it in the scene.
  59824. * @param name The name of the layer
  59825. * @param scene The scene to use the layer in
  59826. */
  59827. constructor(
  59828. /** The Friendly of the effect in the scene */
  59829. name: string, scene: Scene);
  59830. /**
  59831. * Get the effect name of the layer.
  59832. * @return The effect name
  59833. */
  59834. abstract getEffectName(): string;
  59835. /**
  59836. * Checks for the readiness of the element composing the layer.
  59837. * @param subMesh the mesh to check for
  59838. * @param useInstances specify whether or not to use instances to render the mesh
  59839. * @return true if ready otherwise, false
  59840. */
  59841. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59842. /**
  59843. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59844. * @returns true if the effect requires stencil during the main canvas render pass.
  59845. */
  59846. abstract needStencil(): boolean;
  59847. /**
  59848. * Create the merge effect. This is the shader use to blit the information back
  59849. * to the main canvas at the end of the scene rendering.
  59850. * @returns The effect containing the shader used to merge the effect on the main canvas
  59851. */
  59852. protected abstract _createMergeEffect(): Effect;
  59853. /**
  59854. * Creates the render target textures and post processes used in the effect layer.
  59855. */
  59856. protected abstract _createTextureAndPostProcesses(): void;
  59857. /**
  59858. * Implementation specific of rendering the generating effect on the main canvas.
  59859. * @param effect The effect used to render through
  59860. */
  59861. protected abstract _internalRender(effect: Effect): void;
  59862. /**
  59863. * Sets the required values for both the emissive texture and and the main color.
  59864. */
  59865. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59866. /**
  59867. * Free any resources and references associated to a mesh.
  59868. * Internal use
  59869. * @param mesh The mesh to free.
  59870. */
  59871. abstract _disposeMesh(mesh: Mesh): void;
  59872. /**
  59873. * Serializes this layer (Glow or Highlight for example)
  59874. * @returns a serialized layer object
  59875. */
  59876. abstract serialize?(): any;
  59877. /**
  59878. * Initializes the effect layer with the required options.
  59879. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59880. */
  59881. protected _init(options: Partial<IEffectLayerOptions>): void;
  59882. /**
  59883. * Generates the index buffer of the full screen quad blending to the main canvas.
  59884. */
  59885. private _generateIndexBuffer;
  59886. /**
  59887. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59888. */
  59889. private _generateVertexBuffer;
  59890. /**
  59891. * Sets the main texture desired size which is the closest power of two
  59892. * of the engine canvas size.
  59893. */
  59894. private _setMainTextureSize;
  59895. /**
  59896. * Creates the main texture for the effect layer.
  59897. */
  59898. protected _createMainTexture(): void;
  59899. /**
  59900. * Adds specific effects defines.
  59901. * @param defines The defines to add specifics to.
  59902. */
  59903. protected _addCustomEffectDefines(defines: string[]): void;
  59904. /**
  59905. * Checks for the readiness of the element composing the layer.
  59906. * @param subMesh the mesh to check for
  59907. * @param useInstances specify whether or not to use instances to render the mesh
  59908. * @param emissiveTexture the associated emissive texture used to generate the glow
  59909. * @return true if ready otherwise, false
  59910. */
  59911. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59912. /**
  59913. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59914. */
  59915. render(): void;
  59916. /**
  59917. * Determine if a given mesh will be used in the current effect.
  59918. * @param mesh mesh to test
  59919. * @returns true if the mesh will be used
  59920. */
  59921. hasMesh(mesh: AbstractMesh): boolean;
  59922. /**
  59923. * Returns true if the layer contains information to display, otherwise false.
  59924. * @returns true if the glow layer should be rendered
  59925. */
  59926. shouldRender(): boolean;
  59927. /**
  59928. * Returns true if the mesh should render, otherwise false.
  59929. * @param mesh The mesh to render
  59930. * @returns true if it should render otherwise false
  59931. */
  59932. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59933. /**
  59934. * Returns true if the mesh can be rendered, otherwise false.
  59935. * @param mesh The mesh to render
  59936. * @param material The material used on the mesh
  59937. * @returns true if it can be rendered otherwise false
  59938. */
  59939. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59940. /**
  59941. * Returns true if the mesh should render, otherwise false.
  59942. * @param mesh The mesh to render
  59943. * @returns true if it should render otherwise false
  59944. */
  59945. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59946. /**
  59947. * Renders the submesh passed in parameter to the generation map.
  59948. */
  59949. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59950. /**
  59951. * Defines whether the current material of the mesh should be use to render the effect.
  59952. * @param mesh defines the current mesh to render
  59953. */
  59954. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59955. /**
  59956. * Rebuild the required buffers.
  59957. * @hidden Internal use only.
  59958. */
  59959. _rebuild(): void;
  59960. /**
  59961. * Dispose only the render target textures and post process.
  59962. */
  59963. private _disposeTextureAndPostProcesses;
  59964. /**
  59965. * Dispose the highlight layer and free resources.
  59966. */
  59967. dispose(): void;
  59968. /**
  59969. * Gets the class name of the effect layer
  59970. * @returns the string with the class name of the effect layer
  59971. */
  59972. getClassName(): string;
  59973. /**
  59974. * Creates an effect layer from parsed effect layer data
  59975. * @param parsedEffectLayer defines effect layer data
  59976. * @param scene defines the current scene
  59977. * @param rootUrl defines the root URL containing the effect layer information
  59978. * @returns a parsed effect Layer
  59979. */
  59980. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59981. }
  59982. }
  59983. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59984. import { Scene } from "babylonjs/scene";
  59985. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59986. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59987. import { AbstractScene } from "babylonjs/abstractScene";
  59988. module "babylonjs/abstractScene" {
  59989. interface AbstractScene {
  59990. /**
  59991. * The list of effect layers (highlights/glow) added to the scene
  59992. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59993. * @see https://doc.babylonjs.com/how_to/glow_layer
  59994. */
  59995. effectLayers: Array<EffectLayer>;
  59996. /**
  59997. * Removes the given effect layer from this scene.
  59998. * @param toRemove defines the effect layer to remove
  59999. * @returns the index of the removed effect layer
  60000. */
  60001. removeEffectLayer(toRemove: EffectLayer): number;
  60002. /**
  60003. * Adds the given effect layer to this scene
  60004. * @param newEffectLayer defines the effect layer to add
  60005. */
  60006. addEffectLayer(newEffectLayer: EffectLayer): void;
  60007. }
  60008. }
  60009. /**
  60010. * Defines the layer scene component responsible to manage any effect layers
  60011. * in a given scene.
  60012. */
  60013. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60014. /**
  60015. * The component name helpfull to identify the component in the list of scene components.
  60016. */
  60017. readonly name: string;
  60018. /**
  60019. * The scene the component belongs to.
  60020. */
  60021. scene: Scene;
  60022. private _engine;
  60023. private _renderEffects;
  60024. private _needStencil;
  60025. private _previousStencilState;
  60026. /**
  60027. * Creates a new instance of the component for the given scene
  60028. * @param scene Defines the scene to register the component in
  60029. */
  60030. constructor(scene: Scene);
  60031. /**
  60032. * Registers the component in a given scene
  60033. */
  60034. register(): void;
  60035. /**
  60036. * Rebuilds the elements related to this component in case of
  60037. * context lost for instance.
  60038. */
  60039. rebuild(): void;
  60040. /**
  60041. * Serializes the component data to the specified json object
  60042. * @param serializationObject The object to serialize to
  60043. */
  60044. serialize(serializationObject: any): void;
  60045. /**
  60046. * Adds all the elements from the container to the scene
  60047. * @param container the container holding the elements
  60048. */
  60049. addFromContainer(container: AbstractScene): void;
  60050. /**
  60051. * Removes all the elements in the container from the scene
  60052. * @param container contains the elements to remove
  60053. * @param dispose if the removed element should be disposed (default: false)
  60054. */
  60055. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60056. /**
  60057. * Disposes the component and the associated ressources.
  60058. */
  60059. dispose(): void;
  60060. private _isReadyForMesh;
  60061. private _renderMainTexture;
  60062. private _setStencil;
  60063. private _setStencilBack;
  60064. private _draw;
  60065. private _drawCamera;
  60066. private _drawRenderingGroup;
  60067. }
  60068. }
  60069. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60070. /** @hidden */
  60071. export var glowMapMergePixelShader: {
  60072. name: string;
  60073. shader: string;
  60074. };
  60075. }
  60076. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60077. /** @hidden */
  60078. export var glowMapMergeVertexShader: {
  60079. name: string;
  60080. shader: string;
  60081. };
  60082. }
  60083. declare module "babylonjs/Layers/glowLayer" {
  60084. import { Nullable } from "babylonjs/types";
  60085. import { Camera } from "babylonjs/Cameras/camera";
  60086. import { Scene } from "babylonjs/scene";
  60087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60089. import { Mesh } from "babylonjs/Meshes/mesh";
  60090. import { Texture } from "babylonjs/Materials/Textures/texture";
  60091. import { Effect } from "babylonjs/Materials/effect";
  60092. import { Material } from "babylonjs/Materials/material";
  60093. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60094. import { Color4 } from "babylonjs/Maths/math.color";
  60095. import "babylonjs/Shaders/glowMapMerge.fragment";
  60096. import "babylonjs/Shaders/glowMapMerge.vertex";
  60097. import "babylonjs/Layers/effectLayerSceneComponent";
  60098. module "babylonjs/abstractScene" {
  60099. interface AbstractScene {
  60100. /**
  60101. * Return a the first highlight layer of the scene with a given name.
  60102. * @param name The name of the highlight layer to look for.
  60103. * @return The highlight layer if found otherwise null.
  60104. */
  60105. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60106. }
  60107. }
  60108. /**
  60109. * Glow layer options. This helps customizing the behaviour
  60110. * of the glow layer.
  60111. */
  60112. export interface IGlowLayerOptions {
  60113. /**
  60114. * Multiplication factor apply to the canvas size to compute the render target size
  60115. * used to generated the glowing objects (the smaller the faster).
  60116. */
  60117. mainTextureRatio: number;
  60118. /**
  60119. * Enforces a fixed size texture to ensure resize independant blur.
  60120. */
  60121. mainTextureFixedSize?: number;
  60122. /**
  60123. * How big is the kernel of the blur texture.
  60124. */
  60125. blurKernelSize: number;
  60126. /**
  60127. * The camera attached to the layer.
  60128. */
  60129. camera: Nullable<Camera>;
  60130. /**
  60131. * Enable MSAA by chosing the number of samples.
  60132. */
  60133. mainTextureSamples?: number;
  60134. /**
  60135. * The rendering group to draw the layer in.
  60136. */
  60137. renderingGroupId: number;
  60138. }
  60139. /**
  60140. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60141. *
  60142. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60143. *
  60144. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60145. */
  60146. export class GlowLayer extends EffectLayer {
  60147. /**
  60148. * Effect Name of the layer.
  60149. */
  60150. static readonly EffectName: string;
  60151. /**
  60152. * The default blur kernel size used for the glow.
  60153. */
  60154. static DefaultBlurKernelSize: number;
  60155. /**
  60156. * The default texture size ratio used for the glow.
  60157. */
  60158. static DefaultTextureRatio: number;
  60159. /**
  60160. * Sets the kernel size of the blur.
  60161. */
  60162. set blurKernelSize(value: number);
  60163. /**
  60164. * Gets the kernel size of the blur.
  60165. */
  60166. get blurKernelSize(): number;
  60167. /**
  60168. * Sets the glow intensity.
  60169. */
  60170. set intensity(value: number);
  60171. /**
  60172. * Gets the glow intensity.
  60173. */
  60174. get intensity(): number;
  60175. private _options;
  60176. private _intensity;
  60177. private _horizontalBlurPostprocess1;
  60178. private _verticalBlurPostprocess1;
  60179. private _horizontalBlurPostprocess2;
  60180. private _verticalBlurPostprocess2;
  60181. private _blurTexture1;
  60182. private _blurTexture2;
  60183. private _postProcesses1;
  60184. private _postProcesses2;
  60185. private _includedOnlyMeshes;
  60186. private _excludedMeshes;
  60187. private _meshesUsingTheirOwnMaterials;
  60188. /**
  60189. * Callback used to let the user override the color selection on a per mesh basis
  60190. */
  60191. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60192. /**
  60193. * Callback used to let the user override the texture selection on a per mesh basis
  60194. */
  60195. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60196. /**
  60197. * Instantiates a new glow Layer and references it to the scene.
  60198. * @param name The name of the layer
  60199. * @param scene The scene to use the layer in
  60200. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60201. */
  60202. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60203. /**
  60204. * Get the effect name of the layer.
  60205. * @return The effect name
  60206. */
  60207. getEffectName(): string;
  60208. /**
  60209. * Create the merge effect. This is the shader use to blit the information back
  60210. * to the main canvas at the end of the scene rendering.
  60211. */
  60212. protected _createMergeEffect(): Effect;
  60213. /**
  60214. * Creates the render target textures and post processes used in the glow layer.
  60215. */
  60216. protected _createTextureAndPostProcesses(): void;
  60217. /**
  60218. * Checks for the readiness of the element composing the layer.
  60219. * @param subMesh the mesh to check for
  60220. * @param useInstances specify wether or not to use instances to render the mesh
  60221. * @param emissiveTexture the associated emissive texture used to generate the glow
  60222. * @return true if ready otherwise, false
  60223. */
  60224. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60225. /**
  60226. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60227. */
  60228. needStencil(): boolean;
  60229. /**
  60230. * Returns true if the mesh can be rendered, otherwise false.
  60231. * @param mesh The mesh to render
  60232. * @param material The material used on the mesh
  60233. * @returns true if it can be rendered otherwise false
  60234. */
  60235. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60236. /**
  60237. * Implementation specific of rendering the generating effect on the main canvas.
  60238. * @param effect The effect used to render through
  60239. */
  60240. protected _internalRender(effect: Effect): void;
  60241. /**
  60242. * Sets the required values for both the emissive texture and and the main color.
  60243. */
  60244. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60245. /**
  60246. * Returns true if the mesh should render, otherwise false.
  60247. * @param mesh The mesh to render
  60248. * @returns true if it should render otherwise false
  60249. */
  60250. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60251. /**
  60252. * Adds specific effects defines.
  60253. * @param defines The defines to add specifics to.
  60254. */
  60255. protected _addCustomEffectDefines(defines: string[]): void;
  60256. /**
  60257. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60258. * @param mesh The mesh to exclude from the glow layer
  60259. */
  60260. addExcludedMesh(mesh: Mesh): void;
  60261. /**
  60262. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60263. * @param mesh The mesh to remove
  60264. */
  60265. removeExcludedMesh(mesh: Mesh): void;
  60266. /**
  60267. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60268. * @param mesh The mesh to include in the glow layer
  60269. */
  60270. addIncludedOnlyMesh(mesh: Mesh): void;
  60271. /**
  60272. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60273. * @param mesh The mesh to remove
  60274. */
  60275. removeIncludedOnlyMesh(mesh: Mesh): void;
  60276. /**
  60277. * Determine if a given mesh will be used in the glow layer
  60278. * @param mesh The mesh to test
  60279. * @returns true if the mesh will be highlighted by the current glow layer
  60280. */
  60281. hasMesh(mesh: AbstractMesh): boolean;
  60282. /**
  60283. * Defines whether the current material of the mesh should be use to render the effect.
  60284. * @param mesh defines the current mesh to render
  60285. */
  60286. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60287. /**
  60288. * Add a mesh to be rendered through its own material and not with emissive only.
  60289. * @param mesh The mesh for which we need to use its material
  60290. */
  60291. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60292. /**
  60293. * Remove a mesh from being rendered through its own material and not with emissive only.
  60294. * @param mesh The mesh for which we need to not use its material
  60295. */
  60296. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60297. /**
  60298. * Free any resources and references associated to a mesh.
  60299. * Internal use
  60300. * @param mesh The mesh to free.
  60301. * @hidden
  60302. */
  60303. _disposeMesh(mesh: Mesh): void;
  60304. /**
  60305. * Gets the class name of the effect layer
  60306. * @returns the string with the class name of the effect layer
  60307. */
  60308. getClassName(): string;
  60309. /**
  60310. * Serializes this glow layer
  60311. * @returns a serialized glow layer object
  60312. */
  60313. serialize(): any;
  60314. /**
  60315. * Creates a Glow Layer from parsed glow layer data
  60316. * @param parsedGlowLayer defines glow layer data
  60317. * @param scene defines the current scene
  60318. * @param rootUrl defines the root URL containing the glow layer information
  60319. * @returns a parsed Glow Layer
  60320. */
  60321. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60322. }
  60323. }
  60324. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60325. /** @hidden */
  60326. export var glowBlurPostProcessPixelShader: {
  60327. name: string;
  60328. shader: string;
  60329. };
  60330. }
  60331. declare module "babylonjs/Layers/highlightLayer" {
  60332. import { Observable } from "babylonjs/Misc/observable";
  60333. import { Nullable } from "babylonjs/types";
  60334. import { Camera } from "babylonjs/Cameras/camera";
  60335. import { Scene } from "babylonjs/scene";
  60336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60338. import { Mesh } from "babylonjs/Meshes/mesh";
  60339. import { Effect } from "babylonjs/Materials/effect";
  60340. import { Material } from "babylonjs/Materials/material";
  60341. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60342. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60343. import "babylonjs/Shaders/glowMapMerge.fragment";
  60344. import "babylonjs/Shaders/glowMapMerge.vertex";
  60345. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60346. module "babylonjs/abstractScene" {
  60347. interface AbstractScene {
  60348. /**
  60349. * Return a the first highlight layer of the scene with a given name.
  60350. * @param name The name of the highlight layer to look for.
  60351. * @return The highlight layer if found otherwise null.
  60352. */
  60353. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60354. }
  60355. }
  60356. /**
  60357. * Highlight layer options. This helps customizing the behaviour
  60358. * of the highlight layer.
  60359. */
  60360. export interface IHighlightLayerOptions {
  60361. /**
  60362. * Multiplication factor apply to the canvas size to compute the render target size
  60363. * used to generated the glowing objects (the smaller the faster).
  60364. */
  60365. mainTextureRatio: number;
  60366. /**
  60367. * Enforces a fixed size texture to ensure resize independant blur.
  60368. */
  60369. mainTextureFixedSize?: number;
  60370. /**
  60371. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60372. * of the picture to blur (the smaller the faster).
  60373. */
  60374. blurTextureSizeRatio: number;
  60375. /**
  60376. * How big in texel of the blur texture is the vertical blur.
  60377. */
  60378. blurVerticalSize: number;
  60379. /**
  60380. * How big in texel of the blur texture is the horizontal blur.
  60381. */
  60382. blurHorizontalSize: number;
  60383. /**
  60384. * Alpha blending mode used to apply the blur. Default is combine.
  60385. */
  60386. alphaBlendingMode: number;
  60387. /**
  60388. * The camera attached to the layer.
  60389. */
  60390. camera: Nullable<Camera>;
  60391. /**
  60392. * Should we display highlight as a solid stroke?
  60393. */
  60394. isStroke?: boolean;
  60395. /**
  60396. * The rendering group to draw the layer in.
  60397. */
  60398. renderingGroupId: number;
  60399. }
  60400. /**
  60401. * The highlight layer Helps adding a glow effect around a mesh.
  60402. *
  60403. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60404. * glowy meshes to your scene.
  60405. *
  60406. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60407. */
  60408. export class HighlightLayer extends EffectLayer {
  60409. name: string;
  60410. /**
  60411. * Effect Name of the highlight layer.
  60412. */
  60413. static readonly EffectName: string;
  60414. /**
  60415. * The neutral color used during the preparation of the glow effect.
  60416. * This is black by default as the blend operation is a blend operation.
  60417. */
  60418. static NeutralColor: Color4;
  60419. /**
  60420. * Stencil value used for glowing meshes.
  60421. */
  60422. static GlowingMeshStencilReference: number;
  60423. /**
  60424. * Stencil value used for the other meshes in the scene.
  60425. */
  60426. static NormalMeshStencilReference: number;
  60427. /**
  60428. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60429. */
  60430. innerGlow: boolean;
  60431. /**
  60432. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60433. */
  60434. outerGlow: boolean;
  60435. /**
  60436. * Specifies the horizontal size of the blur.
  60437. */
  60438. set blurHorizontalSize(value: number);
  60439. /**
  60440. * Specifies the vertical size of the blur.
  60441. */
  60442. set blurVerticalSize(value: number);
  60443. /**
  60444. * Gets the horizontal size of the blur.
  60445. */
  60446. get blurHorizontalSize(): number;
  60447. /**
  60448. * Gets the vertical size of the blur.
  60449. */
  60450. get blurVerticalSize(): number;
  60451. /**
  60452. * An event triggered when the highlight layer is being blurred.
  60453. */
  60454. onBeforeBlurObservable: Observable<HighlightLayer>;
  60455. /**
  60456. * An event triggered when the highlight layer has been blurred.
  60457. */
  60458. onAfterBlurObservable: Observable<HighlightLayer>;
  60459. private _instanceGlowingMeshStencilReference;
  60460. private _options;
  60461. private _downSamplePostprocess;
  60462. private _horizontalBlurPostprocess;
  60463. private _verticalBlurPostprocess;
  60464. private _blurTexture;
  60465. private _meshes;
  60466. private _excludedMeshes;
  60467. /**
  60468. * Instantiates a new highlight Layer and references it to the scene..
  60469. * @param name The name of the layer
  60470. * @param scene The scene to use the layer in
  60471. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60472. */
  60473. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60474. /**
  60475. * Get the effect name of the layer.
  60476. * @return The effect name
  60477. */
  60478. getEffectName(): string;
  60479. /**
  60480. * Create the merge effect. This is the shader use to blit the information back
  60481. * to the main canvas at the end of the scene rendering.
  60482. */
  60483. protected _createMergeEffect(): Effect;
  60484. /**
  60485. * Creates the render target textures and post processes used in the highlight layer.
  60486. */
  60487. protected _createTextureAndPostProcesses(): void;
  60488. /**
  60489. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60490. */
  60491. needStencil(): boolean;
  60492. /**
  60493. * Checks for the readiness of the element composing the layer.
  60494. * @param subMesh the mesh to check for
  60495. * @param useInstances specify wether or not to use instances to render the mesh
  60496. * @param emissiveTexture the associated emissive texture used to generate the glow
  60497. * @return true if ready otherwise, false
  60498. */
  60499. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60500. /**
  60501. * Implementation specific of rendering the generating effect on the main canvas.
  60502. * @param effect The effect used to render through
  60503. */
  60504. protected _internalRender(effect: Effect): void;
  60505. /**
  60506. * Returns true if the layer contains information to display, otherwise false.
  60507. */
  60508. shouldRender(): boolean;
  60509. /**
  60510. * Returns true if the mesh should render, otherwise false.
  60511. * @param mesh The mesh to render
  60512. * @returns true if it should render otherwise false
  60513. */
  60514. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60515. /**
  60516. * Returns true if the mesh can be rendered, otherwise false.
  60517. * @param mesh The mesh to render
  60518. * @param material The material used on the mesh
  60519. * @returns true if it can be rendered otherwise false
  60520. */
  60521. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60522. /**
  60523. * Adds specific effects defines.
  60524. * @param defines The defines to add specifics to.
  60525. */
  60526. protected _addCustomEffectDefines(defines: string[]): void;
  60527. /**
  60528. * Sets the required values for both the emissive texture and and the main color.
  60529. */
  60530. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60531. /**
  60532. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60533. * @param mesh The mesh to exclude from the highlight layer
  60534. */
  60535. addExcludedMesh(mesh: Mesh): void;
  60536. /**
  60537. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60538. * @param mesh The mesh to highlight
  60539. */
  60540. removeExcludedMesh(mesh: Mesh): void;
  60541. /**
  60542. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60543. * @param mesh mesh to test
  60544. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60545. */
  60546. hasMesh(mesh: AbstractMesh): boolean;
  60547. /**
  60548. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60549. * @param mesh The mesh to highlight
  60550. * @param color The color of the highlight
  60551. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60552. */
  60553. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60554. /**
  60555. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60556. * @param mesh The mesh to highlight
  60557. */
  60558. removeMesh(mesh: Mesh): void;
  60559. /**
  60560. * Remove all the meshes currently referenced in the highlight layer
  60561. */
  60562. removeAllMeshes(): void;
  60563. /**
  60564. * Force the stencil to the normal expected value for none glowing parts
  60565. */
  60566. private _defaultStencilReference;
  60567. /**
  60568. * Free any resources and references associated to a mesh.
  60569. * Internal use
  60570. * @param mesh The mesh to free.
  60571. * @hidden
  60572. */
  60573. _disposeMesh(mesh: Mesh): void;
  60574. /**
  60575. * Dispose the highlight layer and free resources.
  60576. */
  60577. dispose(): void;
  60578. /**
  60579. * Gets the class name of the effect layer
  60580. * @returns the string with the class name of the effect layer
  60581. */
  60582. getClassName(): string;
  60583. /**
  60584. * Serializes this Highlight layer
  60585. * @returns a serialized Highlight layer object
  60586. */
  60587. serialize(): any;
  60588. /**
  60589. * Creates a Highlight layer from parsed Highlight layer data
  60590. * @param parsedHightlightLayer defines the Highlight layer data
  60591. * @param scene defines the current scene
  60592. * @param rootUrl defines the root URL containing the Highlight layer information
  60593. * @returns a parsed Highlight layer
  60594. */
  60595. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60596. }
  60597. }
  60598. declare module "babylonjs/Layers/layerSceneComponent" {
  60599. import { Scene } from "babylonjs/scene";
  60600. import { ISceneComponent } from "babylonjs/sceneComponent";
  60601. import { Layer } from "babylonjs/Layers/layer";
  60602. import { AbstractScene } from "babylonjs/abstractScene";
  60603. module "babylonjs/abstractScene" {
  60604. interface AbstractScene {
  60605. /**
  60606. * The list of layers (background and foreground) of the scene
  60607. */
  60608. layers: Array<Layer>;
  60609. }
  60610. }
  60611. /**
  60612. * Defines the layer scene component responsible to manage any layers
  60613. * in a given scene.
  60614. */
  60615. export class LayerSceneComponent implements ISceneComponent {
  60616. /**
  60617. * The component name helpfull to identify the component in the list of scene components.
  60618. */
  60619. readonly name: string;
  60620. /**
  60621. * The scene the component belongs to.
  60622. */
  60623. scene: Scene;
  60624. private _engine;
  60625. /**
  60626. * Creates a new instance of the component for the given scene
  60627. * @param scene Defines the scene to register the component in
  60628. */
  60629. constructor(scene: Scene);
  60630. /**
  60631. * Registers the component in a given scene
  60632. */
  60633. register(): void;
  60634. /**
  60635. * Rebuilds the elements related to this component in case of
  60636. * context lost for instance.
  60637. */
  60638. rebuild(): void;
  60639. /**
  60640. * Disposes the component and the associated ressources.
  60641. */
  60642. dispose(): void;
  60643. private _draw;
  60644. private _drawCameraPredicate;
  60645. private _drawCameraBackground;
  60646. private _drawCameraForeground;
  60647. private _drawRenderTargetPredicate;
  60648. private _drawRenderTargetBackground;
  60649. private _drawRenderTargetForeground;
  60650. /**
  60651. * Adds all the elements from the container to the scene
  60652. * @param container the container holding the elements
  60653. */
  60654. addFromContainer(container: AbstractScene): void;
  60655. /**
  60656. * Removes all the elements in the container from the scene
  60657. * @param container contains the elements to remove
  60658. * @param dispose if the removed element should be disposed (default: false)
  60659. */
  60660. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60661. }
  60662. }
  60663. declare module "babylonjs/Shaders/layer.fragment" {
  60664. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60665. /** @hidden */
  60666. export var layerPixelShader: {
  60667. name: string;
  60668. shader: string;
  60669. };
  60670. }
  60671. declare module "babylonjs/Shaders/layer.vertex" {
  60672. /** @hidden */
  60673. export var layerVertexShader: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module "babylonjs/Layers/layer" {
  60679. import { Observable } from "babylonjs/Misc/observable";
  60680. import { Nullable } from "babylonjs/types";
  60681. import { Scene } from "babylonjs/scene";
  60682. import { Vector2 } from "babylonjs/Maths/math.vector";
  60683. import { Color4 } from "babylonjs/Maths/math.color";
  60684. import { Texture } from "babylonjs/Materials/Textures/texture";
  60685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60686. import "babylonjs/Shaders/layer.fragment";
  60687. import "babylonjs/Shaders/layer.vertex";
  60688. /**
  60689. * This represents a full screen 2d layer.
  60690. * This can be useful to display a picture in the background of your scene for instance.
  60691. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60692. */
  60693. export class Layer {
  60694. /**
  60695. * Define the name of the layer.
  60696. */
  60697. name: string;
  60698. /**
  60699. * Define the texture the layer should display.
  60700. */
  60701. texture: Nullable<Texture>;
  60702. /**
  60703. * Is the layer in background or foreground.
  60704. */
  60705. isBackground: boolean;
  60706. /**
  60707. * Define the color of the layer (instead of texture).
  60708. */
  60709. color: Color4;
  60710. /**
  60711. * Define the scale of the layer in order to zoom in out of the texture.
  60712. */
  60713. scale: Vector2;
  60714. /**
  60715. * Define an offset for the layer in order to shift the texture.
  60716. */
  60717. offset: Vector2;
  60718. /**
  60719. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60720. */
  60721. alphaBlendingMode: number;
  60722. /**
  60723. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60724. * Alpha test will not mix with the background color in case of transparency.
  60725. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60726. */
  60727. alphaTest: boolean;
  60728. /**
  60729. * Define a mask to restrict the layer to only some of the scene cameras.
  60730. */
  60731. layerMask: number;
  60732. /**
  60733. * Define the list of render target the layer is visible into.
  60734. */
  60735. renderTargetTextures: RenderTargetTexture[];
  60736. /**
  60737. * Define if the layer is only used in renderTarget or if it also
  60738. * renders in the main frame buffer of the canvas.
  60739. */
  60740. renderOnlyInRenderTargetTextures: boolean;
  60741. private _scene;
  60742. private _vertexBuffers;
  60743. private _indexBuffer;
  60744. private _effect;
  60745. private _previousDefines;
  60746. /**
  60747. * An event triggered when the layer is disposed.
  60748. */
  60749. onDisposeObservable: Observable<Layer>;
  60750. private _onDisposeObserver;
  60751. /**
  60752. * Back compatibility with callback before the onDisposeObservable existed.
  60753. * The set callback will be triggered when the layer has been disposed.
  60754. */
  60755. set onDispose(callback: () => void);
  60756. /**
  60757. * An event triggered before rendering the scene
  60758. */
  60759. onBeforeRenderObservable: Observable<Layer>;
  60760. private _onBeforeRenderObserver;
  60761. /**
  60762. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60763. * The set callback will be triggered just before rendering the layer.
  60764. */
  60765. set onBeforeRender(callback: () => void);
  60766. /**
  60767. * An event triggered after rendering the scene
  60768. */
  60769. onAfterRenderObservable: Observable<Layer>;
  60770. private _onAfterRenderObserver;
  60771. /**
  60772. * Back compatibility with callback before the onAfterRenderObservable existed.
  60773. * The set callback will be triggered just after rendering the layer.
  60774. */
  60775. set onAfterRender(callback: () => void);
  60776. /**
  60777. * Instantiates a new layer.
  60778. * This represents a full screen 2d layer.
  60779. * This can be useful to display a picture in the background of your scene for instance.
  60780. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60781. * @param name Define the name of the layer in the scene
  60782. * @param imgUrl Define the url of the texture to display in the layer
  60783. * @param scene Define the scene the layer belongs to
  60784. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60785. * @param color Defines a color for the layer
  60786. */
  60787. constructor(
  60788. /**
  60789. * Define the name of the layer.
  60790. */
  60791. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60792. private _createIndexBuffer;
  60793. /** @hidden */
  60794. _rebuild(): void;
  60795. /**
  60796. * Renders the layer in the scene.
  60797. */
  60798. render(): void;
  60799. /**
  60800. * Disposes and releases the associated ressources.
  60801. */
  60802. dispose(): void;
  60803. }
  60804. }
  60805. declare module "babylonjs/Layers/index" {
  60806. export * from "babylonjs/Layers/effectLayer";
  60807. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60808. export * from "babylonjs/Layers/glowLayer";
  60809. export * from "babylonjs/Layers/highlightLayer";
  60810. export * from "babylonjs/Layers/layer";
  60811. export * from "babylonjs/Layers/layerSceneComponent";
  60812. }
  60813. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60814. /** @hidden */
  60815. export var lensFlarePixelShader: {
  60816. name: string;
  60817. shader: string;
  60818. };
  60819. }
  60820. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60821. /** @hidden */
  60822. export var lensFlareVertexShader: {
  60823. name: string;
  60824. shader: string;
  60825. };
  60826. }
  60827. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60828. import { Scene } from "babylonjs/scene";
  60829. import { Vector3 } from "babylonjs/Maths/math.vector";
  60830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60831. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60832. import "babylonjs/Shaders/lensFlare.fragment";
  60833. import "babylonjs/Shaders/lensFlare.vertex";
  60834. import { Viewport } from "babylonjs/Maths/math.viewport";
  60835. /**
  60836. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60837. * It is usually composed of several `lensFlare`.
  60838. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60839. */
  60840. export class LensFlareSystem {
  60841. /**
  60842. * Define the name of the lens flare system
  60843. */
  60844. name: string;
  60845. /**
  60846. * List of lens flares used in this system.
  60847. */
  60848. lensFlares: LensFlare[];
  60849. /**
  60850. * Define a limit from the border the lens flare can be visible.
  60851. */
  60852. borderLimit: number;
  60853. /**
  60854. * Define a viewport border we do not want to see the lens flare in.
  60855. */
  60856. viewportBorder: number;
  60857. /**
  60858. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60859. */
  60860. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60861. /**
  60862. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60863. */
  60864. layerMask: number;
  60865. /**
  60866. * Define the id of the lens flare system in the scene.
  60867. * (equal to name by default)
  60868. */
  60869. id: string;
  60870. private _scene;
  60871. private _emitter;
  60872. private _vertexBuffers;
  60873. private _indexBuffer;
  60874. private _effect;
  60875. private _positionX;
  60876. private _positionY;
  60877. private _isEnabled;
  60878. /** @hidden */
  60879. static _SceneComponentInitialization: (scene: Scene) => void;
  60880. /**
  60881. * Instantiates a lens flare system.
  60882. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60883. * It is usually composed of several `lensFlare`.
  60884. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60885. * @param name Define the name of the lens flare system in the scene
  60886. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60887. * @param scene Define the scene the lens flare system belongs to
  60888. */
  60889. constructor(
  60890. /**
  60891. * Define the name of the lens flare system
  60892. */
  60893. name: string, emitter: any, scene: Scene);
  60894. /**
  60895. * Define if the lens flare system is enabled.
  60896. */
  60897. get isEnabled(): boolean;
  60898. set isEnabled(value: boolean);
  60899. /**
  60900. * Get the scene the effects belongs to.
  60901. * @returns the scene holding the lens flare system
  60902. */
  60903. getScene(): Scene;
  60904. /**
  60905. * Get the emitter of the lens flare system.
  60906. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60907. * @returns the emitter of the lens flare system
  60908. */
  60909. getEmitter(): any;
  60910. /**
  60911. * Set the emitter of the lens flare system.
  60912. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60913. * @param newEmitter Define the new emitter of the system
  60914. */
  60915. setEmitter(newEmitter: any): void;
  60916. /**
  60917. * Get the lens flare system emitter position.
  60918. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60919. * @returns the position
  60920. */
  60921. getEmitterPosition(): Vector3;
  60922. /**
  60923. * @hidden
  60924. */
  60925. computeEffectivePosition(globalViewport: Viewport): boolean;
  60926. /** @hidden */
  60927. _isVisible(): boolean;
  60928. /**
  60929. * @hidden
  60930. */
  60931. render(): boolean;
  60932. /**
  60933. * Dispose and release the lens flare with its associated resources.
  60934. */
  60935. dispose(): void;
  60936. /**
  60937. * Parse a lens flare system from a JSON repressentation
  60938. * @param parsedLensFlareSystem Define the JSON to parse
  60939. * @param scene Define the scene the parsed system should be instantiated in
  60940. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60941. * @returns the parsed system
  60942. */
  60943. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60944. /**
  60945. * Serialize the current Lens Flare System into a JSON representation.
  60946. * @returns the serialized JSON
  60947. */
  60948. serialize(): any;
  60949. }
  60950. }
  60951. declare module "babylonjs/LensFlares/lensFlare" {
  60952. import { Nullable } from "babylonjs/types";
  60953. import { Color3 } from "babylonjs/Maths/math.color";
  60954. import { Texture } from "babylonjs/Materials/Textures/texture";
  60955. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60956. /**
  60957. * This represents one of the lens effect in a `lensFlareSystem`.
  60958. * It controls one of the indiviual texture used in the effect.
  60959. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60960. */
  60961. export class LensFlare {
  60962. /**
  60963. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60964. */
  60965. size: number;
  60966. /**
  60967. * 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.
  60968. */
  60969. position: number;
  60970. /**
  60971. * Define the lens color.
  60972. */
  60973. color: Color3;
  60974. /**
  60975. * Define the lens texture.
  60976. */
  60977. texture: Nullable<Texture>;
  60978. /**
  60979. * Define the alpha mode to render this particular lens.
  60980. */
  60981. alphaMode: number;
  60982. private _system;
  60983. /**
  60984. * Creates a new Lens Flare.
  60985. * This represents one of the lens effect in a `lensFlareSystem`.
  60986. * It controls one of the indiviual texture used in the effect.
  60987. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60988. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60989. * @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.
  60990. * @param color Define the lens color
  60991. * @param imgUrl Define the lens texture url
  60992. * @param system Define the `lensFlareSystem` this flare is part of
  60993. * @returns The newly created Lens Flare
  60994. */
  60995. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60996. /**
  60997. * Instantiates a new Lens Flare.
  60998. * This represents one of the lens effect in a `lensFlareSystem`.
  60999. * It controls one of the indiviual texture used in the effect.
  61000. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61001. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61002. * @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.
  61003. * @param color Define the lens color
  61004. * @param imgUrl Define the lens texture url
  61005. * @param system Define the `lensFlareSystem` this flare is part of
  61006. */
  61007. constructor(
  61008. /**
  61009. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61010. */
  61011. size: number,
  61012. /**
  61013. * 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.
  61014. */
  61015. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61016. /**
  61017. * Dispose and release the lens flare with its associated resources.
  61018. */
  61019. dispose(): void;
  61020. }
  61021. }
  61022. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61023. import { Nullable } from "babylonjs/types";
  61024. import { Scene } from "babylonjs/scene";
  61025. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61026. import { AbstractScene } from "babylonjs/abstractScene";
  61027. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61028. module "babylonjs/abstractScene" {
  61029. interface AbstractScene {
  61030. /**
  61031. * The list of lens flare system added to the scene
  61032. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61033. */
  61034. lensFlareSystems: Array<LensFlareSystem>;
  61035. /**
  61036. * Removes the given lens flare system from this scene.
  61037. * @param toRemove The lens flare system to remove
  61038. * @returns The index of the removed lens flare system
  61039. */
  61040. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61041. /**
  61042. * Adds the given lens flare system to this scene
  61043. * @param newLensFlareSystem The lens flare system to add
  61044. */
  61045. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61046. /**
  61047. * Gets a lens flare system using its name
  61048. * @param name defines the name to look for
  61049. * @returns the lens flare system or null if not found
  61050. */
  61051. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61052. /**
  61053. * Gets a lens flare system using its id
  61054. * @param id defines the id to look for
  61055. * @returns the lens flare system or null if not found
  61056. */
  61057. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61058. }
  61059. }
  61060. /**
  61061. * Defines the lens flare scene component responsible to manage any lens flares
  61062. * in a given scene.
  61063. */
  61064. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61065. /**
  61066. * The component name helpfull to identify the component in the list of scene components.
  61067. */
  61068. readonly name: string;
  61069. /**
  61070. * The scene the component belongs to.
  61071. */
  61072. scene: Scene;
  61073. /**
  61074. * Creates a new instance of the component for the given scene
  61075. * @param scene Defines the scene to register the component in
  61076. */
  61077. constructor(scene: Scene);
  61078. /**
  61079. * Registers the component in a given scene
  61080. */
  61081. register(): void;
  61082. /**
  61083. * Rebuilds the elements related to this component in case of
  61084. * context lost for instance.
  61085. */
  61086. rebuild(): void;
  61087. /**
  61088. * Adds all the elements from the container to the scene
  61089. * @param container the container holding the elements
  61090. */
  61091. addFromContainer(container: AbstractScene): void;
  61092. /**
  61093. * Removes all the elements in the container from the scene
  61094. * @param container contains the elements to remove
  61095. * @param dispose if the removed element should be disposed (default: false)
  61096. */
  61097. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61098. /**
  61099. * Serializes the component data to the specified json object
  61100. * @param serializationObject The object to serialize to
  61101. */
  61102. serialize(serializationObject: any): void;
  61103. /**
  61104. * Disposes the component and the associated ressources.
  61105. */
  61106. dispose(): void;
  61107. private _draw;
  61108. }
  61109. }
  61110. declare module "babylonjs/LensFlares/index" {
  61111. export * from "babylonjs/LensFlares/lensFlare";
  61112. export * from "babylonjs/LensFlares/lensFlareSystem";
  61113. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61114. }
  61115. declare module "babylonjs/Shaders/depth.fragment" {
  61116. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61117. /** @hidden */
  61118. export var depthPixelShader: {
  61119. name: string;
  61120. shader: string;
  61121. };
  61122. }
  61123. declare module "babylonjs/Shaders/depth.vertex" {
  61124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61126. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61127. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61129. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61130. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61131. /** @hidden */
  61132. export var depthVertexShader: {
  61133. name: string;
  61134. shader: string;
  61135. };
  61136. }
  61137. declare module "babylonjs/Rendering/depthRenderer" {
  61138. import { Nullable } from "babylonjs/types";
  61139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61140. import { Scene } from "babylonjs/scene";
  61141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61142. import { Camera } from "babylonjs/Cameras/camera";
  61143. import "babylonjs/Shaders/depth.fragment";
  61144. import "babylonjs/Shaders/depth.vertex";
  61145. /**
  61146. * This represents a depth renderer in Babylon.
  61147. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61148. */
  61149. export class DepthRenderer {
  61150. private _scene;
  61151. private _depthMap;
  61152. private _effect;
  61153. private readonly _storeNonLinearDepth;
  61154. private readonly _clearColor;
  61155. /** Get if the depth renderer is using packed depth or not */
  61156. readonly isPacked: boolean;
  61157. private _cachedDefines;
  61158. private _camera;
  61159. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61160. enabled: boolean;
  61161. /**
  61162. * Specifiess that the depth renderer will only be used within
  61163. * the camera it is created for.
  61164. * This can help forcing its rendering during the camera processing.
  61165. */
  61166. useOnlyInActiveCamera: boolean;
  61167. /** @hidden */
  61168. static _SceneComponentInitialization: (scene: Scene) => void;
  61169. /**
  61170. * Instantiates a depth renderer
  61171. * @param scene The scene the renderer belongs to
  61172. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61173. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61174. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61175. */
  61176. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61177. /**
  61178. * Creates the depth rendering effect and checks if the effect is ready.
  61179. * @param subMesh The submesh to be used to render the depth map of
  61180. * @param useInstances If multiple world instances should be used
  61181. * @returns if the depth renderer is ready to render the depth map
  61182. */
  61183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61184. /**
  61185. * Gets the texture which the depth map will be written to.
  61186. * @returns The depth map texture
  61187. */
  61188. getDepthMap(): RenderTargetTexture;
  61189. /**
  61190. * Disposes of the depth renderer.
  61191. */
  61192. dispose(): void;
  61193. }
  61194. }
  61195. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61196. /** @hidden */
  61197. export var minmaxReduxPixelShader: {
  61198. name: string;
  61199. shader: string;
  61200. };
  61201. }
  61202. declare module "babylonjs/Misc/minMaxReducer" {
  61203. import { Nullable } from "babylonjs/types";
  61204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61205. import { Camera } from "babylonjs/Cameras/camera";
  61206. import { Observer } from "babylonjs/Misc/observable";
  61207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61208. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61209. import { Observable } from "babylonjs/Misc/observable";
  61210. import "babylonjs/Shaders/minmaxRedux.fragment";
  61211. /**
  61212. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61213. * and maximum values from all values of the texture.
  61214. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61215. * The source values are read from the red channel of the texture.
  61216. */
  61217. export class MinMaxReducer {
  61218. /**
  61219. * Observable triggered when the computation has been performed
  61220. */
  61221. onAfterReductionPerformed: Observable<{
  61222. min: number;
  61223. max: number;
  61224. }>;
  61225. protected _camera: Camera;
  61226. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61227. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61228. protected _postProcessManager: PostProcessManager;
  61229. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61230. protected _forceFullscreenViewport: boolean;
  61231. /**
  61232. * Creates a min/max reducer
  61233. * @param camera The camera to use for the post processes
  61234. */
  61235. constructor(camera: Camera);
  61236. /**
  61237. * Gets the texture used to read the values from.
  61238. */
  61239. get sourceTexture(): Nullable<RenderTargetTexture>;
  61240. /**
  61241. * Sets the source texture to read the values from.
  61242. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61243. * because in such textures '1' value must not be taken into account to compute the maximum
  61244. * as this value is used to clear the texture.
  61245. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61246. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61247. * @param depthRedux Indicates if the texture is a depth texture or not
  61248. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61249. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61250. */
  61251. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61252. /**
  61253. * Defines the refresh rate of the computation.
  61254. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61255. */
  61256. get refreshRate(): number;
  61257. set refreshRate(value: number);
  61258. protected _activated: boolean;
  61259. /**
  61260. * Gets the activation status of the reducer
  61261. */
  61262. get activated(): boolean;
  61263. /**
  61264. * Activates the reduction computation.
  61265. * When activated, the observers registered in onAfterReductionPerformed are
  61266. * called after the compuation is performed
  61267. */
  61268. activate(): void;
  61269. /**
  61270. * Deactivates the reduction computation.
  61271. */
  61272. deactivate(): void;
  61273. /**
  61274. * Disposes the min/max reducer
  61275. * @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.
  61276. */
  61277. dispose(disposeAll?: boolean): void;
  61278. }
  61279. }
  61280. declare module "babylonjs/Misc/depthReducer" {
  61281. import { Nullable } from "babylonjs/types";
  61282. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61283. import { Camera } from "babylonjs/Cameras/camera";
  61284. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61285. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61286. /**
  61287. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61288. */
  61289. export class DepthReducer extends MinMaxReducer {
  61290. private _depthRenderer;
  61291. private _depthRendererId;
  61292. /**
  61293. * Gets the depth renderer used for the computation.
  61294. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61295. */
  61296. get depthRenderer(): Nullable<DepthRenderer>;
  61297. /**
  61298. * Creates a depth reducer
  61299. * @param camera The camera used to render the depth texture
  61300. */
  61301. constructor(camera: Camera);
  61302. /**
  61303. * Sets the depth renderer to use to generate the depth map
  61304. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61305. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61306. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61307. */
  61308. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61309. /** @hidden */
  61310. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61311. /**
  61312. * Activates the reduction computation.
  61313. * When activated, the observers registered in onAfterReductionPerformed are
  61314. * called after the compuation is performed
  61315. */
  61316. activate(): void;
  61317. /**
  61318. * Deactivates the reduction computation.
  61319. */
  61320. deactivate(): void;
  61321. /**
  61322. * Disposes the depth reducer
  61323. * @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.
  61324. */
  61325. dispose(disposeAll?: boolean): void;
  61326. }
  61327. }
  61328. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61329. import { Nullable } from "babylonjs/types";
  61330. import { Scene } from "babylonjs/scene";
  61331. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61334. import { Effect } from "babylonjs/Materials/effect";
  61335. import "babylonjs/Shaders/shadowMap.fragment";
  61336. import "babylonjs/Shaders/shadowMap.vertex";
  61337. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61338. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61339. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61340. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61341. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61342. /**
  61343. * A CSM implementation allowing casting shadows on large scenes.
  61344. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61345. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61346. */
  61347. export class CascadedShadowGenerator extends ShadowGenerator {
  61348. private static readonly frustumCornersNDCSpace;
  61349. /**
  61350. * Name of the CSM class
  61351. */
  61352. static CLASSNAME: string;
  61353. /**
  61354. * Defines the default number of cascades used by the CSM.
  61355. */
  61356. static readonly DEFAULT_CASCADES_COUNT: number;
  61357. /**
  61358. * Defines the minimum number of cascades used by the CSM.
  61359. */
  61360. static readonly MIN_CASCADES_COUNT: number;
  61361. /**
  61362. * Defines the maximum number of cascades used by the CSM.
  61363. */
  61364. static readonly MAX_CASCADES_COUNT: number;
  61365. protected _validateFilter(filter: number): number;
  61366. /**
  61367. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61368. */
  61369. penumbraDarkness: number;
  61370. private _numCascades;
  61371. /**
  61372. * Gets or set the number of cascades used by the CSM.
  61373. */
  61374. get numCascades(): number;
  61375. set numCascades(value: number);
  61376. /**
  61377. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61378. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61379. */
  61380. stabilizeCascades: boolean;
  61381. private _freezeShadowCastersBoundingInfo;
  61382. private _freezeShadowCastersBoundingInfoObservable;
  61383. /**
  61384. * Enables or disables the shadow casters bounding info computation.
  61385. * If your shadow casters don't move, you can disable this feature.
  61386. * If it is enabled, the bounding box computation is done every frame.
  61387. */
  61388. get freezeShadowCastersBoundingInfo(): boolean;
  61389. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61390. private _scbiMin;
  61391. private _scbiMax;
  61392. protected _computeShadowCastersBoundingInfo(): void;
  61393. protected _shadowCastersBoundingInfo: BoundingInfo;
  61394. /**
  61395. * Gets or sets the shadow casters bounding info.
  61396. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61397. * so that the system won't overwrite the bounds you provide
  61398. */
  61399. get shadowCastersBoundingInfo(): BoundingInfo;
  61400. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61401. protected _breaksAreDirty: boolean;
  61402. protected _minDistance: number;
  61403. protected _maxDistance: number;
  61404. /**
  61405. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61406. *
  61407. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61408. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61409. * @param min minimal distance for the breaks (default to 0.)
  61410. * @param max maximal distance for the breaks (default to 1.)
  61411. */
  61412. setMinMaxDistance(min: number, max: number): void;
  61413. /** Gets the minimal distance used in the cascade break computation */
  61414. get minDistance(): number;
  61415. /** Gets the maximal distance used in the cascade break computation */
  61416. get maxDistance(): number;
  61417. /**
  61418. * Gets the class name of that object
  61419. * @returns "CascadedShadowGenerator"
  61420. */
  61421. getClassName(): string;
  61422. private _cascadeMinExtents;
  61423. private _cascadeMaxExtents;
  61424. /**
  61425. * Gets a cascade minimum extents
  61426. * @param cascadeIndex index of the cascade
  61427. * @returns the minimum cascade extents
  61428. */
  61429. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61430. /**
  61431. * Gets a cascade maximum extents
  61432. * @param cascadeIndex index of the cascade
  61433. * @returns the maximum cascade extents
  61434. */
  61435. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61436. private _cascades;
  61437. private _currentLayer;
  61438. private _viewSpaceFrustumsZ;
  61439. private _viewMatrices;
  61440. private _projectionMatrices;
  61441. private _transformMatrices;
  61442. private _transformMatricesAsArray;
  61443. private _frustumLengths;
  61444. private _lightSizeUVCorrection;
  61445. private _depthCorrection;
  61446. private _frustumCornersWorldSpace;
  61447. private _frustumCenter;
  61448. private _shadowCameraPos;
  61449. private _shadowMaxZ;
  61450. /**
  61451. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61452. * It defaults to camera.maxZ
  61453. */
  61454. get shadowMaxZ(): number;
  61455. /**
  61456. * Sets the shadow max z distance.
  61457. */
  61458. set shadowMaxZ(value: number);
  61459. protected _debug: boolean;
  61460. /**
  61461. * Gets or sets the debug flag.
  61462. * When enabled, the cascades are materialized by different colors on the screen.
  61463. */
  61464. get debug(): boolean;
  61465. set debug(dbg: boolean);
  61466. private _depthClamp;
  61467. /**
  61468. * Gets or sets the depth clamping value.
  61469. *
  61470. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61471. * to account for the shadow casters far away.
  61472. *
  61473. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61474. */
  61475. get depthClamp(): boolean;
  61476. set depthClamp(value: boolean);
  61477. private _cascadeBlendPercentage;
  61478. /**
  61479. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61480. * It defaults to 0.1 (10% blending).
  61481. */
  61482. get cascadeBlendPercentage(): number;
  61483. set cascadeBlendPercentage(value: number);
  61484. private _lambda;
  61485. /**
  61486. * Gets or set the lambda parameter.
  61487. * This parameter is used to split the camera frustum and create the cascades.
  61488. * 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.
  61489. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61490. */
  61491. get lambda(): number;
  61492. set lambda(value: number);
  61493. /**
  61494. * Gets the view matrix corresponding to a given cascade
  61495. * @param cascadeNum cascade to retrieve the view matrix from
  61496. * @returns the cascade view matrix
  61497. */
  61498. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61499. /**
  61500. * Gets the projection matrix corresponding to a given cascade
  61501. * @param cascadeNum cascade to retrieve the projection matrix from
  61502. * @returns the cascade projection matrix
  61503. */
  61504. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61505. /**
  61506. * Gets the transformation matrix corresponding to a given cascade
  61507. * @param cascadeNum cascade to retrieve the transformation matrix from
  61508. * @returns the cascade transformation matrix
  61509. */
  61510. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61511. private _depthRenderer;
  61512. /**
  61513. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61514. *
  61515. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61516. *
  61517. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61518. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61519. * @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
  61520. */
  61521. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61522. private _depthReducer;
  61523. private _autoCalcDepthBounds;
  61524. /**
  61525. * Gets or sets the autoCalcDepthBounds property.
  61526. *
  61527. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61528. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61529. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61530. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61531. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61532. */
  61533. get autoCalcDepthBounds(): boolean;
  61534. set autoCalcDepthBounds(value: boolean);
  61535. /**
  61536. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61537. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61538. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61539. * for setting the refresh rate on the renderer yourself!
  61540. */
  61541. get autoCalcDepthBoundsRefreshRate(): number;
  61542. set autoCalcDepthBoundsRefreshRate(value: number);
  61543. /**
  61544. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61545. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61546. * you change the camera near/far planes!
  61547. */
  61548. splitFrustum(): void;
  61549. private _splitFrustum;
  61550. private _computeMatrices;
  61551. private _computeFrustumInWorldSpace;
  61552. private _computeCascadeFrustum;
  61553. /**
  61554. * Support test.
  61555. */
  61556. static get IsSupported(): boolean;
  61557. /** @hidden */
  61558. static _SceneComponentInitialization: (scene: Scene) => void;
  61559. /**
  61560. * Creates a Cascaded Shadow Generator object.
  61561. * A ShadowGenerator is the required tool to use the shadows.
  61562. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61563. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61564. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61565. * @param light The directional light object generating the shadows.
  61566. * @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.
  61567. */
  61568. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61569. protected _initializeGenerator(): void;
  61570. protected _createTargetRenderTexture(): void;
  61571. protected _initializeShadowMap(): void;
  61572. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61573. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61574. /**
  61575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61576. * @param defines Defines of the material we want to update
  61577. * @param lightIndex Index of the light in the enabled light list of the material
  61578. */
  61579. prepareDefines(defines: any, lightIndex: number): void;
  61580. /**
  61581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61582. * defined in the generator but impacting the effect).
  61583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61584. * @param effect The effect we are binfing the information for
  61585. */
  61586. bindShadowLight(lightIndex: string, effect: Effect): void;
  61587. /**
  61588. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61589. * (eq to view projection * shadow projection matrices)
  61590. * @returns The transform matrix used to create the shadow map
  61591. */
  61592. getTransformMatrix(): Matrix;
  61593. /**
  61594. * Disposes the ShadowGenerator.
  61595. * Returns nothing.
  61596. */
  61597. dispose(): void;
  61598. /**
  61599. * Serializes the shadow generator setup to a json object.
  61600. * @returns The serialized JSON object
  61601. */
  61602. serialize(): any;
  61603. /**
  61604. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61605. * @param parsedShadowGenerator The JSON object to parse
  61606. * @param scene The scene to create the shadow map for
  61607. * @returns The parsed shadow generator
  61608. */
  61609. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61610. }
  61611. }
  61612. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61613. import { Scene } from "babylonjs/scene";
  61614. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61615. import { AbstractScene } from "babylonjs/abstractScene";
  61616. /**
  61617. * Defines the shadow generator component responsible to manage any shadow generators
  61618. * in a given scene.
  61619. */
  61620. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61621. /**
  61622. * The component name helpfull to identify the component in the list of scene components.
  61623. */
  61624. readonly name: string;
  61625. /**
  61626. * The scene the component belongs to.
  61627. */
  61628. scene: Scene;
  61629. /**
  61630. * Creates a new instance of the component for the given scene
  61631. * @param scene Defines the scene to register the component in
  61632. */
  61633. constructor(scene: Scene);
  61634. /**
  61635. * Registers the component in a given scene
  61636. */
  61637. register(): void;
  61638. /**
  61639. * Rebuilds the elements related to this component in case of
  61640. * context lost for instance.
  61641. */
  61642. rebuild(): void;
  61643. /**
  61644. * Serializes the component data to the specified json object
  61645. * @param serializationObject The object to serialize to
  61646. */
  61647. serialize(serializationObject: any): void;
  61648. /**
  61649. * Adds all the elements from the container to the scene
  61650. * @param container the container holding the elements
  61651. */
  61652. addFromContainer(container: AbstractScene): void;
  61653. /**
  61654. * Removes all the elements in the container from the scene
  61655. * @param container contains the elements to remove
  61656. * @param dispose if the removed element should be disposed (default: false)
  61657. */
  61658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61659. /**
  61660. * Rebuilds the elements related to this component in case of
  61661. * context lost for instance.
  61662. */
  61663. dispose(): void;
  61664. private _gatherRenderTargets;
  61665. }
  61666. }
  61667. declare module "babylonjs/Lights/Shadows/index" {
  61668. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61669. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61670. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61671. }
  61672. declare module "babylonjs/Lights/pointLight" {
  61673. import { Scene } from "babylonjs/scene";
  61674. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61676. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61677. import { Effect } from "babylonjs/Materials/effect";
  61678. /**
  61679. * A point light is a light defined by an unique point in world space.
  61680. * The light is emitted in every direction from this point.
  61681. * A good example of a point light is a standard light bulb.
  61682. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61683. */
  61684. export class PointLight extends ShadowLight {
  61685. private _shadowAngle;
  61686. /**
  61687. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61688. * This specifies what angle the shadow will use to be created.
  61689. *
  61690. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61691. */
  61692. get shadowAngle(): number;
  61693. /**
  61694. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61695. * This specifies what angle the shadow will use to be created.
  61696. *
  61697. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61698. */
  61699. set shadowAngle(value: number);
  61700. /**
  61701. * Gets the direction if it has been set.
  61702. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61703. */
  61704. get direction(): Vector3;
  61705. /**
  61706. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61707. */
  61708. set direction(value: Vector3);
  61709. /**
  61710. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61711. * A PointLight emits the light in every direction.
  61712. * It can cast shadows.
  61713. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61714. * ```javascript
  61715. * var pointLight = new PointLight("pl", camera.position, scene);
  61716. * ```
  61717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61718. * @param name The light friendly name
  61719. * @param position The position of the point light in the scene
  61720. * @param scene The scene the lights belongs to
  61721. */
  61722. constructor(name: string, position: Vector3, scene: Scene);
  61723. /**
  61724. * Returns the string "PointLight"
  61725. * @returns the class name
  61726. */
  61727. getClassName(): string;
  61728. /**
  61729. * Returns the integer 0.
  61730. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61731. */
  61732. getTypeID(): number;
  61733. /**
  61734. * Specifies wether or not the shadowmap should be a cube texture.
  61735. * @returns true if the shadowmap needs to be a cube texture.
  61736. */
  61737. needCube(): boolean;
  61738. /**
  61739. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61740. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61741. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61742. */
  61743. getShadowDirection(faceIndex?: number): Vector3;
  61744. /**
  61745. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61746. * - fov = PI / 2
  61747. * - aspect ratio : 1.0
  61748. * - z-near and far equal to the active camera minZ and maxZ.
  61749. * Returns the PointLight.
  61750. */
  61751. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61752. protected _buildUniformLayout(): void;
  61753. /**
  61754. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61755. * @param effect The effect to update
  61756. * @param lightIndex The index of the light in the effect to update
  61757. * @returns The point light
  61758. */
  61759. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61760. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61761. /**
  61762. * Prepares the list of defines specific to the light type.
  61763. * @param defines the list of defines
  61764. * @param lightIndex defines the index of the light for the effect
  61765. */
  61766. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61767. }
  61768. }
  61769. declare module "babylonjs/Lights/index" {
  61770. export * from "babylonjs/Lights/light";
  61771. export * from "babylonjs/Lights/shadowLight";
  61772. export * from "babylonjs/Lights/Shadows/index";
  61773. export * from "babylonjs/Lights/directionalLight";
  61774. export * from "babylonjs/Lights/hemisphericLight";
  61775. export * from "babylonjs/Lights/pointLight";
  61776. export * from "babylonjs/Lights/spotLight";
  61777. }
  61778. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61779. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61780. /**
  61781. * Header information of HDR texture files.
  61782. */
  61783. export interface HDRInfo {
  61784. /**
  61785. * The height of the texture in pixels.
  61786. */
  61787. height: number;
  61788. /**
  61789. * The width of the texture in pixels.
  61790. */
  61791. width: number;
  61792. /**
  61793. * The index of the beginning of the data in the binary file.
  61794. */
  61795. dataPosition: number;
  61796. }
  61797. /**
  61798. * This groups tools to convert HDR texture to native colors array.
  61799. */
  61800. export class HDRTools {
  61801. private static Ldexp;
  61802. private static Rgbe2float;
  61803. private static readStringLine;
  61804. /**
  61805. * Reads header information from an RGBE texture stored in a native array.
  61806. * More information on this format are available here:
  61807. * https://en.wikipedia.org/wiki/RGBE_image_format
  61808. *
  61809. * @param uint8array The binary file stored in native array.
  61810. * @return The header information.
  61811. */
  61812. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61813. /**
  61814. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61815. * This RGBE texture needs to store the information as a panorama.
  61816. *
  61817. * More information on this format are available here:
  61818. * https://en.wikipedia.org/wiki/RGBE_image_format
  61819. *
  61820. * @param buffer The binary file stored in an array buffer.
  61821. * @param size The expected size of the extracted cubemap.
  61822. * @return The Cube Map information.
  61823. */
  61824. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61825. /**
  61826. * Returns the pixels data extracted from an RGBE texture.
  61827. * This pixels will be stored left to right up to down in the R G B order in one array.
  61828. *
  61829. * More information on this format are available here:
  61830. * https://en.wikipedia.org/wiki/RGBE_image_format
  61831. *
  61832. * @param uint8array The binary file stored in an array buffer.
  61833. * @param hdrInfo The header information of the file.
  61834. * @return The pixels data in RGB right to left up to down order.
  61835. */
  61836. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61837. private static RGBE_ReadPixels_RLE;
  61838. }
  61839. }
  61840. declare module "babylonjs/Materials/effectRenderer" {
  61841. import { Nullable } from "babylonjs/types";
  61842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61843. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61844. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61845. import { Viewport } from "babylonjs/Maths/math.viewport";
  61846. import { Observable } from "babylonjs/Misc/observable";
  61847. import { Effect } from "babylonjs/Materials/effect";
  61848. import "babylonjs/Shaders/postprocess.vertex";
  61849. /**
  61850. * Effect Render Options
  61851. */
  61852. export interface IEffectRendererOptions {
  61853. /**
  61854. * Defines the vertices positions.
  61855. */
  61856. positions?: number[];
  61857. /**
  61858. * Defines the indices.
  61859. */
  61860. indices?: number[];
  61861. }
  61862. /**
  61863. * Helper class to render one or more effects.
  61864. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61865. */
  61866. export class EffectRenderer {
  61867. private engine;
  61868. private static _DefaultOptions;
  61869. private _vertexBuffers;
  61870. private _indexBuffer;
  61871. private _fullscreenViewport;
  61872. /**
  61873. * Creates an effect renderer
  61874. * @param engine the engine to use for rendering
  61875. * @param options defines the options of the effect renderer
  61876. */
  61877. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61878. /**
  61879. * Sets the current viewport in normalized coordinates 0-1
  61880. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61881. */
  61882. setViewport(viewport?: Viewport): void;
  61883. /**
  61884. * Binds the embedded attributes buffer to the effect.
  61885. * @param effect Defines the effect to bind the attributes for
  61886. */
  61887. bindBuffers(effect: Effect): void;
  61888. /**
  61889. * Sets the current effect wrapper to use during draw.
  61890. * The effect needs to be ready before calling this api.
  61891. * This also sets the default full screen position attribute.
  61892. * @param effectWrapper Defines the effect to draw with
  61893. */
  61894. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61895. /**
  61896. * Restores engine states
  61897. */
  61898. restoreStates(): void;
  61899. /**
  61900. * Draws a full screen quad.
  61901. */
  61902. draw(): void;
  61903. private isRenderTargetTexture;
  61904. /**
  61905. * renders one or more effects to a specified texture
  61906. * @param effectWrapper the effect to renderer
  61907. * @param outputTexture texture to draw to, if null it will render to the screen.
  61908. */
  61909. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61910. /**
  61911. * Disposes of the effect renderer
  61912. */
  61913. dispose(): void;
  61914. }
  61915. /**
  61916. * Options to create an EffectWrapper
  61917. */
  61918. interface EffectWrapperCreationOptions {
  61919. /**
  61920. * Engine to use to create the effect
  61921. */
  61922. engine: ThinEngine;
  61923. /**
  61924. * Fragment shader for the effect
  61925. */
  61926. fragmentShader: string;
  61927. /**
  61928. * Use the shader store instead of direct source code
  61929. */
  61930. useShaderStore?: boolean;
  61931. /**
  61932. * Vertex shader for the effect
  61933. */
  61934. vertexShader?: string;
  61935. /**
  61936. * Attributes to use in the shader
  61937. */
  61938. attributeNames?: Array<string>;
  61939. /**
  61940. * Uniforms to use in the shader
  61941. */
  61942. uniformNames?: Array<string>;
  61943. /**
  61944. * Texture sampler names to use in the shader
  61945. */
  61946. samplerNames?: Array<string>;
  61947. /**
  61948. * Defines to use in the shader
  61949. */
  61950. defines?: Array<string>;
  61951. /**
  61952. * Callback when effect is compiled
  61953. */
  61954. onCompiled?: Nullable<(effect: Effect) => void>;
  61955. /**
  61956. * The friendly name of the effect displayed in Spector.
  61957. */
  61958. name?: string;
  61959. }
  61960. /**
  61961. * Wraps an effect to be used for rendering
  61962. */
  61963. export class EffectWrapper {
  61964. /**
  61965. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61966. */
  61967. onApplyObservable: Observable<{}>;
  61968. /**
  61969. * The underlying effect
  61970. */
  61971. effect: Effect;
  61972. /**
  61973. * Creates an effect to be renderer
  61974. * @param creationOptions options to create the effect
  61975. */
  61976. constructor(creationOptions: EffectWrapperCreationOptions);
  61977. /**
  61978. * Disposes of the effect wrapper
  61979. */
  61980. dispose(): void;
  61981. }
  61982. }
  61983. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61984. /** @hidden */
  61985. export var hdrFilteringVertexShader: {
  61986. name: string;
  61987. shader: string;
  61988. };
  61989. }
  61990. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61992. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61993. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61994. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61995. /** @hidden */
  61996. export var hdrFilteringPixelShader: {
  61997. name: string;
  61998. shader: string;
  61999. };
  62000. }
  62001. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62004. import { Nullable } from "babylonjs/types";
  62005. import "babylonjs/Shaders/hdrFiltering.vertex";
  62006. import "babylonjs/Shaders/hdrFiltering.fragment";
  62007. /**
  62008. * Options for texture filtering
  62009. */
  62010. interface IHDRFilteringOptions {
  62011. /**
  62012. * Scales pixel intensity for the input HDR map.
  62013. */
  62014. hdrScale?: number;
  62015. /**
  62016. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62017. */
  62018. quality?: number;
  62019. }
  62020. /**
  62021. * Filters HDR maps to get correct renderings of PBR reflections
  62022. */
  62023. export class HDRFiltering {
  62024. private _engine;
  62025. private _effectRenderer;
  62026. private _effectWrapper;
  62027. private _lodGenerationOffset;
  62028. private _lodGenerationScale;
  62029. /**
  62030. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62031. * you care about baking speed.
  62032. */
  62033. quality: number;
  62034. /**
  62035. * Scales pixel intensity for the input HDR map.
  62036. */
  62037. hdrScale: number;
  62038. /**
  62039. * Instantiates HDR filter for reflection maps
  62040. *
  62041. * @param engine Thin engine
  62042. * @param options Options
  62043. */
  62044. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62045. private _createRenderTarget;
  62046. private _prefilterInternal;
  62047. private _createEffect;
  62048. /**
  62049. * Get a value indicating if the filter is ready to be used
  62050. * @param texture Texture to filter
  62051. * @returns true if the filter is ready
  62052. */
  62053. isReady(texture: BaseTexture): boolean;
  62054. /**
  62055. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62056. * Prefiltering will be invoked at the end of next rendering pass.
  62057. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62058. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62059. * @param texture Texture to filter
  62060. * @param onFinished Callback when filtering is done
  62061. * @return Promise called when prefiltering is done
  62062. */
  62063. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62064. }
  62065. }
  62066. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62067. import { Nullable } from "babylonjs/types";
  62068. import { Scene } from "babylonjs/scene";
  62069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62071. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62072. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62073. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62074. /**
  62075. * This represents a texture coming from an HDR input.
  62076. *
  62077. * The only supported format is currently panorama picture stored in RGBE format.
  62078. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62079. */
  62080. export class HDRCubeTexture extends BaseTexture {
  62081. private static _facesMapping;
  62082. private _generateHarmonics;
  62083. private _noMipmap;
  62084. private _prefilterOnLoad;
  62085. private _textureMatrix;
  62086. private _size;
  62087. private _onLoad;
  62088. private _onError;
  62089. /**
  62090. * The texture URL.
  62091. */
  62092. url: string;
  62093. /**
  62094. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62095. */
  62096. coordinatesMode: number;
  62097. protected _isBlocking: boolean;
  62098. /**
  62099. * Sets wether or not the texture is blocking during loading.
  62100. */
  62101. set isBlocking(value: boolean);
  62102. /**
  62103. * Gets wether or not the texture is blocking during loading.
  62104. */
  62105. get isBlocking(): boolean;
  62106. protected _rotationY: number;
  62107. /**
  62108. * Sets texture matrix rotation angle around Y axis in radians.
  62109. */
  62110. set rotationY(value: number);
  62111. /**
  62112. * Gets texture matrix rotation angle around Y axis radians.
  62113. */
  62114. get rotationY(): number;
  62115. /**
  62116. * Gets or sets the center of the bounding box associated with the cube texture
  62117. * It must define where the camera used to render the texture was set
  62118. */
  62119. boundingBoxPosition: Vector3;
  62120. private _boundingBoxSize;
  62121. /**
  62122. * Gets or sets the size of the bounding box associated with the cube texture
  62123. * When defined, the cubemap will switch to local mode
  62124. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62125. * @example https://www.babylonjs-playground.com/#RNASML
  62126. */
  62127. set boundingBoxSize(value: Vector3);
  62128. get boundingBoxSize(): Vector3;
  62129. /**
  62130. * Instantiates an HDRTexture from the following parameters.
  62131. *
  62132. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62133. * @param sceneOrEngine The scene or engine the texture will be used in
  62134. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62135. * @param noMipmap Forces to not generate the mipmap if true
  62136. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62137. * @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)
  62138. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62139. */
  62140. 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>);
  62141. /**
  62142. * Get the current class name of the texture useful for serialization or dynamic coding.
  62143. * @returns "HDRCubeTexture"
  62144. */
  62145. getClassName(): string;
  62146. /**
  62147. * Occurs when the file is raw .hdr file.
  62148. */
  62149. private loadTexture;
  62150. clone(): HDRCubeTexture;
  62151. delayLoad(): void;
  62152. /**
  62153. * Get the texture reflection matrix used to rotate/transform the reflection.
  62154. * @returns the reflection matrix
  62155. */
  62156. getReflectionTextureMatrix(): Matrix;
  62157. /**
  62158. * Set the texture reflection matrix used to rotate/transform the reflection.
  62159. * @param value Define the reflection matrix to set
  62160. */
  62161. setReflectionTextureMatrix(value: Matrix): void;
  62162. /**
  62163. * Parses a JSON representation of an HDR Texture in order to create the texture
  62164. * @param parsedTexture Define the JSON representation
  62165. * @param scene Define the scene the texture should be created in
  62166. * @param rootUrl Define the root url in case we need to load relative dependencies
  62167. * @returns the newly created texture after parsing
  62168. */
  62169. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62170. serialize(): any;
  62171. }
  62172. }
  62173. declare module "babylonjs/Physics/physicsEngine" {
  62174. import { Nullable } from "babylonjs/types";
  62175. import { Vector3 } from "babylonjs/Maths/math.vector";
  62176. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62177. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62178. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62179. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62180. /**
  62181. * Class used to control physics engine
  62182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62183. */
  62184. export class PhysicsEngine implements IPhysicsEngine {
  62185. private _physicsPlugin;
  62186. /**
  62187. * Global value used to control the smallest number supported by the simulation
  62188. */
  62189. static Epsilon: number;
  62190. private _impostors;
  62191. private _joints;
  62192. private _subTimeStep;
  62193. /**
  62194. * Gets the gravity vector used by the simulation
  62195. */
  62196. gravity: Vector3;
  62197. /**
  62198. * Factory used to create the default physics plugin.
  62199. * @returns The default physics plugin
  62200. */
  62201. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62202. /**
  62203. * Creates a new Physics Engine
  62204. * @param gravity defines the gravity vector used by the simulation
  62205. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62206. */
  62207. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62208. /**
  62209. * Sets the gravity vector used by the simulation
  62210. * @param gravity defines the gravity vector to use
  62211. */
  62212. setGravity(gravity: Vector3): void;
  62213. /**
  62214. * Set the time step of the physics engine.
  62215. * Default is 1/60.
  62216. * To slow it down, enter 1/600 for example.
  62217. * To speed it up, 1/30
  62218. * @param newTimeStep defines the new timestep to apply to this world.
  62219. */
  62220. setTimeStep(newTimeStep?: number): void;
  62221. /**
  62222. * Get the time step of the physics engine.
  62223. * @returns the current time step
  62224. */
  62225. getTimeStep(): number;
  62226. /**
  62227. * Set the sub time step of the physics engine.
  62228. * Default is 0 meaning there is no sub steps
  62229. * To increase physics resolution precision, set a small value (like 1 ms)
  62230. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62231. */
  62232. setSubTimeStep(subTimeStep?: number): void;
  62233. /**
  62234. * Get the sub time step of the physics engine.
  62235. * @returns the current sub time step
  62236. */
  62237. getSubTimeStep(): number;
  62238. /**
  62239. * Release all resources
  62240. */
  62241. dispose(): void;
  62242. /**
  62243. * Gets the name of the current physics plugin
  62244. * @returns the name of the plugin
  62245. */
  62246. getPhysicsPluginName(): string;
  62247. /**
  62248. * Adding a new impostor for the impostor tracking.
  62249. * This will be done by the impostor itself.
  62250. * @param impostor the impostor to add
  62251. */
  62252. addImpostor(impostor: PhysicsImpostor): void;
  62253. /**
  62254. * Remove an impostor from the engine.
  62255. * This impostor and its mesh will not longer be updated by the physics engine.
  62256. * @param impostor the impostor to remove
  62257. */
  62258. removeImpostor(impostor: PhysicsImpostor): void;
  62259. /**
  62260. * Add a joint to the physics engine
  62261. * @param mainImpostor defines the main impostor to which the joint is added.
  62262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62263. * @param joint defines the joint that will connect both impostors.
  62264. */
  62265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62266. /**
  62267. * Removes a joint from the simulation
  62268. * @param mainImpostor defines the impostor used with the joint
  62269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62270. * @param joint defines the joint to remove
  62271. */
  62272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62273. /**
  62274. * Called by the scene. No need to call it.
  62275. * @param delta defines the timespam between frames
  62276. */
  62277. _step(delta: number): void;
  62278. /**
  62279. * Gets the current plugin used to run the simulation
  62280. * @returns current plugin
  62281. */
  62282. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62283. /**
  62284. * Gets the list of physic impostors
  62285. * @returns an array of PhysicsImpostor
  62286. */
  62287. getImpostors(): Array<PhysicsImpostor>;
  62288. /**
  62289. * Gets the impostor for a physics enabled object
  62290. * @param object defines the object impersonated by the impostor
  62291. * @returns the PhysicsImpostor or null if not found
  62292. */
  62293. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62294. /**
  62295. * Gets the impostor for a physics body object
  62296. * @param body defines physics body used by the impostor
  62297. * @returns the PhysicsImpostor or null if not found
  62298. */
  62299. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62300. /**
  62301. * Does a raycast in the physics world
  62302. * @param from when should the ray start?
  62303. * @param to when should the ray end?
  62304. * @returns PhysicsRaycastResult
  62305. */
  62306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62307. }
  62308. }
  62309. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62310. import { Nullable } from "babylonjs/types";
  62311. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62313. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62314. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62316. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62317. /** @hidden */
  62318. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62319. private _useDeltaForWorldStep;
  62320. world: any;
  62321. name: string;
  62322. private _physicsMaterials;
  62323. private _fixedTimeStep;
  62324. private _cannonRaycastResult;
  62325. private _raycastResult;
  62326. private _physicsBodysToRemoveAfterStep;
  62327. private _firstFrame;
  62328. BJSCANNON: any;
  62329. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62330. setGravity(gravity: Vector3): void;
  62331. setTimeStep(timeStep: number): void;
  62332. getTimeStep(): number;
  62333. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62334. private _removeMarkedPhysicsBodiesFromWorld;
  62335. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62336. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62337. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62338. private _processChildMeshes;
  62339. removePhysicsBody(impostor: PhysicsImpostor): void;
  62340. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62341. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62342. private _addMaterial;
  62343. private _checkWithEpsilon;
  62344. private _createShape;
  62345. private _createHeightmap;
  62346. private _minus90X;
  62347. private _plus90X;
  62348. private _tmpPosition;
  62349. private _tmpDeltaPosition;
  62350. private _tmpUnityRotation;
  62351. private _updatePhysicsBodyTransformation;
  62352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62353. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62354. isSupported(): boolean;
  62355. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62356. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62357. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62358. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62359. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62360. getBodyMass(impostor: PhysicsImpostor): number;
  62361. getBodyFriction(impostor: PhysicsImpostor): number;
  62362. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62363. getBodyRestitution(impostor: PhysicsImpostor): number;
  62364. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62365. sleepBody(impostor: PhysicsImpostor): void;
  62366. wakeUpBody(impostor: PhysicsImpostor): void;
  62367. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62368. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62369. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62370. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62371. getRadius(impostor: PhysicsImpostor): number;
  62372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62373. dispose(): void;
  62374. private _extendNamespace;
  62375. /**
  62376. * Does a raycast in the physics world
  62377. * @param from when should the ray start?
  62378. * @param to when should the ray end?
  62379. * @returns PhysicsRaycastResult
  62380. */
  62381. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62382. }
  62383. }
  62384. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62385. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62386. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62387. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62389. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62390. import { Nullable } from "babylonjs/types";
  62391. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62392. /** @hidden */
  62393. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62394. private _useDeltaForWorldStep;
  62395. world: any;
  62396. name: string;
  62397. BJSOIMO: any;
  62398. private _raycastResult;
  62399. private _fixedTimeStep;
  62400. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62401. setGravity(gravity: Vector3): void;
  62402. setTimeStep(timeStep: number): void;
  62403. getTimeStep(): number;
  62404. private _tmpImpostorsArray;
  62405. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62409. private _tmpPositionVector;
  62410. removePhysicsBody(impostor: PhysicsImpostor): void;
  62411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62413. isSupported(): boolean;
  62414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62421. getBodyMass(impostor: PhysicsImpostor): number;
  62422. getBodyFriction(impostor: PhysicsImpostor): number;
  62423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62424. getBodyRestitution(impostor: PhysicsImpostor): number;
  62425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62426. sleepBody(impostor: PhysicsImpostor): void;
  62427. wakeUpBody(impostor: PhysicsImpostor): void;
  62428. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62429. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62432. getRadius(impostor: PhysicsImpostor): number;
  62433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62434. dispose(): void;
  62435. /**
  62436. * Does a raycast in the physics world
  62437. * @param from when should the ray start?
  62438. * @param to when should the ray end?
  62439. * @returns PhysicsRaycastResult
  62440. */
  62441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62442. }
  62443. }
  62444. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62445. import { Nullable } from "babylonjs/types";
  62446. import { Scene } from "babylonjs/scene";
  62447. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62448. import { Color4 } from "babylonjs/Maths/math.color";
  62449. import { Mesh } from "babylonjs/Meshes/mesh";
  62450. /**
  62451. * Class containing static functions to help procedurally build meshes
  62452. */
  62453. export class RibbonBuilder {
  62454. /**
  62455. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62456. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62457. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62458. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62459. * * 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
  62460. * * 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
  62461. * * 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
  62462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62465. * * 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
  62466. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62467. * * 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
  62468. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62470. * @param name defines the name of the mesh
  62471. * @param options defines the options used to create the mesh
  62472. * @param scene defines the hosting scene
  62473. * @returns the ribbon mesh
  62474. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62476. */
  62477. static CreateRibbon(name: string, options: {
  62478. pathArray: Vector3[][];
  62479. closeArray?: boolean;
  62480. closePath?: boolean;
  62481. offset?: number;
  62482. updatable?: boolean;
  62483. sideOrientation?: number;
  62484. frontUVs?: Vector4;
  62485. backUVs?: Vector4;
  62486. instance?: Mesh;
  62487. invertUV?: boolean;
  62488. uvs?: Vector2[];
  62489. colors?: Color4[];
  62490. }, scene?: Nullable<Scene>): Mesh;
  62491. }
  62492. }
  62493. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62494. import { Nullable } from "babylonjs/types";
  62495. import { Scene } from "babylonjs/scene";
  62496. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62497. import { Mesh } from "babylonjs/Meshes/mesh";
  62498. /**
  62499. * Class containing static functions to help procedurally build meshes
  62500. */
  62501. export class ShapeBuilder {
  62502. /**
  62503. * 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.
  62504. * * 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.
  62505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62506. * * 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.
  62507. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62508. * * 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
  62509. * * 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
  62510. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62515. * @param name defines the name of the mesh
  62516. * @param options defines the options used to create the mesh
  62517. * @param scene defines the hosting scene
  62518. * @returns the extruded shape mesh
  62519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62521. */
  62522. static ExtrudeShape(name: string, options: {
  62523. shape: Vector3[];
  62524. path: Vector3[];
  62525. scale?: number;
  62526. rotation?: number;
  62527. cap?: number;
  62528. updatable?: boolean;
  62529. sideOrientation?: number;
  62530. frontUVs?: Vector4;
  62531. backUVs?: Vector4;
  62532. instance?: Mesh;
  62533. invertUV?: boolean;
  62534. }, scene?: Nullable<Scene>): Mesh;
  62535. /**
  62536. * Creates an custom extruded shape mesh.
  62537. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62538. * * 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.
  62539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62540. * * 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
  62541. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62542. * * 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
  62543. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62544. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62545. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62546. * * 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
  62547. * * 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
  62548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62553. * @param name defines the name of the mesh
  62554. * @param options defines the options used to create the mesh
  62555. * @param scene defines the hosting scene
  62556. * @returns the custom extruded shape mesh
  62557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62560. */
  62561. static ExtrudeShapeCustom(name: string, options: {
  62562. shape: Vector3[];
  62563. path: Vector3[];
  62564. scaleFunction?: any;
  62565. rotationFunction?: any;
  62566. ribbonCloseArray?: boolean;
  62567. ribbonClosePath?: boolean;
  62568. cap?: number;
  62569. updatable?: boolean;
  62570. sideOrientation?: number;
  62571. frontUVs?: Vector4;
  62572. backUVs?: Vector4;
  62573. instance?: Mesh;
  62574. invertUV?: boolean;
  62575. }, scene?: Nullable<Scene>): Mesh;
  62576. private static _ExtrudeShapeGeneric;
  62577. }
  62578. }
  62579. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62580. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62581. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62582. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62583. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62584. import { Nullable } from "babylonjs/types";
  62585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62586. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62587. /**
  62588. * AmmoJS Physics plugin
  62589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62590. * @see https://github.com/kripken/ammo.js/
  62591. */
  62592. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62593. private _useDeltaForWorldStep;
  62594. /**
  62595. * Reference to the Ammo library
  62596. */
  62597. bjsAMMO: any;
  62598. /**
  62599. * Created ammoJS world which physics bodies are added to
  62600. */
  62601. world: any;
  62602. /**
  62603. * Name of the plugin
  62604. */
  62605. name: string;
  62606. private _timeStep;
  62607. private _fixedTimeStep;
  62608. private _maxSteps;
  62609. private _tmpQuaternion;
  62610. private _tmpAmmoTransform;
  62611. private _tmpAmmoQuaternion;
  62612. private _tmpAmmoConcreteContactResultCallback;
  62613. private _collisionConfiguration;
  62614. private _dispatcher;
  62615. private _overlappingPairCache;
  62616. private _solver;
  62617. private _softBodySolver;
  62618. private _tmpAmmoVectorA;
  62619. private _tmpAmmoVectorB;
  62620. private _tmpAmmoVectorC;
  62621. private _tmpAmmoVectorD;
  62622. private _tmpContactCallbackResult;
  62623. private _tmpAmmoVectorRCA;
  62624. private _tmpAmmoVectorRCB;
  62625. private _raycastResult;
  62626. private static readonly DISABLE_COLLISION_FLAG;
  62627. private static readonly KINEMATIC_FLAG;
  62628. private static readonly DISABLE_DEACTIVATION_FLAG;
  62629. /**
  62630. * Initializes the ammoJS plugin
  62631. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62632. * @param ammoInjection can be used to inject your own ammo reference
  62633. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62634. */
  62635. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62636. /**
  62637. * Sets the gravity of the physics world (m/(s^2))
  62638. * @param gravity Gravity to set
  62639. */
  62640. setGravity(gravity: Vector3): void;
  62641. /**
  62642. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62643. * @param timeStep timestep to use in seconds
  62644. */
  62645. setTimeStep(timeStep: number): void;
  62646. /**
  62647. * 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)
  62648. * @param fixedTimeStep fixedTimeStep to use in seconds
  62649. */
  62650. setFixedTimeStep(fixedTimeStep: number): void;
  62651. /**
  62652. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62653. * @param maxSteps the maximum number of steps by the physics engine per frame
  62654. */
  62655. setMaxSteps(maxSteps: number): void;
  62656. /**
  62657. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62658. * @returns the current timestep in seconds
  62659. */
  62660. getTimeStep(): number;
  62661. /**
  62662. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62663. */
  62664. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62665. private _isImpostorInContact;
  62666. private _isImpostorPairInContact;
  62667. private _stepSimulation;
  62668. /**
  62669. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62670. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62671. * After the step the babylon meshes are set to the position of the physics imposters
  62672. * @param delta amount of time to step forward
  62673. * @param impostors array of imposters to update before/after the step
  62674. */
  62675. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62676. /**
  62677. * Update babylon mesh to match physics world object
  62678. * @param impostor imposter to match
  62679. */
  62680. private _afterSoftStep;
  62681. /**
  62682. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62683. * @param impostor imposter to match
  62684. */
  62685. private _ropeStep;
  62686. /**
  62687. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62688. * @param impostor imposter to match
  62689. */
  62690. private _softbodyOrClothStep;
  62691. private _tmpMatrix;
  62692. /**
  62693. * Applies an impulse on the imposter
  62694. * @param impostor imposter to apply impulse to
  62695. * @param force amount of force to be applied to the imposter
  62696. * @param contactPoint the location to apply the impulse on the imposter
  62697. */
  62698. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62699. /**
  62700. * Applies a force on the imposter
  62701. * @param impostor imposter to apply force
  62702. * @param force amount of force to be applied to the imposter
  62703. * @param contactPoint the location to apply the force on the imposter
  62704. */
  62705. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62706. /**
  62707. * Creates a physics body using the plugin
  62708. * @param impostor the imposter to create the physics body on
  62709. */
  62710. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62711. /**
  62712. * Removes the physics body from the imposter and disposes of the body's memory
  62713. * @param impostor imposter to remove the physics body from
  62714. */
  62715. removePhysicsBody(impostor: PhysicsImpostor): void;
  62716. /**
  62717. * Generates a joint
  62718. * @param impostorJoint the imposter joint to create the joint with
  62719. */
  62720. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62721. /**
  62722. * Removes a joint
  62723. * @param impostorJoint the imposter joint to remove the joint from
  62724. */
  62725. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62726. private _addMeshVerts;
  62727. /**
  62728. * Initialise the soft body vertices to match its object's (mesh) vertices
  62729. * Softbody vertices (nodes) are in world space and to match this
  62730. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62731. * @param impostor to create the softbody for
  62732. */
  62733. private _softVertexData;
  62734. /**
  62735. * Create an impostor's soft body
  62736. * @param impostor to create the softbody for
  62737. */
  62738. private _createSoftbody;
  62739. /**
  62740. * Create cloth for an impostor
  62741. * @param impostor to create the softbody for
  62742. */
  62743. private _createCloth;
  62744. /**
  62745. * Create rope for an impostor
  62746. * @param impostor to create the softbody for
  62747. */
  62748. private _createRope;
  62749. /**
  62750. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62751. * @param impostor to create the custom physics shape for
  62752. */
  62753. private _createCustom;
  62754. private _addHullVerts;
  62755. private _createShape;
  62756. /**
  62757. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62758. * @param impostor imposter containing the physics body and babylon object
  62759. */
  62760. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62761. /**
  62762. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62763. * @param impostor imposter containing the physics body and babylon object
  62764. * @param newPosition new position
  62765. * @param newRotation new rotation
  62766. */
  62767. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62768. /**
  62769. * If this plugin is supported
  62770. * @returns true if its supported
  62771. */
  62772. isSupported(): boolean;
  62773. /**
  62774. * Sets the linear velocity of the physics body
  62775. * @param impostor imposter to set the velocity on
  62776. * @param velocity velocity to set
  62777. */
  62778. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62779. /**
  62780. * Sets the angular velocity of the physics body
  62781. * @param impostor imposter to set the velocity on
  62782. * @param velocity velocity to set
  62783. */
  62784. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62785. /**
  62786. * gets the linear velocity
  62787. * @param impostor imposter to get linear velocity from
  62788. * @returns linear velocity
  62789. */
  62790. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62791. /**
  62792. * gets the angular velocity
  62793. * @param impostor imposter to get angular velocity from
  62794. * @returns angular velocity
  62795. */
  62796. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62797. /**
  62798. * Sets the mass of physics body
  62799. * @param impostor imposter to set the mass on
  62800. * @param mass mass to set
  62801. */
  62802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62803. /**
  62804. * Gets the mass of the physics body
  62805. * @param impostor imposter to get the mass from
  62806. * @returns mass
  62807. */
  62808. getBodyMass(impostor: PhysicsImpostor): number;
  62809. /**
  62810. * Gets friction of the impostor
  62811. * @param impostor impostor to get friction from
  62812. * @returns friction value
  62813. */
  62814. getBodyFriction(impostor: PhysicsImpostor): number;
  62815. /**
  62816. * Sets friction of the impostor
  62817. * @param impostor impostor to set friction on
  62818. * @param friction friction value
  62819. */
  62820. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62821. /**
  62822. * Gets restitution of the impostor
  62823. * @param impostor impostor to get restitution from
  62824. * @returns restitution value
  62825. */
  62826. getBodyRestitution(impostor: PhysicsImpostor): number;
  62827. /**
  62828. * Sets resitution of the impostor
  62829. * @param impostor impostor to set resitution on
  62830. * @param restitution resitution value
  62831. */
  62832. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62833. /**
  62834. * Gets pressure inside the impostor
  62835. * @param impostor impostor to get pressure from
  62836. * @returns pressure value
  62837. */
  62838. getBodyPressure(impostor: PhysicsImpostor): number;
  62839. /**
  62840. * Sets pressure inside a soft body impostor
  62841. * Cloth and rope must remain 0 pressure
  62842. * @param impostor impostor to set pressure on
  62843. * @param pressure pressure value
  62844. */
  62845. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62846. /**
  62847. * Gets stiffness of the impostor
  62848. * @param impostor impostor to get stiffness from
  62849. * @returns pressure value
  62850. */
  62851. getBodyStiffness(impostor: PhysicsImpostor): number;
  62852. /**
  62853. * Sets stiffness of the impostor
  62854. * @param impostor impostor to set stiffness on
  62855. * @param stiffness stiffness value from 0 to 1
  62856. */
  62857. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62858. /**
  62859. * Gets velocityIterations of the impostor
  62860. * @param impostor impostor to get velocity iterations from
  62861. * @returns velocityIterations value
  62862. */
  62863. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62864. /**
  62865. * Sets velocityIterations of the impostor
  62866. * @param impostor impostor to set velocity iterations on
  62867. * @param velocityIterations velocityIterations value
  62868. */
  62869. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62870. /**
  62871. * Gets positionIterations of the impostor
  62872. * @param impostor impostor to get position iterations from
  62873. * @returns positionIterations value
  62874. */
  62875. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62876. /**
  62877. * Sets positionIterations of the impostor
  62878. * @param impostor impostor to set position on
  62879. * @param positionIterations positionIterations value
  62880. */
  62881. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62882. /**
  62883. * Append an anchor to a cloth object
  62884. * @param impostor is the cloth impostor to add anchor to
  62885. * @param otherImpostor is the rigid impostor to anchor to
  62886. * @param width ratio across width from 0 to 1
  62887. * @param height ratio up height from 0 to 1
  62888. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62889. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62890. */
  62891. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62892. /**
  62893. * Append an hook to a rope object
  62894. * @param impostor is the rope impostor to add hook to
  62895. * @param otherImpostor is the rigid impostor to hook to
  62896. * @param length ratio along the rope from 0 to 1
  62897. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62898. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62899. */
  62900. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62901. /**
  62902. * Sleeps the physics body and stops it from being active
  62903. * @param impostor impostor to sleep
  62904. */
  62905. sleepBody(impostor: PhysicsImpostor): void;
  62906. /**
  62907. * Activates the physics body
  62908. * @param impostor impostor to activate
  62909. */
  62910. wakeUpBody(impostor: PhysicsImpostor): void;
  62911. /**
  62912. * Updates the distance parameters of the joint
  62913. * @param joint joint to update
  62914. * @param maxDistance maximum distance of the joint
  62915. * @param minDistance minimum distance of the joint
  62916. */
  62917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62918. /**
  62919. * Sets a motor on the joint
  62920. * @param joint joint to set motor on
  62921. * @param speed speed of the motor
  62922. * @param maxForce maximum force of the motor
  62923. * @param motorIndex index of the motor
  62924. */
  62925. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62926. /**
  62927. * Sets the motors limit
  62928. * @param joint joint to set limit on
  62929. * @param upperLimit upper limit
  62930. * @param lowerLimit lower limit
  62931. */
  62932. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62933. /**
  62934. * Syncs the position and rotation of a mesh with the impostor
  62935. * @param mesh mesh to sync
  62936. * @param impostor impostor to update the mesh with
  62937. */
  62938. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62939. /**
  62940. * Gets the radius of the impostor
  62941. * @param impostor impostor to get radius from
  62942. * @returns the radius
  62943. */
  62944. getRadius(impostor: PhysicsImpostor): number;
  62945. /**
  62946. * Gets the box size of the impostor
  62947. * @param impostor impostor to get box size from
  62948. * @param result the resulting box size
  62949. */
  62950. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62951. /**
  62952. * Disposes of the impostor
  62953. */
  62954. dispose(): void;
  62955. /**
  62956. * Does a raycast in the physics world
  62957. * @param from when should the ray start?
  62958. * @param to when should the ray end?
  62959. * @returns PhysicsRaycastResult
  62960. */
  62961. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62962. }
  62963. }
  62964. declare module "babylonjs/Probes/reflectionProbe" {
  62965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62966. import { Vector3 } from "babylonjs/Maths/math.vector";
  62967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62968. import { Nullable } from "babylonjs/types";
  62969. import { Scene } from "babylonjs/scene";
  62970. module "babylonjs/abstractScene" {
  62971. interface AbstractScene {
  62972. /**
  62973. * The list of reflection probes added to the scene
  62974. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62975. */
  62976. reflectionProbes: Array<ReflectionProbe>;
  62977. /**
  62978. * Removes the given reflection probe from this scene.
  62979. * @param toRemove The reflection probe to remove
  62980. * @returns The index of the removed reflection probe
  62981. */
  62982. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62983. /**
  62984. * Adds the given reflection probe to this scene.
  62985. * @param newReflectionProbe The reflection probe to add
  62986. */
  62987. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62988. }
  62989. }
  62990. /**
  62991. * Class used to generate realtime reflection / refraction cube textures
  62992. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62993. */
  62994. export class ReflectionProbe {
  62995. /** defines the name of the probe */
  62996. name: string;
  62997. private _scene;
  62998. private _renderTargetTexture;
  62999. private _projectionMatrix;
  63000. private _viewMatrix;
  63001. private _target;
  63002. private _add;
  63003. private _attachedMesh;
  63004. private _invertYAxis;
  63005. /** Gets or sets probe position (center of the cube map) */
  63006. position: Vector3;
  63007. /**
  63008. * Creates a new reflection probe
  63009. * @param name defines the name of the probe
  63010. * @param size defines the texture resolution (for each face)
  63011. * @param scene defines the hosting scene
  63012. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63013. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63014. */
  63015. constructor(
  63016. /** defines the name of the probe */
  63017. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63018. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63019. get samples(): number;
  63020. set samples(value: number);
  63021. /** Gets or sets the refresh rate to use (on every frame by default) */
  63022. get refreshRate(): number;
  63023. set refreshRate(value: number);
  63024. /**
  63025. * Gets the hosting scene
  63026. * @returns a Scene
  63027. */
  63028. getScene(): Scene;
  63029. /** Gets the internal CubeTexture used to render to */
  63030. get cubeTexture(): RenderTargetTexture;
  63031. /** Gets the list of meshes to render */
  63032. get renderList(): Nullable<AbstractMesh[]>;
  63033. /**
  63034. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63035. * @param mesh defines the mesh to attach to
  63036. */
  63037. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63038. /**
  63039. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63040. * @param renderingGroupId The rendering group id corresponding to its index
  63041. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63042. */
  63043. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63044. /**
  63045. * Clean all associated resources
  63046. */
  63047. dispose(): void;
  63048. /**
  63049. * Converts the reflection probe information to a readable string for debug purpose.
  63050. * @param fullDetails Supports for multiple levels of logging within scene loading
  63051. * @returns the human readable reflection probe info
  63052. */
  63053. toString(fullDetails?: boolean): string;
  63054. /**
  63055. * Get the class name of the relfection probe.
  63056. * @returns "ReflectionProbe"
  63057. */
  63058. getClassName(): string;
  63059. /**
  63060. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63061. * @returns The JSON representation of the texture
  63062. */
  63063. serialize(): any;
  63064. /**
  63065. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63066. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63067. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63068. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63069. * @returns The parsed reflection probe if successful
  63070. */
  63071. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63072. }
  63073. }
  63074. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63075. /** @hidden */
  63076. export var _BabylonLoaderRegistered: boolean;
  63077. /**
  63078. * Helps setting up some configuration for the babylon file loader.
  63079. */
  63080. export class BabylonFileLoaderConfiguration {
  63081. /**
  63082. * The loader does not allow injecting custom physix engine into the plugins.
  63083. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63084. * So you could set this variable to your engine import to make it work.
  63085. */
  63086. static LoaderInjectedPhysicsEngine: any;
  63087. }
  63088. }
  63089. declare module "babylonjs/Loading/Plugins/index" {
  63090. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63091. }
  63092. declare module "babylonjs/Loading/index" {
  63093. export * from "babylonjs/Loading/loadingScreen";
  63094. export * from "babylonjs/Loading/Plugins/index";
  63095. export * from "babylonjs/Loading/sceneLoader";
  63096. export * from "babylonjs/Loading/sceneLoaderFlags";
  63097. }
  63098. declare module "babylonjs/Materials/Background/index" {
  63099. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63100. }
  63101. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63102. import { Scene } from "babylonjs/scene";
  63103. import { Color3 } from "babylonjs/Maths/math.color";
  63104. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63106. /**
  63107. * The Physically based simple base material of BJS.
  63108. *
  63109. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63110. * It is used as the base class for both the specGloss and metalRough conventions.
  63111. */
  63112. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63113. /**
  63114. * Number of Simultaneous lights allowed on the material.
  63115. */
  63116. maxSimultaneousLights: number;
  63117. /**
  63118. * If sets to true, disables all the lights affecting the material.
  63119. */
  63120. disableLighting: boolean;
  63121. /**
  63122. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63123. */
  63124. environmentTexture: BaseTexture;
  63125. /**
  63126. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63127. */
  63128. invertNormalMapX: boolean;
  63129. /**
  63130. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63131. */
  63132. invertNormalMapY: boolean;
  63133. /**
  63134. * Normal map used in the model.
  63135. */
  63136. normalTexture: BaseTexture;
  63137. /**
  63138. * Emissivie color used to self-illuminate the model.
  63139. */
  63140. emissiveColor: Color3;
  63141. /**
  63142. * Emissivie texture used to self-illuminate the model.
  63143. */
  63144. emissiveTexture: BaseTexture;
  63145. /**
  63146. * Occlusion Channel Strenght.
  63147. */
  63148. occlusionStrength: number;
  63149. /**
  63150. * Occlusion Texture of the material (adding extra occlusion effects).
  63151. */
  63152. occlusionTexture: BaseTexture;
  63153. /**
  63154. * Defines the alpha limits in alpha test mode.
  63155. */
  63156. alphaCutOff: number;
  63157. /**
  63158. * Gets the current double sided mode.
  63159. */
  63160. get doubleSided(): boolean;
  63161. /**
  63162. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63163. */
  63164. set doubleSided(value: boolean);
  63165. /**
  63166. * Stores the pre-calculated light information of a mesh in a texture.
  63167. */
  63168. lightmapTexture: BaseTexture;
  63169. /**
  63170. * If true, the light map contains occlusion information instead of lighting info.
  63171. */
  63172. useLightmapAsShadowmap: boolean;
  63173. /**
  63174. * Instantiates a new PBRMaterial instance.
  63175. *
  63176. * @param name The material name
  63177. * @param scene The scene the material will be use in.
  63178. */
  63179. constructor(name: string, scene: Scene);
  63180. getClassName(): string;
  63181. }
  63182. }
  63183. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63184. import { Scene } from "babylonjs/scene";
  63185. import { Color3 } from "babylonjs/Maths/math.color";
  63186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63187. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63188. /**
  63189. * The PBR material of BJS following the metal roughness convention.
  63190. *
  63191. * This fits to the PBR convention in the GLTF definition:
  63192. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63193. */
  63194. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63195. /**
  63196. * The base color has two different interpretations depending on the value of metalness.
  63197. * When the material is a metal, the base color is the specific measured reflectance value
  63198. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63199. * of the material.
  63200. */
  63201. baseColor: Color3;
  63202. /**
  63203. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63204. * well as opacity information in the alpha channel.
  63205. */
  63206. baseTexture: BaseTexture;
  63207. /**
  63208. * Specifies the metallic scalar value of the material.
  63209. * Can also be used to scale the metalness values of the metallic texture.
  63210. */
  63211. metallic: number;
  63212. /**
  63213. * Specifies the roughness scalar value of the material.
  63214. * Can also be used to scale the roughness values of the metallic texture.
  63215. */
  63216. roughness: number;
  63217. /**
  63218. * Texture containing both the metallic value in the B channel and the
  63219. * roughness value in the G channel to keep better precision.
  63220. */
  63221. metallicRoughnessTexture: BaseTexture;
  63222. /**
  63223. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63224. *
  63225. * @param name The material name
  63226. * @param scene The scene the material will be use in.
  63227. */
  63228. constructor(name: string, scene: Scene);
  63229. /**
  63230. * Return the currrent class name of the material.
  63231. */
  63232. getClassName(): string;
  63233. /**
  63234. * Makes a duplicate of the current material.
  63235. * @param name - name to use for the new material.
  63236. */
  63237. clone(name: string): PBRMetallicRoughnessMaterial;
  63238. /**
  63239. * Serialize the material to a parsable JSON object.
  63240. */
  63241. serialize(): any;
  63242. /**
  63243. * Parses a JSON object correponding to the serialize function.
  63244. */
  63245. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63246. }
  63247. }
  63248. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63249. import { Scene } from "babylonjs/scene";
  63250. import { Color3 } from "babylonjs/Maths/math.color";
  63251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63252. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63253. /**
  63254. * The PBR material of BJS following the specular glossiness convention.
  63255. *
  63256. * This fits to the PBR convention in the GLTF definition:
  63257. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63258. */
  63259. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63260. /**
  63261. * Specifies the diffuse color of the material.
  63262. */
  63263. diffuseColor: Color3;
  63264. /**
  63265. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63266. * channel.
  63267. */
  63268. diffuseTexture: BaseTexture;
  63269. /**
  63270. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63271. */
  63272. specularColor: Color3;
  63273. /**
  63274. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63275. */
  63276. glossiness: number;
  63277. /**
  63278. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63279. */
  63280. specularGlossinessTexture: BaseTexture;
  63281. /**
  63282. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63283. *
  63284. * @param name The material name
  63285. * @param scene The scene the material will be use in.
  63286. */
  63287. constructor(name: string, scene: Scene);
  63288. /**
  63289. * Return the currrent class name of the material.
  63290. */
  63291. getClassName(): string;
  63292. /**
  63293. * Makes a duplicate of the current material.
  63294. * @param name - name to use for the new material.
  63295. */
  63296. clone(name: string): PBRSpecularGlossinessMaterial;
  63297. /**
  63298. * Serialize the material to a parsable JSON object.
  63299. */
  63300. serialize(): any;
  63301. /**
  63302. * Parses a JSON object correponding to the serialize function.
  63303. */
  63304. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63305. }
  63306. }
  63307. declare module "babylonjs/Materials/PBR/index" {
  63308. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63309. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63310. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63311. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63312. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63313. }
  63314. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63315. import { Nullable } from "babylonjs/types";
  63316. import { Scene } from "babylonjs/scene";
  63317. import { Matrix } from "babylonjs/Maths/math.vector";
  63318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63319. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63320. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63321. /**
  63322. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63323. * It can help converting any input color in a desired output one. This can then be used to create effects
  63324. * from sepia, black and white to sixties or futuristic rendering...
  63325. *
  63326. * The only supported format is currently 3dl.
  63327. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63328. */
  63329. export class ColorGradingTexture extends BaseTexture {
  63330. /**
  63331. * The texture URL.
  63332. */
  63333. url: string;
  63334. /**
  63335. * Empty line regex stored for GC.
  63336. */
  63337. private static _noneEmptyLineRegex;
  63338. private _textureMatrix;
  63339. private _onLoad;
  63340. /**
  63341. * Instantiates a ColorGradingTexture from the following parameters.
  63342. *
  63343. * @param url The location of the color gradind data (currently only supporting 3dl)
  63344. * @param sceneOrEngine The scene or engine the texture will be used in
  63345. * @param onLoad defines a callback triggered when the texture has been loaded
  63346. */
  63347. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63348. /**
  63349. * Fires the onload event from the constructor if requested.
  63350. */
  63351. private _triggerOnLoad;
  63352. /**
  63353. * Returns the texture matrix used in most of the material.
  63354. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63355. */
  63356. getTextureMatrix(): Matrix;
  63357. /**
  63358. * Occurs when the file being loaded is a .3dl LUT file.
  63359. */
  63360. private load3dlTexture;
  63361. /**
  63362. * Starts the loading process of the texture.
  63363. */
  63364. private loadTexture;
  63365. /**
  63366. * Clones the color gradind texture.
  63367. */
  63368. clone(): ColorGradingTexture;
  63369. /**
  63370. * Called during delayed load for textures.
  63371. */
  63372. delayLoad(): void;
  63373. /**
  63374. * Parses a color grading texture serialized by Babylon.
  63375. * @param parsedTexture The texture information being parsedTexture
  63376. * @param scene The scene to load the texture in
  63377. * @param rootUrl The root url of the data assets to load
  63378. * @return A color gradind texture
  63379. */
  63380. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63381. /**
  63382. * Serializes the LUT texture to json format.
  63383. */
  63384. serialize(): any;
  63385. }
  63386. }
  63387. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63389. import { Scene } from "babylonjs/scene";
  63390. import { Nullable } from "babylonjs/types";
  63391. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63392. /**
  63393. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63394. */
  63395. export class EquiRectangularCubeTexture extends BaseTexture {
  63396. /** The six faces of the cube. */
  63397. private static _FacesMapping;
  63398. private _noMipmap;
  63399. private _onLoad;
  63400. private _onError;
  63401. /** The size of the cubemap. */
  63402. private _size;
  63403. /** The buffer of the image. */
  63404. private _buffer;
  63405. /** The width of the input image. */
  63406. private _width;
  63407. /** The height of the input image. */
  63408. private _height;
  63409. /** The URL to the image. */
  63410. url: string;
  63411. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63412. coordinatesMode: number;
  63413. /**
  63414. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63415. * @param url The location of the image
  63416. * @param scene The scene the texture will be used in
  63417. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63418. * @param noMipmap Forces to not generate the mipmap if true
  63419. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63420. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63421. * @param onLoad — defines a callback called when texture is loaded
  63422. * @param onError — defines a callback called if there is an error
  63423. */
  63424. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63425. /**
  63426. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63427. */
  63428. private loadImage;
  63429. /**
  63430. * Convert the image buffer into a cubemap and create a CubeTexture.
  63431. */
  63432. private loadTexture;
  63433. /**
  63434. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63435. * @param buffer The ArrayBuffer that should be converted.
  63436. * @returns The buffer as Float32Array.
  63437. */
  63438. private getFloat32ArrayFromArrayBuffer;
  63439. /**
  63440. * Get the current class name of the texture useful for serialization or dynamic coding.
  63441. * @returns "EquiRectangularCubeTexture"
  63442. */
  63443. getClassName(): string;
  63444. /**
  63445. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63446. * @returns A clone of the current EquiRectangularCubeTexture.
  63447. */
  63448. clone(): EquiRectangularCubeTexture;
  63449. }
  63450. }
  63451. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63452. import { Nullable } from "babylonjs/types";
  63453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63454. import { Matrix } from "babylonjs/Maths/math.vector";
  63455. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63456. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63457. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63458. import { Scene } from "babylonjs/scene";
  63459. /**
  63460. * Defines the options related to the creation of an HtmlElementTexture
  63461. */
  63462. export interface IHtmlElementTextureOptions {
  63463. /**
  63464. * Defines wether mip maps should be created or not.
  63465. */
  63466. generateMipMaps?: boolean;
  63467. /**
  63468. * Defines the sampling mode of the texture.
  63469. */
  63470. samplingMode?: number;
  63471. /**
  63472. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63473. */
  63474. engine: Nullable<ThinEngine>;
  63475. /**
  63476. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63477. */
  63478. scene: Nullable<Scene>;
  63479. }
  63480. /**
  63481. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63482. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63483. * is automatically managed.
  63484. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63485. * in your application.
  63486. *
  63487. * As the update is not automatic, you need to call them manually.
  63488. */
  63489. export class HtmlElementTexture extends BaseTexture {
  63490. /**
  63491. * The texture URL.
  63492. */
  63493. element: HTMLVideoElement | HTMLCanvasElement;
  63494. private static readonly DefaultOptions;
  63495. private _textureMatrix;
  63496. private _isVideo;
  63497. private _generateMipMaps;
  63498. private _samplingMode;
  63499. /**
  63500. * Instantiates a HtmlElementTexture from the following parameters.
  63501. *
  63502. * @param name Defines the name of the texture
  63503. * @param element Defines the video or canvas the texture is filled with
  63504. * @param options Defines the other none mandatory texture creation options
  63505. */
  63506. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63507. private _createInternalTexture;
  63508. /**
  63509. * Returns the texture matrix used in most of the material.
  63510. */
  63511. getTextureMatrix(): Matrix;
  63512. /**
  63513. * Updates the content of the texture.
  63514. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63515. */
  63516. update(invertY?: Nullable<boolean>): void;
  63517. }
  63518. }
  63519. declare module "babylonjs/Misc/tga" {
  63520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63521. /**
  63522. * Based on jsTGALoader - Javascript loader for TGA file
  63523. * By Vincent Thibault
  63524. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63525. */
  63526. export class TGATools {
  63527. private static _TYPE_INDEXED;
  63528. private static _TYPE_RGB;
  63529. private static _TYPE_GREY;
  63530. private static _TYPE_RLE_INDEXED;
  63531. private static _TYPE_RLE_RGB;
  63532. private static _TYPE_RLE_GREY;
  63533. private static _ORIGIN_MASK;
  63534. private static _ORIGIN_SHIFT;
  63535. private static _ORIGIN_BL;
  63536. private static _ORIGIN_BR;
  63537. private static _ORIGIN_UL;
  63538. private static _ORIGIN_UR;
  63539. /**
  63540. * Gets the header of a TGA file
  63541. * @param data defines the TGA data
  63542. * @returns the header
  63543. */
  63544. static GetTGAHeader(data: Uint8Array): any;
  63545. /**
  63546. * Uploads TGA content to a Babylon Texture
  63547. * @hidden
  63548. */
  63549. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63550. /** @hidden */
  63551. 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;
  63552. /** @hidden */
  63553. 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;
  63554. /** @hidden */
  63555. 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;
  63556. /** @hidden */
  63557. 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;
  63558. /** @hidden */
  63559. 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;
  63560. /** @hidden */
  63561. 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;
  63562. }
  63563. }
  63564. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63565. import { Nullable } from "babylonjs/types";
  63566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63567. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63568. /**
  63569. * Implementation of the TGA Texture Loader.
  63570. * @hidden
  63571. */
  63572. export class _TGATextureLoader implements IInternalTextureLoader {
  63573. /**
  63574. * Defines wether the loader supports cascade loading the different faces.
  63575. */
  63576. readonly supportCascades: boolean;
  63577. /**
  63578. * This returns if the loader support the current file information.
  63579. * @param extension defines the file extension of the file being loaded
  63580. * @returns true if the loader can load the specified file
  63581. */
  63582. canLoad(extension: string): boolean;
  63583. /**
  63584. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63585. * @param data contains the texture data
  63586. * @param texture defines the BabylonJS internal texture
  63587. * @param createPolynomials will be true if polynomials have been requested
  63588. * @param onLoad defines the callback to trigger once the texture is ready
  63589. * @param onError defines the callback to trigger in case of error
  63590. */
  63591. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63592. /**
  63593. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63594. * @param data contains the texture data
  63595. * @param texture defines the BabylonJS internal texture
  63596. * @param callback defines the method to call once ready to upload
  63597. */
  63598. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63599. }
  63600. }
  63601. declare module "babylonjs/Misc/basis" {
  63602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63603. /**
  63604. * Info about the .basis files
  63605. */
  63606. class BasisFileInfo {
  63607. /**
  63608. * If the file has alpha
  63609. */
  63610. hasAlpha: boolean;
  63611. /**
  63612. * Info about each image of the basis file
  63613. */
  63614. images: Array<{
  63615. levels: Array<{
  63616. width: number;
  63617. height: number;
  63618. transcodedPixels: ArrayBufferView;
  63619. }>;
  63620. }>;
  63621. }
  63622. /**
  63623. * Result of transcoding a basis file
  63624. */
  63625. class TranscodeResult {
  63626. /**
  63627. * Info about the .basis file
  63628. */
  63629. fileInfo: BasisFileInfo;
  63630. /**
  63631. * Format to use when loading the file
  63632. */
  63633. format: number;
  63634. }
  63635. /**
  63636. * Configuration options for the Basis transcoder
  63637. */
  63638. export class BasisTranscodeConfiguration {
  63639. /**
  63640. * Supported compression formats used to determine the supported output format of the transcoder
  63641. */
  63642. supportedCompressionFormats?: {
  63643. /**
  63644. * etc1 compression format
  63645. */
  63646. etc1?: boolean;
  63647. /**
  63648. * s3tc compression format
  63649. */
  63650. s3tc?: boolean;
  63651. /**
  63652. * pvrtc compression format
  63653. */
  63654. pvrtc?: boolean;
  63655. /**
  63656. * etc2 compression format
  63657. */
  63658. etc2?: boolean;
  63659. };
  63660. /**
  63661. * If mipmap levels should be loaded for transcoded images (Default: true)
  63662. */
  63663. loadMipmapLevels?: boolean;
  63664. /**
  63665. * Index of a single image to load (Default: all images)
  63666. */
  63667. loadSingleImage?: number;
  63668. }
  63669. /**
  63670. * Used to load .Basis files
  63671. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63672. */
  63673. export class BasisTools {
  63674. private static _IgnoreSupportedFormats;
  63675. /**
  63676. * URL to use when loading the basis transcoder
  63677. */
  63678. static JSModuleURL: string;
  63679. /**
  63680. * URL to use when loading the wasm module for the transcoder
  63681. */
  63682. static WasmModuleURL: string;
  63683. /**
  63684. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63685. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63686. * @returns internal format corresponding to the Basis format
  63687. */
  63688. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63689. private static _WorkerPromise;
  63690. private static _Worker;
  63691. private static _actionId;
  63692. private static _CreateWorkerAsync;
  63693. /**
  63694. * Transcodes a loaded image file to compressed pixel data
  63695. * @param data image data to transcode
  63696. * @param config configuration options for the transcoding
  63697. * @returns a promise resulting in the transcoded image
  63698. */
  63699. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63700. /**
  63701. * Loads a texture from the transcode result
  63702. * @param texture texture load to
  63703. * @param transcodeResult the result of transcoding the basis file to load from
  63704. */
  63705. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63706. }
  63707. }
  63708. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63709. import { Nullable } from "babylonjs/types";
  63710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63711. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63712. /**
  63713. * Loader for .basis file format
  63714. */
  63715. export class _BasisTextureLoader implements IInternalTextureLoader {
  63716. /**
  63717. * Defines whether the loader supports cascade loading the different faces.
  63718. */
  63719. readonly supportCascades: boolean;
  63720. /**
  63721. * This returns if the loader support the current file information.
  63722. * @param extension defines the file extension of the file being loaded
  63723. * @returns true if the loader can load the specified file
  63724. */
  63725. canLoad(extension: string): boolean;
  63726. /**
  63727. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63728. * @param data contains the texture data
  63729. * @param texture defines the BabylonJS internal texture
  63730. * @param createPolynomials will be true if polynomials have been requested
  63731. * @param onLoad defines the callback to trigger once the texture is ready
  63732. * @param onError defines the callback to trigger in case of error
  63733. */
  63734. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63735. /**
  63736. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63737. * @param data contains the texture data
  63738. * @param texture defines the BabylonJS internal texture
  63739. * @param callback defines the method to call once ready to upload
  63740. */
  63741. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63742. }
  63743. }
  63744. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63745. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63746. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63747. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63748. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63749. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63750. }
  63751. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63752. import { Vector2 } from "babylonjs/Maths/math.vector";
  63753. /**
  63754. * Defines the basic options interface of a TexturePacker Frame
  63755. */
  63756. export interface ITexturePackerFrame {
  63757. /**
  63758. * The frame ID
  63759. */
  63760. id: number;
  63761. /**
  63762. * The frames Scale
  63763. */
  63764. scale: Vector2;
  63765. /**
  63766. * The Frames offset
  63767. */
  63768. offset: Vector2;
  63769. }
  63770. /**
  63771. * This is a support class for frame Data on texture packer sets.
  63772. */
  63773. export class TexturePackerFrame implements ITexturePackerFrame {
  63774. /**
  63775. * The frame ID
  63776. */
  63777. id: number;
  63778. /**
  63779. * The frames Scale
  63780. */
  63781. scale: Vector2;
  63782. /**
  63783. * The Frames offset
  63784. */
  63785. offset: Vector2;
  63786. /**
  63787. * Initializes a texture package frame.
  63788. * @param id The numerical frame identifier
  63789. * @param scale Scalar Vector2 for UV frame
  63790. * @param offset Vector2 for the frame position in UV units.
  63791. * @returns TexturePackerFrame
  63792. */
  63793. constructor(id: number, scale: Vector2, offset: Vector2);
  63794. }
  63795. }
  63796. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63798. import { Scene } from "babylonjs/scene";
  63799. import { Nullable } from "babylonjs/types";
  63800. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63801. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63802. /**
  63803. * Defines the basic options interface of a TexturePacker
  63804. */
  63805. export interface ITexturePackerOptions {
  63806. /**
  63807. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63808. */
  63809. map?: string[];
  63810. /**
  63811. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63812. */
  63813. uvsIn?: string;
  63814. /**
  63815. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63816. */
  63817. uvsOut?: string;
  63818. /**
  63819. * number representing the layout style. Defaults to LAYOUT_STRIP
  63820. */
  63821. layout?: number;
  63822. /**
  63823. * number of columns if using custom column count layout(2). This defaults to 4.
  63824. */
  63825. colnum?: number;
  63826. /**
  63827. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63828. */
  63829. updateInputMeshes?: boolean;
  63830. /**
  63831. * boolean flag to dispose all the source textures. Defaults to true.
  63832. */
  63833. disposeSources?: boolean;
  63834. /**
  63835. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63836. */
  63837. fillBlanks?: boolean;
  63838. /**
  63839. * string value representing the context fill style color. Defaults to 'black'.
  63840. */
  63841. customFillColor?: string;
  63842. /**
  63843. * Width and Height Value of each Frame in the TexturePacker Sets
  63844. */
  63845. frameSize?: number;
  63846. /**
  63847. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63848. */
  63849. paddingRatio?: number;
  63850. /**
  63851. * Number that declares the fill method for the padding gutter.
  63852. */
  63853. paddingMode?: number;
  63854. /**
  63855. * If in SUBUV_COLOR padding mode what color to use.
  63856. */
  63857. paddingColor?: Color3 | Color4;
  63858. }
  63859. /**
  63860. * Defines the basic interface of a TexturePacker JSON File
  63861. */
  63862. export interface ITexturePackerJSON {
  63863. /**
  63864. * The frame ID
  63865. */
  63866. name: string;
  63867. /**
  63868. * The base64 channel data
  63869. */
  63870. sets: any;
  63871. /**
  63872. * The options of the Packer
  63873. */
  63874. options: ITexturePackerOptions;
  63875. /**
  63876. * The frame data of the Packer
  63877. */
  63878. frames: Array<number>;
  63879. }
  63880. /**
  63881. * This is a support class that generates a series of packed texture sets.
  63882. * @see https://doc.babylonjs.com/babylon101/materials
  63883. */
  63884. export class TexturePacker {
  63885. /** Packer Layout Constant 0 */
  63886. static readonly LAYOUT_STRIP: number;
  63887. /** Packer Layout Constant 1 */
  63888. static readonly LAYOUT_POWER2: number;
  63889. /** Packer Layout Constant 2 */
  63890. static readonly LAYOUT_COLNUM: number;
  63891. /** Packer Layout Constant 0 */
  63892. static readonly SUBUV_WRAP: number;
  63893. /** Packer Layout Constant 1 */
  63894. static readonly SUBUV_EXTEND: number;
  63895. /** Packer Layout Constant 2 */
  63896. static readonly SUBUV_COLOR: number;
  63897. /** The Name of the Texture Package */
  63898. name: string;
  63899. /** The scene scope of the TexturePacker */
  63900. scene: Scene;
  63901. /** The Meshes to target */
  63902. meshes: AbstractMesh[];
  63903. /** Arguments passed with the Constructor */
  63904. options: ITexturePackerOptions;
  63905. /** The promise that is started upon initialization */
  63906. promise: Nullable<Promise<TexturePacker | string>>;
  63907. /** The Container object for the channel sets that are generated */
  63908. sets: object;
  63909. /** The Container array for the frames that are generated */
  63910. frames: TexturePackerFrame[];
  63911. /** The expected number of textures the system is parsing. */
  63912. private _expecting;
  63913. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63914. private _paddingValue;
  63915. /**
  63916. * Initializes a texture package series from an array of meshes or a single mesh.
  63917. * @param name The name of the package
  63918. * @param meshes The target meshes to compose the package from
  63919. * @param options The arguments that texture packer should follow while building.
  63920. * @param scene The scene which the textures are scoped to.
  63921. * @returns TexturePacker
  63922. */
  63923. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63924. /**
  63925. * Starts the package process
  63926. * @param resolve The promises resolution function
  63927. * @returns TexturePacker
  63928. */
  63929. private _createFrames;
  63930. /**
  63931. * Calculates the Size of the Channel Sets
  63932. * @returns Vector2
  63933. */
  63934. private _calculateSize;
  63935. /**
  63936. * Calculates the UV data for the frames.
  63937. * @param baseSize the base frameSize
  63938. * @param padding the base frame padding
  63939. * @param dtSize size of the Dynamic Texture for that channel
  63940. * @param dtUnits is 1/dtSize
  63941. * @param update flag to update the input meshes
  63942. */
  63943. private _calculateMeshUVFrames;
  63944. /**
  63945. * Calculates the frames Offset.
  63946. * @param index of the frame
  63947. * @returns Vector2
  63948. */
  63949. private _getFrameOffset;
  63950. /**
  63951. * Updates a Mesh to the frame data
  63952. * @param mesh that is the target
  63953. * @param frameID or the frame index
  63954. */
  63955. private _updateMeshUV;
  63956. /**
  63957. * Updates a Meshes materials to use the texture packer channels
  63958. * @param m is the mesh to target
  63959. * @param force all channels on the packer to be set.
  63960. */
  63961. private _updateTextureReferences;
  63962. /**
  63963. * Public method to set a Mesh to a frame
  63964. * @param m that is the target
  63965. * @param frameID or the frame index
  63966. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63967. */
  63968. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63969. /**
  63970. * Starts the async promise to compile the texture packer.
  63971. * @returns Promise<void>
  63972. */
  63973. processAsync(): Promise<void>;
  63974. /**
  63975. * Disposes all textures associated with this packer
  63976. */
  63977. dispose(): void;
  63978. /**
  63979. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63980. * @param imageType is the image type to use.
  63981. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63982. */
  63983. download(imageType?: string, quality?: number): void;
  63984. /**
  63985. * Public method to load a texturePacker JSON file.
  63986. * @param data of the JSON file in string format.
  63987. */
  63988. updateFromJSON(data: string): void;
  63989. }
  63990. }
  63991. declare module "babylonjs/Materials/Textures/Packer/index" {
  63992. export * from "babylonjs/Materials/Textures/Packer/packer";
  63993. export * from "babylonjs/Materials/Textures/Packer/frame";
  63994. }
  63995. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63996. import { Scene } from "babylonjs/scene";
  63997. import { Texture } from "babylonjs/Materials/Textures/texture";
  63998. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63999. /**
  64000. * 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.
  64001. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64002. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64003. */
  64004. export class CustomProceduralTexture extends ProceduralTexture {
  64005. private _animate;
  64006. private _time;
  64007. private _config;
  64008. private _texturePath;
  64009. /**
  64010. * Instantiates a new Custom Procedural Texture.
  64011. * 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.
  64012. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64013. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64014. * @param name Define the name of the texture
  64015. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64016. * @param size Define the size of the texture to create
  64017. * @param scene Define the scene the texture belongs to
  64018. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64019. * @param generateMipMaps Define if the texture should creates mip maps or not
  64020. */
  64021. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64022. private _loadJson;
  64023. /**
  64024. * Is the texture ready to be used ? (rendered at least once)
  64025. * @returns true if ready, otherwise, false.
  64026. */
  64027. isReady(): boolean;
  64028. /**
  64029. * Render the texture to its associated render target.
  64030. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64031. */
  64032. render(useCameraPostProcess?: boolean): void;
  64033. /**
  64034. * Update the list of dependant textures samplers in the shader.
  64035. */
  64036. updateTextures(): void;
  64037. /**
  64038. * Update the uniform values of the procedural texture in the shader.
  64039. */
  64040. updateShaderUniforms(): void;
  64041. /**
  64042. * Define if the texture animates or not.
  64043. */
  64044. get animate(): boolean;
  64045. set animate(value: boolean);
  64046. }
  64047. }
  64048. declare module "babylonjs/Shaders/noise.fragment" {
  64049. /** @hidden */
  64050. export var noisePixelShader: {
  64051. name: string;
  64052. shader: string;
  64053. };
  64054. }
  64055. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64056. import { Nullable } from "babylonjs/types";
  64057. import { Scene } from "babylonjs/scene";
  64058. import { Texture } from "babylonjs/Materials/Textures/texture";
  64059. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64060. import "babylonjs/Shaders/noise.fragment";
  64061. /**
  64062. * Class used to generate noise procedural textures
  64063. */
  64064. export class NoiseProceduralTexture extends ProceduralTexture {
  64065. private _time;
  64066. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64067. brightness: number;
  64068. /** Defines the number of octaves to process */
  64069. octaves: number;
  64070. /** Defines the level of persistence (0.8 by default) */
  64071. persistence: number;
  64072. /** Gets or sets animation speed factor (default is 1) */
  64073. animationSpeedFactor: number;
  64074. /**
  64075. * Creates a new NoiseProceduralTexture
  64076. * @param name defines the name fo the texture
  64077. * @param size defines the size of the texture (default is 256)
  64078. * @param scene defines the hosting scene
  64079. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64080. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64081. */
  64082. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64083. private _updateShaderUniforms;
  64084. protected _getDefines(): string;
  64085. /** Generate the current state of the procedural texture */
  64086. render(useCameraPostProcess?: boolean): void;
  64087. /**
  64088. * Serializes this noise procedural texture
  64089. * @returns a serialized noise procedural texture object
  64090. */
  64091. serialize(): any;
  64092. /**
  64093. * Clone the texture.
  64094. * @returns the cloned texture
  64095. */
  64096. clone(): NoiseProceduralTexture;
  64097. /**
  64098. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64099. * @param parsedTexture defines parsed texture data
  64100. * @param scene defines the current scene
  64101. * @param rootUrl defines the root URL containing noise procedural texture information
  64102. * @returns a parsed NoiseProceduralTexture
  64103. */
  64104. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64105. }
  64106. }
  64107. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64108. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64109. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64110. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64111. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64112. }
  64113. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64114. import { Nullable } from "babylonjs/types";
  64115. import { Scene } from "babylonjs/scene";
  64116. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64118. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64119. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64120. /**
  64121. * Raw cube texture where the raw buffers are passed in
  64122. */
  64123. export class RawCubeTexture extends CubeTexture {
  64124. /**
  64125. * Creates a cube texture where the raw buffers are passed in.
  64126. * @param scene defines the scene the texture is attached to
  64127. * @param data defines the array of data to use to create each face
  64128. * @param size defines the size of the textures
  64129. * @param format defines the format of the data
  64130. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64131. * @param generateMipMaps defines if the engine should generate the mip levels
  64132. * @param invertY defines if data must be stored with Y axis inverted
  64133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64134. * @param compression defines the compression used (null by default)
  64135. */
  64136. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64137. /**
  64138. * Updates the raw cube texture.
  64139. * @param data defines the data to store
  64140. * @param format defines the data format
  64141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64142. * @param invertY defines if data must be stored with Y axis inverted
  64143. * @param compression defines the compression used (null by default)
  64144. * @param level defines which level of the texture to update
  64145. */
  64146. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64147. /**
  64148. * Updates a raw cube texture with RGBD encoded data.
  64149. * @param data defines the array of data [mipmap][face] to use to create each face
  64150. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64151. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64152. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64153. * @returns a promsie that resolves when the operation is complete
  64154. */
  64155. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64156. /**
  64157. * Clones the raw cube texture.
  64158. * @return a new cube texture
  64159. */
  64160. clone(): CubeTexture;
  64161. /** @hidden */
  64162. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64163. }
  64164. }
  64165. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64166. import { Scene } from "babylonjs/scene";
  64167. import { Texture } from "babylonjs/Materials/Textures/texture";
  64168. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64169. /**
  64170. * Class used to store 2D array textures containing user data
  64171. */
  64172. export class RawTexture2DArray extends Texture {
  64173. /** Gets or sets the texture format to use */
  64174. format: number;
  64175. /**
  64176. * Create a new RawTexture2DArray
  64177. * @param data defines the data of the texture
  64178. * @param width defines the width of the texture
  64179. * @param height defines the height of the texture
  64180. * @param depth defines the number of layers of the texture
  64181. * @param format defines the texture format to use
  64182. * @param scene defines the hosting scene
  64183. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64184. * @param invertY defines if texture must be stored with Y axis inverted
  64185. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64186. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64187. */
  64188. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64189. /** Gets or sets the texture format to use */
  64190. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64191. /**
  64192. * Update the texture with new data
  64193. * @param data defines the data to store in the texture
  64194. */
  64195. update(data: ArrayBufferView): void;
  64196. }
  64197. }
  64198. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64199. import { Scene } from "babylonjs/scene";
  64200. import { Texture } from "babylonjs/Materials/Textures/texture";
  64201. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64202. /**
  64203. * Class used to store 3D textures containing user data
  64204. */
  64205. export class RawTexture3D extends Texture {
  64206. /** Gets or sets the texture format to use */
  64207. format: number;
  64208. /**
  64209. * Create a new RawTexture3D
  64210. * @param data defines the data of the texture
  64211. * @param width defines the width of the texture
  64212. * @param height defines the height of the texture
  64213. * @param depth defines the depth of the texture
  64214. * @param format defines the texture format to use
  64215. * @param scene defines the hosting scene
  64216. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64217. * @param invertY defines if texture must be stored with Y axis inverted
  64218. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64219. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64220. */
  64221. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64222. /** Gets or sets the texture format to use */
  64223. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64224. /**
  64225. * Update the texture with new data
  64226. * @param data defines the data to store in the texture
  64227. */
  64228. update(data: ArrayBufferView): void;
  64229. }
  64230. }
  64231. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64232. import { Scene } from "babylonjs/scene";
  64233. import { Plane } from "babylonjs/Maths/math.plane";
  64234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64235. /**
  64236. * Creates a refraction texture used by refraction channel of the standard material.
  64237. * It is like a mirror but to see through a material.
  64238. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64239. */
  64240. export class RefractionTexture extends RenderTargetTexture {
  64241. /**
  64242. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64243. * 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.
  64244. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64245. */
  64246. refractionPlane: Plane;
  64247. /**
  64248. * Define how deep under the surface we should see.
  64249. */
  64250. depth: number;
  64251. /**
  64252. * Creates a refraction texture used by refraction channel of the standard material.
  64253. * It is like a mirror but to see through a material.
  64254. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64255. * @param name Define the texture name
  64256. * @param size Define the size of the underlying texture
  64257. * @param scene Define the scene the refraction belongs to
  64258. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64259. */
  64260. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64261. /**
  64262. * Clone the refraction texture.
  64263. * @returns the cloned texture
  64264. */
  64265. clone(): RefractionTexture;
  64266. /**
  64267. * Serialize the texture to a JSON representation you could use in Parse later on
  64268. * @returns the serialized JSON representation
  64269. */
  64270. serialize(): any;
  64271. }
  64272. }
  64273. declare module "babylonjs/Materials/Textures/index" {
  64274. export * from "babylonjs/Materials/Textures/baseTexture";
  64275. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64276. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64277. export * from "babylonjs/Materials/Textures/cubeTexture";
  64278. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64279. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64280. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64281. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64282. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64283. export * from "babylonjs/Materials/Textures/internalTexture";
  64284. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64285. export * from "babylonjs/Materials/Textures/Loaders/index";
  64286. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64287. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64288. export * from "babylonjs/Materials/Textures/Packer/index";
  64289. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64290. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64291. export * from "babylonjs/Materials/Textures/rawTexture";
  64292. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64293. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64294. export * from "babylonjs/Materials/Textures/refractionTexture";
  64295. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64296. export * from "babylonjs/Materials/Textures/texture";
  64297. export * from "babylonjs/Materials/Textures/videoTexture";
  64298. }
  64299. declare module "babylonjs/Materials/Node/Enums/index" {
  64300. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64301. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64302. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64303. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64304. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64305. }
  64306. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64310. import { Mesh } from "babylonjs/Meshes/mesh";
  64311. import { Effect } from "babylonjs/Materials/effect";
  64312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64313. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64314. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64315. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64316. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64317. /**
  64318. * Block used to add support for vertex skinning (bones)
  64319. */
  64320. export class BonesBlock extends NodeMaterialBlock {
  64321. /**
  64322. * Creates a new BonesBlock
  64323. * @param name defines the block name
  64324. */
  64325. constructor(name: string);
  64326. /**
  64327. * Initialize the block and prepare the context for build
  64328. * @param state defines the state that will be used for the build
  64329. */
  64330. initialize(state: NodeMaterialBuildState): void;
  64331. /**
  64332. * Gets the current class name
  64333. * @returns the class name
  64334. */
  64335. getClassName(): string;
  64336. /**
  64337. * Gets the matrix indices input component
  64338. */
  64339. get matricesIndices(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the matrix weights input component
  64342. */
  64343. get matricesWeights(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the extra matrix indices input component
  64346. */
  64347. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the extra matrix weights input component
  64350. */
  64351. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the world input component
  64354. */
  64355. get world(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the output component
  64358. */
  64359. get output(): NodeMaterialConnectionPoint;
  64360. autoConfigure(material: NodeMaterial): void;
  64361. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64364. protected _buildBlock(state: NodeMaterialBuildState): this;
  64365. }
  64366. }
  64367. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64372. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64374. /**
  64375. * Block used to add support for instances
  64376. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64377. */
  64378. export class InstancesBlock extends NodeMaterialBlock {
  64379. /**
  64380. * Creates a new InstancesBlock
  64381. * @param name defines the block name
  64382. */
  64383. constructor(name: string);
  64384. /**
  64385. * Gets the current class name
  64386. * @returns the class name
  64387. */
  64388. getClassName(): string;
  64389. /**
  64390. * Gets the first world row input component
  64391. */
  64392. get world0(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the second world row input component
  64395. */
  64396. get world1(): NodeMaterialConnectionPoint;
  64397. /**
  64398. * Gets the third world row input component
  64399. */
  64400. get world2(): NodeMaterialConnectionPoint;
  64401. /**
  64402. * Gets the forth world row input component
  64403. */
  64404. get world3(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the world input component
  64407. */
  64408. get world(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the output component
  64411. */
  64412. get output(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the isntanceID component
  64415. */
  64416. get instanceID(): NodeMaterialConnectionPoint;
  64417. autoConfigure(material: NodeMaterial): void;
  64418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64419. protected _buildBlock(state: NodeMaterialBuildState): this;
  64420. }
  64421. }
  64422. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64427. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64428. import { Effect } from "babylonjs/Materials/effect";
  64429. import { Mesh } from "babylonjs/Meshes/mesh";
  64430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64431. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64432. /**
  64433. * Block used to add morph targets support to vertex shader
  64434. */
  64435. export class MorphTargetsBlock extends NodeMaterialBlock {
  64436. private _repeatableContentAnchor;
  64437. /**
  64438. * Create a new MorphTargetsBlock
  64439. * @param name defines the block name
  64440. */
  64441. constructor(name: string);
  64442. /**
  64443. * Gets the current class name
  64444. * @returns the class name
  64445. */
  64446. getClassName(): string;
  64447. /**
  64448. * Gets the position input component
  64449. */
  64450. get position(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the normal input component
  64453. */
  64454. get normal(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the tangent input component
  64457. */
  64458. get tangent(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the tangent input component
  64461. */
  64462. get uv(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the position output component
  64465. */
  64466. get positionOutput(): NodeMaterialConnectionPoint;
  64467. /**
  64468. * Gets the normal output component
  64469. */
  64470. get normalOutput(): NodeMaterialConnectionPoint;
  64471. /**
  64472. * Gets the tangent output component
  64473. */
  64474. get tangentOutput(): NodeMaterialConnectionPoint;
  64475. /**
  64476. * Gets the tangent output component
  64477. */
  64478. get uvOutput(): NodeMaterialConnectionPoint;
  64479. initialize(state: NodeMaterialBuildState): void;
  64480. autoConfigure(material: NodeMaterial): void;
  64481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64483. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64484. protected _buildBlock(state: NodeMaterialBuildState): this;
  64485. }
  64486. }
  64487. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64491. import { Nullable } from "babylonjs/types";
  64492. import { Scene } from "babylonjs/scene";
  64493. import { Effect } from "babylonjs/Materials/effect";
  64494. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64495. import { Mesh } from "babylonjs/Meshes/mesh";
  64496. import { Light } from "babylonjs/Lights/light";
  64497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64498. /**
  64499. * Block used to get data information from a light
  64500. */
  64501. export class LightInformationBlock extends NodeMaterialBlock {
  64502. private _lightDataUniformName;
  64503. private _lightColorUniformName;
  64504. private _lightTypeDefineName;
  64505. /**
  64506. * Gets or sets the light associated with this block
  64507. */
  64508. light: Nullable<Light>;
  64509. /**
  64510. * Creates a new LightInformationBlock
  64511. * @param name defines the block name
  64512. */
  64513. constructor(name: string);
  64514. /**
  64515. * Gets the current class name
  64516. * @returns the class name
  64517. */
  64518. getClassName(): string;
  64519. /**
  64520. * Gets the world position input component
  64521. */
  64522. get worldPosition(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the direction output component
  64525. */
  64526. get direction(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the direction output component
  64529. */
  64530. get color(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the direction output component
  64533. */
  64534. get intensity(): NodeMaterialConnectionPoint;
  64535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64537. protected _buildBlock(state: NodeMaterialBuildState): this;
  64538. serialize(): any;
  64539. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64540. }
  64541. }
  64542. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64543. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64544. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64545. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64546. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64547. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64548. }
  64549. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64554. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64555. import { Effect } from "babylonjs/Materials/effect";
  64556. import { Mesh } from "babylonjs/Meshes/mesh";
  64557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64558. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64559. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64560. /**
  64561. * Block used to add image processing support to fragment shader
  64562. */
  64563. export class ImageProcessingBlock extends NodeMaterialBlock {
  64564. /**
  64565. * Create a new ImageProcessingBlock
  64566. * @param name defines the block name
  64567. */
  64568. constructor(name: string);
  64569. /**
  64570. * Gets the current class name
  64571. * @returns the class name
  64572. */
  64573. getClassName(): string;
  64574. /**
  64575. * Gets the color input component
  64576. */
  64577. get color(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the output component
  64580. */
  64581. get output(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Initialize the block and prepare the context for build
  64584. * @param state defines the state that will be used for the build
  64585. */
  64586. initialize(state: NodeMaterialBuildState): void;
  64587. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64590. protected _buildBlock(state: NodeMaterialBuildState): this;
  64591. }
  64592. }
  64593. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64597. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64599. import { Effect } from "babylonjs/Materials/effect";
  64600. import { Mesh } from "babylonjs/Meshes/mesh";
  64601. import { Scene } from "babylonjs/scene";
  64602. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64603. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64604. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64605. /**
  64606. * Block used to pertub normals based on a normal map
  64607. */
  64608. export class PerturbNormalBlock extends NodeMaterialBlock {
  64609. private _tangentSpaceParameterName;
  64610. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64611. invertX: boolean;
  64612. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64613. invertY: boolean;
  64614. /**
  64615. * Create a new PerturbNormalBlock
  64616. * @param name defines the block name
  64617. */
  64618. constructor(name: string);
  64619. /**
  64620. * Gets the current class name
  64621. * @returns the class name
  64622. */
  64623. getClassName(): string;
  64624. /**
  64625. * Gets the world position input component
  64626. */
  64627. get worldPosition(): NodeMaterialConnectionPoint;
  64628. /**
  64629. * Gets the world normal input component
  64630. */
  64631. get worldNormal(): NodeMaterialConnectionPoint;
  64632. /**
  64633. * Gets the world tangent input component
  64634. */
  64635. get worldTangent(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the uv input component
  64638. */
  64639. get uv(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the normal map color input component
  64642. */
  64643. get normalMapColor(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the strength input component
  64646. */
  64647. get strength(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the output component
  64650. */
  64651. get output(): NodeMaterialConnectionPoint;
  64652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64654. autoConfigure(material: NodeMaterial): void;
  64655. protected _buildBlock(state: NodeMaterialBuildState): this;
  64656. protected _dumpPropertiesCode(): string;
  64657. serialize(): any;
  64658. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64659. }
  64660. }
  64661. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64665. /**
  64666. * Block used to discard a pixel if a value is smaller than a cutoff
  64667. */
  64668. export class DiscardBlock extends NodeMaterialBlock {
  64669. /**
  64670. * Create a new DiscardBlock
  64671. * @param name defines the block name
  64672. */
  64673. constructor(name: string);
  64674. /**
  64675. * Gets the current class name
  64676. * @returns the class name
  64677. */
  64678. getClassName(): string;
  64679. /**
  64680. * Gets the color input component
  64681. */
  64682. get value(): NodeMaterialConnectionPoint;
  64683. /**
  64684. * Gets the cutoff input component
  64685. */
  64686. get cutoff(): NodeMaterialConnectionPoint;
  64687. protected _buildBlock(state: NodeMaterialBuildState): this;
  64688. }
  64689. }
  64690. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64694. /**
  64695. * Block used to test if the fragment shader is front facing
  64696. */
  64697. export class FrontFacingBlock extends NodeMaterialBlock {
  64698. /**
  64699. * Creates a new FrontFacingBlock
  64700. * @param name defines the block name
  64701. */
  64702. constructor(name: string);
  64703. /**
  64704. * Gets the current class name
  64705. * @returns the class name
  64706. */
  64707. getClassName(): string;
  64708. /**
  64709. * Gets the output component
  64710. */
  64711. get output(): NodeMaterialConnectionPoint;
  64712. protected _buildBlock(state: NodeMaterialBuildState): this;
  64713. }
  64714. }
  64715. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64719. /**
  64720. * Block used to get the derivative value on x and y of a given input
  64721. */
  64722. export class DerivativeBlock extends NodeMaterialBlock {
  64723. /**
  64724. * Create a new DerivativeBlock
  64725. * @param name defines the block name
  64726. */
  64727. constructor(name: string);
  64728. /**
  64729. * Gets the current class name
  64730. * @returns the class name
  64731. */
  64732. getClassName(): string;
  64733. /**
  64734. * Gets the input component
  64735. */
  64736. get input(): NodeMaterialConnectionPoint;
  64737. /**
  64738. * Gets the derivative output on x
  64739. */
  64740. get dx(): NodeMaterialConnectionPoint;
  64741. /**
  64742. * Gets the derivative output on y
  64743. */
  64744. get dy(): NodeMaterialConnectionPoint;
  64745. protected _buildBlock(state: NodeMaterialBuildState): this;
  64746. }
  64747. }
  64748. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64752. /**
  64753. * Block used to make gl_FragCoord available
  64754. */
  64755. export class FragCoordBlock extends NodeMaterialBlock {
  64756. /**
  64757. * Creates a new FragCoordBlock
  64758. * @param name defines the block name
  64759. */
  64760. constructor(name: string);
  64761. /**
  64762. * Gets the current class name
  64763. * @returns the class name
  64764. */
  64765. getClassName(): string;
  64766. /**
  64767. * Gets the xy component
  64768. */
  64769. get xy(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the xyz component
  64772. */
  64773. get xyz(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the xyzw component
  64776. */
  64777. get xyzw(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the x component
  64780. */
  64781. get x(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the y component
  64784. */
  64785. get y(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the z component
  64788. */
  64789. get z(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the w component
  64792. */
  64793. get output(): NodeMaterialConnectionPoint;
  64794. protected writeOutputs(state: NodeMaterialBuildState): string;
  64795. protected _buildBlock(state: NodeMaterialBuildState): this;
  64796. }
  64797. }
  64798. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64802. import { Effect } from "babylonjs/Materials/effect";
  64803. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64804. import { Mesh } from "babylonjs/Meshes/mesh";
  64805. /**
  64806. * Block used to get the screen sizes
  64807. */
  64808. export class ScreenSizeBlock extends NodeMaterialBlock {
  64809. private _varName;
  64810. private _scene;
  64811. /**
  64812. * Creates a new ScreenSizeBlock
  64813. * @param name defines the block name
  64814. */
  64815. constructor(name: string);
  64816. /**
  64817. * Gets the current class name
  64818. * @returns the class name
  64819. */
  64820. getClassName(): string;
  64821. /**
  64822. * Gets the xy component
  64823. */
  64824. get xy(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the x component
  64827. */
  64828. get x(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the y component
  64831. */
  64832. get y(): NodeMaterialConnectionPoint;
  64833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64834. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64835. protected _buildBlock(state: NodeMaterialBuildState): this;
  64836. }
  64837. }
  64838. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64839. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64840. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64841. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64842. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64843. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64844. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64845. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64846. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64847. }
  64848. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64851. import { Mesh } from "babylonjs/Meshes/mesh";
  64852. import { Effect } from "babylonjs/Materials/effect";
  64853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64855. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64856. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64857. /**
  64858. * Block used to add support for scene fog
  64859. */
  64860. export class FogBlock extends NodeMaterialBlock {
  64861. private _fogDistanceName;
  64862. private _fogParameters;
  64863. /**
  64864. * Create a new FogBlock
  64865. * @param name defines the block name
  64866. */
  64867. constructor(name: string);
  64868. /**
  64869. * Gets the current class name
  64870. * @returns the class name
  64871. */
  64872. getClassName(): string;
  64873. /**
  64874. * Gets the world position input component
  64875. */
  64876. get worldPosition(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the view input component
  64879. */
  64880. get view(): NodeMaterialConnectionPoint;
  64881. /**
  64882. * Gets the color input component
  64883. */
  64884. get input(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the fog color input component
  64887. */
  64888. get fogColor(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the output component
  64891. */
  64892. get output(): NodeMaterialConnectionPoint;
  64893. autoConfigure(material: NodeMaterial): void;
  64894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64896. protected _buildBlock(state: NodeMaterialBuildState): this;
  64897. }
  64898. }
  64899. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64904. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64905. import { Effect } from "babylonjs/Materials/effect";
  64906. import { Mesh } from "babylonjs/Meshes/mesh";
  64907. import { Light } from "babylonjs/Lights/light";
  64908. import { Nullable } from "babylonjs/types";
  64909. import { Scene } from "babylonjs/scene";
  64910. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64911. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64912. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64913. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64914. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64915. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64916. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64917. /**
  64918. * Block used to add light in the fragment shader
  64919. */
  64920. export class LightBlock extends NodeMaterialBlock {
  64921. private _lightId;
  64922. /**
  64923. * Gets or sets the light associated with this block
  64924. */
  64925. light: Nullable<Light>;
  64926. /**
  64927. * Create a new LightBlock
  64928. * @param name defines the block name
  64929. */
  64930. constructor(name: string);
  64931. /**
  64932. * Gets the current class name
  64933. * @returns the class name
  64934. */
  64935. getClassName(): string;
  64936. /**
  64937. * Gets the world position input component
  64938. */
  64939. get worldPosition(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the world normal input component
  64942. */
  64943. get worldNormal(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the camera (or eye) position component
  64946. */
  64947. get cameraPosition(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the glossiness component
  64950. */
  64951. get glossiness(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the glossinness power component
  64954. */
  64955. get glossPower(): NodeMaterialConnectionPoint;
  64956. /**
  64957. * Gets the diffuse color component
  64958. */
  64959. get diffuseColor(): NodeMaterialConnectionPoint;
  64960. /**
  64961. * Gets the specular color component
  64962. */
  64963. get specularColor(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the diffuse output component
  64966. */
  64967. get diffuseOutput(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the specular output component
  64970. */
  64971. get specularOutput(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the shadow output component
  64974. */
  64975. get shadow(): NodeMaterialConnectionPoint;
  64976. autoConfigure(material: NodeMaterial): void;
  64977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64978. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64980. private _injectVertexCode;
  64981. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64982. serialize(): any;
  64983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64984. }
  64985. }
  64986. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64989. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64990. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64991. /**
  64992. * Block used to read a reflection texture from a sampler
  64993. */
  64994. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64995. /**
  64996. * Create a new ReflectionTextureBlock
  64997. * @param name defines the block name
  64998. */
  64999. constructor(name: string);
  65000. /**
  65001. * Gets the current class name
  65002. * @returns the class name
  65003. */
  65004. getClassName(): string;
  65005. /**
  65006. * Gets the world position input component
  65007. */
  65008. get position(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the world position input component
  65011. */
  65012. get worldPosition(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the world normal input component
  65015. */
  65016. get worldNormal(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the world input component
  65019. */
  65020. get world(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the camera (or eye) position component
  65023. */
  65024. get cameraPosition(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the view input component
  65027. */
  65028. get view(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the rgb output component
  65031. */
  65032. get rgb(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the rgba output component
  65035. */
  65036. get rgba(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the r output component
  65039. */
  65040. get r(): NodeMaterialConnectionPoint;
  65041. /**
  65042. * Gets the g output component
  65043. */
  65044. get g(): NodeMaterialConnectionPoint;
  65045. /**
  65046. * Gets the b output component
  65047. */
  65048. get b(): NodeMaterialConnectionPoint;
  65049. /**
  65050. * Gets the a output component
  65051. */
  65052. get a(): NodeMaterialConnectionPoint;
  65053. autoConfigure(material: NodeMaterial): void;
  65054. protected _buildBlock(state: NodeMaterialBuildState): this;
  65055. }
  65056. }
  65057. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65058. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65059. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65060. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65061. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65062. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65063. }
  65064. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65065. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65066. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65067. }
  65068. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65072. /**
  65073. * Block used to add 2 vectors
  65074. */
  65075. export class AddBlock extends NodeMaterialBlock {
  65076. /**
  65077. * Creates a new AddBlock
  65078. * @param name defines the block name
  65079. */
  65080. constructor(name: string);
  65081. /**
  65082. * Gets the current class name
  65083. * @returns the class name
  65084. */
  65085. getClassName(): string;
  65086. /**
  65087. * Gets the left operand input component
  65088. */
  65089. get left(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the right operand input component
  65092. */
  65093. get right(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the output component
  65096. */
  65097. get output(): NodeMaterialConnectionPoint;
  65098. protected _buildBlock(state: NodeMaterialBuildState): this;
  65099. }
  65100. }
  65101. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65105. /**
  65106. * Block used to scale a vector by a float
  65107. */
  65108. export class ScaleBlock extends NodeMaterialBlock {
  65109. /**
  65110. * Creates a new ScaleBlock
  65111. * @param name defines the block name
  65112. */
  65113. constructor(name: string);
  65114. /**
  65115. * Gets the current class name
  65116. * @returns the class name
  65117. */
  65118. getClassName(): string;
  65119. /**
  65120. * Gets the input component
  65121. */
  65122. get input(): NodeMaterialConnectionPoint;
  65123. /**
  65124. * Gets the factor input component
  65125. */
  65126. get factor(): NodeMaterialConnectionPoint;
  65127. /**
  65128. * Gets the output component
  65129. */
  65130. get output(): NodeMaterialConnectionPoint;
  65131. protected _buildBlock(state: NodeMaterialBuildState): this;
  65132. }
  65133. }
  65134. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65138. import { Scene } from "babylonjs/scene";
  65139. /**
  65140. * Block used to clamp a float
  65141. */
  65142. export class ClampBlock extends NodeMaterialBlock {
  65143. /** Gets or sets the minimum range */
  65144. minimum: number;
  65145. /** Gets or sets the maximum range */
  65146. maximum: number;
  65147. /**
  65148. * Creates a new ClampBlock
  65149. * @param name defines the block name
  65150. */
  65151. constructor(name: string);
  65152. /**
  65153. * Gets the current class name
  65154. * @returns the class name
  65155. */
  65156. getClassName(): string;
  65157. /**
  65158. * Gets the value input component
  65159. */
  65160. get value(): NodeMaterialConnectionPoint;
  65161. /**
  65162. * Gets the output component
  65163. */
  65164. get output(): NodeMaterialConnectionPoint;
  65165. protected _buildBlock(state: NodeMaterialBuildState): this;
  65166. protected _dumpPropertiesCode(): string;
  65167. serialize(): any;
  65168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65169. }
  65170. }
  65171. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65175. /**
  65176. * Block used to apply a cross product between 2 vectors
  65177. */
  65178. export class CrossBlock extends NodeMaterialBlock {
  65179. /**
  65180. * Creates a new CrossBlock
  65181. * @param name defines the block name
  65182. */
  65183. constructor(name: string);
  65184. /**
  65185. * Gets the current class name
  65186. * @returns the class name
  65187. */
  65188. getClassName(): string;
  65189. /**
  65190. * Gets the left operand input component
  65191. */
  65192. get left(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the right operand input component
  65195. */
  65196. get right(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the output component
  65199. */
  65200. get output(): NodeMaterialConnectionPoint;
  65201. protected _buildBlock(state: NodeMaterialBuildState): this;
  65202. }
  65203. }
  65204. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65208. /**
  65209. * Block used to apply a dot product between 2 vectors
  65210. */
  65211. export class DotBlock extends NodeMaterialBlock {
  65212. /**
  65213. * Creates a new DotBlock
  65214. * @param name defines the block name
  65215. */
  65216. constructor(name: string);
  65217. /**
  65218. * Gets the current class name
  65219. * @returns the class name
  65220. */
  65221. getClassName(): string;
  65222. /**
  65223. * Gets the left operand input component
  65224. */
  65225. get left(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the right operand input component
  65228. */
  65229. get right(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the output component
  65232. */
  65233. get output(): NodeMaterialConnectionPoint;
  65234. protected _buildBlock(state: NodeMaterialBuildState): this;
  65235. }
  65236. }
  65237. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65241. /**
  65242. * Block used to normalize a vector
  65243. */
  65244. export class NormalizeBlock extends NodeMaterialBlock {
  65245. /**
  65246. * Creates a new NormalizeBlock
  65247. * @param name defines the block name
  65248. */
  65249. constructor(name: string);
  65250. /**
  65251. * Gets the current class name
  65252. * @returns the class name
  65253. */
  65254. getClassName(): string;
  65255. /**
  65256. * Gets the input component
  65257. */
  65258. get input(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the output component
  65261. */
  65262. get output(): NodeMaterialConnectionPoint;
  65263. protected _buildBlock(state: NodeMaterialBuildState): this;
  65264. }
  65265. }
  65266. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65270. import { Scene } from "babylonjs/scene";
  65271. /**
  65272. * Operations supported by the Trigonometry block
  65273. */
  65274. export enum TrigonometryBlockOperations {
  65275. /** Cos */
  65276. Cos = 0,
  65277. /** Sin */
  65278. Sin = 1,
  65279. /** Abs */
  65280. Abs = 2,
  65281. /** Exp */
  65282. Exp = 3,
  65283. /** Exp2 */
  65284. Exp2 = 4,
  65285. /** Round */
  65286. Round = 5,
  65287. /** Floor */
  65288. Floor = 6,
  65289. /** Ceiling */
  65290. Ceiling = 7,
  65291. /** Square root */
  65292. Sqrt = 8,
  65293. /** Log */
  65294. Log = 9,
  65295. /** Tangent */
  65296. Tan = 10,
  65297. /** Arc tangent */
  65298. ArcTan = 11,
  65299. /** Arc cosinus */
  65300. ArcCos = 12,
  65301. /** Arc sinus */
  65302. ArcSin = 13,
  65303. /** Fraction */
  65304. Fract = 14,
  65305. /** Sign */
  65306. Sign = 15,
  65307. /** To radians (from degrees) */
  65308. Radians = 16,
  65309. /** To degrees (from radians) */
  65310. Degrees = 17
  65311. }
  65312. /**
  65313. * Block used to apply trigonometry operation to floats
  65314. */
  65315. export class TrigonometryBlock extends NodeMaterialBlock {
  65316. /**
  65317. * Gets or sets the operation applied by the block
  65318. */
  65319. operation: TrigonometryBlockOperations;
  65320. /**
  65321. * Creates a new TrigonometryBlock
  65322. * @param name defines the block name
  65323. */
  65324. constructor(name: string);
  65325. /**
  65326. * Gets the current class name
  65327. * @returns the class name
  65328. */
  65329. getClassName(): string;
  65330. /**
  65331. * Gets the input component
  65332. */
  65333. get input(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the output component
  65336. */
  65337. get output(): NodeMaterialConnectionPoint;
  65338. protected _buildBlock(state: NodeMaterialBuildState): this;
  65339. serialize(): any;
  65340. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65341. protected _dumpPropertiesCode(): string;
  65342. }
  65343. }
  65344. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65348. /**
  65349. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65350. */
  65351. export class ColorMergerBlock extends NodeMaterialBlock {
  65352. /**
  65353. * Create a new ColorMergerBlock
  65354. * @param name defines the block name
  65355. */
  65356. constructor(name: string);
  65357. /**
  65358. * Gets the current class name
  65359. * @returns the class name
  65360. */
  65361. getClassName(): string;
  65362. /**
  65363. * Gets the rgb component (input)
  65364. */
  65365. get rgbIn(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the r component (input)
  65368. */
  65369. get r(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the g component (input)
  65372. */
  65373. get g(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the b component (input)
  65376. */
  65377. get b(): NodeMaterialConnectionPoint;
  65378. /**
  65379. * Gets the a component (input)
  65380. */
  65381. get a(): NodeMaterialConnectionPoint;
  65382. /**
  65383. * Gets the rgba component (output)
  65384. */
  65385. get rgba(): NodeMaterialConnectionPoint;
  65386. /**
  65387. * Gets the rgb component (output)
  65388. */
  65389. get rgbOut(): NodeMaterialConnectionPoint;
  65390. /**
  65391. * Gets the rgb component (output)
  65392. * @deprecated Please use rgbOut instead.
  65393. */
  65394. get rgb(): NodeMaterialConnectionPoint;
  65395. protected _buildBlock(state: NodeMaterialBuildState): this;
  65396. }
  65397. }
  65398. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65402. /**
  65403. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65404. */
  65405. export class VectorSplitterBlock extends NodeMaterialBlock {
  65406. /**
  65407. * Create a new VectorSplitterBlock
  65408. * @param name defines the block name
  65409. */
  65410. constructor(name: string);
  65411. /**
  65412. * Gets the current class name
  65413. * @returns the class name
  65414. */
  65415. getClassName(): string;
  65416. /**
  65417. * Gets the xyzw component (input)
  65418. */
  65419. get xyzw(): NodeMaterialConnectionPoint;
  65420. /**
  65421. * Gets the xyz component (input)
  65422. */
  65423. get xyzIn(): NodeMaterialConnectionPoint;
  65424. /**
  65425. * Gets the xy component (input)
  65426. */
  65427. get xyIn(): NodeMaterialConnectionPoint;
  65428. /**
  65429. * Gets the xyz component (output)
  65430. */
  65431. get xyzOut(): NodeMaterialConnectionPoint;
  65432. /**
  65433. * Gets the xy component (output)
  65434. */
  65435. get xyOut(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the x component (output)
  65438. */
  65439. get x(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the y component (output)
  65442. */
  65443. get y(): NodeMaterialConnectionPoint;
  65444. /**
  65445. * Gets the z component (output)
  65446. */
  65447. get z(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the w component (output)
  65450. */
  65451. get w(): NodeMaterialConnectionPoint;
  65452. protected _inputRename(name: string): string;
  65453. protected _outputRename(name: string): string;
  65454. protected _buildBlock(state: NodeMaterialBuildState): this;
  65455. }
  65456. }
  65457. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65461. /**
  65462. * Block used to lerp between 2 values
  65463. */
  65464. export class LerpBlock extends NodeMaterialBlock {
  65465. /**
  65466. * Creates a new LerpBlock
  65467. * @param name defines the block name
  65468. */
  65469. constructor(name: string);
  65470. /**
  65471. * Gets the current class name
  65472. * @returns the class name
  65473. */
  65474. getClassName(): string;
  65475. /**
  65476. * Gets the left operand input component
  65477. */
  65478. get left(): NodeMaterialConnectionPoint;
  65479. /**
  65480. * Gets the right operand input component
  65481. */
  65482. get right(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the gradient operand input component
  65485. */
  65486. get gradient(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the output component
  65489. */
  65490. get output(): NodeMaterialConnectionPoint;
  65491. protected _buildBlock(state: NodeMaterialBuildState): this;
  65492. }
  65493. }
  65494. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65498. /**
  65499. * Block used to divide 2 vectors
  65500. */
  65501. export class DivideBlock extends NodeMaterialBlock {
  65502. /**
  65503. * Creates a new DivideBlock
  65504. * @param name defines the block name
  65505. */
  65506. constructor(name: string);
  65507. /**
  65508. * Gets the current class name
  65509. * @returns the class name
  65510. */
  65511. getClassName(): string;
  65512. /**
  65513. * Gets the left operand input component
  65514. */
  65515. get left(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the right operand input component
  65518. */
  65519. get right(): NodeMaterialConnectionPoint;
  65520. /**
  65521. * Gets the output component
  65522. */
  65523. get output(): NodeMaterialConnectionPoint;
  65524. protected _buildBlock(state: NodeMaterialBuildState): this;
  65525. }
  65526. }
  65527. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65531. /**
  65532. * Block used to subtract 2 vectors
  65533. */
  65534. export class SubtractBlock extends NodeMaterialBlock {
  65535. /**
  65536. * Creates a new SubtractBlock
  65537. * @param name defines the block name
  65538. */
  65539. constructor(name: string);
  65540. /**
  65541. * Gets the current class name
  65542. * @returns the class name
  65543. */
  65544. getClassName(): string;
  65545. /**
  65546. * Gets the left operand input component
  65547. */
  65548. get left(): NodeMaterialConnectionPoint;
  65549. /**
  65550. * Gets the right operand input component
  65551. */
  65552. get right(): NodeMaterialConnectionPoint;
  65553. /**
  65554. * Gets the output component
  65555. */
  65556. get output(): NodeMaterialConnectionPoint;
  65557. protected _buildBlock(state: NodeMaterialBuildState): this;
  65558. }
  65559. }
  65560. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65564. /**
  65565. * Block used to step a value
  65566. */
  65567. export class StepBlock extends NodeMaterialBlock {
  65568. /**
  65569. * Creates a new StepBlock
  65570. * @param name defines the block name
  65571. */
  65572. constructor(name: string);
  65573. /**
  65574. * Gets the current class name
  65575. * @returns the class name
  65576. */
  65577. getClassName(): string;
  65578. /**
  65579. * Gets the value operand input component
  65580. */
  65581. get value(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the edge operand input component
  65584. */
  65585. get edge(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the output component
  65588. */
  65589. get output(): NodeMaterialConnectionPoint;
  65590. protected _buildBlock(state: NodeMaterialBuildState): this;
  65591. }
  65592. }
  65593. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65597. /**
  65598. * Block used to get the opposite (1 - x) of a value
  65599. */
  65600. export class OneMinusBlock extends NodeMaterialBlock {
  65601. /**
  65602. * Creates a new OneMinusBlock
  65603. * @param name defines the block name
  65604. */
  65605. constructor(name: string);
  65606. /**
  65607. * Gets the current class name
  65608. * @returns the class name
  65609. */
  65610. getClassName(): string;
  65611. /**
  65612. * Gets the input component
  65613. */
  65614. get input(): NodeMaterialConnectionPoint;
  65615. /**
  65616. * Gets the output component
  65617. */
  65618. get output(): NodeMaterialConnectionPoint;
  65619. protected _buildBlock(state: NodeMaterialBuildState): this;
  65620. }
  65621. }
  65622. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65626. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65627. /**
  65628. * Block used to get the view direction
  65629. */
  65630. export class ViewDirectionBlock extends NodeMaterialBlock {
  65631. /**
  65632. * Creates a new ViewDirectionBlock
  65633. * @param name defines the block name
  65634. */
  65635. constructor(name: string);
  65636. /**
  65637. * Gets the current class name
  65638. * @returns the class name
  65639. */
  65640. getClassName(): string;
  65641. /**
  65642. * Gets the world position component
  65643. */
  65644. get worldPosition(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the camera position component
  65647. */
  65648. get cameraPosition(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the output component
  65651. */
  65652. get output(): NodeMaterialConnectionPoint;
  65653. autoConfigure(material: NodeMaterial): void;
  65654. protected _buildBlock(state: NodeMaterialBuildState): this;
  65655. }
  65656. }
  65657. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65661. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65662. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65663. /**
  65664. * Block used to compute fresnel value
  65665. */
  65666. export class FresnelBlock extends NodeMaterialBlock {
  65667. /**
  65668. * Create a new FresnelBlock
  65669. * @param name defines the block name
  65670. */
  65671. constructor(name: string);
  65672. /**
  65673. * Gets the current class name
  65674. * @returns the class name
  65675. */
  65676. getClassName(): string;
  65677. /**
  65678. * Gets the world normal input component
  65679. */
  65680. get worldNormal(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the view direction input component
  65683. */
  65684. get viewDirection(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the bias input component
  65687. */
  65688. get bias(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the camera (or eye) position component
  65691. */
  65692. get power(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the fresnel output component
  65695. */
  65696. get fresnel(): NodeMaterialConnectionPoint;
  65697. autoConfigure(material: NodeMaterial): void;
  65698. protected _buildBlock(state: NodeMaterialBuildState): this;
  65699. }
  65700. }
  65701. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65705. /**
  65706. * Block used to get the max of 2 values
  65707. */
  65708. export class MaxBlock extends NodeMaterialBlock {
  65709. /**
  65710. * Creates a new MaxBlock
  65711. * @param name defines the block name
  65712. */
  65713. constructor(name: string);
  65714. /**
  65715. * Gets the current class name
  65716. * @returns the class name
  65717. */
  65718. getClassName(): string;
  65719. /**
  65720. * Gets the left operand input component
  65721. */
  65722. get left(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the right operand input component
  65725. */
  65726. get right(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the output component
  65729. */
  65730. get output(): NodeMaterialConnectionPoint;
  65731. protected _buildBlock(state: NodeMaterialBuildState): this;
  65732. }
  65733. }
  65734. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65738. /**
  65739. * Block used to get the min of 2 values
  65740. */
  65741. export class MinBlock extends NodeMaterialBlock {
  65742. /**
  65743. * Creates a new MinBlock
  65744. * @param name defines the block name
  65745. */
  65746. constructor(name: string);
  65747. /**
  65748. * Gets the current class name
  65749. * @returns the class name
  65750. */
  65751. getClassName(): string;
  65752. /**
  65753. * Gets the left operand input component
  65754. */
  65755. get left(): NodeMaterialConnectionPoint;
  65756. /**
  65757. * Gets the right operand input component
  65758. */
  65759. get right(): NodeMaterialConnectionPoint;
  65760. /**
  65761. * Gets the output component
  65762. */
  65763. get output(): NodeMaterialConnectionPoint;
  65764. protected _buildBlock(state: NodeMaterialBuildState): this;
  65765. }
  65766. }
  65767. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65771. /**
  65772. * Block used to get the distance between 2 values
  65773. */
  65774. export class DistanceBlock extends NodeMaterialBlock {
  65775. /**
  65776. * Creates a new DistanceBlock
  65777. * @param name defines the block name
  65778. */
  65779. constructor(name: string);
  65780. /**
  65781. * Gets the current class name
  65782. * @returns the class name
  65783. */
  65784. getClassName(): string;
  65785. /**
  65786. * Gets the left operand input component
  65787. */
  65788. get left(): NodeMaterialConnectionPoint;
  65789. /**
  65790. * Gets the right operand input component
  65791. */
  65792. get right(): NodeMaterialConnectionPoint;
  65793. /**
  65794. * Gets the output component
  65795. */
  65796. get output(): NodeMaterialConnectionPoint;
  65797. protected _buildBlock(state: NodeMaterialBuildState): this;
  65798. }
  65799. }
  65800. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65804. /**
  65805. * Block used to get the length of a vector
  65806. */
  65807. export class LengthBlock extends NodeMaterialBlock {
  65808. /**
  65809. * Creates a new LengthBlock
  65810. * @param name defines the block name
  65811. */
  65812. constructor(name: string);
  65813. /**
  65814. * Gets the current class name
  65815. * @returns the class name
  65816. */
  65817. getClassName(): string;
  65818. /**
  65819. * Gets the value input component
  65820. */
  65821. get value(): NodeMaterialConnectionPoint;
  65822. /**
  65823. * Gets the output component
  65824. */
  65825. get output(): NodeMaterialConnectionPoint;
  65826. protected _buildBlock(state: NodeMaterialBuildState): this;
  65827. }
  65828. }
  65829. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65833. /**
  65834. * Block used to get negative version of a value (i.e. x * -1)
  65835. */
  65836. export class NegateBlock extends NodeMaterialBlock {
  65837. /**
  65838. * Creates a new NegateBlock
  65839. * @param name defines the block name
  65840. */
  65841. constructor(name: string);
  65842. /**
  65843. * Gets the current class name
  65844. * @returns the class name
  65845. */
  65846. getClassName(): string;
  65847. /**
  65848. * Gets the value input component
  65849. */
  65850. get value(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the output component
  65853. */
  65854. get output(): NodeMaterialConnectionPoint;
  65855. protected _buildBlock(state: NodeMaterialBuildState): this;
  65856. }
  65857. }
  65858. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65862. /**
  65863. * Block used to get the value of the first parameter raised to the power of the second
  65864. */
  65865. export class PowBlock extends NodeMaterialBlock {
  65866. /**
  65867. * Creates a new PowBlock
  65868. * @param name defines the block name
  65869. */
  65870. constructor(name: string);
  65871. /**
  65872. * Gets the current class name
  65873. * @returns the class name
  65874. */
  65875. getClassName(): string;
  65876. /**
  65877. * Gets the value operand input component
  65878. */
  65879. get value(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the power operand input component
  65882. */
  65883. get power(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the output component
  65886. */
  65887. get output(): NodeMaterialConnectionPoint;
  65888. protected _buildBlock(state: NodeMaterialBuildState): this;
  65889. }
  65890. }
  65891. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65896. /**
  65897. * Block used to get a random number
  65898. */
  65899. export class RandomNumberBlock extends NodeMaterialBlock {
  65900. /**
  65901. * Creates a new RandomNumberBlock
  65902. * @param name defines the block name
  65903. */
  65904. constructor(name: string);
  65905. /**
  65906. * Gets the current class name
  65907. * @returns the class name
  65908. */
  65909. getClassName(): string;
  65910. /**
  65911. * Gets the seed input component
  65912. */
  65913. get seed(): NodeMaterialConnectionPoint;
  65914. /**
  65915. * Gets the output component
  65916. */
  65917. get output(): NodeMaterialConnectionPoint;
  65918. protected _buildBlock(state: NodeMaterialBuildState): this;
  65919. }
  65920. }
  65921. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65925. /**
  65926. * Block used to compute arc tangent of 2 values
  65927. */
  65928. export class ArcTan2Block extends NodeMaterialBlock {
  65929. /**
  65930. * Creates a new ArcTan2Block
  65931. * @param name defines the block name
  65932. */
  65933. constructor(name: string);
  65934. /**
  65935. * Gets the current class name
  65936. * @returns the class name
  65937. */
  65938. getClassName(): string;
  65939. /**
  65940. * Gets the x operand input component
  65941. */
  65942. get x(): NodeMaterialConnectionPoint;
  65943. /**
  65944. * Gets the y operand input component
  65945. */
  65946. get y(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the output component
  65949. */
  65950. get output(): NodeMaterialConnectionPoint;
  65951. protected _buildBlock(state: NodeMaterialBuildState): this;
  65952. }
  65953. }
  65954. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65958. /**
  65959. * Block used to smooth step a value
  65960. */
  65961. export class SmoothStepBlock extends NodeMaterialBlock {
  65962. /**
  65963. * Creates a new SmoothStepBlock
  65964. * @param name defines the block name
  65965. */
  65966. constructor(name: string);
  65967. /**
  65968. * Gets the current class name
  65969. * @returns the class name
  65970. */
  65971. getClassName(): string;
  65972. /**
  65973. * Gets the value operand input component
  65974. */
  65975. get value(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the first edge operand input component
  65978. */
  65979. get edge0(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the second edge operand input component
  65982. */
  65983. get edge1(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the output component
  65986. */
  65987. get output(): NodeMaterialConnectionPoint;
  65988. protected _buildBlock(state: NodeMaterialBuildState): this;
  65989. }
  65990. }
  65991. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65995. /**
  65996. * Block used to get the reciprocal (1 / x) of a value
  65997. */
  65998. export class ReciprocalBlock extends NodeMaterialBlock {
  65999. /**
  66000. * Creates a new ReciprocalBlock
  66001. * @param name defines the block name
  66002. */
  66003. constructor(name: string);
  66004. /**
  66005. * Gets the current class name
  66006. * @returns the class name
  66007. */
  66008. getClassName(): string;
  66009. /**
  66010. * Gets the input component
  66011. */
  66012. get input(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the output component
  66015. */
  66016. get output(): NodeMaterialConnectionPoint;
  66017. protected _buildBlock(state: NodeMaterialBuildState): this;
  66018. }
  66019. }
  66020. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66024. /**
  66025. * Block used to replace a color by another one
  66026. */
  66027. export class ReplaceColorBlock extends NodeMaterialBlock {
  66028. /**
  66029. * Creates a new ReplaceColorBlock
  66030. * @param name defines the block name
  66031. */
  66032. constructor(name: string);
  66033. /**
  66034. * Gets the current class name
  66035. * @returns the class name
  66036. */
  66037. getClassName(): string;
  66038. /**
  66039. * Gets the value input component
  66040. */
  66041. get value(): NodeMaterialConnectionPoint;
  66042. /**
  66043. * Gets the reference input component
  66044. */
  66045. get reference(): NodeMaterialConnectionPoint;
  66046. /**
  66047. * Gets the distance input component
  66048. */
  66049. get distance(): NodeMaterialConnectionPoint;
  66050. /**
  66051. * Gets the replacement input component
  66052. */
  66053. get replacement(): NodeMaterialConnectionPoint;
  66054. /**
  66055. * Gets the output component
  66056. */
  66057. get output(): NodeMaterialConnectionPoint;
  66058. protected _buildBlock(state: NodeMaterialBuildState): this;
  66059. }
  66060. }
  66061. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66065. /**
  66066. * Block used to posterize a value
  66067. * @see https://en.wikipedia.org/wiki/Posterization
  66068. */
  66069. export class PosterizeBlock extends NodeMaterialBlock {
  66070. /**
  66071. * Creates a new PosterizeBlock
  66072. * @param name defines the block name
  66073. */
  66074. constructor(name: string);
  66075. /**
  66076. * Gets the current class name
  66077. * @returns the class name
  66078. */
  66079. getClassName(): string;
  66080. /**
  66081. * Gets the value input component
  66082. */
  66083. get value(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the steps input component
  66086. */
  66087. get steps(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the output component
  66090. */
  66091. get output(): NodeMaterialConnectionPoint;
  66092. protected _buildBlock(state: NodeMaterialBuildState): this;
  66093. }
  66094. }
  66095. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66099. import { Scene } from "babylonjs/scene";
  66100. /**
  66101. * Operations supported by the Wave block
  66102. */
  66103. export enum WaveBlockKind {
  66104. /** SawTooth */
  66105. SawTooth = 0,
  66106. /** Square */
  66107. Square = 1,
  66108. /** Triangle */
  66109. Triangle = 2
  66110. }
  66111. /**
  66112. * Block used to apply wave operation to floats
  66113. */
  66114. export class WaveBlock extends NodeMaterialBlock {
  66115. /**
  66116. * Gets or sets the kibnd of wave to be applied by the block
  66117. */
  66118. kind: WaveBlockKind;
  66119. /**
  66120. * Creates a new WaveBlock
  66121. * @param name defines the block name
  66122. */
  66123. constructor(name: string);
  66124. /**
  66125. * Gets the current class name
  66126. * @returns the class name
  66127. */
  66128. getClassName(): string;
  66129. /**
  66130. * Gets the input component
  66131. */
  66132. get input(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the output component
  66135. */
  66136. get output(): NodeMaterialConnectionPoint;
  66137. protected _buildBlock(state: NodeMaterialBuildState): this;
  66138. serialize(): any;
  66139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66140. }
  66141. }
  66142. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66146. import { Color3 } from "babylonjs/Maths/math.color";
  66147. import { Scene } from "babylonjs/scene";
  66148. /**
  66149. * Class used to store a color step for the GradientBlock
  66150. */
  66151. export class GradientBlockColorStep {
  66152. /**
  66153. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66154. */
  66155. step: number;
  66156. /**
  66157. * Gets or sets the color associated with this step
  66158. */
  66159. color: Color3;
  66160. /**
  66161. * Creates a new GradientBlockColorStep
  66162. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66163. * @param color defines the color associated with this step
  66164. */
  66165. constructor(
  66166. /**
  66167. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66168. */
  66169. step: number,
  66170. /**
  66171. * Gets or sets the color associated with this step
  66172. */
  66173. color: Color3);
  66174. }
  66175. /**
  66176. * Block used to return a color from a gradient based on an input value between 0 and 1
  66177. */
  66178. export class GradientBlock extends NodeMaterialBlock {
  66179. /**
  66180. * Gets or sets the list of color steps
  66181. */
  66182. colorSteps: GradientBlockColorStep[];
  66183. /**
  66184. * Creates a new GradientBlock
  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 gradient input component
  66195. */
  66196. get gradient(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the output component
  66199. */
  66200. get output(): NodeMaterialConnectionPoint;
  66201. private _writeColorConstant;
  66202. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66203. serialize(): any;
  66204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66205. protected _dumpPropertiesCode(): string;
  66206. }
  66207. }
  66208. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66212. /**
  66213. * Block used to normalize lerp between 2 values
  66214. */
  66215. export class NLerpBlock extends NodeMaterialBlock {
  66216. /**
  66217. * Creates a new NLerpBlock
  66218. * @param name defines the block name
  66219. */
  66220. constructor(name: string);
  66221. /**
  66222. * Gets the current class name
  66223. * @returns the class name
  66224. */
  66225. getClassName(): string;
  66226. /**
  66227. * Gets the left operand input component
  66228. */
  66229. get left(): NodeMaterialConnectionPoint;
  66230. /**
  66231. * Gets the right operand input component
  66232. */
  66233. get right(): NodeMaterialConnectionPoint;
  66234. /**
  66235. * Gets the gradient operand input component
  66236. */
  66237. get gradient(): NodeMaterialConnectionPoint;
  66238. /**
  66239. * Gets the output component
  66240. */
  66241. get output(): NodeMaterialConnectionPoint;
  66242. protected _buildBlock(state: NodeMaterialBuildState): this;
  66243. }
  66244. }
  66245. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66249. import { Scene } from "babylonjs/scene";
  66250. /**
  66251. * block used to Generate a Worley Noise 3D Noise Pattern
  66252. */
  66253. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66254. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66255. manhattanDistance: boolean;
  66256. /**
  66257. * Creates a new WorleyNoise3DBlock
  66258. * @param name defines the block name
  66259. */
  66260. constructor(name: string);
  66261. /**
  66262. * Gets the current class name
  66263. * @returns the class name
  66264. */
  66265. getClassName(): string;
  66266. /**
  66267. * Gets the seed input component
  66268. */
  66269. get seed(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the jitter input component
  66272. */
  66273. get jitter(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the output component
  66276. */
  66277. get output(): NodeMaterialConnectionPoint;
  66278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66279. /**
  66280. * Exposes the properties to the UI?
  66281. */
  66282. protected _dumpPropertiesCode(): string;
  66283. /**
  66284. * Exposes the properties to the Seralize?
  66285. */
  66286. serialize(): any;
  66287. /**
  66288. * Exposes the properties to the deseralize?
  66289. */
  66290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66291. }
  66292. }
  66293. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66297. /**
  66298. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66299. */
  66300. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66301. /**
  66302. * Creates a new SimplexPerlin3DBlock
  66303. * @param name defines the block name
  66304. */
  66305. constructor(name: string);
  66306. /**
  66307. * Gets the current class name
  66308. * @returns the class name
  66309. */
  66310. getClassName(): string;
  66311. /**
  66312. * Gets the seed operand input component
  66313. */
  66314. get seed(): NodeMaterialConnectionPoint;
  66315. /**
  66316. * Gets the output component
  66317. */
  66318. get output(): NodeMaterialConnectionPoint;
  66319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66320. }
  66321. }
  66322. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66326. /**
  66327. * Block used to blend normals
  66328. */
  66329. export class NormalBlendBlock extends NodeMaterialBlock {
  66330. /**
  66331. * Creates a new NormalBlendBlock
  66332. * @param name defines the block name
  66333. */
  66334. constructor(name: string);
  66335. /**
  66336. * Gets the current class name
  66337. * @returns the class name
  66338. */
  66339. getClassName(): string;
  66340. /**
  66341. * Gets the first input component
  66342. */
  66343. get normalMap0(): NodeMaterialConnectionPoint;
  66344. /**
  66345. * Gets the second input component
  66346. */
  66347. get normalMap1(): NodeMaterialConnectionPoint;
  66348. /**
  66349. * Gets the output component
  66350. */
  66351. get output(): NodeMaterialConnectionPoint;
  66352. protected _buildBlock(state: NodeMaterialBuildState): this;
  66353. }
  66354. }
  66355. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66359. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66360. /**
  66361. * Block used to rotate a 2d vector by a given angle
  66362. */
  66363. export class Rotate2dBlock extends NodeMaterialBlock {
  66364. /**
  66365. * Creates a new Rotate2dBlock
  66366. * @param name defines the block name
  66367. */
  66368. constructor(name: string);
  66369. /**
  66370. * Gets the current class name
  66371. * @returns the class name
  66372. */
  66373. getClassName(): string;
  66374. /**
  66375. * Gets the input vector
  66376. */
  66377. get input(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the input angle
  66380. */
  66381. get angle(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the output component
  66384. */
  66385. get output(): NodeMaterialConnectionPoint;
  66386. autoConfigure(material: NodeMaterial): void;
  66387. protected _buildBlock(state: NodeMaterialBuildState): this;
  66388. }
  66389. }
  66390. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  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 get the reflected vector from a direction and a normal
  66396. */
  66397. export class ReflectBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Creates a new ReflectBlock
  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 incident component
  66410. */
  66411. get incident(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the normal component
  66414. */
  66415. get normal(): 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/refractBlock" {
  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 get the refracted vector from a direction and a normal
  66429. */
  66430. export class RefractBlock extends NodeMaterialBlock {
  66431. /**
  66432. * Creates a new RefractBlock
  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 incident component
  66443. */
  66444. get incident(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the normal component
  66447. */
  66448. get normal(): NodeMaterialConnectionPoint;
  66449. /**
  66450. * Gets the index of refraction component
  66451. */
  66452. get ior(): NodeMaterialConnectionPoint;
  66453. /**
  66454. * Gets the output component
  66455. */
  66456. get output(): NodeMaterialConnectionPoint;
  66457. protected _buildBlock(state: NodeMaterialBuildState): this;
  66458. }
  66459. }
  66460. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66464. /**
  66465. * Block used to desaturate a color
  66466. */
  66467. export class DesaturateBlock extends NodeMaterialBlock {
  66468. /**
  66469. * Creates a new DesaturateBlock
  66470. * @param name defines the block name
  66471. */
  66472. constructor(name: string);
  66473. /**
  66474. * Gets the current class name
  66475. * @returns the class name
  66476. */
  66477. getClassName(): string;
  66478. /**
  66479. * Gets the color operand input component
  66480. */
  66481. get color(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the level operand input component
  66484. */
  66485. get level(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the output component
  66488. */
  66489. get output(): NodeMaterialConnectionPoint;
  66490. protected _buildBlock(state: NodeMaterialBuildState): this;
  66491. }
  66492. }
  66493. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66497. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66498. import { Nullable } from "babylonjs/types";
  66499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66500. import { Scene } from "babylonjs/scene";
  66501. /**
  66502. * Block used to implement the ambient occlusion module of the PBR material
  66503. */
  66504. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66505. /**
  66506. * Create a new AmbientOcclusionBlock
  66507. * @param name defines the block name
  66508. */
  66509. constructor(name: string);
  66510. /**
  66511. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66512. */
  66513. useAmbientInGrayScale: boolean;
  66514. /**
  66515. * Initialize the block and prepare the context for build
  66516. * @param state defines the state that will be used for the build
  66517. */
  66518. initialize(state: NodeMaterialBuildState): void;
  66519. /**
  66520. * Gets the current class name
  66521. * @returns the class name
  66522. */
  66523. getClassName(): string;
  66524. /**
  66525. * Gets the texture input component
  66526. */
  66527. get texture(): NodeMaterialConnectionPoint;
  66528. /**
  66529. * Gets the texture intensity component
  66530. */
  66531. get intensity(): NodeMaterialConnectionPoint;
  66532. /**
  66533. * Gets the direct light intensity input component
  66534. */
  66535. get directLightIntensity(): NodeMaterialConnectionPoint;
  66536. /**
  66537. * Gets the ambient occlusion object output component
  66538. */
  66539. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66540. /**
  66541. * Gets the main code of the block (fragment side)
  66542. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66543. * @returns the shader code
  66544. */
  66545. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66547. protected _buildBlock(state: NodeMaterialBuildState): this;
  66548. protected _dumpPropertiesCode(): string;
  66549. serialize(): any;
  66550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66551. }
  66552. }
  66553. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66557. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66559. import { Nullable } from "babylonjs/types";
  66560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66561. import { Mesh } from "babylonjs/Meshes/mesh";
  66562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66563. import { Effect } from "babylonjs/Materials/effect";
  66564. import { Scene } from "babylonjs/scene";
  66565. /**
  66566. * Block used to implement the reflection module of the PBR material
  66567. */
  66568. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66569. /** @hidden */
  66570. _defineLODReflectionAlpha: string;
  66571. /** @hidden */
  66572. _defineLinearSpecularReflection: string;
  66573. private _vEnvironmentIrradianceName;
  66574. /** @hidden */
  66575. _vReflectionMicrosurfaceInfosName: string;
  66576. /** @hidden */
  66577. _vReflectionInfosName: string;
  66578. /** @hidden */
  66579. _vReflectionFilteringInfoName: string;
  66580. private _scene;
  66581. /**
  66582. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66583. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66584. * It's less burden on the user side in the editor part.
  66585. */
  66586. /** @hidden */
  66587. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66588. /** @hidden */
  66589. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66590. /** @hidden */
  66591. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66592. /**
  66593. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66594. * diffuse part of the IBL.
  66595. */
  66596. useSphericalHarmonics: boolean;
  66597. /**
  66598. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66599. */
  66600. forceIrradianceInFragment: boolean;
  66601. /**
  66602. * Create a new ReflectionBlock
  66603. * @param name defines the block name
  66604. */
  66605. constructor(name: string);
  66606. /**
  66607. * Gets the current class name
  66608. * @returns the class name
  66609. */
  66610. getClassName(): string;
  66611. /**
  66612. * Gets the position input component
  66613. */
  66614. get position(): NodeMaterialConnectionPoint;
  66615. /**
  66616. * Gets the world position input component
  66617. */
  66618. get worldPosition(): NodeMaterialConnectionPoint;
  66619. /**
  66620. * Gets the world normal input component
  66621. */
  66622. get worldNormal(): NodeMaterialConnectionPoint;
  66623. /**
  66624. * Gets the world input component
  66625. */
  66626. get world(): NodeMaterialConnectionPoint;
  66627. /**
  66628. * Gets the camera (or eye) position component
  66629. */
  66630. get cameraPosition(): NodeMaterialConnectionPoint;
  66631. /**
  66632. * Gets the view input component
  66633. */
  66634. get view(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the color input component
  66637. */
  66638. get color(): NodeMaterialConnectionPoint;
  66639. /**
  66640. * Gets the reflection object output component
  66641. */
  66642. get reflection(): NodeMaterialConnectionPoint;
  66643. /**
  66644. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66645. */
  66646. get hasTexture(): boolean;
  66647. /**
  66648. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66649. */
  66650. get reflectionColor(): string;
  66651. protected _getTexture(): Nullable<BaseTexture>;
  66652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66654. /**
  66655. * Gets the code to inject in the vertex shader
  66656. * @param state current state of the node material building
  66657. * @returns the shader code
  66658. */
  66659. handleVertexSide(state: NodeMaterialBuildState): string;
  66660. /**
  66661. * Gets the main code of the block (fragment side)
  66662. * @param state current state of the node material building
  66663. * @param normalVarName name of the existing variable corresponding to the normal
  66664. * @returns the shader code
  66665. */
  66666. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66667. protected _buildBlock(state: NodeMaterialBuildState): this;
  66668. protected _dumpPropertiesCode(): string;
  66669. serialize(): any;
  66670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66671. }
  66672. }
  66673. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66677. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66679. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66680. import { Scene } from "babylonjs/scene";
  66681. import { Nullable } from "babylonjs/types";
  66682. /**
  66683. * Block used to implement the sheen module of the PBR material
  66684. */
  66685. export class SheenBlock extends NodeMaterialBlock {
  66686. /**
  66687. * Create a new SheenBlock
  66688. * @param name defines the block name
  66689. */
  66690. constructor(name: string);
  66691. /**
  66692. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66693. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66694. * making it easier to setup and tweak the effect
  66695. */
  66696. albedoScaling: boolean;
  66697. /**
  66698. * Defines if the sheen is linked to the sheen color.
  66699. */
  66700. linkSheenWithAlbedo: boolean;
  66701. /**
  66702. * Initialize the block and prepare the context for build
  66703. * @param state defines the state that will be used for the build
  66704. */
  66705. initialize(state: NodeMaterialBuildState): void;
  66706. /**
  66707. * Gets the current class name
  66708. * @returns the class name
  66709. */
  66710. getClassName(): string;
  66711. /**
  66712. * Gets the intensity input component
  66713. */
  66714. get intensity(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the color input component
  66717. */
  66718. get color(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the roughness input component
  66721. */
  66722. get roughness(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the sheen object output component
  66725. */
  66726. get sheen(): NodeMaterialConnectionPoint;
  66727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66728. /**
  66729. * Gets the main code of the block (fragment side)
  66730. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66731. * @returns the shader code
  66732. */
  66733. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66734. protected _buildBlock(state: NodeMaterialBuildState): this;
  66735. protected _dumpPropertiesCode(): string;
  66736. serialize(): any;
  66737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66738. }
  66739. }
  66740. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66741. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66746. import { Scene } from "babylonjs/scene";
  66747. import { Nullable } from "babylonjs/types";
  66748. import { Mesh } from "babylonjs/Meshes/mesh";
  66749. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66750. import { Effect } from "babylonjs/Materials/effect";
  66751. /**
  66752. * Block used to implement the reflectivity module of the PBR material
  66753. */
  66754. export class ReflectivityBlock extends NodeMaterialBlock {
  66755. private _metallicReflectanceColor;
  66756. private _metallicF0Factor;
  66757. /** @hidden */
  66758. _vMetallicReflectanceFactorsName: string;
  66759. /**
  66760. * The property below is set by the main PBR block prior to calling methods of this class.
  66761. */
  66762. /** @hidden */
  66763. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66764. /**
  66765. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66766. */
  66767. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66768. /**
  66769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66770. */
  66771. useMetallnessFromMetallicTextureBlue: boolean;
  66772. /**
  66773. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66774. */
  66775. useRoughnessFromMetallicTextureAlpha: boolean;
  66776. /**
  66777. * Specifies if the metallic texture contains the roughness information in its green channel.
  66778. */
  66779. useRoughnessFromMetallicTextureGreen: boolean;
  66780. /**
  66781. * Create a new ReflectivityBlock
  66782. * @param name defines the block name
  66783. */
  66784. constructor(name: string);
  66785. /**
  66786. * Initialize the block and prepare the context for build
  66787. * @param state defines the state that will be used for the build
  66788. */
  66789. initialize(state: NodeMaterialBuildState): void;
  66790. /**
  66791. * Gets the current class name
  66792. * @returns the class name
  66793. */
  66794. getClassName(): string;
  66795. /**
  66796. * Gets the metallic input component
  66797. */
  66798. get metallic(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the roughness input component
  66801. */
  66802. get roughness(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the texture input component
  66805. */
  66806. get texture(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the reflectivity object output component
  66809. */
  66810. get reflectivity(): NodeMaterialConnectionPoint;
  66811. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66812. /**
  66813. * Gets the main code of the block (fragment side)
  66814. * @param state current state of the node material building
  66815. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66816. * @returns the shader code
  66817. */
  66818. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66820. protected _buildBlock(state: NodeMaterialBuildState): this;
  66821. protected _dumpPropertiesCode(): string;
  66822. serialize(): any;
  66823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66824. }
  66825. }
  66826. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66832. /**
  66833. * Block used to implement the anisotropy module of the PBR material
  66834. */
  66835. export class AnisotropyBlock extends NodeMaterialBlock {
  66836. /**
  66837. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66838. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66839. * It's less burden on the user side in the editor part.
  66840. */
  66841. /** @hidden */
  66842. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66843. /** @hidden */
  66844. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66845. /**
  66846. * Create a new AnisotropyBlock
  66847. * @param name defines the block name
  66848. */
  66849. constructor(name: string);
  66850. /**
  66851. * Initialize the block and prepare the context for build
  66852. * @param state defines the state that will be used for the build
  66853. */
  66854. initialize(state: NodeMaterialBuildState): void;
  66855. /**
  66856. * Gets the current class name
  66857. * @returns the class name
  66858. */
  66859. getClassName(): string;
  66860. /**
  66861. * Gets the intensity input component
  66862. */
  66863. get intensity(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the direction input component
  66866. */
  66867. get direction(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the texture input component
  66870. */
  66871. get texture(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the uv input component
  66874. */
  66875. get uv(): NodeMaterialConnectionPoint;
  66876. /**
  66877. * Gets the worldTangent input component
  66878. */
  66879. get worldTangent(): NodeMaterialConnectionPoint;
  66880. /**
  66881. * Gets the anisotropy object output component
  66882. */
  66883. get anisotropy(): NodeMaterialConnectionPoint;
  66884. private _generateTBNSpace;
  66885. /**
  66886. * Gets the main code of the block (fragment side)
  66887. * @param state current state of the node material building
  66888. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66889. * @returns the shader code
  66890. */
  66891. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66893. protected _buildBlock(state: NodeMaterialBuildState): this;
  66894. }
  66895. }
  66896. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66900. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66902. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66903. import { Nullable } from "babylonjs/types";
  66904. import { Mesh } from "babylonjs/Meshes/mesh";
  66905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66906. import { Effect } from "babylonjs/Materials/effect";
  66907. /**
  66908. * Block used to implement the clear coat module of the PBR material
  66909. */
  66910. export class ClearCoatBlock extends NodeMaterialBlock {
  66911. private _scene;
  66912. /**
  66913. * Create a new ClearCoatBlock
  66914. * @param name defines the block name
  66915. */
  66916. constructor(name: string);
  66917. /**
  66918. * Initialize the block and prepare the context for build
  66919. * @param state defines the state that will be used for the build
  66920. */
  66921. initialize(state: NodeMaterialBuildState): void;
  66922. /**
  66923. * Gets the current class name
  66924. * @returns the class name
  66925. */
  66926. getClassName(): string;
  66927. /**
  66928. * Gets the intensity input component
  66929. */
  66930. get intensity(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the roughness input component
  66933. */
  66934. get roughness(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the ior input component
  66937. */
  66938. get ior(): NodeMaterialConnectionPoint;
  66939. /**
  66940. * Gets the texture input component
  66941. */
  66942. get texture(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the bump texture input component
  66945. */
  66946. get bumpTexture(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the uv input component
  66949. */
  66950. get uv(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the tint color input component
  66953. */
  66954. get tintColor(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the tint "at distance" input component
  66957. */
  66958. get tintAtDistance(): NodeMaterialConnectionPoint;
  66959. /**
  66960. * Gets the tint thickness input component
  66961. */
  66962. get tintThickness(): NodeMaterialConnectionPoint;
  66963. /**
  66964. * Gets the world tangent input component
  66965. */
  66966. get worldTangent(): NodeMaterialConnectionPoint;
  66967. /**
  66968. * Gets the clear coat object output component
  66969. */
  66970. get clearcoat(): NodeMaterialConnectionPoint;
  66971. autoConfigure(material: NodeMaterial): void;
  66972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66974. private _generateTBNSpace;
  66975. /**
  66976. * Gets the main code of the block (fragment side)
  66977. * @param state current state of the node material building
  66978. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66979. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66980. * @param worldPosVarName name of the variable holding the world position
  66981. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66982. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66983. * @param worldNormalVarName name of the variable holding the world normal
  66984. * @returns the shader code
  66985. */
  66986. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66987. protected _buildBlock(state: NodeMaterialBuildState): this;
  66988. }
  66989. }
  66990. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66994. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66996. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66997. import { Nullable } from "babylonjs/types";
  66998. /**
  66999. * Block used to implement the sub surface module of the PBR material
  67000. */
  67001. export class SubSurfaceBlock extends NodeMaterialBlock {
  67002. /**
  67003. * Create a new SubSurfaceBlock
  67004. * @param name defines the block name
  67005. */
  67006. constructor(name: string);
  67007. /**
  67008. * Stores the intensity of the different subsurface effects in the thickness texture.
  67009. * * the green channel is the translucency intensity.
  67010. * * the blue channel is the scattering intensity.
  67011. * * the alpha channel is the refraction intensity.
  67012. */
  67013. useMaskFromThicknessTexture: boolean;
  67014. /**
  67015. * Initialize the block and prepare the context for build
  67016. * @param state defines the state that will be used for the build
  67017. */
  67018. initialize(state: NodeMaterialBuildState): void;
  67019. /**
  67020. * Gets the current class name
  67021. * @returns the class name
  67022. */
  67023. getClassName(): string;
  67024. /**
  67025. * Gets the min thickness input component
  67026. */
  67027. get minThickness(): NodeMaterialConnectionPoint;
  67028. /**
  67029. * Gets the max thickness input component
  67030. */
  67031. get maxThickness(): NodeMaterialConnectionPoint;
  67032. /**
  67033. * Gets the thickness texture component
  67034. */
  67035. get thicknessTexture(): NodeMaterialConnectionPoint;
  67036. /**
  67037. * Gets the tint color input component
  67038. */
  67039. get tintColor(): NodeMaterialConnectionPoint;
  67040. /**
  67041. * Gets the translucency intensity input component
  67042. */
  67043. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the translucency diffusion distance input component
  67046. */
  67047. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the refraction object parameters
  67050. */
  67051. get refraction(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the sub surface object output component
  67054. */
  67055. get subsurface(): NodeMaterialConnectionPoint;
  67056. autoConfigure(material: NodeMaterial): void;
  67057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67058. /**
  67059. * Gets the main code of the block (fragment side)
  67060. * @param state current state of the node material building
  67061. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67062. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67063. * @param worldPosVarName name of the variable holding the world position
  67064. * @returns the shader code
  67065. */
  67066. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67067. protected _buildBlock(state: NodeMaterialBuildState): this;
  67068. }
  67069. }
  67070. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67075. import { Light } from "babylonjs/Lights/light";
  67076. import { Nullable } from "babylonjs/types";
  67077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67078. import { Effect } from "babylonjs/Materials/effect";
  67079. import { Mesh } from "babylonjs/Meshes/mesh";
  67080. import { Scene } from "babylonjs/scene";
  67081. /**
  67082. * Block used to implement the PBR metallic/roughness model
  67083. */
  67084. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67085. /**
  67086. * Gets or sets the light associated with this block
  67087. */
  67088. light: Nullable<Light>;
  67089. private _lightId;
  67090. private _scene;
  67091. private _environmentBRDFTexture;
  67092. private _environmentBrdfSamplerName;
  67093. private _vNormalWName;
  67094. private _invertNormalName;
  67095. /**
  67096. * Create a new ReflectionBlock
  67097. * @param name defines the block name
  67098. */
  67099. constructor(name: string);
  67100. /**
  67101. * Intensity of the direct lights e.g. the four lights available in your scene.
  67102. * This impacts both the direct diffuse and specular highlights.
  67103. */
  67104. directIntensity: number;
  67105. /**
  67106. * Intensity of the environment e.g. how much the environment will light the object
  67107. * either through harmonics for rough material or through the refelction for shiny ones.
  67108. */
  67109. environmentIntensity: number;
  67110. /**
  67111. * This is a special control allowing the reduction of the specular highlights coming from the
  67112. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67113. */
  67114. specularIntensity: number;
  67115. /**
  67116. * Defines the falloff type used in this material.
  67117. * It by default is Physical.
  67118. */
  67119. lightFalloff: number;
  67120. /**
  67121. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67122. */
  67123. useAlphaFromAlbedoTexture: boolean;
  67124. /**
  67125. * Specifies that alpha test should be used
  67126. */
  67127. useAlphaTest: boolean;
  67128. /**
  67129. * Defines the alpha limits in alpha test mode.
  67130. */
  67131. alphaTestCutoff: number;
  67132. /**
  67133. * Specifies that alpha blending should be used
  67134. */
  67135. useAlphaBlending: boolean;
  67136. /**
  67137. * Defines if the alpha value should be determined via the rgb values.
  67138. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67139. */
  67140. opacityRGB: boolean;
  67141. /**
  67142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67144. */
  67145. useRadianceOverAlpha: boolean;
  67146. /**
  67147. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67148. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67149. */
  67150. useSpecularOverAlpha: boolean;
  67151. /**
  67152. * Enables specular anti aliasing in the PBR shader.
  67153. * It will both interacts on the Geometry for analytical and IBL lighting.
  67154. * It also prefilter the roughness map based on the bump values.
  67155. */
  67156. enableSpecularAntiAliasing: boolean;
  67157. /**
  67158. * Enables realtime filtering on the texture.
  67159. */
  67160. realTimeFiltering: boolean;
  67161. /**
  67162. * Quality switch for realtime filtering
  67163. */
  67164. realTimeFilteringQuality: number;
  67165. /**
  67166. * Defines if the material uses energy conservation.
  67167. */
  67168. useEnergyConservation: boolean;
  67169. /**
  67170. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67171. * too much the area relying on ambient texture to define their ambient occlusion.
  67172. */
  67173. useRadianceOcclusion: boolean;
  67174. /**
  67175. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67176. * makes the reflect vector face the model (under horizon).
  67177. */
  67178. useHorizonOcclusion: boolean;
  67179. /**
  67180. * If set to true, no lighting calculations will be applied.
  67181. */
  67182. unlit: boolean;
  67183. /**
  67184. * Force normal to face away from face.
  67185. */
  67186. forceNormalForward: boolean;
  67187. /**
  67188. * Defines the material debug mode.
  67189. * It helps seeing only some components of the material while troubleshooting.
  67190. */
  67191. debugMode: number;
  67192. /**
  67193. * Specify from where on screen the debug mode should start.
  67194. * The value goes from -1 (full screen) to 1 (not visible)
  67195. * It helps with side by side comparison against the final render
  67196. * This defaults to 0
  67197. */
  67198. debugLimit: number;
  67199. /**
  67200. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67201. * You can use the factor to better multiply the final value.
  67202. */
  67203. debugFactor: number;
  67204. /**
  67205. * Initialize the block and prepare the context for build
  67206. * @param state defines the state that will be used for the build
  67207. */
  67208. initialize(state: NodeMaterialBuildState): void;
  67209. /**
  67210. * Gets the current class name
  67211. * @returns the class name
  67212. */
  67213. getClassName(): string;
  67214. /**
  67215. * Gets the world position input component
  67216. */
  67217. get worldPosition(): NodeMaterialConnectionPoint;
  67218. /**
  67219. * Gets the world normal input component
  67220. */
  67221. get worldNormal(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the perturbed normal input component
  67224. */
  67225. get perturbedNormal(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the camera position input component
  67228. */
  67229. get cameraPosition(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the base color input component
  67232. */
  67233. get baseColor(): NodeMaterialConnectionPoint;
  67234. /**
  67235. * Gets the opacity texture input component
  67236. */
  67237. get opacityTexture(): NodeMaterialConnectionPoint;
  67238. /**
  67239. * Gets the ambient color input component
  67240. */
  67241. get ambientColor(): NodeMaterialConnectionPoint;
  67242. /**
  67243. * Gets the reflectivity object parameters
  67244. */
  67245. get reflectivity(): NodeMaterialConnectionPoint;
  67246. /**
  67247. * Gets the ambient occlusion object parameters
  67248. */
  67249. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67250. /**
  67251. * Gets the reflection object parameters
  67252. */
  67253. get reflection(): NodeMaterialConnectionPoint;
  67254. /**
  67255. * Gets the sheen object parameters
  67256. */
  67257. get sheen(): NodeMaterialConnectionPoint;
  67258. /**
  67259. * Gets the clear coat object parameters
  67260. */
  67261. get clearcoat(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the sub surface object parameters
  67264. */
  67265. get subsurface(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Gets the anisotropy object parameters
  67268. */
  67269. get anisotropy(): NodeMaterialConnectionPoint;
  67270. /**
  67271. * Gets the ambient output component
  67272. */
  67273. get ambient(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the diffuse output component
  67276. */
  67277. get diffuse(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the specular output component
  67280. */
  67281. get specular(): NodeMaterialConnectionPoint;
  67282. /**
  67283. * Gets the sheen output component
  67284. */
  67285. get sheenDir(): NodeMaterialConnectionPoint;
  67286. /**
  67287. * Gets the clear coat output component
  67288. */
  67289. get clearcoatDir(): NodeMaterialConnectionPoint;
  67290. /**
  67291. * Gets the indirect diffuse output component
  67292. */
  67293. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67294. /**
  67295. * Gets the indirect specular output component
  67296. */
  67297. get specularIndirect(): NodeMaterialConnectionPoint;
  67298. /**
  67299. * Gets the indirect sheen output component
  67300. */
  67301. get sheenIndirect(): NodeMaterialConnectionPoint;
  67302. /**
  67303. * Gets the indirect clear coat output component
  67304. */
  67305. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the refraction output component
  67308. */
  67309. get refraction(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the global lighting output component
  67312. */
  67313. get lighting(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the shadow output component
  67316. */
  67317. get shadow(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the alpha output component
  67320. */
  67321. get alpha(): NodeMaterialConnectionPoint;
  67322. autoConfigure(material: NodeMaterial): void;
  67323. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67324. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67326. private _injectVertexCode;
  67327. /**
  67328. * Gets the code corresponding to the albedo/opacity module
  67329. * @returns the shader code
  67330. */
  67331. getAlbedoOpacityCode(): string;
  67332. protected _buildBlock(state: NodeMaterialBuildState): this;
  67333. protected _dumpPropertiesCode(): string;
  67334. serialize(): any;
  67335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67336. }
  67337. }
  67338. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67339. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67340. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67341. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67342. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67343. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67344. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67345. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67346. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67347. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67348. }
  67349. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67350. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67351. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67352. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67353. }
  67354. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67358. /**
  67359. * Block used to compute value of one parameter modulo another
  67360. */
  67361. export class ModBlock extends NodeMaterialBlock {
  67362. /**
  67363. * Creates a new ModBlock
  67364. * @param name defines the block name
  67365. */
  67366. constructor(name: string);
  67367. /**
  67368. * Gets the current class name
  67369. * @returns the class name
  67370. */
  67371. getClassName(): string;
  67372. /**
  67373. * Gets the left operand input component
  67374. */
  67375. get left(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the right operand input component
  67378. */
  67379. get right(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the output component
  67382. */
  67383. get output(): NodeMaterialConnectionPoint;
  67384. protected _buildBlock(state: NodeMaterialBuildState): this;
  67385. }
  67386. }
  67387. declare module "babylonjs/Materials/Node/Blocks/index" {
  67388. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67389. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67390. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67391. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67392. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67393. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67394. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67395. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67396. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67397. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67398. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67399. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67400. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67401. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67402. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67403. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67404. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67405. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67406. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67407. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67408. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67409. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67410. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67411. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67412. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67413. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67414. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67415. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67416. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67417. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67418. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67419. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67420. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67421. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67422. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67423. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67424. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67425. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67426. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67427. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67428. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67429. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67430. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67431. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67432. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67433. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67434. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67435. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67436. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67437. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67438. }
  67439. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67440. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67441. }
  67442. declare module "babylonjs/Materials/Node/index" {
  67443. export * from "babylonjs/Materials/Node/Enums/index";
  67444. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67445. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67446. export * from "babylonjs/Materials/Node/nodeMaterial";
  67447. export * from "babylonjs/Materials/Node/Blocks/index";
  67448. export * from "babylonjs/Materials/Node/Optimizers/index";
  67449. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67450. }
  67451. declare module "babylonjs/Materials/index" {
  67452. export * from "babylonjs/Materials/Background/index";
  67453. export * from "babylonjs/Materials/colorCurves";
  67454. export * from "babylonjs/Materials/iEffectFallbacks";
  67455. export * from "babylonjs/Materials/effectFallbacks";
  67456. export * from "babylonjs/Materials/effect";
  67457. export * from "babylonjs/Materials/fresnelParameters";
  67458. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67459. export * from "babylonjs/Materials/material";
  67460. export * from "babylonjs/Materials/materialDefines";
  67461. export * from "babylonjs/Materials/materialHelper";
  67462. export * from "babylonjs/Materials/multiMaterial";
  67463. export * from "babylonjs/Materials/PBR/index";
  67464. export * from "babylonjs/Materials/pushMaterial";
  67465. export * from "babylonjs/Materials/shaderMaterial";
  67466. export * from "babylonjs/Materials/standardMaterial";
  67467. export * from "babylonjs/Materials/Textures/index";
  67468. export * from "babylonjs/Materials/uniformBuffer";
  67469. export * from "babylonjs/Materials/materialFlags";
  67470. export * from "babylonjs/Materials/Node/index";
  67471. export * from "babylonjs/Materials/effectRenderer";
  67472. export * from "babylonjs/Materials/shadowDepthWrapper";
  67473. }
  67474. declare module "babylonjs/Maths/index" {
  67475. export * from "babylonjs/Maths/math.scalar";
  67476. export * from "babylonjs/Maths/math";
  67477. export * from "babylonjs/Maths/sphericalPolynomial";
  67478. }
  67479. declare module "babylonjs/Misc/workerPool" {
  67480. import { IDisposable } from "babylonjs/scene";
  67481. /**
  67482. * Helper class to push actions to a pool of workers.
  67483. */
  67484. export class WorkerPool implements IDisposable {
  67485. private _workerInfos;
  67486. private _pendingActions;
  67487. /**
  67488. * Constructor
  67489. * @param workers Array of workers to use for actions
  67490. */
  67491. constructor(workers: Array<Worker>);
  67492. /**
  67493. * Terminates all workers and clears any pending actions.
  67494. */
  67495. dispose(): void;
  67496. /**
  67497. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67498. * pended until a worker has completed its action.
  67499. * @param action The action to perform. Call onComplete when the action is complete.
  67500. */
  67501. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67502. private _execute;
  67503. }
  67504. }
  67505. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67506. import { IDisposable } from "babylonjs/scene";
  67507. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67508. /**
  67509. * Configuration for Draco compression
  67510. */
  67511. export interface IDracoCompressionConfiguration {
  67512. /**
  67513. * Configuration for the decoder.
  67514. */
  67515. decoder: {
  67516. /**
  67517. * The url to the WebAssembly module.
  67518. */
  67519. wasmUrl?: string;
  67520. /**
  67521. * The url to the WebAssembly binary.
  67522. */
  67523. wasmBinaryUrl?: string;
  67524. /**
  67525. * The url to the fallback JavaScript module.
  67526. */
  67527. fallbackUrl?: string;
  67528. };
  67529. }
  67530. /**
  67531. * Draco compression (https://google.github.io/draco/)
  67532. *
  67533. * This class wraps the Draco module.
  67534. *
  67535. * **Encoder**
  67536. *
  67537. * The encoder is not currently implemented.
  67538. *
  67539. * **Decoder**
  67540. *
  67541. * 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.
  67542. *
  67543. * To update the configuration, use the following code:
  67544. * ```javascript
  67545. * DracoCompression.Configuration = {
  67546. * decoder: {
  67547. * wasmUrl: "<url to the WebAssembly library>",
  67548. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67549. * fallbackUrl: "<url to the fallback JavaScript library>",
  67550. * }
  67551. * };
  67552. * ```
  67553. *
  67554. * 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.
  67555. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67556. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67557. *
  67558. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67559. * ```javascript
  67560. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67561. * ```
  67562. *
  67563. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67564. */
  67565. export class DracoCompression implements IDisposable {
  67566. private _workerPoolPromise?;
  67567. private _decoderModulePromise?;
  67568. /**
  67569. * The configuration. Defaults to the following urls:
  67570. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67571. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67572. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67573. */
  67574. static Configuration: IDracoCompressionConfiguration;
  67575. /**
  67576. * Returns true if the decoder configuration is available.
  67577. */
  67578. static get DecoderAvailable(): boolean;
  67579. /**
  67580. * Default number of workers to create when creating the draco compression object.
  67581. */
  67582. static DefaultNumWorkers: number;
  67583. private static GetDefaultNumWorkers;
  67584. private static _Default;
  67585. /**
  67586. * Default instance for the draco compression object.
  67587. */
  67588. static get Default(): DracoCompression;
  67589. /**
  67590. * Constructor
  67591. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67592. */
  67593. constructor(numWorkers?: number);
  67594. /**
  67595. * Stop all async operations and release resources.
  67596. */
  67597. dispose(): void;
  67598. /**
  67599. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67600. * @returns a promise that resolves when ready
  67601. */
  67602. whenReadyAsync(): Promise<void>;
  67603. /**
  67604. * Decode Draco compressed mesh data to vertex data.
  67605. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67606. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67607. * @returns A promise that resolves with the decoded vertex data
  67608. */
  67609. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67610. [kind: string]: number;
  67611. }): Promise<VertexData>;
  67612. }
  67613. }
  67614. declare module "babylonjs/Meshes/Compression/index" {
  67615. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67616. }
  67617. declare module "babylonjs/Meshes/csg" {
  67618. import { Nullable } from "babylonjs/types";
  67619. import { Scene } from "babylonjs/scene";
  67620. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67621. import { Mesh } from "babylonjs/Meshes/mesh";
  67622. import { Material } from "babylonjs/Materials/material";
  67623. /**
  67624. * Class for building Constructive Solid Geometry
  67625. */
  67626. export class CSG {
  67627. private polygons;
  67628. /**
  67629. * The world matrix
  67630. */
  67631. matrix: Matrix;
  67632. /**
  67633. * Stores the position
  67634. */
  67635. position: Vector3;
  67636. /**
  67637. * Stores the rotation
  67638. */
  67639. rotation: Vector3;
  67640. /**
  67641. * Stores the rotation quaternion
  67642. */
  67643. rotationQuaternion: Nullable<Quaternion>;
  67644. /**
  67645. * Stores the scaling vector
  67646. */
  67647. scaling: Vector3;
  67648. /**
  67649. * Convert the Mesh to CSG
  67650. * @param mesh The Mesh to convert to CSG
  67651. * @returns A new CSG from the Mesh
  67652. */
  67653. static FromMesh(mesh: Mesh): CSG;
  67654. /**
  67655. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67656. * @param polygons Polygons used to construct a CSG solid
  67657. */
  67658. private static FromPolygons;
  67659. /**
  67660. * Clones, or makes a deep copy, of the CSG
  67661. * @returns A new CSG
  67662. */
  67663. clone(): CSG;
  67664. /**
  67665. * Unions this CSG with another CSG
  67666. * @param csg The CSG to union against this CSG
  67667. * @returns The unioned CSG
  67668. */
  67669. union(csg: CSG): CSG;
  67670. /**
  67671. * Unions this CSG with another CSG in place
  67672. * @param csg The CSG to union against this CSG
  67673. */
  67674. unionInPlace(csg: CSG): void;
  67675. /**
  67676. * Subtracts this CSG with another CSG
  67677. * @param csg The CSG to subtract against this CSG
  67678. * @returns A new CSG
  67679. */
  67680. subtract(csg: CSG): CSG;
  67681. /**
  67682. * Subtracts this CSG with another CSG in place
  67683. * @param csg The CSG to subtact against this CSG
  67684. */
  67685. subtractInPlace(csg: CSG): void;
  67686. /**
  67687. * Intersect this CSG with another CSG
  67688. * @param csg The CSG to intersect against this CSG
  67689. * @returns A new CSG
  67690. */
  67691. intersect(csg: CSG): CSG;
  67692. /**
  67693. * Intersects this CSG with another CSG in place
  67694. * @param csg The CSG to intersect against this CSG
  67695. */
  67696. intersectInPlace(csg: CSG): void;
  67697. /**
  67698. * Return a new CSG solid with solid and empty space switched. This solid is
  67699. * not modified.
  67700. * @returns A new CSG solid with solid and empty space switched
  67701. */
  67702. inverse(): CSG;
  67703. /**
  67704. * Inverses the CSG in place
  67705. */
  67706. inverseInPlace(): void;
  67707. /**
  67708. * This is used to keep meshes transformations so they can be restored
  67709. * when we build back a Babylon Mesh
  67710. * NB : All CSG operations are performed in world coordinates
  67711. * @param csg The CSG to copy the transform attributes from
  67712. * @returns This CSG
  67713. */
  67714. copyTransformAttributes(csg: CSG): CSG;
  67715. /**
  67716. * Build Raw mesh from CSG
  67717. * Coordinates here are in world space
  67718. * @param name The name of the mesh geometry
  67719. * @param scene The Scene
  67720. * @param keepSubMeshes Specifies if the submeshes should be kept
  67721. * @returns A new Mesh
  67722. */
  67723. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67724. /**
  67725. * Build Mesh from CSG taking material and transforms into account
  67726. * @param name The name of the Mesh
  67727. * @param material The material of the Mesh
  67728. * @param scene The Scene
  67729. * @param keepSubMeshes Specifies if submeshes should be kept
  67730. * @returns The new Mesh
  67731. */
  67732. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67733. }
  67734. }
  67735. declare module "babylonjs/Meshes/trailMesh" {
  67736. import { Mesh } from "babylonjs/Meshes/mesh";
  67737. import { Scene } from "babylonjs/scene";
  67738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67739. /**
  67740. * Class used to create a trail following a mesh
  67741. */
  67742. export class TrailMesh extends Mesh {
  67743. private _generator;
  67744. private _autoStart;
  67745. private _running;
  67746. private _diameter;
  67747. private _length;
  67748. private _sectionPolygonPointsCount;
  67749. private _sectionVectors;
  67750. private _sectionNormalVectors;
  67751. private _beforeRenderObserver;
  67752. /**
  67753. * @constructor
  67754. * @param name The value used by scene.getMeshByName() to do a lookup.
  67755. * @param generator The mesh or transform node to generate a trail.
  67756. * @param scene The scene to add this mesh to.
  67757. * @param diameter Diameter of trailing mesh. Default is 1.
  67758. * @param length Length of trailing mesh. Default is 60.
  67759. * @param autoStart Automatically start trailing mesh. Default true.
  67760. */
  67761. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67762. /**
  67763. * "TrailMesh"
  67764. * @returns "TrailMesh"
  67765. */
  67766. getClassName(): string;
  67767. private _createMesh;
  67768. /**
  67769. * Start trailing mesh.
  67770. */
  67771. start(): void;
  67772. /**
  67773. * Stop trailing mesh.
  67774. */
  67775. stop(): void;
  67776. /**
  67777. * Update trailing mesh geometry.
  67778. */
  67779. update(): void;
  67780. /**
  67781. * Returns a new TrailMesh object.
  67782. * @param name is a string, the name given to the new mesh
  67783. * @param newGenerator use new generator object for cloned trail mesh
  67784. * @returns a new mesh
  67785. */
  67786. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67787. /**
  67788. * Serializes this trail mesh
  67789. * @param serializationObject object to write serialization to
  67790. */
  67791. serialize(serializationObject: any): void;
  67792. /**
  67793. * Parses a serialized trail mesh
  67794. * @param parsedMesh the serialized mesh
  67795. * @param scene the scene to create the trail mesh in
  67796. * @returns the created trail mesh
  67797. */
  67798. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67799. }
  67800. }
  67801. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67802. import { Nullable } from "babylonjs/types";
  67803. import { Scene } from "babylonjs/scene";
  67804. import { Vector4 } from "babylonjs/Maths/math.vector";
  67805. import { Color4 } from "babylonjs/Maths/math.color";
  67806. import { Mesh } from "babylonjs/Meshes/mesh";
  67807. /**
  67808. * Class containing static functions to help procedurally build meshes
  67809. */
  67810. export class TiledBoxBuilder {
  67811. /**
  67812. * Creates a box mesh
  67813. * 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)
  67814. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67818. * @param name defines the name of the mesh
  67819. * @param options defines the options used to create the mesh
  67820. * @param scene defines the hosting scene
  67821. * @returns the box mesh
  67822. */
  67823. static CreateTiledBox(name: string, options: {
  67824. pattern?: number;
  67825. width?: number;
  67826. height?: number;
  67827. depth?: number;
  67828. tileSize?: number;
  67829. tileWidth?: number;
  67830. tileHeight?: number;
  67831. alignHorizontal?: number;
  67832. alignVertical?: number;
  67833. faceUV?: Vector4[];
  67834. faceColors?: Color4[];
  67835. sideOrientation?: number;
  67836. updatable?: boolean;
  67837. }, scene?: Nullable<Scene>): Mesh;
  67838. }
  67839. }
  67840. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67841. import { Vector4 } from "babylonjs/Maths/math.vector";
  67842. import { Mesh } from "babylonjs/Meshes/mesh";
  67843. /**
  67844. * Class containing static functions to help procedurally build meshes
  67845. */
  67846. export class TorusKnotBuilder {
  67847. /**
  67848. * Creates a torus knot mesh
  67849. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67850. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67851. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67852. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67856. * @param name defines the name of the mesh
  67857. * @param options defines the options used to create the mesh
  67858. * @param scene defines the hosting scene
  67859. * @returns the torus knot mesh
  67860. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67861. */
  67862. static CreateTorusKnot(name: string, options: {
  67863. radius?: number;
  67864. tube?: number;
  67865. radialSegments?: number;
  67866. tubularSegments?: number;
  67867. p?: number;
  67868. q?: number;
  67869. updatable?: boolean;
  67870. sideOrientation?: number;
  67871. frontUVs?: Vector4;
  67872. backUVs?: Vector4;
  67873. }, scene: any): Mesh;
  67874. }
  67875. }
  67876. declare module "babylonjs/Meshes/polygonMesh" {
  67877. import { Scene } from "babylonjs/scene";
  67878. import { Vector2 } from "babylonjs/Maths/math.vector";
  67879. import { Mesh } from "babylonjs/Meshes/mesh";
  67880. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67881. import { Path2 } from "babylonjs/Maths/math.path";
  67882. /**
  67883. * Polygon
  67884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67885. */
  67886. export class Polygon {
  67887. /**
  67888. * Creates a rectangle
  67889. * @param xmin bottom X coord
  67890. * @param ymin bottom Y coord
  67891. * @param xmax top X coord
  67892. * @param ymax top Y coord
  67893. * @returns points that make the resulting rectation
  67894. */
  67895. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67896. /**
  67897. * Creates a circle
  67898. * @param radius radius of circle
  67899. * @param cx scale in x
  67900. * @param cy scale in y
  67901. * @param numberOfSides number of sides that make up the circle
  67902. * @returns points that make the resulting circle
  67903. */
  67904. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67905. /**
  67906. * Creates a polygon from input string
  67907. * @param input Input polygon data
  67908. * @returns the parsed points
  67909. */
  67910. static Parse(input: string): Vector2[];
  67911. /**
  67912. * Starts building a polygon from x and y coordinates
  67913. * @param x x coordinate
  67914. * @param y y coordinate
  67915. * @returns the started path2
  67916. */
  67917. static StartingAt(x: number, y: number): Path2;
  67918. }
  67919. /**
  67920. * Builds a polygon
  67921. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67922. */
  67923. export class PolygonMeshBuilder {
  67924. private _points;
  67925. private _outlinepoints;
  67926. private _holes;
  67927. private _name;
  67928. private _scene;
  67929. private _epoints;
  67930. private _eholes;
  67931. private _addToepoint;
  67932. /**
  67933. * Babylon reference to the earcut plugin.
  67934. */
  67935. bjsEarcut: any;
  67936. /**
  67937. * Creates a PolygonMeshBuilder
  67938. * @param name name of the builder
  67939. * @param contours Path of the polygon
  67940. * @param scene scene to add to when creating the mesh
  67941. * @param earcutInjection can be used to inject your own earcut reference
  67942. */
  67943. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67944. /**
  67945. * Adds a whole within the polygon
  67946. * @param hole Array of points defining the hole
  67947. * @returns this
  67948. */
  67949. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67950. /**
  67951. * Creates the polygon
  67952. * @param updatable If the mesh should be updatable
  67953. * @param depth The depth of the mesh created
  67954. * @returns the created mesh
  67955. */
  67956. build(updatable?: boolean, depth?: number): Mesh;
  67957. /**
  67958. * Creates the polygon
  67959. * @param depth The depth of the mesh created
  67960. * @returns the created VertexData
  67961. */
  67962. buildVertexData(depth?: number): VertexData;
  67963. /**
  67964. * Adds a side to the polygon
  67965. * @param positions points that make the polygon
  67966. * @param normals normals of the polygon
  67967. * @param uvs uvs of the polygon
  67968. * @param indices indices of the polygon
  67969. * @param bounds bounds of the polygon
  67970. * @param points points of the polygon
  67971. * @param depth depth of the polygon
  67972. * @param flip flip of the polygon
  67973. */
  67974. private addSide;
  67975. }
  67976. }
  67977. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67978. import { Scene } from "babylonjs/scene";
  67979. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67980. import { Color4 } from "babylonjs/Maths/math.color";
  67981. import { Mesh } from "babylonjs/Meshes/mesh";
  67982. import { Nullable } from "babylonjs/types";
  67983. /**
  67984. * Class containing static functions to help procedurally build meshes
  67985. */
  67986. export class PolygonBuilder {
  67987. /**
  67988. * Creates a polygon mesh
  67989. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67990. * * 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
  67991. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67994. * * Remember you can only change the shape positions, not their number when updating a polygon
  67995. * @param name defines the name of the mesh
  67996. * @param options defines the options used to create the mesh
  67997. * @param scene defines the hosting scene
  67998. * @param earcutInjection can be used to inject your own earcut reference
  67999. * @returns the polygon mesh
  68000. */
  68001. static CreatePolygon(name: string, options: {
  68002. shape: Vector3[];
  68003. holes?: Vector3[][];
  68004. depth?: number;
  68005. faceUV?: Vector4[];
  68006. faceColors?: Color4[];
  68007. updatable?: boolean;
  68008. sideOrientation?: number;
  68009. frontUVs?: Vector4;
  68010. backUVs?: Vector4;
  68011. wrap?: boolean;
  68012. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68013. /**
  68014. * Creates an extruded polygon mesh, with depth in the Y direction.
  68015. * * 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)
  68016. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68017. * @param name defines the name of the mesh
  68018. * @param options defines the options used to create the mesh
  68019. * @param scene defines the hosting scene
  68020. * @param earcutInjection can be used to inject your own earcut reference
  68021. * @returns the polygon mesh
  68022. */
  68023. static ExtrudePolygon(name: string, options: {
  68024. shape: Vector3[];
  68025. holes?: Vector3[][];
  68026. depth?: number;
  68027. faceUV?: Vector4[];
  68028. faceColors?: Color4[];
  68029. updatable?: boolean;
  68030. sideOrientation?: number;
  68031. frontUVs?: Vector4;
  68032. backUVs?: Vector4;
  68033. wrap?: boolean;
  68034. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68035. }
  68036. }
  68037. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68038. import { Scene } from "babylonjs/scene";
  68039. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68040. import { Mesh } from "babylonjs/Meshes/mesh";
  68041. import { Nullable } from "babylonjs/types";
  68042. /**
  68043. * Class containing static functions to help procedurally build meshes
  68044. */
  68045. export class LatheBuilder {
  68046. /**
  68047. * Creates lathe mesh.
  68048. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68049. * * 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
  68050. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68051. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68052. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68053. * * 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
  68054. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68055. * * 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
  68056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68060. * @param name defines the name of the mesh
  68061. * @param options defines the options used to create the mesh
  68062. * @param scene defines the hosting scene
  68063. * @returns the lathe mesh
  68064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68065. */
  68066. static CreateLathe(name: string, options: {
  68067. shape: Vector3[];
  68068. radius?: number;
  68069. tessellation?: number;
  68070. clip?: number;
  68071. arc?: number;
  68072. closed?: boolean;
  68073. updatable?: boolean;
  68074. sideOrientation?: number;
  68075. frontUVs?: Vector4;
  68076. backUVs?: Vector4;
  68077. cap?: number;
  68078. invertUV?: boolean;
  68079. }, scene?: Nullable<Scene>): Mesh;
  68080. }
  68081. }
  68082. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68083. import { Nullable } from "babylonjs/types";
  68084. import { Scene } from "babylonjs/scene";
  68085. import { Vector4 } from "babylonjs/Maths/math.vector";
  68086. import { Mesh } from "babylonjs/Meshes/mesh";
  68087. /**
  68088. * Class containing static functions to help procedurally build meshes
  68089. */
  68090. export class TiledPlaneBuilder {
  68091. /**
  68092. * Creates a tiled plane mesh
  68093. * * The parameter `pattern` will, depending on value, do nothing or
  68094. * * * flip (reflect about central vertical) alternate tiles across and up
  68095. * * * flip every tile on alternate rows
  68096. * * * rotate (180 degs) alternate tiles across and up
  68097. * * * rotate every tile on alternate rows
  68098. * * * flip and rotate alternate tiles across and up
  68099. * * * flip and rotate every tile on alternate rows
  68100. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68101. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68104. * * 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)
  68105. * * 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)
  68106. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68107. * @param name defines the name of the mesh
  68108. * @param options defines the options used to create the mesh
  68109. * @param scene defines the hosting scene
  68110. * @returns the box mesh
  68111. */
  68112. static CreateTiledPlane(name: string, options: {
  68113. pattern?: number;
  68114. tileSize?: number;
  68115. tileWidth?: number;
  68116. tileHeight?: number;
  68117. size?: number;
  68118. width?: number;
  68119. height?: number;
  68120. alignHorizontal?: number;
  68121. alignVertical?: number;
  68122. sideOrientation?: number;
  68123. frontUVs?: Vector4;
  68124. backUVs?: Vector4;
  68125. updatable?: boolean;
  68126. }, scene?: Nullable<Scene>): Mesh;
  68127. }
  68128. }
  68129. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68130. import { Nullable } from "babylonjs/types";
  68131. import { Scene } from "babylonjs/scene";
  68132. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68133. import { Mesh } from "babylonjs/Meshes/mesh";
  68134. /**
  68135. * Class containing static functions to help procedurally build meshes
  68136. */
  68137. export class TubeBuilder {
  68138. /**
  68139. * Creates a tube mesh.
  68140. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68141. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68142. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68143. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68144. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68145. * * 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)
  68146. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68147. * * 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
  68148. * * 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
  68149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68153. * @param name defines the name of the mesh
  68154. * @param options defines the options used to create the mesh
  68155. * @param scene defines the hosting scene
  68156. * @returns the tube mesh
  68157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68158. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68159. */
  68160. static CreateTube(name: string, options: {
  68161. path: Vector3[];
  68162. radius?: number;
  68163. tessellation?: number;
  68164. radiusFunction?: {
  68165. (i: number, distance: number): number;
  68166. };
  68167. cap?: number;
  68168. arc?: number;
  68169. updatable?: boolean;
  68170. sideOrientation?: number;
  68171. frontUVs?: Vector4;
  68172. backUVs?: Vector4;
  68173. instance?: Mesh;
  68174. invertUV?: boolean;
  68175. }, scene?: Nullable<Scene>): Mesh;
  68176. }
  68177. }
  68178. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68179. import { Scene } from "babylonjs/scene";
  68180. import { Vector4 } from "babylonjs/Maths/math.vector";
  68181. import { Mesh } from "babylonjs/Meshes/mesh";
  68182. import { Nullable } from "babylonjs/types";
  68183. /**
  68184. * Class containing static functions to help procedurally build meshes
  68185. */
  68186. export class IcoSphereBuilder {
  68187. /**
  68188. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68189. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68190. * * 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`)
  68191. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68192. * * 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
  68193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68196. * @param name defines the name of the mesh
  68197. * @param options defines the options used to create the mesh
  68198. * @param scene defines the hosting scene
  68199. * @returns the icosahedron mesh
  68200. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68201. */
  68202. static CreateIcoSphere(name: string, options: {
  68203. radius?: number;
  68204. radiusX?: number;
  68205. radiusY?: number;
  68206. radiusZ?: number;
  68207. flat?: boolean;
  68208. subdivisions?: number;
  68209. sideOrientation?: number;
  68210. frontUVs?: Vector4;
  68211. backUVs?: Vector4;
  68212. updatable?: boolean;
  68213. }, scene?: Nullable<Scene>): Mesh;
  68214. }
  68215. }
  68216. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68217. import { Vector3 } from "babylonjs/Maths/math.vector";
  68218. import { Mesh } from "babylonjs/Meshes/mesh";
  68219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68220. /**
  68221. * Class containing static functions to help procedurally build meshes
  68222. */
  68223. export class DecalBuilder {
  68224. /**
  68225. * Creates a decal mesh.
  68226. * 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
  68227. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68228. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68229. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68230. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68231. * @param name defines the name of the mesh
  68232. * @param sourceMesh defines the mesh where the decal must be applied
  68233. * @param options defines the options used to create the mesh
  68234. * @param scene defines the hosting scene
  68235. * @returns the decal mesh
  68236. * @see https://doc.babylonjs.com/how_to/decals
  68237. */
  68238. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68239. position?: Vector3;
  68240. normal?: Vector3;
  68241. size?: Vector3;
  68242. angle?: number;
  68243. }): Mesh;
  68244. }
  68245. }
  68246. declare module "babylonjs/Meshes/meshBuilder" {
  68247. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68248. import { Nullable } from "babylonjs/types";
  68249. import { Scene } from "babylonjs/scene";
  68250. import { Mesh } from "babylonjs/Meshes/mesh";
  68251. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68252. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68254. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68255. import { Plane } from "babylonjs/Maths/math.plane";
  68256. /**
  68257. * Class containing static functions to help procedurally build meshes
  68258. */
  68259. export class MeshBuilder {
  68260. /**
  68261. * Creates a box mesh
  68262. * * The parameter `size` sets the size (float) of each box side (default 1)
  68263. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68264. * * 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)
  68265. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68269. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68270. * @param name defines the name of the mesh
  68271. * @param options defines the options used to create the mesh
  68272. * @param scene defines the hosting scene
  68273. * @returns the box mesh
  68274. */
  68275. static CreateBox(name: string, options: {
  68276. size?: number;
  68277. width?: number;
  68278. height?: number;
  68279. depth?: number;
  68280. faceUV?: Vector4[];
  68281. faceColors?: Color4[];
  68282. sideOrientation?: number;
  68283. frontUVs?: Vector4;
  68284. backUVs?: Vector4;
  68285. wrap?: boolean;
  68286. topBaseAt?: number;
  68287. bottomBaseAt?: number;
  68288. updatable?: boolean;
  68289. }, scene?: Nullable<Scene>): Mesh;
  68290. /**
  68291. * Creates a tiled box mesh
  68292. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68294. * @param name defines the name of the mesh
  68295. * @param options defines the options used to create the mesh
  68296. * @param scene defines the hosting scene
  68297. * @returns the tiled box mesh
  68298. */
  68299. static CreateTiledBox(name: string, options: {
  68300. pattern?: number;
  68301. size?: number;
  68302. width?: number;
  68303. height?: number;
  68304. depth: number;
  68305. tileSize?: number;
  68306. tileWidth?: number;
  68307. tileHeight?: number;
  68308. faceUV?: Vector4[];
  68309. faceColors?: Color4[];
  68310. alignHorizontal?: number;
  68311. alignVertical?: number;
  68312. sideOrientation?: number;
  68313. updatable?: boolean;
  68314. }, scene?: Nullable<Scene>): Mesh;
  68315. /**
  68316. * Creates a sphere mesh
  68317. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68318. * * 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`)
  68319. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68320. * * 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
  68321. * * 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)
  68322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68325. * @param name defines the name of the mesh
  68326. * @param options defines the options used to create the mesh
  68327. * @param scene defines the hosting scene
  68328. * @returns the sphere mesh
  68329. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68330. */
  68331. static CreateSphere(name: string, options: {
  68332. segments?: number;
  68333. diameter?: number;
  68334. diameterX?: number;
  68335. diameterY?: number;
  68336. diameterZ?: number;
  68337. arc?: number;
  68338. slice?: number;
  68339. sideOrientation?: number;
  68340. frontUVs?: Vector4;
  68341. backUVs?: Vector4;
  68342. updatable?: boolean;
  68343. }, scene?: Nullable<Scene>): Mesh;
  68344. /**
  68345. * Creates a plane polygonal mesh. By default, this is a disc
  68346. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68347. * * 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
  68348. * * 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
  68349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68352. * @param name defines the name of the mesh
  68353. * @param options defines the options used to create the mesh
  68354. * @param scene defines the hosting scene
  68355. * @returns the plane polygonal mesh
  68356. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68357. */
  68358. static CreateDisc(name: string, options: {
  68359. radius?: number;
  68360. tessellation?: number;
  68361. arc?: number;
  68362. updatable?: boolean;
  68363. sideOrientation?: number;
  68364. frontUVs?: Vector4;
  68365. backUVs?: Vector4;
  68366. }, scene?: Nullable<Scene>): Mesh;
  68367. /**
  68368. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68369. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68370. * * 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`)
  68371. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68372. * * 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
  68373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68376. * @param name defines the name of the mesh
  68377. * @param options defines the options used to create the mesh
  68378. * @param scene defines the hosting scene
  68379. * @returns the icosahedron mesh
  68380. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68381. */
  68382. static CreateIcoSphere(name: string, options: {
  68383. radius?: number;
  68384. radiusX?: number;
  68385. radiusY?: number;
  68386. radiusZ?: number;
  68387. flat?: boolean;
  68388. subdivisions?: number;
  68389. sideOrientation?: number;
  68390. frontUVs?: Vector4;
  68391. backUVs?: Vector4;
  68392. updatable?: boolean;
  68393. }, scene?: Nullable<Scene>): Mesh;
  68394. /**
  68395. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68396. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68397. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68398. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68399. * * 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
  68400. * * 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
  68401. * * 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
  68402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68405. * * 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
  68406. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68407. * * 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
  68408. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68410. * @param name defines the name of the mesh
  68411. * @param options defines the options used to create the mesh
  68412. * @param scene defines the hosting scene
  68413. * @returns the ribbon mesh
  68414. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68416. */
  68417. static CreateRibbon(name: string, options: {
  68418. pathArray: Vector3[][];
  68419. closeArray?: boolean;
  68420. closePath?: boolean;
  68421. offset?: number;
  68422. updatable?: boolean;
  68423. sideOrientation?: number;
  68424. frontUVs?: Vector4;
  68425. backUVs?: Vector4;
  68426. instance?: Mesh;
  68427. invertUV?: boolean;
  68428. uvs?: Vector2[];
  68429. colors?: Color4[];
  68430. }, scene?: Nullable<Scene>): Mesh;
  68431. /**
  68432. * Creates a cylinder or a cone mesh
  68433. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68434. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68435. * * 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.
  68436. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68437. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68438. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68439. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68440. * * 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).
  68441. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68442. * * 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).
  68443. * * 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
  68444. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68445. * * 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
  68446. * * 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.
  68447. * * If `enclose` is false, a ring surface is one element.
  68448. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68449. * * 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
  68450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68453. * @param name defines the name of the mesh
  68454. * @param options defines the options used to create the mesh
  68455. * @param scene defines the hosting scene
  68456. * @returns the cylinder mesh
  68457. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68458. */
  68459. static CreateCylinder(name: string, options: {
  68460. height?: number;
  68461. diameterTop?: number;
  68462. diameterBottom?: number;
  68463. diameter?: number;
  68464. tessellation?: number;
  68465. subdivisions?: number;
  68466. arc?: number;
  68467. faceColors?: Color4[];
  68468. faceUV?: Vector4[];
  68469. updatable?: boolean;
  68470. hasRings?: boolean;
  68471. enclose?: boolean;
  68472. cap?: number;
  68473. sideOrientation?: number;
  68474. frontUVs?: Vector4;
  68475. backUVs?: Vector4;
  68476. }, scene?: Nullable<Scene>): Mesh;
  68477. /**
  68478. * Creates a torus mesh
  68479. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68480. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68481. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68485. * @param name defines the name of the mesh
  68486. * @param options defines the options used to create the mesh
  68487. * @param scene defines the hosting scene
  68488. * @returns the torus mesh
  68489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68490. */
  68491. static CreateTorus(name: string, options: {
  68492. diameter?: number;
  68493. thickness?: number;
  68494. tessellation?: number;
  68495. updatable?: boolean;
  68496. sideOrientation?: number;
  68497. frontUVs?: Vector4;
  68498. backUVs?: Vector4;
  68499. }, scene?: Nullable<Scene>): Mesh;
  68500. /**
  68501. * Creates a torus knot mesh
  68502. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68503. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68504. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68505. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68509. * @param name defines the name of the mesh
  68510. * @param options defines the options used to create the mesh
  68511. * @param scene defines the hosting scene
  68512. * @returns the torus knot mesh
  68513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68514. */
  68515. static CreateTorusKnot(name: string, options: {
  68516. radius?: number;
  68517. tube?: number;
  68518. radialSegments?: number;
  68519. tubularSegments?: number;
  68520. p?: number;
  68521. q?: number;
  68522. updatable?: boolean;
  68523. sideOrientation?: number;
  68524. frontUVs?: Vector4;
  68525. backUVs?: Vector4;
  68526. }, scene?: Nullable<Scene>): Mesh;
  68527. /**
  68528. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68529. * * 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
  68530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68531. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68532. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68533. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68535. * * 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
  68536. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68539. * @param name defines the name of the new line system
  68540. * @param options defines the options used to create the line system
  68541. * @param scene defines the hosting scene
  68542. * @returns a new line system mesh
  68543. */
  68544. static CreateLineSystem(name: string, options: {
  68545. lines: Vector3[][];
  68546. updatable?: boolean;
  68547. instance?: Nullable<LinesMesh>;
  68548. colors?: Nullable<Color4[][]>;
  68549. useVertexAlpha?: boolean;
  68550. }, scene: Nullable<Scene>): LinesMesh;
  68551. /**
  68552. * Creates a line mesh
  68553. * 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
  68554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68555. * * The parameter `points` is an array successive Vector3
  68556. * * 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
  68557. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68559. * * When updating an instance, remember that only point positions can change, not the number of points
  68560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68562. * @param name defines the name of the new line system
  68563. * @param options defines the options used to create the line system
  68564. * @param scene defines the hosting scene
  68565. * @returns a new line mesh
  68566. */
  68567. static CreateLines(name: string, options: {
  68568. points: Vector3[];
  68569. updatable?: boolean;
  68570. instance?: Nullable<LinesMesh>;
  68571. colors?: Color4[];
  68572. useVertexAlpha?: boolean;
  68573. }, scene?: Nullable<Scene>): LinesMesh;
  68574. /**
  68575. * Creates a dashed line mesh
  68576. * * 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
  68577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68578. * * The parameter `points` is an array successive Vector3
  68579. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68580. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68581. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68582. * * 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
  68583. * * When updating an instance, remember that only point positions can change, not the number of points
  68584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68585. * @param name defines the name of the mesh
  68586. * @param options defines the options used to create the mesh
  68587. * @param scene defines the hosting scene
  68588. * @returns the dashed line mesh
  68589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68590. */
  68591. static CreateDashedLines(name: string, options: {
  68592. points: Vector3[];
  68593. dashSize?: number;
  68594. gapSize?: number;
  68595. dashNb?: number;
  68596. updatable?: boolean;
  68597. instance?: LinesMesh;
  68598. }, scene?: Nullable<Scene>): LinesMesh;
  68599. /**
  68600. * 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.
  68601. * * 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.
  68602. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68603. * * 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.
  68604. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68605. * * 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
  68606. * * 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
  68607. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68612. * @param name defines the name of the mesh
  68613. * @param options defines the options used to create the mesh
  68614. * @param scene defines the hosting scene
  68615. * @returns the extruded shape mesh
  68616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68618. */
  68619. static ExtrudeShape(name: string, options: {
  68620. shape: Vector3[];
  68621. path: Vector3[];
  68622. scale?: number;
  68623. rotation?: number;
  68624. cap?: number;
  68625. updatable?: boolean;
  68626. sideOrientation?: number;
  68627. frontUVs?: Vector4;
  68628. backUVs?: Vector4;
  68629. instance?: Mesh;
  68630. invertUV?: boolean;
  68631. }, scene?: Nullable<Scene>): Mesh;
  68632. /**
  68633. * Creates an custom extruded shape mesh.
  68634. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68635. * * 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.
  68636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68637. * * 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
  68638. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68639. * * 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
  68640. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68641. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68642. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68643. * * 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
  68644. * * 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
  68645. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68650. * @param name defines the name of the mesh
  68651. * @param options defines the options used to create the mesh
  68652. * @param scene defines the hosting scene
  68653. * @returns the custom extruded shape mesh
  68654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68657. */
  68658. static ExtrudeShapeCustom(name: string, options: {
  68659. shape: Vector3[];
  68660. path: Vector3[];
  68661. scaleFunction?: any;
  68662. rotationFunction?: any;
  68663. ribbonCloseArray?: boolean;
  68664. ribbonClosePath?: boolean;
  68665. cap?: number;
  68666. updatable?: boolean;
  68667. sideOrientation?: number;
  68668. frontUVs?: Vector4;
  68669. backUVs?: Vector4;
  68670. instance?: Mesh;
  68671. invertUV?: boolean;
  68672. }, scene?: Nullable<Scene>): Mesh;
  68673. /**
  68674. * Creates lathe mesh.
  68675. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68676. * * 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
  68677. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68678. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68679. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68680. * * 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
  68681. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68682. * * 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
  68683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68687. * @param name defines the name of the mesh
  68688. * @param options defines the options used to create the mesh
  68689. * @param scene defines the hosting scene
  68690. * @returns the lathe mesh
  68691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68692. */
  68693. static CreateLathe(name: string, options: {
  68694. shape: Vector3[];
  68695. radius?: number;
  68696. tessellation?: number;
  68697. clip?: number;
  68698. arc?: number;
  68699. closed?: boolean;
  68700. updatable?: boolean;
  68701. sideOrientation?: number;
  68702. frontUVs?: Vector4;
  68703. backUVs?: Vector4;
  68704. cap?: number;
  68705. invertUV?: boolean;
  68706. }, scene?: Nullable<Scene>): Mesh;
  68707. /**
  68708. * Creates a tiled plane mesh
  68709. * * You can set a limited pattern arrangement with the tiles
  68710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68713. * @param name defines the name of the mesh
  68714. * @param options defines the options used to create the mesh
  68715. * @param scene defines the hosting scene
  68716. * @returns the plane mesh
  68717. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68718. */
  68719. static CreateTiledPlane(name: string, options: {
  68720. pattern?: number;
  68721. tileSize?: number;
  68722. tileWidth?: number;
  68723. tileHeight?: number;
  68724. size?: number;
  68725. width?: number;
  68726. height?: number;
  68727. alignHorizontal?: number;
  68728. alignVertical?: number;
  68729. sideOrientation?: number;
  68730. frontUVs?: Vector4;
  68731. backUVs?: Vector4;
  68732. updatable?: boolean;
  68733. }, scene?: Nullable<Scene>): Mesh;
  68734. /**
  68735. * Creates a plane mesh
  68736. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68737. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68738. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68742. * @param name defines the name of the mesh
  68743. * @param options defines the options used to create the mesh
  68744. * @param scene defines the hosting scene
  68745. * @returns the plane mesh
  68746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68747. */
  68748. static CreatePlane(name: string, options: {
  68749. size?: number;
  68750. width?: number;
  68751. height?: number;
  68752. sideOrientation?: number;
  68753. frontUVs?: Vector4;
  68754. backUVs?: Vector4;
  68755. updatable?: boolean;
  68756. sourcePlane?: Plane;
  68757. }, scene?: Nullable<Scene>): Mesh;
  68758. /**
  68759. * Creates a ground mesh
  68760. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68761. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68763. * @param name defines the name of the mesh
  68764. * @param options defines the options used to create the mesh
  68765. * @param scene defines the hosting scene
  68766. * @returns the ground mesh
  68767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68768. */
  68769. static CreateGround(name: string, options: {
  68770. width?: number;
  68771. height?: number;
  68772. subdivisions?: number;
  68773. subdivisionsX?: number;
  68774. subdivisionsY?: number;
  68775. updatable?: boolean;
  68776. }, scene?: Nullable<Scene>): Mesh;
  68777. /**
  68778. * Creates a tiled ground mesh
  68779. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68780. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68781. * * 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
  68782. * * 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
  68783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68784. * @param name defines the name of the mesh
  68785. * @param options defines the options used to create the mesh
  68786. * @param scene defines the hosting scene
  68787. * @returns the tiled ground mesh
  68788. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68789. */
  68790. static CreateTiledGround(name: string, options: {
  68791. xmin: number;
  68792. zmin: number;
  68793. xmax: number;
  68794. zmax: number;
  68795. subdivisions?: {
  68796. w: number;
  68797. h: number;
  68798. };
  68799. precision?: {
  68800. w: number;
  68801. h: number;
  68802. };
  68803. updatable?: boolean;
  68804. }, scene?: Nullable<Scene>): Mesh;
  68805. /**
  68806. * Creates a ground mesh from a height map
  68807. * * The parameter `url` sets the URL of the height map image resource.
  68808. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68809. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68810. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68811. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68812. * * 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.
  68813. * * 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).
  68814. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68816. * @param name defines the name of the mesh
  68817. * @param url defines the url to the height map
  68818. * @param options defines the options used to create the mesh
  68819. * @param scene defines the hosting scene
  68820. * @returns the ground mesh
  68821. * @see https://doc.babylonjs.com/babylon101/height_map
  68822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68823. */
  68824. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68825. width?: number;
  68826. height?: number;
  68827. subdivisions?: number;
  68828. minHeight?: number;
  68829. maxHeight?: number;
  68830. colorFilter?: Color3;
  68831. alphaFilter?: number;
  68832. updatable?: boolean;
  68833. onReady?: (mesh: GroundMesh) => void;
  68834. }, scene?: Nullable<Scene>): GroundMesh;
  68835. /**
  68836. * Creates a polygon mesh
  68837. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68838. * * 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
  68839. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68842. * * Remember you can only change the shape positions, not their number when updating a polygon
  68843. * @param name defines the name of the mesh
  68844. * @param options defines the options used to create the mesh
  68845. * @param scene defines the hosting scene
  68846. * @param earcutInjection can be used to inject your own earcut reference
  68847. * @returns the polygon mesh
  68848. */
  68849. static CreatePolygon(name: string, options: {
  68850. shape: Vector3[];
  68851. holes?: Vector3[][];
  68852. depth?: number;
  68853. faceUV?: Vector4[];
  68854. faceColors?: Color4[];
  68855. updatable?: boolean;
  68856. sideOrientation?: number;
  68857. frontUVs?: Vector4;
  68858. backUVs?: Vector4;
  68859. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68860. /**
  68861. * Creates an extruded polygon mesh, with depth in the Y direction.
  68862. * * 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)
  68863. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68864. * @param name defines the name of the mesh
  68865. * @param options defines the options used to create the mesh
  68866. * @param scene defines the hosting scene
  68867. * @param earcutInjection can be used to inject your own earcut reference
  68868. * @returns the polygon mesh
  68869. */
  68870. static ExtrudePolygon(name: string, options: {
  68871. shape: Vector3[];
  68872. holes?: Vector3[][];
  68873. depth?: number;
  68874. faceUV?: Vector4[];
  68875. faceColors?: Color4[];
  68876. updatable?: boolean;
  68877. sideOrientation?: number;
  68878. frontUVs?: Vector4;
  68879. backUVs?: Vector4;
  68880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68881. /**
  68882. * Creates a tube mesh.
  68883. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68884. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68885. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68886. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68887. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68888. * * 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)
  68889. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68890. * * 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
  68891. * * 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
  68892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68896. * @param name defines the name of the mesh
  68897. * @param options defines the options used to create the mesh
  68898. * @param scene defines the hosting scene
  68899. * @returns the tube mesh
  68900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68901. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68902. */
  68903. static CreateTube(name: string, options: {
  68904. path: Vector3[];
  68905. radius?: number;
  68906. tessellation?: number;
  68907. radiusFunction?: {
  68908. (i: number, distance: number): number;
  68909. };
  68910. cap?: number;
  68911. arc?: number;
  68912. updatable?: boolean;
  68913. sideOrientation?: number;
  68914. frontUVs?: Vector4;
  68915. backUVs?: Vector4;
  68916. instance?: Mesh;
  68917. invertUV?: boolean;
  68918. }, scene?: Nullable<Scene>): Mesh;
  68919. /**
  68920. * Creates a polyhedron mesh
  68921. * * 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
  68922. * * The parameter `size` (positive float, default 1) sets the polygon size
  68923. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68924. * * 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`
  68925. * * 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
  68926. * * 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)`)
  68927. * * 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
  68928. * * 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
  68929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68932. * @param name defines the name of the mesh
  68933. * @param options defines the options used to create the mesh
  68934. * @param scene defines the hosting scene
  68935. * @returns the polyhedron mesh
  68936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68937. */
  68938. static CreatePolyhedron(name: string, options: {
  68939. type?: number;
  68940. size?: number;
  68941. sizeX?: number;
  68942. sizeY?: number;
  68943. sizeZ?: number;
  68944. custom?: any;
  68945. faceUV?: Vector4[];
  68946. faceColors?: Color4[];
  68947. flat?: boolean;
  68948. updatable?: boolean;
  68949. sideOrientation?: number;
  68950. frontUVs?: Vector4;
  68951. backUVs?: Vector4;
  68952. }, scene?: Nullable<Scene>): Mesh;
  68953. /**
  68954. * Creates a decal mesh.
  68955. * 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
  68956. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68957. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68958. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68959. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68960. * @param name defines the name of the mesh
  68961. * @param sourceMesh defines the mesh where the decal must be applied
  68962. * @param options defines the options used to create the mesh
  68963. * @param scene defines the hosting scene
  68964. * @returns the decal mesh
  68965. * @see https://doc.babylonjs.com/how_to/decals
  68966. */
  68967. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68968. position?: Vector3;
  68969. normal?: Vector3;
  68970. size?: Vector3;
  68971. angle?: number;
  68972. }): Mesh;
  68973. }
  68974. }
  68975. declare module "babylonjs/Meshes/meshSimplification" {
  68976. import { Mesh } from "babylonjs/Meshes/mesh";
  68977. /**
  68978. * A simplifier interface for future simplification implementations
  68979. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68980. */
  68981. export interface ISimplifier {
  68982. /**
  68983. * Simplification of a given mesh according to the given settings.
  68984. * Since this requires computation, it is assumed that the function runs async.
  68985. * @param settings The settings of the simplification, including quality and distance
  68986. * @param successCallback A callback that will be called after the mesh was simplified.
  68987. * @param errorCallback in case of an error, this callback will be called. optional.
  68988. */
  68989. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68990. }
  68991. /**
  68992. * Expected simplification settings.
  68993. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68994. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68995. */
  68996. export interface ISimplificationSettings {
  68997. /**
  68998. * Gets or sets the expected quality
  68999. */
  69000. quality: number;
  69001. /**
  69002. * Gets or sets the distance when this optimized version should be used
  69003. */
  69004. distance: number;
  69005. /**
  69006. * Gets an already optimized mesh
  69007. */
  69008. optimizeMesh?: boolean;
  69009. }
  69010. /**
  69011. * Class used to specify simplification options
  69012. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69013. */
  69014. export class SimplificationSettings implements ISimplificationSettings {
  69015. /** expected quality */
  69016. quality: number;
  69017. /** distance when this optimized version should be used */
  69018. distance: number;
  69019. /** already optimized mesh */
  69020. optimizeMesh?: boolean | undefined;
  69021. /**
  69022. * Creates a SimplificationSettings
  69023. * @param quality expected quality
  69024. * @param distance distance when this optimized version should be used
  69025. * @param optimizeMesh already optimized mesh
  69026. */
  69027. constructor(
  69028. /** expected quality */
  69029. quality: number,
  69030. /** distance when this optimized version should be used */
  69031. distance: number,
  69032. /** already optimized mesh */
  69033. optimizeMesh?: boolean | undefined);
  69034. }
  69035. /**
  69036. * Interface used to define a simplification task
  69037. */
  69038. export interface ISimplificationTask {
  69039. /**
  69040. * Array of settings
  69041. */
  69042. settings: Array<ISimplificationSettings>;
  69043. /**
  69044. * Simplification type
  69045. */
  69046. simplificationType: SimplificationType;
  69047. /**
  69048. * Mesh to simplify
  69049. */
  69050. mesh: Mesh;
  69051. /**
  69052. * Callback called on success
  69053. */
  69054. successCallback?: () => void;
  69055. /**
  69056. * Defines if parallel processing can be used
  69057. */
  69058. parallelProcessing: boolean;
  69059. }
  69060. /**
  69061. * Queue used to order the simplification tasks
  69062. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69063. */
  69064. export class SimplificationQueue {
  69065. private _simplificationArray;
  69066. /**
  69067. * Gets a boolean indicating that the process is still running
  69068. */
  69069. running: boolean;
  69070. /**
  69071. * Creates a new queue
  69072. */
  69073. constructor();
  69074. /**
  69075. * Adds a new simplification task
  69076. * @param task defines a task to add
  69077. */
  69078. addTask(task: ISimplificationTask): void;
  69079. /**
  69080. * Execute next task
  69081. */
  69082. executeNext(): void;
  69083. /**
  69084. * Execute a simplification task
  69085. * @param task defines the task to run
  69086. */
  69087. runSimplification(task: ISimplificationTask): void;
  69088. private getSimplifier;
  69089. }
  69090. /**
  69091. * The implemented types of simplification
  69092. * At the moment only Quadratic Error Decimation is implemented
  69093. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69094. */
  69095. export enum SimplificationType {
  69096. /** Quadratic error decimation */
  69097. QUADRATIC = 0
  69098. }
  69099. /**
  69100. * An implementation of the Quadratic Error simplification algorithm.
  69101. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69102. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69103. * @author RaananW
  69104. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69105. */
  69106. export class QuadraticErrorSimplification implements ISimplifier {
  69107. private _mesh;
  69108. private triangles;
  69109. private vertices;
  69110. private references;
  69111. private _reconstructedMesh;
  69112. /** Gets or sets the number pf sync interations */
  69113. syncIterations: number;
  69114. /** Gets or sets the aggressiveness of the simplifier */
  69115. aggressiveness: number;
  69116. /** Gets or sets the number of allowed iterations for decimation */
  69117. decimationIterations: number;
  69118. /** Gets or sets the espilon to use for bounding box computation */
  69119. boundingBoxEpsilon: number;
  69120. /**
  69121. * Creates a new QuadraticErrorSimplification
  69122. * @param _mesh defines the target mesh
  69123. */
  69124. constructor(_mesh: Mesh);
  69125. /**
  69126. * Simplification of a given mesh according to the given settings.
  69127. * Since this requires computation, it is assumed that the function runs async.
  69128. * @param settings The settings of the simplification, including quality and distance
  69129. * @param successCallback A callback that will be called after the mesh was simplified.
  69130. */
  69131. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69132. private runDecimation;
  69133. private initWithMesh;
  69134. private init;
  69135. private reconstructMesh;
  69136. private initDecimatedMesh;
  69137. private isFlipped;
  69138. private updateTriangles;
  69139. private identifyBorder;
  69140. private updateMesh;
  69141. private vertexError;
  69142. private calculateError;
  69143. }
  69144. }
  69145. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69146. import { Scene } from "babylonjs/scene";
  69147. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69148. import { ISceneComponent } from "babylonjs/sceneComponent";
  69149. module "babylonjs/scene" {
  69150. interface Scene {
  69151. /** @hidden (Backing field) */
  69152. _simplificationQueue: SimplificationQueue;
  69153. /**
  69154. * Gets or sets the simplification queue attached to the scene
  69155. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69156. */
  69157. simplificationQueue: SimplificationQueue;
  69158. }
  69159. }
  69160. module "babylonjs/Meshes/mesh" {
  69161. interface Mesh {
  69162. /**
  69163. * Simplify the mesh according to the given array of settings.
  69164. * Function will return immediately and will simplify async
  69165. * @param settings a collection of simplification settings
  69166. * @param parallelProcessing should all levels calculate parallel or one after the other
  69167. * @param simplificationType the type of simplification to run
  69168. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69169. * @returns the current mesh
  69170. */
  69171. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69172. }
  69173. }
  69174. /**
  69175. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69176. * created in a scene
  69177. */
  69178. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69179. /**
  69180. * The component name helpfull to identify the component in the list of scene components.
  69181. */
  69182. readonly name: string;
  69183. /**
  69184. * The scene the component belongs to.
  69185. */
  69186. scene: Scene;
  69187. /**
  69188. * Creates a new instance of the component for the given scene
  69189. * @param scene Defines the scene to register the component in
  69190. */
  69191. constructor(scene: Scene);
  69192. /**
  69193. * Registers the component in a given scene
  69194. */
  69195. register(): void;
  69196. /**
  69197. * Rebuilds the elements related to this component in case of
  69198. * context lost for instance.
  69199. */
  69200. rebuild(): void;
  69201. /**
  69202. * Disposes the component and the associated ressources
  69203. */
  69204. dispose(): void;
  69205. private _beforeCameraUpdate;
  69206. }
  69207. }
  69208. declare module "babylonjs/Meshes/Builders/index" {
  69209. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69210. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69211. export * from "babylonjs/Meshes/Builders/discBuilder";
  69212. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69213. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69214. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69215. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69216. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69217. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69218. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69219. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69220. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69221. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69222. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69223. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69224. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69225. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69226. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69227. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69228. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69229. }
  69230. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69231. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69232. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69233. import { Matrix } from "babylonjs/Maths/math.vector";
  69234. module "babylonjs/Meshes/mesh" {
  69235. interface Mesh {
  69236. /**
  69237. * Creates a new thin instance
  69238. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69239. * @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
  69240. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69241. */
  69242. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69243. /**
  69244. * Adds the transformation (matrix) of the current mesh as a thin instance
  69245. * @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
  69246. * @returns the thin instance index number
  69247. */
  69248. thinInstanceAddSelf(refresh: boolean): number;
  69249. /**
  69250. * Registers a custom attribute to be used with thin instances
  69251. * @param kind name of the attribute
  69252. * @param stride size in floats of the attribute
  69253. */
  69254. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69255. /**
  69256. * Sets the matrix of a thin instance
  69257. * @param index index of the thin instance
  69258. * @param matrix matrix to set
  69259. * @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
  69260. */
  69261. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69262. /**
  69263. * Sets the value of a custom attribute for a thin instance
  69264. * @param kind name of the attribute
  69265. * @param index index of the thin instance
  69266. * @param value value to set
  69267. * @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
  69268. */
  69269. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69270. /**
  69271. * 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.
  69272. */
  69273. thinInstanceCount: number;
  69274. /**
  69275. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69276. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69277. * @param buffer buffer to set
  69278. * @param stride size in floats of each value of the buffer
  69279. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69280. */
  69281. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69282. /**
  69283. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69284. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69285. */
  69286. thinInstanceBufferUpdated(kind: string): void;
  69287. /**
  69288. * Refreshes the bounding info, taking into account all the thin instances defined
  69289. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69290. */
  69291. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69292. /** @hidden */
  69293. _thinInstanceInitializeUserStorage(): void;
  69294. /** @hidden */
  69295. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69296. /** @hidden */
  69297. _userThinInstanceBuffersStorage: {
  69298. data: {
  69299. [key: string]: Float32Array;
  69300. };
  69301. sizes: {
  69302. [key: string]: number;
  69303. };
  69304. vertexBuffers: {
  69305. [key: string]: Nullable<VertexBuffer>;
  69306. };
  69307. strides: {
  69308. [key: string]: number;
  69309. };
  69310. };
  69311. }
  69312. }
  69313. }
  69314. declare module "babylonjs/Meshes/index" {
  69315. export * from "babylonjs/Meshes/abstractMesh";
  69316. export * from "babylonjs/Meshes/buffer";
  69317. export * from "babylonjs/Meshes/Compression/index";
  69318. export * from "babylonjs/Meshes/csg";
  69319. export * from "babylonjs/Meshes/geometry";
  69320. export * from "babylonjs/Meshes/groundMesh";
  69321. export * from "babylonjs/Meshes/trailMesh";
  69322. export * from "babylonjs/Meshes/instancedMesh";
  69323. export * from "babylonjs/Meshes/linesMesh";
  69324. export * from "babylonjs/Meshes/mesh";
  69325. export * from "babylonjs/Meshes/mesh.vertexData";
  69326. export * from "babylonjs/Meshes/meshBuilder";
  69327. export * from "babylonjs/Meshes/meshSimplification";
  69328. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69329. export * from "babylonjs/Meshes/polygonMesh";
  69330. export * from "babylonjs/Meshes/subMesh";
  69331. export * from "babylonjs/Meshes/meshLODLevel";
  69332. export * from "babylonjs/Meshes/transformNode";
  69333. export * from "babylonjs/Meshes/Builders/index";
  69334. export * from "babylonjs/Meshes/dataBuffer";
  69335. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69336. import "babylonjs/Meshes/thinInstanceMesh";
  69337. export * from "babylonjs/Meshes/thinInstanceMesh";
  69338. }
  69339. declare module "babylonjs/Morph/index" {
  69340. export * from "babylonjs/Morph/morphTarget";
  69341. export * from "babylonjs/Morph/morphTargetManager";
  69342. }
  69343. declare module "babylonjs/Navigation/INavigationEngine" {
  69344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69345. import { Vector3 } from "babylonjs/Maths/math";
  69346. import { Mesh } from "babylonjs/Meshes/mesh";
  69347. import { Scene } from "babylonjs/scene";
  69348. /**
  69349. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69350. */
  69351. export interface INavigationEnginePlugin {
  69352. /**
  69353. * plugin name
  69354. */
  69355. name: string;
  69356. /**
  69357. * Creates a navigation mesh
  69358. * @param meshes array of all the geometry used to compute the navigatio mesh
  69359. * @param parameters bunch of parameters used to filter geometry
  69360. */
  69361. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69362. /**
  69363. * Create a navigation mesh debug mesh
  69364. * @param scene is where the mesh will be added
  69365. * @returns debug display mesh
  69366. */
  69367. createDebugNavMesh(scene: Scene): Mesh;
  69368. /**
  69369. * Get a navigation mesh constrained position, closest to the parameter position
  69370. * @param position world position
  69371. * @returns the closest point to position constrained by the navigation mesh
  69372. */
  69373. getClosestPoint(position: Vector3): Vector3;
  69374. /**
  69375. * Get a navigation mesh constrained position, closest to the parameter position
  69376. * @param position world position
  69377. * @param result output the closest point to position constrained by the navigation mesh
  69378. */
  69379. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69380. /**
  69381. * Get a navigation mesh constrained position, within a particular radius
  69382. * @param position world position
  69383. * @param maxRadius the maximum distance to the constrained world position
  69384. * @returns the closest point to position constrained by the navigation mesh
  69385. */
  69386. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69387. /**
  69388. * Get a navigation mesh constrained position, within a particular radius
  69389. * @param position world position
  69390. * @param maxRadius the maximum distance to the constrained world position
  69391. * @param result output the closest point to position constrained by the navigation mesh
  69392. */
  69393. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69394. /**
  69395. * Compute the final position from a segment made of destination-position
  69396. * @param position world position
  69397. * @param destination world position
  69398. * @returns the resulting point along the navmesh
  69399. */
  69400. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69401. /**
  69402. * Compute the final position from a segment made of destination-position
  69403. * @param position world position
  69404. * @param destination world position
  69405. * @param result output the resulting point along the navmesh
  69406. */
  69407. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69408. /**
  69409. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69410. * @param start world position
  69411. * @param end world position
  69412. * @returns array containing world position composing the path
  69413. */
  69414. computePath(start: Vector3, end: Vector3): Vector3[];
  69415. /**
  69416. * If this plugin is supported
  69417. * @returns true if plugin is supported
  69418. */
  69419. isSupported(): boolean;
  69420. /**
  69421. * Create a new Crowd so you can add agents
  69422. * @param maxAgents the maximum agent count in the crowd
  69423. * @param maxAgentRadius the maximum radius an agent can have
  69424. * @param scene to attach the crowd to
  69425. * @returns the crowd you can add agents to
  69426. */
  69427. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69428. /**
  69429. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69430. * The queries will try to find a solution within those bounds
  69431. * default is (1,1,1)
  69432. * @param extent x,y,z value that define the extent around the queries point of reference
  69433. */
  69434. setDefaultQueryExtent(extent: Vector3): void;
  69435. /**
  69436. * Get the Bounding box extent specified by setDefaultQueryExtent
  69437. * @returns the box extent values
  69438. */
  69439. getDefaultQueryExtent(): Vector3;
  69440. /**
  69441. * build the navmesh from a previously saved state using getNavmeshData
  69442. * @param data the Uint8Array returned by getNavmeshData
  69443. */
  69444. buildFromNavmeshData(data: Uint8Array): void;
  69445. /**
  69446. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69447. * @returns data the Uint8Array that can be saved and reused
  69448. */
  69449. getNavmeshData(): Uint8Array;
  69450. /**
  69451. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69452. * @param result output the box extent values
  69453. */
  69454. getDefaultQueryExtentToRef(result: Vector3): void;
  69455. /**
  69456. * Release all resources
  69457. */
  69458. dispose(): void;
  69459. }
  69460. /**
  69461. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69462. */
  69463. export interface ICrowd {
  69464. /**
  69465. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69466. * You can attach anything to that node. The node position is updated in the scene update tick.
  69467. * @param pos world position that will be constrained by the navigation mesh
  69468. * @param parameters agent parameters
  69469. * @param transform hooked to the agent that will be update by the scene
  69470. * @returns agent index
  69471. */
  69472. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69473. /**
  69474. * Returns the agent position in world space
  69475. * @param index agent index returned by addAgent
  69476. * @returns world space position
  69477. */
  69478. getAgentPosition(index: number): Vector3;
  69479. /**
  69480. * Gets the agent position result in world space
  69481. * @param index agent index returned by addAgent
  69482. * @param result output world space position
  69483. */
  69484. getAgentPositionToRef(index: number, result: Vector3): void;
  69485. /**
  69486. * Gets the agent velocity in world space
  69487. * @param index agent index returned by addAgent
  69488. * @returns world space velocity
  69489. */
  69490. getAgentVelocity(index: number): Vector3;
  69491. /**
  69492. * Gets the agent velocity result in world space
  69493. * @param index agent index returned by addAgent
  69494. * @param result output world space velocity
  69495. */
  69496. getAgentVelocityToRef(index: number, result: Vector3): void;
  69497. /**
  69498. * remove a particular agent previously created
  69499. * @param index agent index returned by addAgent
  69500. */
  69501. removeAgent(index: number): void;
  69502. /**
  69503. * get the list of all agents attached to this crowd
  69504. * @returns list of agent indices
  69505. */
  69506. getAgents(): number[];
  69507. /**
  69508. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69509. * @param deltaTime in seconds
  69510. */
  69511. update(deltaTime: number): void;
  69512. /**
  69513. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69514. * @param index agent index returned by addAgent
  69515. * @param destination targeted world position
  69516. */
  69517. agentGoto(index: number, destination: Vector3): void;
  69518. /**
  69519. * Teleport the agent to a new position
  69520. * @param index agent index returned by addAgent
  69521. * @param destination targeted world position
  69522. */
  69523. agentTeleport(index: number, destination: Vector3): void;
  69524. /**
  69525. * Update agent parameters
  69526. * @param index agent index returned by addAgent
  69527. * @param parameters agent parameters
  69528. */
  69529. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69530. /**
  69531. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69532. * The queries will try to find a solution within those bounds
  69533. * default is (1,1,1)
  69534. * @param extent x,y,z value that define the extent around the queries point of reference
  69535. */
  69536. setDefaultQueryExtent(extent: Vector3): void;
  69537. /**
  69538. * Get the Bounding box extent specified by setDefaultQueryExtent
  69539. * @returns the box extent values
  69540. */
  69541. getDefaultQueryExtent(): Vector3;
  69542. /**
  69543. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69544. * @param result output the box extent values
  69545. */
  69546. getDefaultQueryExtentToRef(result: Vector3): void;
  69547. /**
  69548. * Release all resources
  69549. */
  69550. dispose(): void;
  69551. }
  69552. /**
  69553. * Configures an agent
  69554. */
  69555. export interface IAgentParameters {
  69556. /**
  69557. * Agent radius. [Limit: >= 0]
  69558. */
  69559. radius: number;
  69560. /**
  69561. * Agent height. [Limit: > 0]
  69562. */
  69563. height: number;
  69564. /**
  69565. * Maximum allowed acceleration. [Limit: >= 0]
  69566. */
  69567. maxAcceleration: number;
  69568. /**
  69569. * Maximum allowed speed. [Limit: >= 0]
  69570. */
  69571. maxSpeed: number;
  69572. /**
  69573. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69574. */
  69575. collisionQueryRange: number;
  69576. /**
  69577. * The path visibility optimization range. [Limit: > 0]
  69578. */
  69579. pathOptimizationRange: number;
  69580. /**
  69581. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69582. */
  69583. separationWeight: number;
  69584. }
  69585. /**
  69586. * Configures the navigation mesh creation
  69587. */
  69588. export interface INavMeshParameters {
  69589. /**
  69590. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69591. */
  69592. cs: number;
  69593. /**
  69594. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69595. */
  69596. ch: number;
  69597. /**
  69598. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69599. */
  69600. walkableSlopeAngle: number;
  69601. /**
  69602. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69603. * be considered walkable. [Limit: >= 3] [Units: vx]
  69604. */
  69605. walkableHeight: number;
  69606. /**
  69607. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69608. */
  69609. walkableClimb: number;
  69610. /**
  69611. * The distance to erode/shrink the walkable area of the heightfield away from
  69612. * obstructions. [Limit: >=0] [Units: vx]
  69613. */
  69614. walkableRadius: number;
  69615. /**
  69616. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69617. */
  69618. maxEdgeLen: number;
  69619. /**
  69620. * The maximum distance a simplfied contour's border edges should deviate
  69621. * the original raw contour. [Limit: >=0] [Units: vx]
  69622. */
  69623. maxSimplificationError: number;
  69624. /**
  69625. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69626. */
  69627. minRegionArea: number;
  69628. /**
  69629. * Any regions with a span count smaller than this value will, if possible,
  69630. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69631. */
  69632. mergeRegionArea: number;
  69633. /**
  69634. * The maximum number of vertices allowed for polygons generated during the
  69635. * contour to polygon conversion process. [Limit: >= 3]
  69636. */
  69637. maxVertsPerPoly: number;
  69638. /**
  69639. * Sets the sampling distance to use when generating the detail mesh.
  69640. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69641. */
  69642. detailSampleDist: number;
  69643. /**
  69644. * The maximum distance the detail mesh surface should deviate from heightfield
  69645. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69646. */
  69647. detailSampleMaxError: number;
  69648. }
  69649. }
  69650. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69651. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69652. import { Mesh } from "babylonjs/Meshes/mesh";
  69653. import { Scene } from "babylonjs/scene";
  69654. import { Vector3 } from "babylonjs/Maths/math";
  69655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69656. /**
  69657. * RecastJS navigation plugin
  69658. */
  69659. export class RecastJSPlugin implements INavigationEnginePlugin {
  69660. /**
  69661. * Reference to the Recast library
  69662. */
  69663. bjsRECAST: any;
  69664. /**
  69665. * plugin name
  69666. */
  69667. name: string;
  69668. /**
  69669. * the first navmesh created. We might extend this to support multiple navmeshes
  69670. */
  69671. navMesh: any;
  69672. /**
  69673. * Initializes the recastJS plugin
  69674. * @param recastInjection can be used to inject your own recast reference
  69675. */
  69676. constructor(recastInjection?: any);
  69677. /**
  69678. * Creates a navigation mesh
  69679. * @param meshes array of all the geometry used to compute the navigatio mesh
  69680. * @param parameters bunch of parameters used to filter geometry
  69681. */
  69682. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69683. /**
  69684. * Create a navigation mesh debug mesh
  69685. * @param scene is where the mesh will be added
  69686. * @returns debug display mesh
  69687. */
  69688. createDebugNavMesh(scene: Scene): Mesh;
  69689. /**
  69690. * Get a navigation mesh constrained position, closest to the parameter position
  69691. * @param position world position
  69692. * @returns the closest point to position constrained by the navigation mesh
  69693. */
  69694. getClosestPoint(position: Vector3): Vector3;
  69695. /**
  69696. * Get a navigation mesh constrained position, closest to the parameter position
  69697. * @param position world position
  69698. * @param result output the closest point to position constrained by the navigation mesh
  69699. */
  69700. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69701. /**
  69702. * Get a navigation mesh constrained position, within a particular radius
  69703. * @param position world position
  69704. * @param maxRadius the maximum distance to the constrained world position
  69705. * @returns the closest point to position constrained by the navigation mesh
  69706. */
  69707. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69708. /**
  69709. * Get a navigation mesh constrained position, within a particular radius
  69710. * @param position world position
  69711. * @param maxRadius the maximum distance to the constrained world position
  69712. * @param result output the closest point to position constrained by the navigation mesh
  69713. */
  69714. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69715. /**
  69716. * Compute the final position from a segment made of destination-position
  69717. * @param position world position
  69718. * @param destination world position
  69719. * @returns the resulting point along the navmesh
  69720. */
  69721. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69722. /**
  69723. * Compute the final position from a segment made of destination-position
  69724. * @param position world position
  69725. * @param destination world position
  69726. * @param result output the resulting point along the navmesh
  69727. */
  69728. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69729. /**
  69730. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69731. * @param start world position
  69732. * @param end world position
  69733. * @returns array containing world position composing the path
  69734. */
  69735. computePath(start: Vector3, end: Vector3): Vector3[];
  69736. /**
  69737. * Create a new Crowd so you can add agents
  69738. * @param maxAgents the maximum agent count in the crowd
  69739. * @param maxAgentRadius the maximum radius an agent can have
  69740. * @param scene to attach the crowd to
  69741. * @returns the crowd you can add agents to
  69742. */
  69743. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69744. /**
  69745. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69746. * The queries will try to find a solution within those bounds
  69747. * default is (1,1,1)
  69748. * @param extent x,y,z value that define the extent around the queries point of reference
  69749. */
  69750. setDefaultQueryExtent(extent: Vector3): void;
  69751. /**
  69752. * Get the Bounding box extent specified by setDefaultQueryExtent
  69753. * @returns the box extent values
  69754. */
  69755. getDefaultQueryExtent(): Vector3;
  69756. /**
  69757. * build the navmesh from a previously saved state using getNavmeshData
  69758. * @param data the Uint8Array returned by getNavmeshData
  69759. */
  69760. buildFromNavmeshData(data: Uint8Array): void;
  69761. /**
  69762. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69763. * @returns data the Uint8Array that can be saved and reused
  69764. */
  69765. getNavmeshData(): Uint8Array;
  69766. /**
  69767. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69768. * @param result output the box extent values
  69769. */
  69770. getDefaultQueryExtentToRef(result: Vector3): void;
  69771. /**
  69772. * Disposes
  69773. */
  69774. dispose(): void;
  69775. /**
  69776. * If this plugin is supported
  69777. * @returns true if plugin is supported
  69778. */
  69779. isSupported(): boolean;
  69780. }
  69781. /**
  69782. * Recast detour crowd implementation
  69783. */
  69784. export class RecastJSCrowd implements ICrowd {
  69785. /**
  69786. * Recast/detour plugin
  69787. */
  69788. bjsRECASTPlugin: RecastJSPlugin;
  69789. /**
  69790. * Link to the detour crowd
  69791. */
  69792. recastCrowd: any;
  69793. /**
  69794. * One transform per agent
  69795. */
  69796. transforms: TransformNode[];
  69797. /**
  69798. * All agents created
  69799. */
  69800. agents: number[];
  69801. /**
  69802. * Link to the scene is kept to unregister the crowd from the scene
  69803. */
  69804. private _scene;
  69805. /**
  69806. * Observer for crowd updates
  69807. */
  69808. private _onBeforeAnimationsObserver;
  69809. /**
  69810. * Constructor
  69811. * @param plugin recastJS plugin
  69812. * @param maxAgents the maximum agent count in the crowd
  69813. * @param maxAgentRadius the maximum radius an agent can have
  69814. * @param scene to attach the crowd to
  69815. * @returns the crowd you can add agents to
  69816. */
  69817. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69818. /**
  69819. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69820. * You can attach anything to that node. The node position is updated in the scene update tick.
  69821. * @param pos world position that will be constrained by the navigation mesh
  69822. * @param parameters agent parameters
  69823. * @param transform hooked to the agent that will be update by the scene
  69824. * @returns agent index
  69825. */
  69826. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69827. /**
  69828. * Returns the agent position in world space
  69829. * @param index agent index returned by addAgent
  69830. * @returns world space position
  69831. */
  69832. getAgentPosition(index: number): Vector3;
  69833. /**
  69834. * Returns the agent position result in world space
  69835. * @param index agent index returned by addAgent
  69836. * @param result output world space position
  69837. */
  69838. getAgentPositionToRef(index: number, result: Vector3): void;
  69839. /**
  69840. * Returns the agent velocity in world space
  69841. * @param index agent index returned by addAgent
  69842. * @returns world space velocity
  69843. */
  69844. getAgentVelocity(index: number): Vector3;
  69845. /**
  69846. * Returns the agent velocity result in world space
  69847. * @param index agent index returned by addAgent
  69848. * @param result output world space velocity
  69849. */
  69850. getAgentVelocityToRef(index: number, result: Vector3): void;
  69851. /**
  69852. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69853. * @param index agent index returned by addAgent
  69854. * @param destination targeted world position
  69855. */
  69856. agentGoto(index: number, destination: Vector3): void;
  69857. /**
  69858. * Teleport the agent to a new position
  69859. * @param index agent index returned by addAgent
  69860. * @param destination targeted world position
  69861. */
  69862. agentTeleport(index: number, destination: Vector3): void;
  69863. /**
  69864. * Update agent parameters
  69865. * @param index agent index returned by addAgent
  69866. * @param parameters agent parameters
  69867. */
  69868. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69869. /**
  69870. * remove a particular agent previously created
  69871. * @param index agent index returned by addAgent
  69872. */
  69873. removeAgent(index: number): void;
  69874. /**
  69875. * get the list of all agents attached to this crowd
  69876. * @returns list of agent indices
  69877. */
  69878. getAgents(): number[];
  69879. /**
  69880. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69881. * @param deltaTime in seconds
  69882. */
  69883. update(deltaTime: number): void;
  69884. /**
  69885. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69886. * The queries will try to find a solution within those bounds
  69887. * default is (1,1,1)
  69888. * @param extent x,y,z value that define the extent around the queries point of reference
  69889. */
  69890. setDefaultQueryExtent(extent: Vector3): void;
  69891. /**
  69892. * Get the Bounding box extent specified by setDefaultQueryExtent
  69893. * @returns the box extent values
  69894. */
  69895. getDefaultQueryExtent(): Vector3;
  69896. /**
  69897. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69898. * @param result output the box extent values
  69899. */
  69900. getDefaultQueryExtentToRef(result: Vector3): void;
  69901. /**
  69902. * Release all resources
  69903. */
  69904. dispose(): void;
  69905. }
  69906. }
  69907. declare module "babylonjs/Navigation/Plugins/index" {
  69908. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69909. }
  69910. declare module "babylonjs/Navigation/index" {
  69911. export * from "babylonjs/Navigation/INavigationEngine";
  69912. export * from "babylonjs/Navigation/Plugins/index";
  69913. }
  69914. declare module "babylonjs/Offline/database" {
  69915. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69916. /**
  69917. * Class used to enable access to IndexedDB
  69918. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69919. */
  69920. export class Database implements IOfflineProvider {
  69921. private _callbackManifestChecked;
  69922. private _currentSceneUrl;
  69923. private _db;
  69924. private _enableSceneOffline;
  69925. private _enableTexturesOffline;
  69926. private _manifestVersionFound;
  69927. private _mustUpdateRessources;
  69928. private _hasReachedQuota;
  69929. private _isSupported;
  69930. private _idbFactory;
  69931. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69932. private static IsUASupportingBlobStorage;
  69933. /**
  69934. * Gets a boolean indicating if Database storate is enabled (off by default)
  69935. */
  69936. static IDBStorageEnabled: boolean;
  69937. /**
  69938. * Gets a boolean indicating if scene must be saved in the database
  69939. */
  69940. get enableSceneOffline(): boolean;
  69941. /**
  69942. * Gets a boolean indicating if textures must be saved in the database
  69943. */
  69944. get enableTexturesOffline(): boolean;
  69945. /**
  69946. * Creates a new Database
  69947. * @param urlToScene defines the url to load the scene
  69948. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69949. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69950. */
  69951. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69952. private static _ParseURL;
  69953. private static _ReturnFullUrlLocation;
  69954. private _checkManifestFile;
  69955. /**
  69956. * Open the database and make it available
  69957. * @param successCallback defines the callback to call on success
  69958. * @param errorCallback defines the callback to call on error
  69959. */
  69960. open(successCallback: () => void, errorCallback: () => void): void;
  69961. /**
  69962. * Loads an image from the database
  69963. * @param url defines the url to load from
  69964. * @param image defines the target DOM image
  69965. */
  69966. loadImage(url: string, image: HTMLImageElement): void;
  69967. private _loadImageFromDBAsync;
  69968. private _saveImageIntoDBAsync;
  69969. private _checkVersionFromDB;
  69970. private _loadVersionFromDBAsync;
  69971. private _saveVersionIntoDBAsync;
  69972. /**
  69973. * Loads a file from database
  69974. * @param url defines the URL to load from
  69975. * @param sceneLoaded defines a callback to call on success
  69976. * @param progressCallBack defines a callback to call when progress changed
  69977. * @param errorCallback defines a callback to call on error
  69978. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69979. */
  69980. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69981. private _loadFileAsync;
  69982. private _saveFileAsync;
  69983. /**
  69984. * Validates if xhr data is correct
  69985. * @param xhr defines the request to validate
  69986. * @param dataType defines the expected data type
  69987. * @returns true if data is correct
  69988. */
  69989. private static _ValidateXHRData;
  69990. }
  69991. }
  69992. declare module "babylonjs/Offline/index" {
  69993. export * from "babylonjs/Offline/database";
  69994. export * from "babylonjs/Offline/IOfflineProvider";
  69995. }
  69996. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69997. /** @hidden */
  69998. export var gpuUpdateParticlesPixelShader: {
  69999. name: string;
  70000. shader: string;
  70001. };
  70002. }
  70003. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70004. /** @hidden */
  70005. export var gpuUpdateParticlesVertexShader: {
  70006. name: string;
  70007. shader: string;
  70008. };
  70009. }
  70010. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70011. /** @hidden */
  70012. export var clipPlaneFragmentDeclaration2: {
  70013. name: string;
  70014. shader: string;
  70015. };
  70016. }
  70017. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70018. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70019. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70020. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70021. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70022. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70023. /** @hidden */
  70024. export var gpuRenderParticlesPixelShader: {
  70025. name: string;
  70026. shader: string;
  70027. };
  70028. }
  70029. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70030. /** @hidden */
  70031. export var clipPlaneVertexDeclaration2: {
  70032. name: string;
  70033. shader: string;
  70034. };
  70035. }
  70036. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70037. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70038. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70039. /** @hidden */
  70040. export var gpuRenderParticlesVertexShader: {
  70041. name: string;
  70042. shader: string;
  70043. };
  70044. }
  70045. declare module "babylonjs/Particles/gpuParticleSystem" {
  70046. import { Nullable } from "babylonjs/types";
  70047. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70048. import { Observable } from "babylonjs/Misc/observable";
  70049. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70051. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70052. import { Scene, IDisposable } from "babylonjs/scene";
  70053. import { Effect } from "babylonjs/Materials/effect";
  70054. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70056. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70057. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70058. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70059. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70060. /**
  70061. * This represents a GPU particle system in Babylon
  70062. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70063. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70064. */
  70065. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70066. /**
  70067. * The layer mask we are rendering the particles through.
  70068. */
  70069. layerMask: number;
  70070. private _capacity;
  70071. private _activeCount;
  70072. private _currentActiveCount;
  70073. private _accumulatedCount;
  70074. private _renderEffect;
  70075. private _updateEffect;
  70076. private _buffer0;
  70077. private _buffer1;
  70078. private _spriteBuffer;
  70079. private _updateVAO;
  70080. private _renderVAO;
  70081. private _targetIndex;
  70082. private _sourceBuffer;
  70083. private _targetBuffer;
  70084. private _engine;
  70085. private _currentRenderId;
  70086. private _started;
  70087. private _stopped;
  70088. private _timeDelta;
  70089. private _randomTexture;
  70090. private _randomTexture2;
  70091. private _attributesStrideSize;
  70092. private _updateEffectOptions;
  70093. private _randomTextureSize;
  70094. private _actualFrame;
  70095. private _customEffect;
  70096. private readonly _rawTextureWidth;
  70097. /**
  70098. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70099. */
  70100. static get IsSupported(): boolean;
  70101. /**
  70102. * An event triggered when the system is disposed.
  70103. */
  70104. onDisposeObservable: Observable<IParticleSystem>;
  70105. /**
  70106. * Gets the maximum number of particles active at the same time.
  70107. * @returns The max number of active particles.
  70108. */
  70109. getCapacity(): number;
  70110. /**
  70111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70112. * to override the particles.
  70113. */
  70114. forceDepthWrite: boolean;
  70115. /**
  70116. * Gets or set the number of active particles
  70117. */
  70118. get activeParticleCount(): number;
  70119. set activeParticleCount(value: number);
  70120. private _preWarmDone;
  70121. /**
  70122. * Specifies if the particles are updated in emitter local space or world space.
  70123. */
  70124. isLocal: boolean;
  70125. /**
  70126. * Is this system ready to be used/rendered
  70127. * @return true if the system is ready
  70128. */
  70129. isReady(): boolean;
  70130. /**
  70131. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70132. * @returns True if it has been started, otherwise false.
  70133. */
  70134. isStarted(): boolean;
  70135. /**
  70136. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70137. * @returns True if it has been stopped, otherwise false.
  70138. */
  70139. isStopped(): boolean;
  70140. /**
  70141. * Gets a boolean indicating that the system is stopping
  70142. * @returns true if the system is currently stopping
  70143. */
  70144. isStopping(): boolean;
  70145. /**
  70146. * Gets the number of particles active at the same time.
  70147. * @returns The number of active particles.
  70148. */
  70149. getActiveCount(): number;
  70150. /**
  70151. * Starts the particle system and begins to emit
  70152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70153. */
  70154. start(delay?: number): void;
  70155. /**
  70156. * Stops the particle system.
  70157. */
  70158. stop(): void;
  70159. /**
  70160. * Remove all active particles
  70161. */
  70162. reset(): void;
  70163. /**
  70164. * Returns the string "GPUParticleSystem"
  70165. * @returns a string containing the class name
  70166. */
  70167. getClassName(): string;
  70168. /**
  70169. * Gets the custom effect used to render the particles
  70170. * @param blendMode Blend mode for which the effect should be retrieved
  70171. * @returns The effect
  70172. */
  70173. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70174. /**
  70175. * Sets the custom effect used to render the particles
  70176. * @param effect The effect to set
  70177. * @param blendMode Blend mode for which the effect should be set
  70178. */
  70179. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70180. /** @hidden */
  70181. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70182. /**
  70183. * Observable that will be called just before the particles are drawn
  70184. */
  70185. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70186. /**
  70187. * Gets the name of the particle vertex shader
  70188. */
  70189. get vertexShaderName(): string;
  70190. private _colorGradientsTexture;
  70191. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70192. /**
  70193. * Adds a new color gradient
  70194. * @param gradient defines the gradient to use (between 0 and 1)
  70195. * @param color1 defines the color to affect to the specified gradient
  70196. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70197. * @returns the current particle system
  70198. */
  70199. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70200. private _refreshColorGradient;
  70201. /** Force the system to rebuild all gradients that need to be resync */
  70202. forceRefreshGradients(): void;
  70203. /**
  70204. * Remove a specific color gradient
  70205. * @param gradient defines the gradient to remove
  70206. * @returns the current particle system
  70207. */
  70208. removeColorGradient(gradient: number): GPUParticleSystem;
  70209. private _angularSpeedGradientsTexture;
  70210. private _sizeGradientsTexture;
  70211. private _velocityGradientsTexture;
  70212. private _limitVelocityGradientsTexture;
  70213. private _dragGradientsTexture;
  70214. private _addFactorGradient;
  70215. /**
  70216. * Adds a new size gradient
  70217. * @param gradient defines the gradient to use (between 0 and 1)
  70218. * @param factor defines the size factor to affect to the specified gradient
  70219. * @returns the current particle system
  70220. */
  70221. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70222. /**
  70223. * Remove a specific size gradient
  70224. * @param gradient defines the gradient to remove
  70225. * @returns the current particle system
  70226. */
  70227. removeSizeGradient(gradient: number): GPUParticleSystem;
  70228. private _refreshFactorGradient;
  70229. /**
  70230. * Adds a new angular speed gradient
  70231. * @param gradient defines the gradient to use (between 0 and 1)
  70232. * @param factor defines the angular speed to affect to the specified gradient
  70233. * @returns the current particle system
  70234. */
  70235. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70236. /**
  70237. * Remove a specific angular speed gradient
  70238. * @param gradient defines the gradient to remove
  70239. * @returns the current particle system
  70240. */
  70241. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70242. /**
  70243. * Adds a new velocity gradient
  70244. * @param gradient defines the gradient to use (between 0 and 1)
  70245. * @param factor defines the velocity to affect to the specified gradient
  70246. * @returns the current particle system
  70247. */
  70248. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70249. /**
  70250. * Remove a specific velocity gradient
  70251. * @param gradient defines the gradient to remove
  70252. * @returns the current particle system
  70253. */
  70254. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70255. /**
  70256. * Adds a new limit velocity gradient
  70257. * @param gradient defines the gradient to use (between 0 and 1)
  70258. * @param factor defines the limit velocity value to affect to the specified gradient
  70259. * @returns the current particle system
  70260. */
  70261. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70262. /**
  70263. * Remove a specific limit velocity gradient
  70264. * @param gradient defines the gradient to remove
  70265. * @returns the current particle system
  70266. */
  70267. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70268. /**
  70269. * Adds a new drag gradient
  70270. * @param gradient defines the gradient to use (between 0 and 1)
  70271. * @param factor defines the drag value to affect to the specified gradient
  70272. * @returns the current particle system
  70273. */
  70274. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70275. /**
  70276. * Remove a specific drag gradient
  70277. * @param gradient defines the gradient to remove
  70278. * @returns the current particle system
  70279. */
  70280. removeDragGradient(gradient: number): GPUParticleSystem;
  70281. /**
  70282. * Not supported by GPUParticleSystem
  70283. * @param gradient defines the gradient to use (between 0 and 1)
  70284. * @param factor defines the emit rate value to affect to the specified gradient
  70285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70286. * @returns the current particle system
  70287. */
  70288. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70289. /**
  70290. * Not supported by GPUParticleSystem
  70291. * @param gradient defines the gradient to remove
  70292. * @returns the current particle system
  70293. */
  70294. removeEmitRateGradient(gradient: number): IParticleSystem;
  70295. /**
  70296. * Not supported by GPUParticleSystem
  70297. * @param gradient defines the gradient to use (between 0 and 1)
  70298. * @param factor defines the start size value to affect to the specified gradient
  70299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70300. * @returns the current particle system
  70301. */
  70302. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70303. /**
  70304. * Not supported by GPUParticleSystem
  70305. * @param gradient defines the gradient to remove
  70306. * @returns the current particle system
  70307. */
  70308. removeStartSizeGradient(gradient: number): IParticleSystem;
  70309. /**
  70310. * Not supported by GPUParticleSystem
  70311. * @param gradient defines the gradient to use (between 0 and 1)
  70312. * @param min defines the color remap minimal range
  70313. * @param max defines the color remap maximal range
  70314. * @returns the current particle system
  70315. */
  70316. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70317. /**
  70318. * Not supported by GPUParticleSystem
  70319. * @param gradient defines the gradient to remove
  70320. * @returns the current particle system
  70321. */
  70322. removeColorRemapGradient(): IParticleSystem;
  70323. /**
  70324. * Not supported by GPUParticleSystem
  70325. * @param gradient defines the gradient to use (between 0 and 1)
  70326. * @param min defines the alpha remap minimal range
  70327. * @param max defines the alpha remap maximal range
  70328. * @returns the current particle system
  70329. */
  70330. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70331. /**
  70332. * Not supported by GPUParticleSystem
  70333. * @param gradient defines the gradient to remove
  70334. * @returns the current particle system
  70335. */
  70336. removeAlphaRemapGradient(): IParticleSystem;
  70337. /**
  70338. * Not supported by GPUParticleSystem
  70339. * @param gradient defines the gradient to use (between 0 and 1)
  70340. * @param color defines the color to affect to the specified gradient
  70341. * @returns the current particle system
  70342. */
  70343. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70344. /**
  70345. * Not supported by GPUParticleSystem
  70346. * @param gradient defines the gradient to remove
  70347. * @returns the current particle system
  70348. */
  70349. removeRampGradient(): IParticleSystem;
  70350. /**
  70351. * Not supported by GPUParticleSystem
  70352. * @returns the list of ramp gradients
  70353. */
  70354. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70355. /**
  70356. * Not supported by GPUParticleSystem
  70357. * Gets or sets a boolean indicating that ramp gradients must be used
  70358. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70359. */
  70360. get useRampGradients(): boolean;
  70361. set useRampGradients(value: boolean);
  70362. /**
  70363. * Not supported by GPUParticleSystem
  70364. * @param gradient defines the gradient to use (between 0 and 1)
  70365. * @param factor defines the life time factor to affect to the specified gradient
  70366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70367. * @returns the current particle system
  70368. */
  70369. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70370. /**
  70371. * Not supported by GPUParticleSystem
  70372. * @param gradient defines the gradient to remove
  70373. * @returns the current particle system
  70374. */
  70375. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70376. /**
  70377. * Instantiates a GPU particle system.
  70378. * 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.
  70379. * @param name The name of the particle system
  70380. * @param options The options used to create the system
  70381. * @param scene The scene the particle system belongs to
  70382. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70383. * @param customEffect a custom effect used to change the way particles are rendered by default
  70384. */
  70385. constructor(name: string, options: Partial<{
  70386. capacity: number;
  70387. randomTextureSize: number;
  70388. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70389. protected _reset(): void;
  70390. private _createUpdateVAO;
  70391. private _createRenderVAO;
  70392. private _initialize;
  70393. /** @hidden */
  70394. _recreateUpdateEffect(): void;
  70395. private _getEffect;
  70396. /**
  70397. * Fill the defines array according to the current settings of the particle system
  70398. * @param defines Array to be updated
  70399. * @param blendMode blend mode to take into account when updating the array
  70400. */
  70401. fillDefines(defines: Array<string>, blendMode?: number): void;
  70402. /**
  70403. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70404. * @param uniforms Uniforms array to fill
  70405. * @param attributes Attributes array to fill
  70406. * @param samplers Samplers array to fill
  70407. */
  70408. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70409. /** @hidden */
  70410. _recreateRenderEffect(): Effect;
  70411. /**
  70412. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70413. * @param preWarm defines if we are in the pre-warmimg phase
  70414. */
  70415. animate(preWarm?: boolean): void;
  70416. private _createFactorGradientTexture;
  70417. private _createSizeGradientTexture;
  70418. private _createAngularSpeedGradientTexture;
  70419. private _createVelocityGradientTexture;
  70420. private _createLimitVelocityGradientTexture;
  70421. private _createDragGradientTexture;
  70422. private _createColorGradientTexture;
  70423. /**
  70424. * Renders the particle system in its current state
  70425. * @param preWarm defines if the system should only update the particles but not render them
  70426. * @returns the current number of particles
  70427. */
  70428. render(preWarm?: boolean): number;
  70429. /**
  70430. * Rebuilds the particle system
  70431. */
  70432. rebuild(): void;
  70433. private _releaseBuffers;
  70434. private _releaseVAOs;
  70435. /**
  70436. * Disposes the particle system and free the associated resources
  70437. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70438. */
  70439. dispose(disposeTexture?: boolean): void;
  70440. /**
  70441. * Clones the particle system.
  70442. * @param name The name of the cloned object
  70443. * @param newEmitter The new emitter to use
  70444. * @returns the cloned particle system
  70445. */
  70446. clone(name: string, newEmitter: any): GPUParticleSystem;
  70447. /**
  70448. * Serializes the particle system to a JSON object
  70449. * @param serializeTexture defines if the texture must be serialized as well
  70450. * @returns the JSON object
  70451. */
  70452. serialize(serializeTexture?: boolean): any;
  70453. /**
  70454. * Parses a JSON object to create a GPU particle system.
  70455. * @param parsedParticleSystem The JSON object to parse
  70456. * @param scene The scene to create the particle system in
  70457. * @param rootUrl The root url to use to load external dependencies like texture
  70458. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70459. * @returns the parsed GPU particle system
  70460. */
  70461. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70462. }
  70463. }
  70464. declare module "babylonjs/Particles/particleSystemSet" {
  70465. import { Nullable } from "babylonjs/types";
  70466. import { Color3 } from "babylonjs/Maths/math.color";
  70467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70469. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70470. import { Scene, IDisposable } from "babylonjs/scene";
  70471. /**
  70472. * Represents a set of particle systems working together to create a specific effect
  70473. */
  70474. export class ParticleSystemSet implements IDisposable {
  70475. /**
  70476. * Gets or sets base Assets URL
  70477. */
  70478. static BaseAssetsUrl: string;
  70479. private _emitterCreationOptions;
  70480. private _emitterNode;
  70481. /**
  70482. * Gets the particle system list
  70483. */
  70484. systems: IParticleSystem[];
  70485. /**
  70486. * Gets the emitter node used with this set
  70487. */
  70488. get emitterNode(): Nullable<TransformNode>;
  70489. /**
  70490. * Creates a new emitter mesh as a sphere
  70491. * @param options defines the options used to create the sphere
  70492. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70493. * @param scene defines the hosting scene
  70494. */
  70495. setEmitterAsSphere(options: {
  70496. diameter: number;
  70497. segments: number;
  70498. color: Color3;
  70499. }, renderingGroupId: number, scene: Scene): void;
  70500. /**
  70501. * Starts all particle systems of the set
  70502. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70503. */
  70504. start(emitter?: AbstractMesh): void;
  70505. /**
  70506. * Release all associated resources
  70507. */
  70508. dispose(): void;
  70509. /**
  70510. * Serialize the set into a JSON compatible object
  70511. * @param serializeTexture defines if the texture must be serialized as well
  70512. * @returns a JSON compatible representation of the set
  70513. */
  70514. serialize(serializeTexture?: boolean): any;
  70515. /**
  70516. * Parse a new ParticleSystemSet from a serialized source
  70517. * @param data defines a JSON compatible representation of the set
  70518. * @param scene defines the hosting scene
  70519. * @param gpu defines if we want GPU particles or CPU particles
  70520. * @returns a new ParticleSystemSet
  70521. */
  70522. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70523. }
  70524. }
  70525. declare module "babylonjs/Particles/particleHelper" {
  70526. import { Nullable } from "babylonjs/types";
  70527. import { Scene } from "babylonjs/scene";
  70528. import { Vector3 } from "babylonjs/Maths/math.vector";
  70529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70530. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70531. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70532. /**
  70533. * This class is made for on one-liner static method to help creating particle system set.
  70534. */
  70535. export class ParticleHelper {
  70536. /**
  70537. * Gets or sets base Assets URL
  70538. */
  70539. static BaseAssetsUrl: string;
  70540. /** Define the Url to load snippets */
  70541. static SnippetUrl: string;
  70542. /**
  70543. * Create a default particle system that you can tweak
  70544. * @param emitter defines the emitter to use
  70545. * @param capacity defines the system capacity (default is 500 particles)
  70546. * @param scene defines the hosting scene
  70547. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70548. * @returns the new Particle system
  70549. */
  70550. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70551. /**
  70552. * This is the main static method (one-liner) of this helper to create different particle systems
  70553. * @param type This string represents the type to the particle system to create
  70554. * @param scene The scene where the particle system should live
  70555. * @param gpu If the system will use gpu
  70556. * @returns the ParticleSystemSet created
  70557. */
  70558. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70559. /**
  70560. * Static function used to export a particle system to a ParticleSystemSet variable.
  70561. * Please note that the emitter shape is not exported
  70562. * @param systems defines the particle systems to export
  70563. * @returns the created particle system set
  70564. */
  70565. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70566. /**
  70567. * Creates a particle system from a snippet saved in a remote file
  70568. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70569. * @param url defines the url to load from
  70570. * @param scene defines the hosting scene
  70571. * @param gpu If the system will use gpu
  70572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70573. * @returns a promise that will resolve to the new particle system
  70574. */
  70575. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70576. /**
  70577. * Creates a particle system from a snippet saved by the particle system editor
  70578. * @param snippetId defines the snippet to load
  70579. * @param scene defines the hosting scene
  70580. * @param gpu If the system will use gpu
  70581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70582. * @returns a promise that will resolve to the new particle system
  70583. */
  70584. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70585. }
  70586. }
  70587. declare module "babylonjs/Particles/particleSystemComponent" {
  70588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70589. import { Effect } from "babylonjs/Materials/effect";
  70590. import "babylonjs/Shaders/particles.vertex";
  70591. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70592. module "babylonjs/Engines/engine" {
  70593. interface Engine {
  70594. /**
  70595. * Create an effect to use with particle systems.
  70596. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70597. * the particle system for which you want to create a custom effect in the last parameter
  70598. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70599. * @param uniformsNames defines a list of attribute names
  70600. * @param samplers defines an array of string used to represent textures
  70601. * @param defines defines the string containing the defines to use to compile the shaders
  70602. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70603. * @param onCompiled defines a function to call when the effect creation is successful
  70604. * @param onError defines a function to call when the effect creation has failed
  70605. * @param particleSystem the particle system you want to create the effect for
  70606. * @returns the new Effect
  70607. */
  70608. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70609. }
  70610. }
  70611. module "babylonjs/Meshes/mesh" {
  70612. interface Mesh {
  70613. /**
  70614. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70615. * @returns an array of IParticleSystem
  70616. */
  70617. getEmittedParticleSystems(): IParticleSystem[];
  70618. /**
  70619. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70620. * @returns an array of IParticleSystem
  70621. */
  70622. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70623. }
  70624. }
  70625. }
  70626. declare module "babylonjs/Particles/pointsCloudSystem" {
  70627. import { Color4 } from "babylonjs/Maths/math";
  70628. import { Mesh } from "babylonjs/Meshes/mesh";
  70629. import { Scene, IDisposable } from "babylonjs/scene";
  70630. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70631. /** Defines the 4 color options */
  70632. export enum PointColor {
  70633. /** color value */
  70634. Color = 2,
  70635. /** uv value */
  70636. UV = 1,
  70637. /** random value */
  70638. Random = 0,
  70639. /** stated value */
  70640. Stated = 3
  70641. }
  70642. /**
  70643. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70644. * 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.
  70645. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70646. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70647. *
  70648. * Full documentation here : TO BE ENTERED
  70649. */
  70650. export class PointsCloudSystem implements IDisposable {
  70651. /**
  70652. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70653. * Example : var p = SPS.particles[i];
  70654. */
  70655. particles: CloudPoint[];
  70656. /**
  70657. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70658. */
  70659. nbParticles: number;
  70660. /**
  70661. * This a counter for your own usage. It's not set by any SPS functions.
  70662. */
  70663. counter: number;
  70664. /**
  70665. * The PCS name. This name is also given to the underlying mesh.
  70666. */
  70667. name: string;
  70668. /**
  70669. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70670. */
  70671. mesh: Mesh;
  70672. /**
  70673. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70674. * Please read :
  70675. */
  70676. vars: any;
  70677. /**
  70678. * @hidden
  70679. */
  70680. _size: number;
  70681. private _scene;
  70682. private _promises;
  70683. private _positions;
  70684. private _indices;
  70685. private _normals;
  70686. private _colors;
  70687. private _uvs;
  70688. private _indices32;
  70689. private _positions32;
  70690. private _colors32;
  70691. private _uvs32;
  70692. private _updatable;
  70693. private _isVisibilityBoxLocked;
  70694. private _alwaysVisible;
  70695. private _groups;
  70696. private _groupCounter;
  70697. private _computeParticleColor;
  70698. private _computeParticleTexture;
  70699. private _computeParticleRotation;
  70700. private _computeBoundingBox;
  70701. private _isReady;
  70702. /**
  70703. * Creates a PCS (Points Cloud System) object
  70704. * @param name (String) is the PCS name, this will be the underlying mesh name
  70705. * @param pointSize (number) is the size for each point
  70706. * @param scene (Scene) is the scene in which the PCS is added
  70707. * @param options defines the options of the PCS e.g.
  70708. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70709. */
  70710. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70711. updatable?: boolean;
  70712. });
  70713. /**
  70714. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70715. * If no points were added to the PCS, the returned mesh is just a single point.
  70716. * @returns a promise for the created mesh
  70717. */
  70718. buildMeshAsync(): Promise<Mesh>;
  70719. /**
  70720. * @hidden
  70721. */
  70722. private _buildMesh;
  70723. private _addParticle;
  70724. private _randomUnitVector;
  70725. private _getColorIndicesForCoord;
  70726. private _setPointsColorOrUV;
  70727. private _colorFromTexture;
  70728. private _calculateDensity;
  70729. /**
  70730. * Adds points to the PCS in random positions within a unit sphere
  70731. * @param nb (positive integer) the number of particles to be created from this model
  70732. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70733. * @returns the number of groups in the system
  70734. */
  70735. addPoints(nb: number, pointFunction?: any): number;
  70736. /**
  70737. * Adds points to the PCS from the surface of the model shape
  70738. * @param mesh is any Mesh object that will be used as a surface model for the points
  70739. * @param nb (positive integer) the number of particles to be created from this model
  70740. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70741. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70742. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70743. * @returns the number of groups in the system
  70744. */
  70745. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70746. /**
  70747. * Adds points to the PCS inside the model shape
  70748. * @param mesh is any Mesh object that will be used as a surface model for the points
  70749. * @param nb (positive integer) the number of particles to be created from this model
  70750. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70751. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70752. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70753. * @returns the number of groups in the system
  70754. */
  70755. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70756. /**
  70757. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70758. * This method calls `updateParticle()` for each particle of the SPS.
  70759. * For an animated SPS, it is usually called within the render loop.
  70760. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70761. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70762. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70763. * @returns the PCS.
  70764. */
  70765. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70766. /**
  70767. * Disposes the PCS.
  70768. */
  70769. dispose(): void;
  70770. /**
  70771. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70772. * doc :
  70773. * @returns the PCS.
  70774. */
  70775. refreshVisibleSize(): PointsCloudSystem;
  70776. /**
  70777. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70778. * @param size the size (float) of the visibility box
  70779. * note : this doesn't lock the PCS mesh bounding box.
  70780. * doc :
  70781. */
  70782. setVisibilityBox(size: number): void;
  70783. /**
  70784. * Gets whether the PCS is always visible or not
  70785. * doc :
  70786. */
  70787. get isAlwaysVisible(): boolean;
  70788. /**
  70789. * Sets the PCS as always visible or not
  70790. * doc :
  70791. */
  70792. set isAlwaysVisible(val: boolean);
  70793. /**
  70794. * Tells to `setParticles()` to compute the particle rotations or not
  70795. * Default value : false. The PCS is faster when it's set to false
  70796. * Note : particle rotations are only applied to parent particles
  70797. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70798. */
  70799. set computeParticleRotation(val: boolean);
  70800. /**
  70801. * Tells to `setParticles()` to compute the particle colors or not.
  70802. * Default value : true. The PCS is faster when it's set to false.
  70803. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70804. */
  70805. set computeParticleColor(val: boolean);
  70806. set computeParticleTexture(val: boolean);
  70807. /**
  70808. * Gets if `setParticles()` computes the particle colors or not.
  70809. * Default value : false. The PCS is faster when it's set to false.
  70810. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70811. */
  70812. get computeParticleColor(): boolean;
  70813. /**
  70814. * Gets if `setParticles()` computes the particle textures or not.
  70815. * Default value : false. The PCS is faster when it's set to false.
  70816. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70817. */
  70818. get computeParticleTexture(): boolean;
  70819. /**
  70820. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70821. */
  70822. set computeBoundingBox(val: boolean);
  70823. /**
  70824. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70825. */
  70826. get computeBoundingBox(): boolean;
  70827. /**
  70828. * This function does nothing. It may be overwritten to set all the particle first values.
  70829. * The PCS doesn't call this function, you may have to call it by your own.
  70830. * doc :
  70831. */
  70832. initParticles(): void;
  70833. /**
  70834. * This function does nothing. It may be overwritten to recycle a particle
  70835. * The PCS doesn't call this function, you can to call it
  70836. * doc :
  70837. * @param particle The particle to recycle
  70838. * @returns the recycled particle
  70839. */
  70840. recycleParticle(particle: CloudPoint): CloudPoint;
  70841. /**
  70842. * Updates a particle : this function should be overwritten by the user.
  70843. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70844. * doc :
  70845. * @example : just set a particle position or velocity and recycle conditions
  70846. * @param particle The particle to update
  70847. * @returns the updated particle
  70848. */
  70849. updateParticle(particle: CloudPoint): CloudPoint;
  70850. /**
  70851. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70852. * This does nothing and may be overwritten by the user.
  70853. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70854. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70855. * @param update the boolean update value actually passed to setParticles()
  70856. */
  70857. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70858. /**
  70859. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70860. * This will be passed three parameters.
  70861. * This does nothing and may be overwritten by the user.
  70862. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70863. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70864. * @param update the boolean update value actually passed to setParticles()
  70865. */
  70866. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70867. }
  70868. }
  70869. declare module "babylonjs/Particles/cloudPoint" {
  70870. import { Nullable } from "babylonjs/types";
  70871. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70872. import { Mesh } from "babylonjs/Meshes/mesh";
  70873. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70874. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70875. /**
  70876. * Represents one particle of a points cloud system.
  70877. */
  70878. export class CloudPoint {
  70879. /**
  70880. * particle global index
  70881. */
  70882. idx: number;
  70883. /**
  70884. * The color of the particle
  70885. */
  70886. color: Nullable<Color4>;
  70887. /**
  70888. * The world space position of the particle.
  70889. */
  70890. position: Vector3;
  70891. /**
  70892. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70893. */
  70894. rotation: Vector3;
  70895. /**
  70896. * The world space rotation quaternion of the particle.
  70897. */
  70898. rotationQuaternion: Nullable<Quaternion>;
  70899. /**
  70900. * The uv of the particle.
  70901. */
  70902. uv: Nullable<Vector2>;
  70903. /**
  70904. * The current speed of the particle.
  70905. */
  70906. velocity: Vector3;
  70907. /**
  70908. * The pivot point in the particle local space.
  70909. */
  70910. pivot: Vector3;
  70911. /**
  70912. * Must the particle be translated from its pivot point in its local space ?
  70913. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70914. * Default : false
  70915. */
  70916. translateFromPivot: boolean;
  70917. /**
  70918. * Index of this particle in the global "positions" array (Internal use)
  70919. * @hidden
  70920. */
  70921. _pos: number;
  70922. /**
  70923. * @hidden Index of this particle in the global "indices" array (Internal use)
  70924. */
  70925. _ind: number;
  70926. /**
  70927. * Group this particle belongs to
  70928. */
  70929. _group: PointsGroup;
  70930. /**
  70931. * Group id of this particle
  70932. */
  70933. groupId: number;
  70934. /**
  70935. * Index of the particle in its group id (Internal use)
  70936. */
  70937. idxInGroup: number;
  70938. /**
  70939. * @hidden Particle BoundingInfo object (Internal use)
  70940. */
  70941. _boundingInfo: BoundingInfo;
  70942. /**
  70943. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70944. */
  70945. _pcs: PointsCloudSystem;
  70946. /**
  70947. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70948. */
  70949. _stillInvisible: boolean;
  70950. /**
  70951. * @hidden Last computed particle rotation matrix
  70952. */
  70953. _rotationMatrix: number[];
  70954. /**
  70955. * Parent particle Id, if any.
  70956. * Default null.
  70957. */
  70958. parentId: Nullable<number>;
  70959. /**
  70960. * @hidden Internal global position in the PCS.
  70961. */
  70962. _globalPosition: Vector3;
  70963. /**
  70964. * Creates a Point Cloud object.
  70965. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70966. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70967. * @param group (PointsGroup) is the group the particle belongs to
  70968. * @param groupId (integer) is the group identifier in the PCS.
  70969. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70970. * @param pcs defines the PCS it is associated to
  70971. */
  70972. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70973. /**
  70974. * get point size
  70975. */
  70976. get size(): Vector3;
  70977. /**
  70978. * Set point size
  70979. */
  70980. set size(scale: Vector3);
  70981. /**
  70982. * Legacy support, changed quaternion to rotationQuaternion
  70983. */
  70984. get quaternion(): Nullable<Quaternion>;
  70985. /**
  70986. * Legacy support, changed quaternion to rotationQuaternion
  70987. */
  70988. set quaternion(q: Nullable<Quaternion>);
  70989. /**
  70990. * Returns a boolean. True if the particle intersects a mesh, else false
  70991. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70992. * @param target is the object (point or mesh) what the intersection is computed against
  70993. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70994. * @returns true if it intersects
  70995. */
  70996. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70997. /**
  70998. * get the rotation matrix of the particle
  70999. * @hidden
  71000. */
  71001. getRotationMatrix(m: Matrix): void;
  71002. }
  71003. /**
  71004. * Represents a group of points in a points cloud system
  71005. * * PCS internal tool, don't use it manually.
  71006. */
  71007. export class PointsGroup {
  71008. /**
  71009. * The group id
  71010. * @hidden
  71011. */
  71012. groupID: number;
  71013. /**
  71014. * image data for group (internal use)
  71015. * @hidden
  71016. */
  71017. _groupImageData: Nullable<ArrayBufferView>;
  71018. /**
  71019. * Image Width (internal use)
  71020. * @hidden
  71021. */
  71022. _groupImgWidth: number;
  71023. /**
  71024. * Image Height (internal use)
  71025. * @hidden
  71026. */
  71027. _groupImgHeight: number;
  71028. /**
  71029. * Custom position function (internal use)
  71030. * @hidden
  71031. */
  71032. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71033. /**
  71034. * density per facet for surface points
  71035. * @hidden
  71036. */
  71037. _groupDensity: number[];
  71038. /**
  71039. * Only when points are colored by texture carries pointer to texture list array
  71040. * @hidden
  71041. */
  71042. _textureNb: number;
  71043. /**
  71044. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71045. * PCS internal tool, don't use it manually.
  71046. * @hidden
  71047. */
  71048. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71049. }
  71050. }
  71051. declare module "babylonjs/Particles/index" {
  71052. export * from "babylonjs/Particles/baseParticleSystem";
  71053. export * from "babylonjs/Particles/EmitterTypes/index";
  71054. export * from "babylonjs/Particles/gpuParticleSystem";
  71055. export * from "babylonjs/Particles/IParticleSystem";
  71056. export * from "babylonjs/Particles/particle";
  71057. export * from "babylonjs/Particles/particleHelper";
  71058. export * from "babylonjs/Particles/particleSystem";
  71059. import "babylonjs/Particles/particleSystemComponent";
  71060. export * from "babylonjs/Particles/particleSystemComponent";
  71061. export * from "babylonjs/Particles/particleSystemSet";
  71062. export * from "babylonjs/Particles/solidParticle";
  71063. export * from "babylonjs/Particles/solidParticleSystem";
  71064. export * from "babylonjs/Particles/cloudPoint";
  71065. export * from "babylonjs/Particles/pointsCloudSystem";
  71066. export * from "babylonjs/Particles/subEmitter";
  71067. }
  71068. declare module "babylonjs/Physics/physicsEngineComponent" {
  71069. import { Nullable } from "babylonjs/types";
  71070. import { Observable, Observer } from "babylonjs/Misc/observable";
  71071. import { Vector3 } from "babylonjs/Maths/math.vector";
  71072. import { Mesh } from "babylonjs/Meshes/mesh";
  71073. import { ISceneComponent } from "babylonjs/sceneComponent";
  71074. import { Scene } from "babylonjs/scene";
  71075. import { Node } from "babylonjs/node";
  71076. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71077. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71078. module "babylonjs/scene" {
  71079. interface Scene {
  71080. /** @hidden (Backing field) */
  71081. _physicsEngine: Nullable<IPhysicsEngine>;
  71082. /** @hidden */
  71083. _physicsTimeAccumulator: number;
  71084. /**
  71085. * Gets the current physics engine
  71086. * @returns a IPhysicsEngine or null if none attached
  71087. */
  71088. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71089. /**
  71090. * Enables physics to the current scene
  71091. * @param gravity defines the scene's gravity for the physics engine
  71092. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71093. * @return a boolean indicating if the physics engine was initialized
  71094. */
  71095. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71096. /**
  71097. * Disables and disposes the physics engine associated with the scene
  71098. */
  71099. disablePhysicsEngine(): void;
  71100. /**
  71101. * Gets a boolean indicating if there is an active physics engine
  71102. * @returns a boolean indicating if there is an active physics engine
  71103. */
  71104. isPhysicsEnabled(): boolean;
  71105. /**
  71106. * Deletes a physics compound impostor
  71107. * @param compound defines the compound to delete
  71108. */
  71109. deleteCompoundImpostor(compound: any): void;
  71110. /**
  71111. * An event triggered when physic simulation is about to be run
  71112. */
  71113. onBeforePhysicsObservable: Observable<Scene>;
  71114. /**
  71115. * An event triggered when physic simulation has been done
  71116. */
  71117. onAfterPhysicsObservable: Observable<Scene>;
  71118. }
  71119. }
  71120. module "babylonjs/Meshes/abstractMesh" {
  71121. interface AbstractMesh {
  71122. /** @hidden */
  71123. _physicsImpostor: Nullable<PhysicsImpostor>;
  71124. /**
  71125. * Gets or sets impostor used for physic simulation
  71126. * @see https://doc.babylonjs.com/features/physics_engine
  71127. */
  71128. physicsImpostor: Nullable<PhysicsImpostor>;
  71129. /**
  71130. * Gets the current physics impostor
  71131. * @see https://doc.babylonjs.com/features/physics_engine
  71132. * @returns a physics impostor or null
  71133. */
  71134. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71135. /** Apply a physic impulse to the mesh
  71136. * @param force defines the force to apply
  71137. * @param contactPoint defines where to apply the force
  71138. * @returns the current mesh
  71139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71140. */
  71141. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71142. /**
  71143. * Creates a physic joint between two meshes
  71144. * @param otherMesh defines the other mesh to use
  71145. * @param pivot1 defines the pivot to use on this mesh
  71146. * @param pivot2 defines the pivot to use on the other mesh
  71147. * @param options defines additional options (can be plugin dependent)
  71148. * @returns the current mesh
  71149. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71150. */
  71151. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71152. /** @hidden */
  71153. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71154. }
  71155. }
  71156. /**
  71157. * Defines the physics engine scene component responsible to manage a physics engine
  71158. */
  71159. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71160. /**
  71161. * The component name helpful to identify the component in the list of scene components.
  71162. */
  71163. readonly name: string;
  71164. /**
  71165. * The scene the component belongs to.
  71166. */
  71167. scene: Scene;
  71168. /**
  71169. * Creates a new instance of the component for the given scene
  71170. * @param scene Defines the scene to register the component in
  71171. */
  71172. constructor(scene: Scene);
  71173. /**
  71174. * Registers the component in a given scene
  71175. */
  71176. register(): void;
  71177. /**
  71178. * Rebuilds the elements related to this component in case of
  71179. * context lost for instance.
  71180. */
  71181. rebuild(): void;
  71182. /**
  71183. * Disposes the component and the associated ressources
  71184. */
  71185. dispose(): void;
  71186. }
  71187. }
  71188. declare module "babylonjs/Physics/physicsHelper" {
  71189. import { Nullable } from "babylonjs/types";
  71190. import { Vector3 } from "babylonjs/Maths/math.vector";
  71191. import { Mesh } from "babylonjs/Meshes/mesh";
  71192. import { Scene } from "babylonjs/scene";
  71193. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71194. /**
  71195. * A helper for physics simulations
  71196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71197. */
  71198. export class PhysicsHelper {
  71199. private _scene;
  71200. private _physicsEngine;
  71201. /**
  71202. * Initializes the Physics helper
  71203. * @param scene Babylon.js scene
  71204. */
  71205. constructor(scene: Scene);
  71206. /**
  71207. * Applies a radial explosion impulse
  71208. * @param origin the origin of the explosion
  71209. * @param radiusOrEventOptions the radius or the options of radial explosion
  71210. * @param strength the explosion strength
  71211. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71212. * @returns A physics radial explosion event, or null
  71213. */
  71214. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71215. /**
  71216. * Applies a radial explosion force
  71217. * @param origin the origin of the explosion
  71218. * @param radiusOrEventOptions the radius or the options of radial explosion
  71219. * @param strength the explosion strength
  71220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71221. * @returns A physics radial explosion event, or null
  71222. */
  71223. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71224. /**
  71225. * Creates a gravitational field
  71226. * @param origin the origin of the explosion
  71227. * @param radiusOrEventOptions the radius or the options of radial explosion
  71228. * @param strength the explosion strength
  71229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71230. * @returns A physics gravitational field event, or null
  71231. */
  71232. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71233. /**
  71234. * Creates a physics updraft event
  71235. * @param origin the origin of the updraft
  71236. * @param radiusOrEventOptions the radius or the options of the updraft
  71237. * @param strength the strength of the updraft
  71238. * @param height the height of the updraft
  71239. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71240. * @returns A physics updraft event, or null
  71241. */
  71242. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71243. /**
  71244. * Creates a physics vortex event
  71245. * @param origin the of the vortex
  71246. * @param radiusOrEventOptions the radius or the options of the vortex
  71247. * @param strength the strength of the vortex
  71248. * @param height the height of the vortex
  71249. * @returns a Physics vortex event, or null
  71250. * A physics vortex event or null
  71251. */
  71252. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71253. }
  71254. /**
  71255. * Represents a physics radial explosion event
  71256. */
  71257. class PhysicsRadialExplosionEvent {
  71258. private _scene;
  71259. private _options;
  71260. private _sphere;
  71261. private _dataFetched;
  71262. /**
  71263. * Initializes a radial explosioin event
  71264. * @param _scene BabylonJS scene
  71265. * @param _options The options for the vortex event
  71266. */
  71267. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71268. /**
  71269. * Returns the data related to the radial explosion event (sphere).
  71270. * @returns The radial explosion event data
  71271. */
  71272. getData(): PhysicsRadialExplosionEventData;
  71273. /**
  71274. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71275. * @param impostor A physics imposter
  71276. * @param origin the origin of the explosion
  71277. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71278. */
  71279. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71280. /**
  71281. * Triggers affecterd impostors callbacks
  71282. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71283. */
  71284. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71285. /**
  71286. * Disposes the sphere.
  71287. * @param force Specifies if the sphere should be disposed by force
  71288. */
  71289. dispose(force?: boolean): void;
  71290. /*** Helpers ***/
  71291. private _prepareSphere;
  71292. private _intersectsWithSphere;
  71293. }
  71294. /**
  71295. * Represents a gravitational field event
  71296. */
  71297. class PhysicsGravitationalFieldEvent {
  71298. private _physicsHelper;
  71299. private _scene;
  71300. private _origin;
  71301. private _options;
  71302. private _tickCallback;
  71303. private _sphere;
  71304. private _dataFetched;
  71305. /**
  71306. * Initializes the physics gravitational field event
  71307. * @param _physicsHelper A physics helper
  71308. * @param _scene BabylonJS scene
  71309. * @param _origin The origin position of the gravitational field event
  71310. * @param _options The options for the vortex event
  71311. */
  71312. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71313. /**
  71314. * Returns the data related to the gravitational field event (sphere).
  71315. * @returns A gravitational field event
  71316. */
  71317. getData(): PhysicsGravitationalFieldEventData;
  71318. /**
  71319. * Enables the gravitational field.
  71320. */
  71321. enable(): void;
  71322. /**
  71323. * Disables the gravitational field.
  71324. */
  71325. disable(): void;
  71326. /**
  71327. * Disposes the sphere.
  71328. * @param force The force to dispose from the gravitational field event
  71329. */
  71330. dispose(force?: boolean): void;
  71331. private _tick;
  71332. }
  71333. /**
  71334. * Represents a physics updraft event
  71335. */
  71336. class PhysicsUpdraftEvent {
  71337. private _scene;
  71338. private _origin;
  71339. private _options;
  71340. private _physicsEngine;
  71341. private _originTop;
  71342. private _originDirection;
  71343. private _tickCallback;
  71344. private _cylinder;
  71345. private _cylinderPosition;
  71346. private _dataFetched;
  71347. /**
  71348. * Initializes the physics updraft event
  71349. * @param _scene BabylonJS scene
  71350. * @param _origin The origin position of the updraft
  71351. * @param _options The options for the updraft event
  71352. */
  71353. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71354. /**
  71355. * Returns the data related to the updraft event (cylinder).
  71356. * @returns A physics updraft event
  71357. */
  71358. getData(): PhysicsUpdraftEventData;
  71359. /**
  71360. * Enables the updraft.
  71361. */
  71362. enable(): void;
  71363. /**
  71364. * Disables the updraft.
  71365. */
  71366. disable(): void;
  71367. /**
  71368. * Disposes the cylinder.
  71369. * @param force Specifies if the updraft should be disposed by force
  71370. */
  71371. dispose(force?: boolean): void;
  71372. private getImpostorHitData;
  71373. private _tick;
  71374. /*** Helpers ***/
  71375. private _prepareCylinder;
  71376. private _intersectsWithCylinder;
  71377. }
  71378. /**
  71379. * Represents a physics vortex event
  71380. */
  71381. class PhysicsVortexEvent {
  71382. private _scene;
  71383. private _origin;
  71384. private _options;
  71385. private _physicsEngine;
  71386. private _originTop;
  71387. private _tickCallback;
  71388. private _cylinder;
  71389. private _cylinderPosition;
  71390. private _dataFetched;
  71391. /**
  71392. * Initializes the physics vortex event
  71393. * @param _scene The BabylonJS scene
  71394. * @param _origin The origin position of the vortex
  71395. * @param _options The options for the vortex event
  71396. */
  71397. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71398. /**
  71399. * Returns the data related to the vortex event (cylinder).
  71400. * @returns The physics vortex event data
  71401. */
  71402. getData(): PhysicsVortexEventData;
  71403. /**
  71404. * Enables the vortex.
  71405. */
  71406. enable(): void;
  71407. /**
  71408. * Disables the cortex.
  71409. */
  71410. disable(): void;
  71411. /**
  71412. * Disposes the sphere.
  71413. * @param force
  71414. */
  71415. dispose(force?: boolean): void;
  71416. private getImpostorHitData;
  71417. private _tick;
  71418. /*** Helpers ***/
  71419. private _prepareCylinder;
  71420. private _intersectsWithCylinder;
  71421. }
  71422. /**
  71423. * Options fot the radial explosion event
  71424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71425. */
  71426. export class PhysicsRadialExplosionEventOptions {
  71427. /**
  71428. * The radius of the sphere for the radial explosion.
  71429. */
  71430. radius: number;
  71431. /**
  71432. * The strenth of the explosion.
  71433. */
  71434. strength: number;
  71435. /**
  71436. * The strenght of the force in correspondence to the distance of the affected object
  71437. */
  71438. falloff: PhysicsRadialImpulseFalloff;
  71439. /**
  71440. * Sphere options for the radial explosion.
  71441. */
  71442. sphere: {
  71443. segments: number;
  71444. diameter: number;
  71445. };
  71446. /**
  71447. * Sphere options for the radial explosion.
  71448. */
  71449. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71450. }
  71451. /**
  71452. * Options fot the updraft event
  71453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71454. */
  71455. export class PhysicsUpdraftEventOptions {
  71456. /**
  71457. * The radius of the cylinder for the vortex
  71458. */
  71459. radius: number;
  71460. /**
  71461. * The strenth of the updraft.
  71462. */
  71463. strength: number;
  71464. /**
  71465. * The height of the cylinder for the updraft.
  71466. */
  71467. height: number;
  71468. /**
  71469. * The mode for the the updraft.
  71470. */
  71471. updraftMode: PhysicsUpdraftMode;
  71472. }
  71473. /**
  71474. * Options fot the vortex event
  71475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71476. */
  71477. export class PhysicsVortexEventOptions {
  71478. /**
  71479. * The radius of the cylinder for the vortex
  71480. */
  71481. radius: number;
  71482. /**
  71483. * The strenth of the vortex.
  71484. */
  71485. strength: number;
  71486. /**
  71487. * The height of the cylinder for the vortex.
  71488. */
  71489. height: number;
  71490. /**
  71491. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71492. */
  71493. centripetalForceThreshold: number;
  71494. /**
  71495. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71496. */
  71497. centripetalForceMultiplier: number;
  71498. /**
  71499. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71500. */
  71501. centrifugalForceMultiplier: number;
  71502. /**
  71503. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71504. */
  71505. updraftForceMultiplier: number;
  71506. }
  71507. /**
  71508. * The strenght of the force in correspondence to the distance of the affected object
  71509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71510. */
  71511. export enum PhysicsRadialImpulseFalloff {
  71512. /** Defines that impulse is constant in strength across it's whole radius */
  71513. Constant = 0,
  71514. /** Defines that impulse gets weaker if it's further from the origin */
  71515. Linear = 1
  71516. }
  71517. /**
  71518. * The strength of the force in correspondence to the distance of the affected object
  71519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71520. */
  71521. export enum PhysicsUpdraftMode {
  71522. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71523. Center = 0,
  71524. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71525. Perpendicular = 1
  71526. }
  71527. /**
  71528. * Interface for a physics hit data
  71529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71530. */
  71531. export interface PhysicsHitData {
  71532. /**
  71533. * The force applied at the contact point
  71534. */
  71535. force: Vector3;
  71536. /**
  71537. * The contact point
  71538. */
  71539. contactPoint: Vector3;
  71540. /**
  71541. * The distance from the origin to the contact point
  71542. */
  71543. distanceFromOrigin: number;
  71544. }
  71545. /**
  71546. * Interface for radial explosion event data
  71547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71548. */
  71549. export interface PhysicsRadialExplosionEventData {
  71550. /**
  71551. * A sphere used for the radial explosion event
  71552. */
  71553. sphere: Mesh;
  71554. }
  71555. /**
  71556. * Interface for gravitational field event data
  71557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71558. */
  71559. export interface PhysicsGravitationalFieldEventData {
  71560. /**
  71561. * A sphere mesh used for the gravitational field event
  71562. */
  71563. sphere: Mesh;
  71564. }
  71565. /**
  71566. * Interface for updraft event data
  71567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71568. */
  71569. export interface PhysicsUpdraftEventData {
  71570. /**
  71571. * A cylinder used for the updraft event
  71572. */
  71573. cylinder: Mesh;
  71574. }
  71575. /**
  71576. * Interface for vortex event data
  71577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71578. */
  71579. export interface PhysicsVortexEventData {
  71580. /**
  71581. * A cylinder used for the vortex event
  71582. */
  71583. cylinder: Mesh;
  71584. }
  71585. /**
  71586. * Interface for an affected physics impostor
  71587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71588. */
  71589. export interface PhysicsAffectedImpostorWithData {
  71590. /**
  71591. * The impostor affected by the effect
  71592. */
  71593. impostor: PhysicsImpostor;
  71594. /**
  71595. * The data about the hit/horce from the explosion
  71596. */
  71597. hitData: PhysicsHitData;
  71598. }
  71599. }
  71600. declare module "babylonjs/Physics/Plugins/index" {
  71601. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71602. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71603. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71604. }
  71605. declare module "babylonjs/Physics/index" {
  71606. export * from "babylonjs/Physics/IPhysicsEngine";
  71607. export * from "babylonjs/Physics/physicsEngine";
  71608. export * from "babylonjs/Physics/physicsEngineComponent";
  71609. export * from "babylonjs/Physics/physicsHelper";
  71610. export * from "babylonjs/Physics/physicsImpostor";
  71611. export * from "babylonjs/Physics/physicsJoint";
  71612. export * from "babylonjs/Physics/Plugins/index";
  71613. }
  71614. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71615. /** @hidden */
  71616. export var blackAndWhitePixelShader: {
  71617. name: string;
  71618. shader: string;
  71619. };
  71620. }
  71621. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71623. import { Camera } from "babylonjs/Cameras/camera";
  71624. import { Engine } from "babylonjs/Engines/engine";
  71625. import "babylonjs/Shaders/blackAndWhite.fragment";
  71626. /**
  71627. * Post process used to render in black and white
  71628. */
  71629. export class BlackAndWhitePostProcess extends PostProcess {
  71630. /**
  71631. * Linear about to convert he result to black and white (default: 1)
  71632. */
  71633. degree: number;
  71634. /**
  71635. * Creates a black and white post process
  71636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71637. * @param name The name of the effect.
  71638. * @param options The required width/height ratio to downsize to before computing the render pass.
  71639. * @param camera The camera to apply the render pass to.
  71640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71641. * @param engine The engine which the post process will be applied. (default: current engine)
  71642. * @param reusable If the post process can be reused on the same frame. (default: false)
  71643. */
  71644. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71645. }
  71646. }
  71647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71648. import { Nullable } from "babylonjs/types";
  71649. import { Camera } from "babylonjs/Cameras/camera";
  71650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71651. import { Engine } from "babylonjs/Engines/engine";
  71652. /**
  71653. * This represents a set of one or more post processes in Babylon.
  71654. * A post process can be used to apply a shader to a texture after it is rendered.
  71655. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71656. */
  71657. export class PostProcessRenderEffect {
  71658. private _postProcesses;
  71659. private _getPostProcesses;
  71660. private _singleInstance;
  71661. private _cameras;
  71662. private _indicesForCamera;
  71663. /**
  71664. * Name of the effect
  71665. * @hidden
  71666. */
  71667. _name: string;
  71668. /**
  71669. * Instantiates a post process render effect.
  71670. * A post process can be used to apply a shader to a texture after it is rendered.
  71671. * @param engine The engine the effect is tied to
  71672. * @param name The name of the effect
  71673. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71674. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71675. */
  71676. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71677. /**
  71678. * Checks if all the post processes in the effect are supported.
  71679. */
  71680. get isSupported(): boolean;
  71681. /**
  71682. * Updates the current state of the effect
  71683. * @hidden
  71684. */
  71685. _update(): void;
  71686. /**
  71687. * Attaches the effect on cameras
  71688. * @param cameras The camera to attach to.
  71689. * @hidden
  71690. */
  71691. _attachCameras(cameras: Camera): void;
  71692. /**
  71693. * Attaches the effect on cameras
  71694. * @param cameras The camera to attach to.
  71695. * @hidden
  71696. */
  71697. _attachCameras(cameras: Camera[]): void;
  71698. /**
  71699. * Detaches the effect on cameras
  71700. * @param cameras The camera to detatch from.
  71701. * @hidden
  71702. */
  71703. _detachCameras(cameras: Camera): void;
  71704. /**
  71705. * Detatches the effect on cameras
  71706. * @param cameras The camera to detatch from.
  71707. * @hidden
  71708. */
  71709. _detachCameras(cameras: Camera[]): void;
  71710. /**
  71711. * Enables the effect on given cameras
  71712. * @param cameras The camera to enable.
  71713. * @hidden
  71714. */
  71715. _enable(cameras: Camera): void;
  71716. /**
  71717. * Enables the effect on given cameras
  71718. * @param cameras The camera to enable.
  71719. * @hidden
  71720. */
  71721. _enable(cameras: Nullable<Camera[]>): void;
  71722. /**
  71723. * Disables the effect on the given cameras
  71724. * @param cameras The camera to disable.
  71725. * @hidden
  71726. */
  71727. _disable(cameras: Camera): void;
  71728. /**
  71729. * Disables the effect on the given cameras
  71730. * @param cameras The camera to disable.
  71731. * @hidden
  71732. */
  71733. _disable(cameras: Nullable<Camera[]>): void;
  71734. /**
  71735. * Gets a list of the post processes contained in the effect.
  71736. * @param camera The camera to get the post processes on.
  71737. * @returns The list of the post processes in the effect.
  71738. */
  71739. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71740. }
  71741. }
  71742. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71744. /** @hidden */
  71745. export var extractHighlightsPixelShader: {
  71746. name: string;
  71747. shader: string;
  71748. };
  71749. }
  71750. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71751. import { Nullable } from "babylonjs/types";
  71752. import { Camera } from "babylonjs/Cameras/camera";
  71753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71754. import { Engine } from "babylonjs/Engines/engine";
  71755. import "babylonjs/Shaders/extractHighlights.fragment";
  71756. /**
  71757. * 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.
  71758. */
  71759. export class ExtractHighlightsPostProcess extends PostProcess {
  71760. /**
  71761. * The luminance threshold, pixels below this value will be set to black.
  71762. */
  71763. threshold: number;
  71764. /** @hidden */
  71765. _exposure: number;
  71766. /**
  71767. * Post process which has the input texture to be used when performing highlight extraction
  71768. * @hidden
  71769. */
  71770. _inputPostProcess: Nullable<PostProcess>;
  71771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71772. }
  71773. }
  71774. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71775. /** @hidden */
  71776. export var bloomMergePixelShader: {
  71777. name: string;
  71778. shader: string;
  71779. };
  71780. }
  71781. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71783. import { Nullable } from "babylonjs/types";
  71784. import { Engine } from "babylonjs/Engines/engine";
  71785. import { Camera } from "babylonjs/Cameras/camera";
  71786. import "babylonjs/Shaders/bloomMerge.fragment";
  71787. /**
  71788. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71789. */
  71790. export class BloomMergePostProcess extends PostProcess {
  71791. /** Weight of the bloom to be added to the original input. */
  71792. weight: number;
  71793. /**
  71794. * Creates a new instance of @see BloomMergePostProcess
  71795. * @param name The name of the effect.
  71796. * @param originalFromInput Post process which's input will be used for the merge.
  71797. * @param blurred Blurred highlights post process which's output will be used.
  71798. * @param weight Weight of the bloom to be added to the original input.
  71799. * @param options The required width/height ratio to downsize to before computing the render pass.
  71800. * @param camera The camera to apply the render pass to.
  71801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71802. * @param engine The engine which the post process will be applied. (default: current engine)
  71803. * @param reusable If the post process can be reused on the same frame. (default: false)
  71804. * @param textureType Type of textures used when performing the post process. (default: 0)
  71805. * @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)
  71806. */
  71807. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71808. /** Weight of the bloom to be added to the original input. */
  71809. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71810. }
  71811. }
  71812. declare module "babylonjs/PostProcesses/bloomEffect" {
  71813. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71815. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71816. import { Camera } from "babylonjs/Cameras/camera";
  71817. import { Scene } from "babylonjs/scene";
  71818. /**
  71819. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71820. */
  71821. export class BloomEffect extends PostProcessRenderEffect {
  71822. private bloomScale;
  71823. /**
  71824. * @hidden Internal
  71825. */
  71826. _effects: Array<PostProcess>;
  71827. /**
  71828. * @hidden Internal
  71829. */
  71830. _downscale: ExtractHighlightsPostProcess;
  71831. private _blurX;
  71832. private _blurY;
  71833. private _merge;
  71834. /**
  71835. * The luminance threshold to find bright areas of the image to bloom.
  71836. */
  71837. get threshold(): number;
  71838. set threshold(value: number);
  71839. /**
  71840. * The strength of the bloom.
  71841. */
  71842. get weight(): number;
  71843. set weight(value: number);
  71844. /**
  71845. * Specifies the size of the bloom blur kernel, relative to the final output size
  71846. */
  71847. get kernel(): number;
  71848. set kernel(value: number);
  71849. /**
  71850. * Creates a new instance of @see BloomEffect
  71851. * @param scene The scene the effect belongs to.
  71852. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71853. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71854. * @param bloomWeight The the strength of bloom.
  71855. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71856. * @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)
  71857. */
  71858. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71859. /**
  71860. * Disposes each of the internal effects for a given camera.
  71861. * @param camera The camera to dispose the effect on.
  71862. */
  71863. disposeEffects(camera: Camera): void;
  71864. /**
  71865. * @hidden Internal
  71866. */
  71867. _updateEffects(): void;
  71868. /**
  71869. * Internal
  71870. * @returns if all the contained post processes are ready.
  71871. * @hidden
  71872. */
  71873. _isReady(): boolean;
  71874. }
  71875. }
  71876. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71877. /** @hidden */
  71878. export var chromaticAberrationPixelShader: {
  71879. name: string;
  71880. shader: string;
  71881. };
  71882. }
  71883. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71884. import { Vector2 } from "babylonjs/Maths/math.vector";
  71885. import { Nullable } from "babylonjs/types";
  71886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71887. import { Camera } from "babylonjs/Cameras/camera";
  71888. import { Engine } from "babylonjs/Engines/engine";
  71889. import "babylonjs/Shaders/chromaticAberration.fragment";
  71890. /**
  71891. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71892. */
  71893. export class ChromaticAberrationPostProcess extends PostProcess {
  71894. /**
  71895. * The amount of seperation of rgb channels (default: 30)
  71896. */
  71897. aberrationAmount: number;
  71898. /**
  71899. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71900. */
  71901. radialIntensity: number;
  71902. /**
  71903. * 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))
  71904. */
  71905. direction: Vector2;
  71906. /**
  71907. * 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))
  71908. */
  71909. centerPosition: Vector2;
  71910. /**
  71911. * Creates a new instance ChromaticAberrationPostProcess
  71912. * @param name The name of the effect.
  71913. * @param screenWidth The width of the screen to apply the effect on.
  71914. * @param screenHeight The height of the screen to apply the effect on.
  71915. * @param options The required width/height ratio to downsize to before computing the render pass.
  71916. * @param camera The camera to apply the render pass to.
  71917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71918. * @param engine The engine which the post process will be applied. (default: current engine)
  71919. * @param reusable If the post process can be reused on the same frame. (default: false)
  71920. * @param textureType Type of textures used when performing the post process. (default: 0)
  71921. * @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)
  71922. */
  71923. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71924. }
  71925. }
  71926. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71927. /** @hidden */
  71928. export var circleOfConfusionPixelShader: {
  71929. name: string;
  71930. shader: string;
  71931. };
  71932. }
  71933. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71934. import { Nullable } from "babylonjs/types";
  71935. import { Engine } from "babylonjs/Engines/engine";
  71936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71937. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71938. import { Camera } from "babylonjs/Cameras/camera";
  71939. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71940. /**
  71941. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71942. */
  71943. export class CircleOfConfusionPostProcess extends PostProcess {
  71944. /**
  71945. * 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.
  71946. */
  71947. lensSize: number;
  71948. /**
  71949. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71950. */
  71951. fStop: number;
  71952. /**
  71953. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71954. */
  71955. focusDistance: number;
  71956. /**
  71957. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71958. */
  71959. focalLength: number;
  71960. private _depthTexture;
  71961. /**
  71962. * Creates a new instance CircleOfConfusionPostProcess
  71963. * @param name The name of the effect.
  71964. * @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.
  71965. * @param options The required width/height ratio to downsize to before computing the render pass.
  71966. * @param camera The camera to apply the render pass to.
  71967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71968. * @param engine The engine which the post process will be applied. (default: current engine)
  71969. * @param reusable If the post process can be reused on the same frame. (default: false)
  71970. * @param textureType Type of textures used when performing the post process. (default: 0)
  71971. * @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)
  71972. */
  71973. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71974. /**
  71975. * 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.
  71976. */
  71977. set depthTexture(value: RenderTargetTexture);
  71978. }
  71979. }
  71980. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71981. /** @hidden */
  71982. export var colorCorrectionPixelShader: {
  71983. name: string;
  71984. shader: string;
  71985. };
  71986. }
  71987. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71989. import { Engine } from "babylonjs/Engines/engine";
  71990. import { Camera } from "babylonjs/Cameras/camera";
  71991. import "babylonjs/Shaders/colorCorrection.fragment";
  71992. /**
  71993. *
  71994. * This post-process allows the modification of rendered colors by using
  71995. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71996. *
  71997. * The object needs to be provided an url to a texture containing the color
  71998. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71999. * Use an image editing software to tweak the LUT to match your needs.
  72000. *
  72001. * For an example of a color LUT, see here:
  72002. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72003. * For explanations on color grading, see here:
  72004. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72005. *
  72006. */
  72007. export class ColorCorrectionPostProcess extends PostProcess {
  72008. private _colorTableTexture;
  72009. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72010. }
  72011. }
  72012. declare module "babylonjs/Shaders/convolution.fragment" {
  72013. /** @hidden */
  72014. export var convolutionPixelShader: {
  72015. name: string;
  72016. shader: string;
  72017. };
  72018. }
  72019. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72020. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72021. import { Nullable } from "babylonjs/types";
  72022. import { Camera } from "babylonjs/Cameras/camera";
  72023. import { Engine } from "babylonjs/Engines/engine";
  72024. import "babylonjs/Shaders/convolution.fragment";
  72025. /**
  72026. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72027. * input texture to perform effects such as edge detection or sharpening
  72028. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72029. */
  72030. export class ConvolutionPostProcess extends PostProcess {
  72031. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72032. kernel: number[];
  72033. /**
  72034. * Creates a new instance ConvolutionPostProcess
  72035. * @param name The name of the effect.
  72036. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72037. * @param options The required width/height ratio to downsize to before computing the render pass.
  72038. * @param camera The camera to apply the render pass to.
  72039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72040. * @param engine The engine which the post process will be applied. (default: current engine)
  72041. * @param reusable If the post process can be reused on the same frame. (default: false)
  72042. * @param textureType Type of textures used when performing the post process. (default: 0)
  72043. */
  72044. constructor(name: string,
  72045. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72046. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72047. /**
  72048. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72049. */
  72050. static EdgeDetect0Kernel: number[];
  72051. /**
  72052. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72053. */
  72054. static EdgeDetect1Kernel: number[];
  72055. /**
  72056. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72057. */
  72058. static EdgeDetect2Kernel: number[];
  72059. /**
  72060. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72061. */
  72062. static SharpenKernel: number[];
  72063. /**
  72064. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72065. */
  72066. static EmbossKernel: number[];
  72067. /**
  72068. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72069. */
  72070. static GaussianKernel: number[];
  72071. }
  72072. }
  72073. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72074. import { Nullable } from "babylonjs/types";
  72075. import { Vector2 } from "babylonjs/Maths/math.vector";
  72076. import { Camera } from "babylonjs/Cameras/camera";
  72077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72078. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72079. import { Engine } from "babylonjs/Engines/engine";
  72080. import { Scene } from "babylonjs/scene";
  72081. /**
  72082. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72083. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72084. * based on samples that have a large difference in distance than the center pixel.
  72085. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72086. */
  72087. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72088. direction: Vector2;
  72089. /**
  72090. * Creates a new instance CircleOfConfusionPostProcess
  72091. * @param name The name of the effect.
  72092. * @param scene The scene the effect belongs to.
  72093. * @param direction The direction the blur should be applied.
  72094. * @param kernel The size of the kernel used to blur.
  72095. * @param options The required width/height ratio to downsize to before computing the render pass.
  72096. * @param camera The camera to apply the render pass to.
  72097. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72098. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72100. * @param engine The engine which the post process will be applied. (default: current engine)
  72101. * @param reusable If the post process can be reused on the same frame. (default: false)
  72102. * @param textureType Type of textures used when performing the post process. (default: 0)
  72103. * @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)
  72104. */
  72105. 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);
  72106. }
  72107. }
  72108. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72109. /** @hidden */
  72110. export var depthOfFieldMergePixelShader: {
  72111. name: string;
  72112. shader: string;
  72113. };
  72114. }
  72115. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72116. import { Nullable } from "babylonjs/types";
  72117. import { Camera } from "babylonjs/Cameras/camera";
  72118. import { Effect } from "babylonjs/Materials/effect";
  72119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72120. import { Engine } from "babylonjs/Engines/engine";
  72121. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72122. /**
  72123. * Options to be set when merging outputs from the default pipeline.
  72124. */
  72125. export class DepthOfFieldMergePostProcessOptions {
  72126. /**
  72127. * The original image to merge on top of
  72128. */
  72129. originalFromInput: PostProcess;
  72130. /**
  72131. * Parameters to perform the merge of the depth of field effect
  72132. */
  72133. depthOfField?: {
  72134. circleOfConfusion: PostProcess;
  72135. blurSteps: Array<PostProcess>;
  72136. };
  72137. /**
  72138. * Parameters to perform the merge of bloom effect
  72139. */
  72140. bloom?: {
  72141. blurred: PostProcess;
  72142. weight: number;
  72143. };
  72144. }
  72145. /**
  72146. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72147. */
  72148. export class DepthOfFieldMergePostProcess extends PostProcess {
  72149. private blurSteps;
  72150. /**
  72151. * Creates a new instance of DepthOfFieldMergePostProcess
  72152. * @param name The name of the effect.
  72153. * @param originalFromInput Post process which's input will be used for the merge.
  72154. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72155. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72156. * @param options The required width/height ratio to downsize to before computing the render pass.
  72157. * @param camera The camera to apply the render pass to.
  72158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72159. * @param engine The engine which the post process will be applied. (default: current engine)
  72160. * @param reusable If the post process can be reused on the same frame. (default: false)
  72161. * @param textureType Type of textures used when performing the post process. (default: 0)
  72162. * @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)
  72163. */
  72164. 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);
  72165. /**
  72166. * Updates the effect with the current post process compile time values and recompiles the shader.
  72167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72170. * @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
  72171. * @param onCompiled Called when the shader has been compiled.
  72172. * @param onError Called if there is an error when compiling a shader.
  72173. */
  72174. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72175. }
  72176. }
  72177. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72178. import { Nullable } from "babylonjs/types";
  72179. import { Camera } from "babylonjs/Cameras/camera";
  72180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72182. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72183. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72184. import { Scene } from "babylonjs/scene";
  72185. /**
  72186. * Specifies the level of max blur that should be applied when using the depth of field effect
  72187. */
  72188. export enum DepthOfFieldEffectBlurLevel {
  72189. /**
  72190. * Subtle blur
  72191. */
  72192. Low = 0,
  72193. /**
  72194. * Medium blur
  72195. */
  72196. Medium = 1,
  72197. /**
  72198. * Large blur
  72199. */
  72200. High = 2
  72201. }
  72202. /**
  72203. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72204. */
  72205. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72206. private _circleOfConfusion;
  72207. /**
  72208. * @hidden Internal, blurs from high to low
  72209. */
  72210. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72211. private _depthOfFieldBlurY;
  72212. private _dofMerge;
  72213. /**
  72214. * @hidden Internal post processes in depth of field effect
  72215. */
  72216. _effects: Array<PostProcess>;
  72217. /**
  72218. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72219. */
  72220. set focalLength(value: number);
  72221. get focalLength(): number;
  72222. /**
  72223. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72224. */
  72225. set fStop(value: number);
  72226. get fStop(): number;
  72227. /**
  72228. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72229. */
  72230. set focusDistance(value: number);
  72231. get focusDistance(): number;
  72232. /**
  72233. * 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.
  72234. */
  72235. set lensSize(value: number);
  72236. get lensSize(): number;
  72237. /**
  72238. * Creates a new instance DepthOfFieldEffect
  72239. * @param scene The scene the effect belongs to.
  72240. * @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.
  72241. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72242. * @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)
  72243. */
  72244. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72245. /**
  72246. * Get the current class name of the current effet
  72247. * @returns "DepthOfFieldEffect"
  72248. */
  72249. getClassName(): string;
  72250. /**
  72251. * 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.
  72252. */
  72253. set depthTexture(value: RenderTargetTexture);
  72254. /**
  72255. * Disposes each of the internal effects for a given camera.
  72256. * @param camera The camera to dispose the effect on.
  72257. */
  72258. disposeEffects(camera: Camera): void;
  72259. /**
  72260. * @hidden Internal
  72261. */
  72262. _updateEffects(): void;
  72263. /**
  72264. * Internal
  72265. * @returns if all the contained post processes are ready.
  72266. * @hidden
  72267. */
  72268. _isReady(): boolean;
  72269. }
  72270. }
  72271. declare module "babylonjs/Shaders/displayPass.fragment" {
  72272. /** @hidden */
  72273. export var displayPassPixelShader: {
  72274. name: string;
  72275. shader: string;
  72276. };
  72277. }
  72278. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72279. import { Nullable } from "babylonjs/types";
  72280. import { Camera } from "babylonjs/Cameras/camera";
  72281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72282. import { Engine } from "babylonjs/Engines/engine";
  72283. import "babylonjs/Shaders/displayPass.fragment";
  72284. /**
  72285. * DisplayPassPostProcess which produces an output the same as it's input
  72286. */
  72287. export class DisplayPassPostProcess extends PostProcess {
  72288. /**
  72289. * Creates the DisplayPassPostProcess
  72290. * @param name The name of the effect.
  72291. * @param options The required width/height ratio to downsize to before computing the render pass.
  72292. * @param camera The camera to apply the render pass to.
  72293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72294. * @param engine The engine which the post process will be applied. (default: current engine)
  72295. * @param reusable If the post process can be reused on the same frame. (default: false)
  72296. */
  72297. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72298. }
  72299. }
  72300. declare module "babylonjs/Shaders/filter.fragment" {
  72301. /** @hidden */
  72302. export var filterPixelShader: {
  72303. name: string;
  72304. shader: string;
  72305. };
  72306. }
  72307. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72308. import { Nullable } from "babylonjs/types";
  72309. import { Matrix } from "babylonjs/Maths/math.vector";
  72310. import { Camera } from "babylonjs/Cameras/camera";
  72311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72312. import { Engine } from "babylonjs/Engines/engine";
  72313. import "babylonjs/Shaders/filter.fragment";
  72314. /**
  72315. * Applies a kernel filter to the image
  72316. */
  72317. export class FilterPostProcess extends PostProcess {
  72318. /** The matrix to be applied to the image */
  72319. kernelMatrix: Matrix;
  72320. /**
  72321. *
  72322. * @param name The name of the effect.
  72323. * @param kernelMatrix The matrix to be applied to the image
  72324. * @param options The required width/height ratio to downsize to before computing the render pass.
  72325. * @param camera The camera to apply the render pass to.
  72326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72327. * @param engine The engine which the post process will be applied. (default: current engine)
  72328. * @param reusable If the post process can be reused on the same frame. (default: false)
  72329. */
  72330. constructor(name: string,
  72331. /** The matrix to be applied to the image */
  72332. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72333. }
  72334. }
  72335. declare module "babylonjs/Shaders/fxaa.fragment" {
  72336. /** @hidden */
  72337. export var fxaaPixelShader: {
  72338. name: string;
  72339. shader: string;
  72340. };
  72341. }
  72342. declare module "babylonjs/Shaders/fxaa.vertex" {
  72343. /** @hidden */
  72344. export var fxaaVertexShader: {
  72345. name: string;
  72346. shader: string;
  72347. };
  72348. }
  72349. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72350. import { Nullable } from "babylonjs/types";
  72351. import { Camera } from "babylonjs/Cameras/camera";
  72352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72353. import { Engine } from "babylonjs/Engines/engine";
  72354. import "babylonjs/Shaders/fxaa.fragment";
  72355. import "babylonjs/Shaders/fxaa.vertex";
  72356. /**
  72357. * Fxaa post process
  72358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72359. */
  72360. export class FxaaPostProcess extends PostProcess {
  72361. /** @hidden */
  72362. texelWidth: number;
  72363. /** @hidden */
  72364. texelHeight: number;
  72365. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72366. private _getDefines;
  72367. }
  72368. }
  72369. declare module "babylonjs/Shaders/grain.fragment" {
  72370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72371. /** @hidden */
  72372. export var grainPixelShader: {
  72373. name: string;
  72374. shader: string;
  72375. };
  72376. }
  72377. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72378. import { Nullable } from "babylonjs/types";
  72379. import { Camera } from "babylonjs/Cameras/camera";
  72380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72381. import { Engine } from "babylonjs/Engines/engine";
  72382. import "babylonjs/Shaders/grain.fragment";
  72383. /**
  72384. * The GrainPostProcess adds noise to the image at mid luminance levels
  72385. */
  72386. export class GrainPostProcess extends PostProcess {
  72387. /**
  72388. * The intensity of the grain added (default: 30)
  72389. */
  72390. intensity: number;
  72391. /**
  72392. * If the grain should be randomized on every frame
  72393. */
  72394. animated: boolean;
  72395. /**
  72396. * Creates a new instance of @see GrainPostProcess
  72397. * @param name The name of the effect.
  72398. * @param options The required width/height ratio to downsize to before computing the render pass.
  72399. * @param camera The camera to apply the render pass to.
  72400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72401. * @param engine The engine which the post process will be applied. (default: current engine)
  72402. * @param reusable If the post process can be reused on the same frame. (default: false)
  72403. * @param textureType Type of textures used when performing the post process. (default: 0)
  72404. * @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)
  72405. */
  72406. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72407. }
  72408. }
  72409. declare module "babylonjs/Shaders/highlights.fragment" {
  72410. /** @hidden */
  72411. export var highlightsPixelShader: {
  72412. name: string;
  72413. shader: string;
  72414. };
  72415. }
  72416. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72417. import { Nullable } from "babylonjs/types";
  72418. import { Camera } from "babylonjs/Cameras/camera";
  72419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72420. import { Engine } from "babylonjs/Engines/engine";
  72421. import "babylonjs/Shaders/highlights.fragment";
  72422. /**
  72423. * Extracts highlights from the image
  72424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72425. */
  72426. export class HighlightsPostProcess extends PostProcess {
  72427. /**
  72428. * Extracts highlights from the image
  72429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72430. * @param name The name of the effect.
  72431. * @param options The required width/height ratio to downsize to before computing the render pass.
  72432. * @param camera The camera to apply the render pass to.
  72433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72434. * @param engine The engine which the post process will be applied. (default: current engine)
  72435. * @param reusable If the post process can be reused on the same frame. (default: false)
  72436. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72437. */
  72438. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72439. }
  72440. }
  72441. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72442. /** @hidden */
  72443. export var mrtFragmentDeclaration: {
  72444. name: string;
  72445. shader: string;
  72446. };
  72447. }
  72448. declare module "babylonjs/Shaders/geometry.fragment" {
  72449. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72450. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72451. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72452. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72453. /** @hidden */
  72454. export var geometryPixelShader: {
  72455. name: string;
  72456. shader: string;
  72457. };
  72458. }
  72459. declare module "babylonjs/Shaders/geometry.vertex" {
  72460. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72463. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72466. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72467. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72468. /** @hidden */
  72469. export var geometryVertexShader: {
  72470. name: string;
  72471. shader: string;
  72472. };
  72473. }
  72474. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72475. import { Matrix } from "babylonjs/Maths/math.vector";
  72476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72477. import { Mesh } from "babylonjs/Meshes/mesh";
  72478. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72479. import { Effect } from "babylonjs/Materials/effect";
  72480. import { Scene } from "babylonjs/scene";
  72481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72482. import "babylonjs/Shaders/geometry.fragment";
  72483. import "babylonjs/Shaders/geometry.vertex";
  72484. /** @hidden */
  72485. interface ISavedTransformationMatrix {
  72486. world: Matrix;
  72487. viewProjection: Matrix;
  72488. }
  72489. /**
  72490. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72491. */
  72492. export class GeometryBufferRenderer {
  72493. /**
  72494. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72495. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72496. */
  72497. static readonly POSITION_TEXTURE_TYPE: number;
  72498. /**
  72499. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72500. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72501. */
  72502. static readonly VELOCITY_TEXTURE_TYPE: number;
  72503. /**
  72504. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72505. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72506. */
  72507. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72508. /**
  72509. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72510. * in order to compute objects velocities when enableVelocity is set to "true"
  72511. * @hidden
  72512. */
  72513. _previousTransformationMatrices: {
  72514. [index: number]: ISavedTransformationMatrix;
  72515. };
  72516. /**
  72517. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72518. * in order to compute objects velocities when enableVelocity is set to "true"
  72519. * @hidden
  72520. */
  72521. _previousBonesTransformationMatrices: {
  72522. [index: number]: Float32Array;
  72523. };
  72524. /**
  72525. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72526. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72527. */
  72528. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72529. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72530. renderTransparentMeshes: boolean;
  72531. private _scene;
  72532. private _multiRenderTarget;
  72533. private _ratio;
  72534. private _enablePosition;
  72535. private _enableVelocity;
  72536. private _enableReflectivity;
  72537. private _positionIndex;
  72538. private _velocityIndex;
  72539. private _reflectivityIndex;
  72540. protected _effect: Effect;
  72541. protected _cachedDefines: string;
  72542. /**
  72543. * Set the render list (meshes to be rendered) used in the G buffer.
  72544. */
  72545. set renderList(meshes: Mesh[]);
  72546. /**
  72547. * Gets wether or not G buffer are supported by the running hardware.
  72548. * This requires draw buffer supports
  72549. */
  72550. get isSupported(): boolean;
  72551. /**
  72552. * Returns the index of the given texture type in the G-Buffer textures array
  72553. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72554. * @returns the index of the given texture type in the G-Buffer textures array
  72555. */
  72556. getTextureIndex(textureType: number): number;
  72557. /**
  72558. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72559. */
  72560. get enablePosition(): boolean;
  72561. /**
  72562. * Sets whether or not objects positions are enabled for the G buffer.
  72563. */
  72564. set enablePosition(enable: boolean);
  72565. /**
  72566. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72567. */
  72568. get enableVelocity(): boolean;
  72569. /**
  72570. * Sets wether or not objects velocities are enabled for the G buffer.
  72571. */
  72572. set enableVelocity(enable: boolean);
  72573. /**
  72574. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72575. */
  72576. get enableReflectivity(): boolean;
  72577. /**
  72578. * Sets wether or not objects roughness are enabled for the G buffer.
  72579. */
  72580. set enableReflectivity(enable: boolean);
  72581. /**
  72582. * Gets the scene associated with the buffer.
  72583. */
  72584. get scene(): Scene;
  72585. /**
  72586. * Gets the ratio used by the buffer during its creation.
  72587. * How big is the buffer related to the main canvas.
  72588. */
  72589. get ratio(): number;
  72590. /** @hidden */
  72591. static _SceneComponentInitialization: (scene: Scene) => void;
  72592. /**
  72593. * Creates a new G Buffer for the scene
  72594. * @param scene The scene the buffer belongs to
  72595. * @param ratio How big is the buffer related to the main canvas.
  72596. */
  72597. constructor(scene: Scene, ratio?: number);
  72598. /**
  72599. * Checks wether everything is ready to render a submesh to the G buffer.
  72600. * @param subMesh the submesh to check readiness for
  72601. * @param useInstances is the mesh drawn using instance or not
  72602. * @returns true if ready otherwise false
  72603. */
  72604. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72605. /**
  72606. * Gets the current underlying G Buffer.
  72607. * @returns the buffer
  72608. */
  72609. getGBuffer(): MultiRenderTarget;
  72610. /**
  72611. * Gets the number of samples used to render the buffer (anti aliasing).
  72612. */
  72613. get samples(): number;
  72614. /**
  72615. * Sets the number of samples used to render the buffer (anti aliasing).
  72616. */
  72617. set samples(value: number);
  72618. /**
  72619. * Disposes the renderer and frees up associated resources.
  72620. */
  72621. dispose(): void;
  72622. protected _createRenderTargets(): void;
  72623. private _copyBonesTransformationMatrices;
  72624. }
  72625. }
  72626. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72627. import { Nullable } from "babylonjs/types";
  72628. import { Scene } from "babylonjs/scene";
  72629. import { ISceneComponent } from "babylonjs/sceneComponent";
  72630. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72631. module "babylonjs/scene" {
  72632. interface Scene {
  72633. /** @hidden (Backing field) */
  72634. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72635. /**
  72636. * Gets or Sets the current geometry buffer associated to the scene.
  72637. */
  72638. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72639. /**
  72640. * Enables a GeometryBufferRender and associates it with the scene
  72641. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72642. * @returns the GeometryBufferRenderer
  72643. */
  72644. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72645. /**
  72646. * Disables the GeometryBufferRender associated with the scene
  72647. */
  72648. disableGeometryBufferRenderer(): void;
  72649. }
  72650. }
  72651. /**
  72652. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72653. * in several rendering techniques.
  72654. */
  72655. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72656. /**
  72657. * The component name helpful to identify the component in the list of scene components.
  72658. */
  72659. readonly name: string;
  72660. /**
  72661. * The scene the component belongs to.
  72662. */
  72663. scene: Scene;
  72664. /**
  72665. * Creates a new instance of the component for the given scene
  72666. * @param scene Defines the scene to register the component in
  72667. */
  72668. constructor(scene: Scene);
  72669. /**
  72670. * Registers the component in a given scene
  72671. */
  72672. register(): void;
  72673. /**
  72674. * Rebuilds the elements related to this component in case of
  72675. * context lost for instance.
  72676. */
  72677. rebuild(): void;
  72678. /**
  72679. * Disposes the component and the associated ressources
  72680. */
  72681. dispose(): void;
  72682. private _gatherRenderTargets;
  72683. }
  72684. }
  72685. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72686. /** @hidden */
  72687. export var motionBlurPixelShader: {
  72688. name: string;
  72689. shader: string;
  72690. };
  72691. }
  72692. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72693. import { Nullable } from "babylonjs/types";
  72694. import { Camera } from "babylonjs/Cameras/camera";
  72695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72696. import { Scene } from "babylonjs/scene";
  72697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72698. import "babylonjs/Animations/animatable";
  72699. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72700. import "babylonjs/Shaders/motionBlur.fragment";
  72701. import { Engine } from "babylonjs/Engines/engine";
  72702. /**
  72703. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72704. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72705. * As an example, all you have to do is to create the post-process:
  72706. * var mb = new BABYLON.MotionBlurPostProcess(
  72707. * 'mb', // The name of the effect.
  72708. * scene, // The scene containing the objects to blur according to their velocity.
  72709. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72710. * camera // The camera to apply the render pass to.
  72711. * );
  72712. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72713. */
  72714. export class MotionBlurPostProcess extends PostProcess {
  72715. /**
  72716. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72717. */
  72718. motionStrength: number;
  72719. /**
  72720. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72721. */
  72722. get motionBlurSamples(): number;
  72723. /**
  72724. * Sets the number of iterations to be used for motion blur quality
  72725. */
  72726. set motionBlurSamples(samples: number);
  72727. private _motionBlurSamples;
  72728. private _geometryBufferRenderer;
  72729. /**
  72730. * Creates a new instance MotionBlurPostProcess
  72731. * @param name The name of the effect.
  72732. * @param scene The scene containing the objects to blur according to their velocity.
  72733. * @param options The required width/height ratio to downsize to before computing the render pass.
  72734. * @param camera The camera to apply the render pass to.
  72735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72736. * @param engine The engine which the post process will be applied. (default: current engine)
  72737. * @param reusable If the post process can be reused on the same frame. (default: false)
  72738. * @param textureType Type of textures used when performing the post process. (default: 0)
  72739. * @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)
  72740. */
  72741. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72742. /**
  72743. * Excludes the given skinned mesh from computing bones velocities.
  72744. * 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.
  72745. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72746. */
  72747. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72748. /**
  72749. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72750. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72751. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72752. */
  72753. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72754. /**
  72755. * Disposes the post process.
  72756. * @param camera The camera to dispose the post process on.
  72757. */
  72758. dispose(camera?: Camera): void;
  72759. }
  72760. }
  72761. declare module "babylonjs/Shaders/refraction.fragment" {
  72762. /** @hidden */
  72763. export var refractionPixelShader: {
  72764. name: string;
  72765. shader: string;
  72766. };
  72767. }
  72768. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72769. import { Color3 } from "babylonjs/Maths/math.color";
  72770. import { Camera } from "babylonjs/Cameras/camera";
  72771. import { Texture } from "babylonjs/Materials/Textures/texture";
  72772. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72773. import { Engine } from "babylonjs/Engines/engine";
  72774. import "babylonjs/Shaders/refraction.fragment";
  72775. /**
  72776. * Post process which applies a refractin texture
  72777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72778. */
  72779. export class RefractionPostProcess extends PostProcess {
  72780. /** the base color of the refraction (used to taint the rendering) */
  72781. color: Color3;
  72782. /** simulated refraction depth */
  72783. depth: number;
  72784. /** the coefficient of the base color (0 to remove base color tainting) */
  72785. colorLevel: number;
  72786. private _refTexture;
  72787. private _ownRefractionTexture;
  72788. /**
  72789. * Gets or sets the refraction texture
  72790. * Please note that you are responsible for disposing the texture if you set it manually
  72791. */
  72792. get refractionTexture(): Texture;
  72793. set refractionTexture(value: Texture);
  72794. /**
  72795. * Initializes the RefractionPostProcess
  72796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72797. * @param name The name of the effect.
  72798. * @param refractionTextureUrl Url of the refraction texture to use
  72799. * @param color the base color of the refraction (used to taint the rendering)
  72800. * @param depth simulated refraction depth
  72801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72802. * @param camera The camera to apply the render pass to.
  72803. * @param options The required width/height ratio to downsize to before computing the render pass.
  72804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72805. * @param engine The engine which the post process will be applied. (default: current engine)
  72806. * @param reusable If the post process can be reused on the same frame. (default: false)
  72807. */
  72808. constructor(name: string, refractionTextureUrl: string,
  72809. /** the base color of the refraction (used to taint the rendering) */
  72810. color: Color3,
  72811. /** simulated refraction depth */
  72812. depth: number,
  72813. /** the coefficient of the base color (0 to remove base color tainting) */
  72814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72815. /**
  72816. * Disposes of the post process
  72817. * @param camera Camera to dispose post process on
  72818. */
  72819. dispose(camera: Camera): void;
  72820. }
  72821. }
  72822. declare module "babylonjs/Shaders/sharpen.fragment" {
  72823. /** @hidden */
  72824. export var sharpenPixelShader: {
  72825. name: string;
  72826. shader: string;
  72827. };
  72828. }
  72829. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72830. import { Nullable } from "babylonjs/types";
  72831. import { Camera } from "babylonjs/Cameras/camera";
  72832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72833. import "babylonjs/Shaders/sharpen.fragment";
  72834. import { Engine } from "babylonjs/Engines/engine";
  72835. /**
  72836. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72837. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72838. */
  72839. export class SharpenPostProcess extends PostProcess {
  72840. /**
  72841. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72842. */
  72843. colorAmount: number;
  72844. /**
  72845. * How much sharpness should be applied (default: 0.3)
  72846. */
  72847. edgeAmount: number;
  72848. /**
  72849. * Creates a new instance ConvolutionPostProcess
  72850. * @param name The name of the effect.
  72851. * @param options The required width/height ratio to downsize to before computing the render pass.
  72852. * @param camera The camera to apply the render pass to.
  72853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72854. * @param engine The engine which the post process will be applied. (default: current engine)
  72855. * @param reusable If the post process can be reused on the same frame. (default: false)
  72856. * @param textureType Type of textures used when performing the post process. (default: 0)
  72857. * @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)
  72858. */
  72859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72860. }
  72861. }
  72862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72863. import { Nullable } from "babylonjs/types";
  72864. import { Camera } from "babylonjs/Cameras/camera";
  72865. import { Engine } from "babylonjs/Engines/engine";
  72866. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72867. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72868. /**
  72869. * PostProcessRenderPipeline
  72870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72871. */
  72872. export class PostProcessRenderPipeline {
  72873. private engine;
  72874. private _renderEffects;
  72875. private _renderEffectsForIsolatedPass;
  72876. /**
  72877. * List of inspectable custom properties (used by the Inspector)
  72878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72879. */
  72880. inspectableCustomProperties: IInspectable[];
  72881. /**
  72882. * @hidden
  72883. */
  72884. protected _cameras: Camera[];
  72885. /** @hidden */
  72886. _name: string;
  72887. /**
  72888. * Gets pipeline name
  72889. */
  72890. get name(): string;
  72891. /** Gets the list of attached cameras */
  72892. get cameras(): Camera[];
  72893. /**
  72894. * Initializes a PostProcessRenderPipeline
  72895. * @param engine engine to add the pipeline to
  72896. * @param name name of the pipeline
  72897. */
  72898. constructor(engine: Engine, name: string);
  72899. /**
  72900. * Gets the class name
  72901. * @returns "PostProcessRenderPipeline"
  72902. */
  72903. getClassName(): string;
  72904. /**
  72905. * If all the render effects in the pipeline are supported
  72906. */
  72907. get isSupported(): boolean;
  72908. /**
  72909. * Adds an effect to the pipeline
  72910. * @param renderEffect the effect to add
  72911. */
  72912. addEffect(renderEffect: PostProcessRenderEffect): void;
  72913. /** @hidden */
  72914. _rebuild(): void;
  72915. /** @hidden */
  72916. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72917. /** @hidden */
  72918. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72919. /** @hidden */
  72920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72921. /** @hidden */
  72922. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72923. /** @hidden */
  72924. _attachCameras(cameras: Camera, unique: boolean): void;
  72925. /** @hidden */
  72926. _attachCameras(cameras: Camera[], unique: boolean): void;
  72927. /** @hidden */
  72928. _detachCameras(cameras: Camera): void;
  72929. /** @hidden */
  72930. _detachCameras(cameras: Nullable<Camera[]>): void;
  72931. /** @hidden */
  72932. _update(): void;
  72933. /** @hidden */
  72934. _reset(): void;
  72935. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72936. /**
  72937. * Disposes of the pipeline
  72938. */
  72939. dispose(): void;
  72940. }
  72941. }
  72942. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72943. import { Camera } from "babylonjs/Cameras/camera";
  72944. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72945. /**
  72946. * PostProcessRenderPipelineManager class
  72947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72948. */
  72949. export class PostProcessRenderPipelineManager {
  72950. private _renderPipelines;
  72951. /**
  72952. * Initializes a PostProcessRenderPipelineManager
  72953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72954. */
  72955. constructor();
  72956. /**
  72957. * Gets the list of supported render pipelines
  72958. */
  72959. get supportedPipelines(): PostProcessRenderPipeline[];
  72960. /**
  72961. * Adds a pipeline to the manager
  72962. * @param renderPipeline The pipeline to add
  72963. */
  72964. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72965. /**
  72966. * Attaches a camera to the pipeline
  72967. * @param renderPipelineName The name of the pipeline to attach to
  72968. * @param cameras the camera to attach
  72969. * @param unique if the camera can be attached multiple times to the pipeline
  72970. */
  72971. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72972. /**
  72973. * Detaches a camera from the pipeline
  72974. * @param renderPipelineName The name of the pipeline to detach from
  72975. * @param cameras the camera to detach
  72976. */
  72977. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72978. /**
  72979. * Enables an effect by name on a pipeline
  72980. * @param renderPipelineName the name of the pipeline to enable the effect in
  72981. * @param renderEffectName the name of the effect to enable
  72982. * @param cameras the cameras that the effect should be enabled on
  72983. */
  72984. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72985. /**
  72986. * Disables an effect by name on a pipeline
  72987. * @param renderPipelineName the name of the pipeline to disable the effect in
  72988. * @param renderEffectName the name of the effect to disable
  72989. * @param cameras the cameras that the effect should be disabled on
  72990. */
  72991. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72992. /**
  72993. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72994. */
  72995. update(): void;
  72996. /** @hidden */
  72997. _rebuild(): void;
  72998. /**
  72999. * Disposes of the manager and pipelines
  73000. */
  73001. dispose(): void;
  73002. }
  73003. }
  73004. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73005. import { ISceneComponent } from "babylonjs/sceneComponent";
  73006. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73007. import { Scene } from "babylonjs/scene";
  73008. module "babylonjs/scene" {
  73009. interface Scene {
  73010. /** @hidden (Backing field) */
  73011. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73012. /**
  73013. * Gets the postprocess render pipeline manager
  73014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73015. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73016. */
  73017. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73018. }
  73019. }
  73020. /**
  73021. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73022. */
  73023. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73024. /**
  73025. * The component name helpfull to identify the component in the list of scene components.
  73026. */
  73027. readonly name: string;
  73028. /**
  73029. * The scene the component belongs to.
  73030. */
  73031. scene: Scene;
  73032. /**
  73033. * Creates a new instance of the component for the given scene
  73034. * @param scene Defines the scene to register the component in
  73035. */
  73036. constructor(scene: Scene);
  73037. /**
  73038. * Registers the component in a given scene
  73039. */
  73040. register(): void;
  73041. /**
  73042. * Rebuilds the elements related to this component in case of
  73043. * context lost for instance.
  73044. */
  73045. rebuild(): void;
  73046. /**
  73047. * Disposes the component and the associated ressources
  73048. */
  73049. dispose(): void;
  73050. private _gatherRenderTargets;
  73051. }
  73052. }
  73053. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73054. import { Nullable } from "babylonjs/types";
  73055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73056. import { Camera } from "babylonjs/Cameras/camera";
  73057. import { IDisposable } from "babylonjs/scene";
  73058. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73059. import { Scene } from "babylonjs/scene";
  73060. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73061. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73062. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73063. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73064. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73065. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73066. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73067. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73068. import { Animation } from "babylonjs/Animations/animation";
  73069. /**
  73070. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73071. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73072. */
  73073. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73074. private _scene;
  73075. private _camerasToBeAttached;
  73076. /**
  73077. * ID of the sharpen post process,
  73078. */
  73079. private readonly SharpenPostProcessId;
  73080. /**
  73081. * @ignore
  73082. * ID of the image processing post process;
  73083. */
  73084. readonly ImageProcessingPostProcessId: string;
  73085. /**
  73086. * @ignore
  73087. * ID of the Fast Approximate Anti-Aliasing post process;
  73088. */
  73089. readonly FxaaPostProcessId: string;
  73090. /**
  73091. * ID of the chromatic aberration post process,
  73092. */
  73093. private readonly ChromaticAberrationPostProcessId;
  73094. /**
  73095. * ID of the grain post process
  73096. */
  73097. private readonly GrainPostProcessId;
  73098. /**
  73099. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73100. */
  73101. sharpen: SharpenPostProcess;
  73102. private _sharpenEffect;
  73103. private bloom;
  73104. /**
  73105. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73106. */
  73107. depthOfField: DepthOfFieldEffect;
  73108. /**
  73109. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73110. */
  73111. fxaa: FxaaPostProcess;
  73112. /**
  73113. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73114. */
  73115. imageProcessing: ImageProcessingPostProcess;
  73116. /**
  73117. * Chromatic aberration post process which will shift rgb colors in the image
  73118. */
  73119. chromaticAberration: ChromaticAberrationPostProcess;
  73120. private _chromaticAberrationEffect;
  73121. /**
  73122. * Grain post process which add noise to the image
  73123. */
  73124. grain: GrainPostProcess;
  73125. private _grainEffect;
  73126. /**
  73127. * Glow post process which adds a glow to emissive areas of the image
  73128. */
  73129. private _glowLayer;
  73130. /**
  73131. * Animations which can be used to tweak settings over a period of time
  73132. */
  73133. animations: Animation[];
  73134. private _imageProcessingConfigurationObserver;
  73135. private _sharpenEnabled;
  73136. private _bloomEnabled;
  73137. private _depthOfFieldEnabled;
  73138. private _depthOfFieldBlurLevel;
  73139. private _fxaaEnabled;
  73140. private _imageProcessingEnabled;
  73141. private _defaultPipelineTextureType;
  73142. private _bloomScale;
  73143. private _chromaticAberrationEnabled;
  73144. private _grainEnabled;
  73145. private _buildAllowed;
  73146. /**
  73147. * Gets active scene
  73148. */
  73149. get scene(): Scene;
  73150. /**
  73151. * Enable or disable the sharpen process from the pipeline
  73152. */
  73153. set sharpenEnabled(enabled: boolean);
  73154. get sharpenEnabled(): boolean;
  73155. private _resizeObserver;
  73156. private _hardwareScaleLevel;
  73157. private _bloomKernel;
  73158. /**
  73159. * Specifies the size of the bloom blur kernel, relative to the final output size
  73160. */
  73161. get bloomKernel(): number;
  73162. set bloomKernel(value: number);
  73163. /**
  73164. * Specifies the weight of the bloom in the final rendering
  73165. */
  73166. private _bloomWeight;
  73167. /**
  73168. * Specifies the luma threshold for the area that will be blurred by the bloom
  73169. */
  73170. private _bloomThreshold;
  73171. private _hdr;
  73172. /**
  73173. * The strength of the bloom.
  73174. */
  73175. set bloomWeight(value: number);
  73176. get bloomWeight(): number;
  73177. /**
  73178. * The strength of the bloom.
  73179. */
  73180. set bloomThreshold(value: number);
  73181. get bloomThreshold(): number;
  73182. /**
  73183. * The scale of the bloom, lower value will provide better performance.
  73184. */
  73185. set bloomScale(value: number);
  73186. get bloomScale(): number;
  73187. /**
  73188. * Enable or disable the bloom from the pipeline
  73189. */
  73190. set bloomEnabled(enabled: boolean);
  73191. get bloomEnabled(): boolean;
  73192. private _rebuildBloom;
  73193. /**
  73194. * If the depth of field is enabled.
  73195. */
  73196. get depthOfFieldEnabled(): boolean;
  73197. set depthOfFieldEnabled(enabled: boolean);
  73198. /**
  73199. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73200. */
  73201. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73202. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73203. /**
  73204. * If the anti aliasing is enabled.
  73205. */
  73206. set fxaaEnabled(enabled: boolean);
  73207. get fxaaEnabled(): boolean;
  73208. private _samples;
  73209. /**
  73210. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73211. */
  73212. set samples(sampleCount: number);
  73213. get samples(): number;
  73214. /**
  73215. * If image processing is enabled.
  73216. */
  73217. set imageProcessingEnabled(enabled: boolean);
  73218. get imageProcessingEnabled(): boolean;
  73219. /**
  73220. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73221. */
  73222. set glowLayerEnabled(enabled: boolean);
  73223. get glowLayerEnabled(): boolean;
  73224. /**
  73225. * Gets the glow layer (or null if not defined)
  73226. */
  73227. get glowLayer(): Nullable<GlowLayer>;
  73228. /**
  73229. * Enable or disable the chromaticAberration process from the pipeline
  73230. */
  73231. set chromaticAberrationEnabled(enabled: boolean);
  73232. get chromaticAberrationEnabled(): boolean;
  73233. /**
  73234. * Enable or disable the grain process from the pipeline
  73235. */
  73236. set grainEnabled(enabled: boolean);
  73237. get grainEnabled(): boolean;
  73238. /**
  73239. * @constructor
  73240. * @param name - The rendering pipeline name (default: "")
  73241. * @param hdr - If high dynamic range textures should be used (default: true)
  73242. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73243. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73244. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73245. */
  73246. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73247. /**
  73248. * Get the class name
  73249. * @returns "DefaultRenderingPipeline"
  73250. */
  73251. getClassName(): string;
  73252. /**
  73253. * Force the compilation of the entire pipeline.
  73254. */
  73255. prepare(): void;
  73256. private _hasCleared;
  73257. private _prevPostProcess;
  73258. private _prevPrevPostProcess;
  73259. private _setAutoClearAndTextureSharing;
  73260. private _depthOfFieldSceneObserver;
  73261. private _buildPipeline;
  73262. private _disposePostProcesses;
  73263. /**
  73264. * Adds a camera to the pipeline
  73265. * @param camera the camera to be added
  73266. */
  73267. addCamera(camera: Camera): void;
  73268. /**
  73269. * Removes a camera from the pipeline
  73270. * @param camera the camera to remove
  73271. */
  73272. removeCamera(camera: Camera): void;
  73273. /**
  73274. * Dispose of the pipeline and stop all post processes
  73275. */
  73276. dispose(): void;
  73277. /**
  73278. * Serialize the rendering pipeline (Used when exporting)
  73279. * @returns the serialized object
  73280. */
  73281. serialize(): any;
  73282. /**
  73283. * Parse the serialized pipeline
  73284. * @param source Source pipeline.
  73285. * @param scene The scene to load the pipeline to.
  73286. * @param rootUrl The URL of the serialized pipeline.
  73287. * @returns An instantiated pipeline from the serialized object.
  73288. */
  73289. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73290. }
  73291. }
  73292. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73293. /** @hidden */
  73294. export var lensHighlightsPixelShader: {
  73295. name: string;
  73296. shader: string;
  73297. };
  73298. }
  73299. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73300. /** @hidden */
  73301. export var depthOfFieldPixelShader: {
  73302. name: string;
  73303. shader: string;
  73304. };
  73305. }
  73306. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73307. import { Camera } from "babylonjs/Cameras/camera";
  73308. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73309. import { Scene } from "babylonjs/scene";
  73310. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73311. import "babylonjs/Shaders/chromaticAberration.fragment";
  73312. import "babylonjs/Shaders/lensHighlights.fragment";
  73313. import "babylonjs/Shaders/depthOfField.fragment";
  73314. /**
  73315. * BABYLON.JS Chromatic Aberration GLSL Shader
  73316. * Author: Olivier Guyot
  73317. * Separates very slightly R, G and B colors on the edges of the screen
  73318. * Inspired by Francois Tarlier & Martins Upitis
  73319. */
  73320. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73321. /**
  73322. * @ignore
  73323. * The chromatic aberration PostProcess id in the pipeline
  73324. */
  73325. LensChromaticAberrationEffect: string;
  73326. /**
  73327. * @ignore
  73328. * The highlights enhancing PostProcess id in the pipeline
  73329. */
  73330. HighlightsEnhancingEffect: string;
  73331. /**
  73332. * @ignore
  73333. * The depth-of-field PostProcess id in the pipeline
  73334. */
  73335. LensDepthOfFieldEffect: string;
  73336. private _scene;
  73337. private _depthTexture;
  73338. private _grainTexture;
  73339. private _chromaticAberrationPostProcess;
  73340. private _highlightsPostProcess;
  73341. private _depthOfFieldPostProcess;
  73342. private _edgeBlur;
  73343. private _grainAmount;
  73344. private _chromaticAberration;
  73345. private _distortion;
  73346. private _highlightsGain;
  73347. private _highlightsThreshold;
  73348. private _dofDistance;
  73349. private _dofAperture;
  73350. private _dofDarken;
  73351. private _dofPentagon;
  73352. private _blurNoise;
  73353. /**
  73354. * @constructor
  73355. *
  73356. * Effect parameters are as follow:
  73357. * {
  73358. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73359. * edge_blur: number; // from 0 to x (1 for realism)
  73360. * distortion: number; // from 0 to x (1 for realism)
  73361. * grain_amount: number; // from 0 to 1
  73362. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73363. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73364. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73365. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73366. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73367. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73368. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73369. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73370. * }
  73371. * Note: if an effect parameter is unset, effect is disabled
  73372. *
  73373. * @param name The rendering pipeline name
  73374. * @param parameters - An object containing all parameters (see above)
  73375. * @param scene The scene linked to this pipeline
  73376. * @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)
  73377. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73378. */
  73379. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73380. /**
  73381. * Get the class name
  73382. * @returns "LensRenderingPipeline"
  73383. */
  73384. getClassName(): string;
  73385. /**
  73386. * Gets associated scene
  73387. */
  73388. get scene(): Scene;
  73389. /**
  73390. * Gets or sets the edge blur
  73391. */
  73392. get edgeBlur(): number;
  73393. set edgeBlur(value: number);
  73394. /**
  73395. * Gets or sets the grain amount
  73396. */
  73397. get grainAmount(): number;
  73398. set grainAmount(value: number);
  73399. /**
  73400. * Gets or sets the chromatic aberration amount
  73401. */
  73402. get chromaticAberration(): number;
  73403. set chromaticAberration(value: number);
  73404. /**
  73405. * Gets or sets the depth of field aperture
  73406. */
  73407. get dofAperture(): number;
  73408. set dofAperture(value: number);
  73409. /**
  73410. * Gets or sets the edge distortion
  73411. */
  73412. get edgeDistortion(): number;
  73413. set edgeDistortion(value: number);
  73414. /**
  73415. * Gets or sets the depth of field distortion
  73416. */
  73417. get dofDistortion(): number;
  73418. set dofDistortion(value: number);
  73419. /**
  73420. * Gets or sets the darken out of focus amount
  73421. */
  73422. get darkenOutOfFocus(): number;
  73423. set darkenOutOfFocus(value: number);
  73424. /**
  73425. * Gets or sets a boolean indicating if blur noise is enabled
  73426. */
  73427. get blurNoise(): boolean;
  73428. set blurNoise(value: boolean);
  73429. /**
  73430. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73431. */
  73432. get pentagonBokeh(): boolean;
  73433. set pentagonBokeh(value: boolean);
  73434. /**
  73435. * Gets or sets the highlight grain amount
  73436. */
  73437. get highlightsGain(): number;
  73438. set highlightsGain(value: number);
  73439. /**
  73440. * Gets or sets the highlight threshold
  73441. */
  73442. get highlightsThreshold(): number;
  73443. set highlightsThreshold(value: number);
  73444. /**
  73445. * Sets the amount of blur at the edges
  73446. * @param amount blur amount
  73447. */
  73448. setEdgeBlur(amount: number): void;
  73449. /**
  73450. * Sets edge blur to 0
  73451. */
  73452. disableEdgeBlur(): void;
  73453. /**
  73454. * Sets the amout of grain
  73455. * @param amount Amount of grain
  73456. */
  73457. setGrainAmount(amount: number): void;
  73458. /**
  73459. * Set grain amount to 0
  73460. */
  73461. disableGrain(): void;
  73462. /**
  73463. * Sets the chromatic aberration amount
  73464. * @param amount amount of chromatic aberration
  73465. */
  73466. setChromaticAberration(amount: number): void;
  73467. /**
  73468. * Sets chromatic aberration amount to 0
  73469. */
  73470. disableChromaticAberration(): void;
  73471. /**
  73472. * Sets the EdgeDistortion amount
  73473. * @param amount amount of EdgeDistortion
  73474. */
  73475. setEdgeDistortion(amount: number): void;
  73476. /**
  73477. * Sets edge distortion to 0
  73478. */
  73479. disableEdgeDistortion(): void;
  73480. /**
  73481. * Sets the FocusDistance amount
  73482. * @param amount amount of FocusDistance
  73483. */
  73484. setFocusDistance(amount: number): void;
  73485. /**
  73486. * Disables depth of field
  73487. */
  73488. disableDepthOfField(): void;
  73489. /**
  73490. * Sets the Aperture amount
  73491. * @param amount amount of Aperture
  73492. */
  73493. setAperture(amount: number): void;
  73494. /**
  73495. * Sets the DarkenOutOfFocus amount
  73496. * @param amount amount of DarkenOutOfFocus
  73497. */
  73498. setDarkenOutOfFocus(amount: number): void;
  73499. private _pentagonBokehIsEnabled;
  73500. /**
  73501. * Creates a pentagon bokeh effect
  73502. */
  73503. enablePentagonBokeh(): void;
  73504. /**
  73505. * Disables the pentagon bokeh effect
  73506. */
  73507. disablePentagonBokeh(): void;
  73508. /**
  73509. * Enables noise blur
  73510. */
  73511. enableNoiseBlur(): void;
  73512. /**
  73513. * Disables noise blur
  73514. */
  73515. disableNoiseBlur(): void;
  73516. /**
  73517. * Sets the HighlightsGain amount
  73518. * @param amount amount of HighlightsGain
  73519. */
  73520. setHighlightsGain(amount: number): void;
  73521. /**
  73522. * Sets the HighlightsThreshold amount
  73523. * @param amount amount of HighlightsThreshold
  73524. */
  73525. setHighlightsThreshold(amount: number): void;
  73526. /**
  73527. * Disables highlights
  73528. */
  73529. disableHighlights(): void;
  73530. /**
  73531. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73532. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73533. */
  73534. dispose(disableDepthRender?: boolean): void;
  73535. private _createChromaticAberrationPostProcess;
  73536. private _createHighlightsPostProcess;
  73537. private _createDepthOfFieldPostProcess;
  73538. private _createGrainTexture;
  73539. }
  73540. }
  73541. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  73542. /** @hidden */
  73543. export var fibonacci: {
  73544. name: string;
  73545. shader: string;
  73546. };
  73547. }
  73548. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  73549. /** @hidden */
  73550. export var diffusionProfile: {
  73551. name: string;
  73552. shader: string;
  73553. };
  73554. }
  73555. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  73556. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  73557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73558. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  73559. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  73560. /** @hidden */
  73561. export var subSurfaceScatteringPixelShader: {
  73562. name: string;
  73563. shader: string;
  73564. };
  73565. }
  73566. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  73567. import { Nullable } from "babylonjs/types";
  73568. import { Camera } from "babylonjs/Cameras/camera";
  73569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73570. import { Engine } from "babylonjs/Engines/engine";
  73571. import { Scene } from "babylonjs/scene";
  73572. import "babylonjs/Shaders/imageProcessing.fragment";
  73573. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  73574. import "babylonjs/Shaders/postprocess.vertex";
  73575. /**
  73576. * Sub surface scattering post process
  73577. */
  73578. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73579. /** @hidden */
  73580. texelWidth: number;
  73581. /** @hidden */
  73582. texelHeight: number;
  73583. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73584. }
  73585. }
  73586. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  73587. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73588. /**
  73589. * Interface for defining prepass effects in the prepass post-process pipeline
  73590. */
  73591. export interface PrePassEffectConfiguration {
  73592. /**
  73593. * Post process to attach for this effect
  73594. */
  73595. postProcess: PostProcess;
  73596. /**
  73597. * Is the effect enabled
  73598. */
  73599. enabled: boolean;
  73600. /**
  73601. * Disposes the effect configuration
  73602. */
  73603. dispose(): void;
  73604. /**
  73605. * Disposes the effect configuration
  73606. */
  73607. createPostProcess: () => PostProcess;
  73608. }
  73609. }
  73610. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  73611. import { Scene } from "babylonjs/scene";
  73612. import { Color3 } from "babylonjs/Maths/math.color";
  73613. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  73614. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  73615. /**
  73616. * Contains all parameters needed for the prepass to perform
  73617. * screen space subsurface scattering
  73618. */
  73619. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73620. private _ssDiffusionS;
  73621. private _ssFilterRadii;
  73622. private _ssDiffusionD;
  73623. /**
  73624. * Post process to attach for screen space subsurface scattering
  73625. */
  73626. postProcess: SubSurfaceScatteringPostProcess;
  73627. /**
  73628. * Diffusion profile color for subsurface scattering
  73629. */
  73630. get ssDiffusionS(): number[];
  73631. /**
  73632. * Diffusion profile max color channel value for subsurface scattering
  73633. */
  73634. get ssDiffusionD(): number[];
  73635. /**
  73636. * Diffusion profile filter radius for subsurface scattering
  73637. */
  73638. get ssFilterRadii(): number[];
  73639. /**
  73640. * Is subsurface enabled
  73641. */
  73642. enabled: boolean;
  73643. /**
  73644. * Diffusion profile colors for subsurface scattering
  73645. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73646. * See ...
  73647. * Note that you can only store up to 5 of them
  73648. */
  73649. ssDiffusionProfileColors: Color3[];
  73650. /**
  73651. * Defines the ratio real world => scene units.
  73652. * Used for subsurface scattering
  73653. */
  73654. metersPerUnit: number;
  73655. private _scene;
  73656. /**
  73657. * Builds a subsurface configuration object
  73658. * @param scene The scene
  73659. */
  73660. constructor(scene: Scene);
  73661. /**
  73662. * Adds a new diffusion profile.
  73663. * Useful for more realistic subsurface scattering on diverse materials.
  73664. * @param color The color of the diffusion profile. Should be the average color of the material.
  73665. * @return The index of the diffusion profile for the material subsurface configuration
  73666. */
  73667. addDiffusionProfile(color: Color3): number;
  73668. /**
  73669. * Creates the sss post process
  73670. * @return The created post process
  73671. */
  73672. createPostProcess(): SubSurfaceScatteringPostProcess;
  73673. /**
  73674. * Deletes all diffusion profiles.
  73675. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73676. */
  73677. clearAllDiffusionProfiles(): void;
  73678. /**
  73679. * Disposes this object
  73680. */
  73681. dispose(): void;
  73682. /**
  73683. * @hidden
  73684. * https://zero-radiance.github.io/post/sampling-diffusion/
  73685. *
  73686. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73687. * ------------------------------------------------------------------------------------
  73688. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73689. * PDF[r, phi, s] = r * R[r, phi, s]
  73690. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73691. * ------------------------------------------------------------------------------------
  73692. * We importance sample the color channel with the widest scattering distance.
  73693. */
  73694. getDiffusionProfileParameters(color: Color3): number;
  73695. /**
  73696. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73697. * 'u' is the random number (the value of the CDF): [0, 1).
  73698. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73699. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73700. */
  73701. private _sampleBurleyDiffusionProfile;
  73702. }
  73703. }
  73704. declare module "babylonjs/Rendering/prePassRenderer" {
  73705. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73706. import { Scene } from "babylonjs/scene";
  73707. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73708. import { Effect } from "babylonjs/Materials/effect";
  73709. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  73710. /**
  73711. * Renders a pre pass of the scene
  73712. * This means every mesh in the scene will be rendered to a render target texture
  73713. * And then this texture will be composited to the rendering canvas with post processes
  73714. * It is necessary for effects like subsurface scattering or deferred shading
  73715. */
  73716. export class PrePassRenderer {
  73717. /** @hidden */
  73718. static _SceneComponentInitialization: (scene: Scene) => void;
  73719. private _scene;
  73720. private _engine;
  73721. private _isDirty;
  73722. /**
  73723. * Number of textures in the multi render target texture where the scene is directly rendered
  73724. */
  73725. readonly mrtCount: number;
  73726. /**
  73727. * The render target where the scene is directly rendered
  73728. */
  73729. prePassRT: MultiRenderTarget;
  73730. private _mrtTypes;
  73731. private _multiRenderAttachments;
  73732. private _defaultAttachments;
  73733. private _clearAttachments;
  73734. private _postProcesses;
  73735. private readonly _clearColor;
  73736. /**
  73737. * Image processing post process for composition
  73738. */
  73739. imageProcessingPostProcess: ImageProcessingPostProcess;
  73740. /**
  73741. * Configuration for sub surface scattering post process
  73742. */
  73743. subSurfaceConfiguration: SubSurfaceConfiguration;
  73744. /**
  73745. * Should materials render their geometry on the MRT
  73746. */
  73747. materialsShouldRenderGeometry: boolean;
  73748. /**
  73749. * Should materials render the irradiance information on the MRT
  73750. */
  73751. materialsShouldRenderIrradiance: boolean;
  73752. private _enabled;
  73753. /**
  73754. * Indicates if the prepass is enabled
  73755. */
  73756. get enabled(): boolean;
  73757. /**
  73758. * How many samples are used for MSAA of the scene render target
  73759. */
  73760. get samples(): number;
  73761. set samples(n: number);
  73762. /**
  73763. * Instanciates a prepass renderer
  73764. * @param scene The scene
  73765. */
  73766. constructor(scene: Scene);
  73767. private _initializeAttachments;
  73768. private _createCompositionEffect;
  73769. /**
  73770. * Indicates if rendering a prepass is supported
  73771. */
  73772. get isSupported(): boolean;
  73773. /**
  73774. * Sets the proper output textures to draw in the engine.
  73775. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  73776. */
  73777. bindAttachmentsForEffect(effect: Effect): void;
  73778. /**
  73779. * @hidden
  73780. */
  73781. _beforeCameraDraw(): void;
  73782. /**
  73783. * @hidden
  73784. */
  73785. _afterCameraDraw(): void;
  73786. private _checkRTSize;
  73787. private _bindFrameBuffer;
  73788. /**
  73789. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  73790. */
  73791. clear(): void;
  73792. private _setState;
  73793. private _enable;
  73794. private _disable;
  73795. private _resetPostProcessChain;
  73796. private _bindPostProcessChain;
  73797. /**
  73798. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  73799. */
  73800. markAsDirty(): void;
  73801. private _update;
  73802. /**
  73803. * Disposes the prepass renderer.
  73804. */
  73805. dispose(): void;
  73806. }
  73807. }
  73808. declare module "babylonjs/Shaders/ssao2.fragment" {
  73809. /** @hidden */
  73810. export var ssao2PixelShader: {
  73811. name: string;
  73812. shader: string;
  73813. };
  73814. }
  73815. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73816. /** @hidden */
  73817. export var ssaoCombinePixelShader: {
  73818. name: string;
  73819. shader: string;
  73820. };
  73821. }
  73822. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73823. import { Camera } from "babylonjs/Cameras/camera";
  73824. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73825. import { Scene } from "babylonjs/scene";
  73826. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73827. import "babylonjs/Shaders/ssao2.fragment";
  73828. import "babylonjs/Shaders/ssaoCombine.fragment";
  73829. /**
  73830. * Render pipeline to produce ssao effect
  73831. */
  73832. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73833. /**
  73834. * @ignore
  73835. * The PassPostProcess id in the pipeline that contains the original scene color
  73836. */
  73837. SSAOOriginalSceneColorEffect: string;
  73838. /**
  73839. * @ignore
  73840. * The SSAO PostProcess id in the pipeline
  73841. */
  73842. SSAORenderEffect: string;
  73843. /**
  73844. * @ignore
  73845. * The horizontal blur PostProcess id in the pipeline
  73846. */
  73847. SSAOBlurHRenderEffect: string;
  73848. /**
  73849. * @ignore
  73850. * The vertical blur PostProcess id in the pipeline
  73851. */
  73852. SSAOBlurVRenderEffect: string;
  73853. /**
  73854. * @ignore
  73855. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73856. */
  73857. SSAOCombineRenderEffect: string;
  73858. /**
  73859. * The output strength of the SSAO post-process. Default value is 1.0.
  73860. */
  73861. totalStrength: number;
  73862. /**
  73863. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73864. */
  73865. maxZ: number;
  73866. /**
  73867. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73868. */
  73869. minZAspect: number;
  73870. private _samples;
  73871. /**
  73872. * Number of samples used for the SSAO calculations. Default value is 8
  73873. */
  73874. set samples(n: number);
  73875. get samples(): number;
  73876. private _textureSamples;
  73877. /**
  73878. * Number of samples to use for antialiasing
  73879. */
  73880. set textureSamples(n: number);
  73881. get textureSamples(): number;
  73882. /**
  73883. * Force rendering the geometry through geometry buffer
  73884. */
  73885. private _forceGeometryBuffer;
  73886. /**
  73887. * Ratio object used for SSAO ratio and blur ratio
  73888. */
  73889. private _ratio;
  73890. /**
  73891. * Dynamically generated sphere sampler.
  73892. */
  73893. private _sampleSphere;
  73894. /**
  73895. * Blur filter offsets
  73896. */
  73897. private _samplerOffsets;
  73898. private _expensiveBlur;
  73899. /**
  73900. * If bilateral blur should be used
  73901. */
  73902. set expensiveBlur(b: boolean);
  73903. get expensiveBlur(): boolean;
  73904. /**
  73905. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73906. */
  73907. radius: number;
  73908. /**
  73909. * The base color of the SSAO post-process
  73910. * The final result is "base + ssao" between [0, 1]
  73911. */
  73912. base: number;
  73913. /**
  73914. * Support test.
  73915. */
  73916. static get IsSupported(): boolean;
  73917. private _scene;
  73918. private _randomTexture;
  73919. private _originalColorPostProcess;
  73920. private _ssaoPostProcess;
  73921. private _blurHPostProcess;
  73922. private _blurVPostProcess;
  73923. private _ssaoCombinePostProcess;
  73924. private _prePassRenderer;
  73925. /**
  73926. * Gets active scene
  73927. */
  73928. get scene(): Scene;
  73929. /**
  73930. * @constructor
  73931. * @param name The rendering pipeline name
  73932. * @param scene The scene linked to this pipeline
  73933. * @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 }
  73934. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73935. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  73936. */
  73937. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  73938. /**
  73939. * Get the class name
  73940. * @returns "SSAO2RenderingPipeline"
  73941. */
  73942. getClassName(): string;
  73943. /**
  73944. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73945. */
  73946. dispose(disableGeometryBufferRenderer?: boolean): void;
  73947. private _createBlurPostProcess;
  73948. /** @hidden */
  73949. _rebuild(): void;
  73950. private _bits;
  73951. private _radicalInverse_VdC;
  73952. private _hammersley;
  73953. private _hemisphereSample_uniform;
  73954. private _generateHemisphere;
  73955. private _getDefinesForSSAO;
  73956. private _createSSAOPostProcess;
  73957. private _createSSAOCombinePostProcess;
  73958. private _createRandomTexture;
  73959. /**
  73960. * Serialize the rendering pipeline (Used when exporting)
  73961. * @returns the serialized object
  73962. */
  73963. serialize(): any;
  73964. /**
  73965. * Parse the serialized pipeline
  73966. * @param source Source pipeline.
  73967. * @param scene The scene to load the pipeline to.
  73968. * @param rootUrl The URL of the serialized pipeline.
  73969. * @returns An instantiated pipeline from the serialized object.
  73970. */
  73971. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73972. }
  73973. }
  73974. declare module "babylonjs/Shaders/ssao.fragment" {
  73975. /** @hidden */
  73976. export var ssaoPixelShader: {
  73977. name: string;
  73978. shader: string;
  73979. };
  73980. }
  73981. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73982. import { Camera } from "babylonjs/Cameras/camera";
  73983. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73984. import { Scene } from "babylonjs/scene";
  73985. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73986. import "babylonjs/Shaders/ssao.fragment";
  73987. import "babylonjs/Shaders/ssaoCombine.fragment";
  73988. /**
  73989. * Render pipeline to produce ssao effect
  73990. */
  73991. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73992. /**
  73993. * @ignore
  73994. * The PassPostProcess id in the pipeline that contains the original scene color
  73995. */
  73996. SSAOOriginalSceneColorEffect: string;
  73997. /**
  73998. * @ignore
  73999. * The SSAO PostProcess id in the pipeline
  74000. */
  74001. SSAORenderEffect: string;
  74002. /**
  74003. * @ignore
  74004. * The horizontal blur PostProcess id in the pipeline
  74005. */
  74006. SSAOBlurHRenderEffect: string;
  74007. /**
  74008. * @ignore
  74009. * The vertical blur PostProcess id in the pipeline
  74010. */
  74011. SSAOBlurVRenderEffect: string;
  74012. /**
  74013. * @ignore
  74014. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74015. */
  74016. SSAOCombineRenderEffect: string;
  74017. /**
  74018. * The output strength of the SSAO post-process. Default value is 1.0.
  74019. */
  74020. totalStrength: number;
  74021. /**
  74022. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74023. */
  74024. radius: number;
  74025. /**
  74026. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74027. * Must not be equal to fallOff and superior to fallOff.
  74028. * Default value is 0.0075
  74029. */
  74030. area: number;
  74031. /**
  74032. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74033. * Must not be equal to area and inferior to area.
  74034. * Default value is 0.000001
  74035. */
  74036. fallOff: number;
  74037. /**
  74038. * The base color of the SSAO post-process
  74039. * The final result is "base + ssao" between [0, 1]
  74040. */
  74041. base: number;
  74042. private _scene;
  74043. private _depthTexture;
  74044. private _randomTexture;
  74045. private _originalColorPostProcess;
  74046. private _ssaoPostProcess;
  74047. private _blurHPostProcess;
  74048. private _blurVPostProcess;
  74049. private _ssaoCombinePostProcess;
  74050. private _firstUpdate;
  74051. /**
  74052. * Gets active scene
  74053. */
  74054. get scene(): Scene;
  74055. /**
  74056. * @constructor
  74057. * @param name - The rendering pipeline name
  74058. * @param scene - The scene linked to this pipeline
  74059. * @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 }
  74060. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74061. */
  74062. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74063. /**
  74064. * Get the class name
  74065. * @returns "SSAORenderingPipeline"
  74066. */
  74067. getClassName(): string;
  74068. /**
  74069. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74070. */
  74071. dispose(disableDepthRender?: boolean): void;
  74072. private _createBlurPostProcess;
  74073. /** @hidden */
  74074. _rebuild(): void;
  74075. private _createSSAOPostProcess;
  74076. private _createSSAOCombinePostProcess;
  74077. private _createRandomTexture;
  74078. }
  74079. }
  74080. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74081. /** @hidden */
  74082. export var screenSpaceReflectionPixelShader: {
  74083. name: string;
  74084. shader: string;
  74085. };
  74086. }
  74087. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74088. import { Nullable } from "babylonjs/types";
  74089. import { Camera } from "babylonjs/Cameras/camera";
  74090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74091. import { Scene } from "babylonjs/scene";
  74092. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74093. import { Engine } from "babylonjs/Engines/engine";
  74094. /**
  74095. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74096. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74097. */
  74098. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74099. /**
  74100. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74101. */
  74102. threshold: number;
  74103. /**
  74104. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74105. */
  74106. strength: number;
  74107. /**
  74108. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74109. */
  74110. reflectionSpecularFalloffExponent: number;
  74111. /**
  74112. * 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]
  74113. */
  74114. step: number;
  74115. /**
  74116. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74117. */
  74118. roughnessFactor: number;
  74119. private _geometryBufferRenderer;
  74120. private _enableSmoothReflections;
  74121. private _reflectionSamples;
  74122. private _smoothSteps;
  74123. /**
  74124. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74125. * @param name The name of the effect.
  74126. * @param scene The scene containing the objects to calculate reflections.
  74127. * @param options The required width/height ratio to downsize to before computing the render pass.
  74128. * @param camera The camera to apply the render pass to.
  74129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74130. * @param engine The engine which the post process will be applied. (default: current engine)
  74131. * @param reusable If the post process can be reused on the same frame. (default: false)
  74132. * @param textureType Type of textures used when performing the post process. (default: 0)
  74133. * @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)
  74134. */
  74135. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74136. /**
  74137. * Gets wether or not smoothing reflections is enabled.
  74138. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74139. */
  74140. get enableSmoothReflections(): boolean;
  74141. /**
  74142. * Sets wether or not smoothing reflections is enabled.
  74143. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74144. */
  74145. set enableSmoothReflections(enabled: boolean);
  74146. /**
  74147. * Gets the number of samples taken while computing reflections. More samples count is high,
  74148. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74149. */
  74150. get reflectionSamples(): number;
  74151. /**
  74152. * Sets the number of samples taken while computing reflections. More samples count is high,
  74153. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74154. */
  74155. set reflectionSamples(samples: number);
  74156. /**
  74157. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74158. * more the post-process will require GPU power and can generate a drop in FPS.
  74159. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74160. */
  74161. get smoothSteps(): number;
  74162. set smoothSteps(steps: number);
  74163. private _updateEffectDefines;
  74164. }
  74165. }
  74166. declare module "babylonjs/Shaders/standard.fragment" {
  74167. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74168. /** @hidden */
  74169. export var standardPixelShader: {
  74170. name: string;
  74171. shader: string;
  74172. };
  74173. }
  74174. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74175. import { Nullable } from "babylonjs/types";
  74176. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74177. import { Camera } from "babylonjs/Cameras/camera";
  74178. import { Texture } from "babylonjs/Materials/Textures/texture";
  74179. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74180. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74181. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74182. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74183. import { IDisposable } from "babylonjs/scene";
  74184. import { SpotLight } from "babylonjs/Lights/spotLight";
  74185. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74186. import { Scene } from "babylonjs/scene";
  74187. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74188. import { Animation } from "babylonjs/Animations/animation";
  74189. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74190. import "babylonjs/Shaders/standard.fragment";
  74191. /**
  74192. * Standard rendering pipeline
  74193. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74194. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74195. */
  74196. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74197. /**
  74198. * Public members
  74199. */
  74200. /**
  74201. * Post-process which contains the original scene color before the pipeline applies all the effects
  74202. */
  74203. originalPostProcess: Nullable<PostProcess>;
  74204. /**
  74205. * Post-process used to down scale an image x4
  74206. */
  74207. downSampleX4PostProcess: Nullable<PostProcess>;
  74208. /**
  74209. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74210. */
  74211. brightPassPostProcess: Nullable<PostProcess>;
  74212. /**
  74213. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74214. */
  74215. blurHPostProcesses: PostProcess[];
  74216. /**
  74217. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74218. */
  74219. blurVPostProcesses: PostProcess[];
  74220. /**
  74221. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74222. */
  74223. textureAdderPostProcess: Nullable<PostProcess>;
  74224. /**
  74225. * Post-process used to create volumetric lighting effect
  74226. */
  74227. volumetricLightPostProcess: Nullable<PostProcess>;
  74228. /**
  74229. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74230. */
  74231. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74232. /**
  74233. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74234. */
  74235. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74236. /**
  74237. * Post-process used to merge the volumetric light effect and the real scene color
  74238. */
  74239. volumetricLightMergePostProces: Nullable<PostProcess>;
  74240. /**
  74241. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74242. */
  74243. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74244. /**
  74245. * Base post-process used to calculate the average luminance of the final image for HDR
  74246. */
  74247. luminancePostProcess: Nullable<PostProcess>;
  74248. /**
  74249. * Post-processes used to create down sample post-processes in order to get
  74250. * the average luminance of the final image for HDR
  74251. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74252. */
  74253. luminanceDownSamplePostProcesses: PostProcess[];
  74254. /**
  74255. * Post-process used to create a HDR effect (light adaptation)
  74256. */
  74257. hdrPostProcess: Nullable<PostProcess>;
  74258. /**
  74259. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74260. */
  74261. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74262. /**
  74263. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74264. */
  74265. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74266. /**
  74267. * Post-process used to merge the final HDR post-process and the real scene color
  74268. */
  74269. hdrFinalPostProcess: Nullable<PostProcess>;
  74270. /**
  74271. * Post-process used to create a lens flare effect
  74272. */
  74273. lensFlarePostProcess: Nullable<PostProcess>;
  74274. /**
  74275. * Post-process that merges the result of the lens flare post-process and the real scene color
  74276. */
  74277. lensFlareComposePostProcess: Nullable<PostProcess>;
  74278. /**
  74279. * Post-process used to create a motion blur effect
  74280. */
  74281. motionBlurPostProcess: Nullable<PostProcess>;
  74282. /**
  74283. * Post-process used to create a depth of field effect
  74284. */
  74285. depthOfFieldPostProcess: Nullable<PostProcess>;
  74286. /**
  74287. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74288. */
  74289. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74290. /**
  74291. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74292. */
  74293. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74294. /**
  74295. * Represents the brightness threshold in order to configure the illuminated surfaces
  74296. */
  74297. brightThreshold: number;
  74298. /**
  74299. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74300. */
  74301. blurWidth: number;
  74302. /**
  74303. * Sets if the blur for highlighted surfaces must be only horizontal
  74304. */
  74305. horizontalBlur: boolean;
  74306. /**
  74307. * Gets the overall exposure used by the pipeline
  74308. */
  74309. get exposure(): number;
  74310. /**
  74311. * Sets the overall exposure used by the pipeline
  74312. */
  74313. set exposure(value: number);
  74314. /**
  74315. * Texture used typically to simulate "dirty" on camera lens
  74316. */
  74317. lensTexture: Nullable<Texture>;
  74318. /**
  74319. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74320. */
  74321. volumetricLightCoefficient: number;
  74322. /**
  74323. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74324. */
  74325. volumetricLightPower: number;
  74326. /**
  74327. * Used the set the blur intensity to smooth the volumetric lights
  74328. */
  74329. volumetricLightBlurScale: number;
  74330. /**
  74331. * Light (spot or directional) used to generate the volumetric lights rays
  74332. * The source light must have a shadow generate so the pipeline can get its
  74333. * depth map
  74334. */
  74335. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74336. /**
  74337. * For eye adaptation, represents the minimum luminance the eye can see
  74338. */
  74339. hdrMinimumLuminance: number;
  74340. /**
  74341. * For eye adaptation, represents the decrease luminance speed
  74342. */
  74343. hdrDecreaseRate: number;
  74344. /**
  74345. * For eye adaptation, represents the increase luminance speed
  74346. */
  74347. hdrIncreaseRate: number;
  74348. /**
  74349. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74350. */
  74351. get hdrAutoExposure(): boolean;
  74352. /**
  74353. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74354. */
  74355. set hdrAutoExposure(value: boolean);
  74356. /**
  74357. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74358. */
  74359. lensColorTexture: Nullable<Texture>;
  74360. /**
  74361. * The overall strengh for the lens flare effect
  74362. */
  74363. lensFlareStrength: number;
  74364. /**
  74365. * Dispersion coefficient for lens flare ghosts
  74366. */
  74367. lensFlareGhostDispersal: number;
  74368. /**
  74369. * Main lens flare halo width
  74370. */
  74371. lensFlareHaloWidth: number;
  74372. /**
  74373. * Based on the lens distortion effect, defines how much the lens flare result
  74374. * is distorted
  74375. */
  74376. lensFlareDistortionStrength: number;
  74377. /**
  74378. * Configures the blur intensity used for for lens flare (halo)
  74379. */
  74380. lensFlareBlurWidth: number;
  74381. /**
  74382. * Lens star texture must be used to simulate rays on the flares and is available
  74383. * in the documentation
  74384. */
  74385. lensStarTexture: Nullable<Texture>;
  74386. /**
  74387. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74388. * flare effect by taking account of the dirt texture
  74389. */
  74390. lensFlareDirtTexture: Nullable<Texture>;
  74391. /**
  74392. * Represents the focal length for the depth of field effect
  74393. */
  74394. depthOfFieldDistance: number;
  74395. /**
  74396. * Represents the blur intensity for the blurred part of the depth of field effect
  74397. */
  74398. depthOfFieldBlurWidth: number;
  74399. /**
  74400. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74401. */
  74402. get motionStrength(): number;
  74403. /**
  74404. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74405. */
  74406. set motionStrength(strength: number);
  74407. /**
  74408. * Gets wether or not the motion blur post-process is object based or screen based.
  74409. */
  74410. get objectBasedMotionBlur(): boolean;
  74411. /**
  74412. * Sets wether or not the motion blur post-process should be object based or screen based
  74413. */
  74414. set objectBasedMotionBlur(value: boolean);
  74415. /**
  74416. * List of animations for the pipeline (IAnimatable implementation)
  74417. */
  74418. animations: Animation[];
  74419. /**
  74420. * Private members
  74421. */
  74422. private _scene;
  74423. private _currentDepthOfFieldSource;
  74424. private _basePostProcess;
  74425. private _fixedExposure;
  74426. private _currentExposure;
  74427. private _hdrAutoExposure;
  74428. private _hdrCurrentLuminance;
  74429. private _motionStrength;
  74430. private _isObjectBasedMotionBlur;
  74431. private _floatTextureType;
  74432. private _camerasToBeAttached;
  74433. private _ratio;
  74434. private _bloomEnabled;
  74435. private _depthOfFieldEnabled;
  74436. private _vlsEnabled;
  74437. private _lensFlareEnabled;
  74438. private _hdrEnabled;
  74439. private _motionBlurEnabled;
  74440. private _fxaaEnabled;
  74441. private _screenSpaceReflectionsEnabled;
  74442. private _motionBlurSamples;
  74443. private _volumetricLightStepsCount;
  74444. private _samples;
  74445. /**
  74446. * @ignore
  74447. * Specifies if the bloom pipeline is enabled
  74448. */
  74449. get BloomEnabled(): boolean;
  74450. set BloomEnabled(enabled: boolean);
  74451. /**
  74452. * @ignore
  74453. * Specifies if the depth of field pipeline is enabed
  74454. */
  74455. get DepthOfFieldEnabled(): boolean;
  74456. set DepthOfFieldEnabled(enabled: boolean);
  74457. /**
  74458. * @ignore
  74459. * Specifies if the lens flare pipeline is enabed
  74460. */
  74461. get LensFlareEnabled(): boolean;
  74462. set LensFlareEnabled(enabled: boolean);
  74463. /**
  74464. * @ignore
  74465. * Specifies if the HDR pipeline is enabled
  74466. */
  74467. get HDREnabled(): boolean;
  74468. set HDREnabled(enabled: boolean);
  74469. /**
  74470. * @ignore
  74471. * Specifies if the volumetric lights scattering effect is enabled
  74472. */
  74473. get VLSEnabled(): boolean;
  74474. set VLSEnabled(enabled: boolean);
  74475. /**
  74476. * @ignore
  74477. * Specifies if the motion blur effect is enabled
  74478. */
  74479. get MotionBlurEnabled(): boolean;
  74480. set MotionBlurEnabled(enabled: boolean);
  74481. /**
  74482. * Specifies if anti-aliasing is enabled
  74483. */
  74484. get fxaaEnabled(): boolean;
  74485. set fxaaEnabled(enabled: boolean);
  74486. /**
  74487. * Specifies if screen space reflections are enabled.
  74488. */
  74489. get screenSpaceReflectionsEnabled(): boolean;
  74490. set screenSpaceReflectionsEnabled(enabled: boolean);
  74491. /**
  74492. * Specifies the number of steps used to calculate the volumetric lights
  74493. * Typically in interval [50, 200]
  74494. */
  74495. get volumetricLightStepsCount(): number;
  74496. set volumetricLightStepsCount(count: number);
  74497. /**
  74498. * Specifies the number of samples used for the motion blur effect
  74499. * Typically in interval [16, 64]
  74500. */
  74501. get motionBlurSamples(): number;
  74502. set motionBlurSamples(samples: number);
  74503. /**
  74504. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74505. */
  74506. get samples(): number;
  74507. set samples(sampleCount: number);
  74508. /**
  74509. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74510. * @constructor
  74511. * @param name The rendering pipeline name
  74512. * @param scene The scene linked to this pipeline
  74513. * @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)
  74514. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74515. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74516. */
  74517. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74518. private _buildPipeline;
  74519. private _createDownSampleX4PostProcess;
  74520. private _createBrightPassPostProcess;
  74521. private _createBlurPostProcesses;
  74522. private _createTextureAdderPostProcess;
  74523. private _createVolumetricLightPostProcess;
  74524. private _createLuminancePostProcesses;
  74525. private _createHdrPostProcess;
  74526. private _createLensFlarePostProcess;
  74527. private _createDepthOfFieldPostProcess;
  74528. private _createMotionBlurPostProcess;
  74529. private _getDepthTexture;
  74530. private _disposePostProcesses;
  74531. /**
  74532. * Dispose of the pipeline and stop all post processes
  74533. */
  74534. dispose(): void;
  74535. /**
  74536. * Serialize the rendering pipeline (Used when exporting)
  74537. * @returns the serialized object
  74538. */
  74539. serialize(): any;
  74540. /**
  74541. * Parse the serialized pipeline
  74542. * @param source Source pipeline.
  74543. * @param scene The scene to load the pipeline to.
  74544. * @param rootUrl The URL of the serialized pipeline.
  74545. * @returns An instantiated pipeline from the serialized object.
  74546. */
  74547. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74548. /**
  74549. * Luminance steps
  74550. */
  74551. static LuminanceSteps: number;
  74552. }
  74553. }
  74554. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74555. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74556. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74557. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74558. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74559. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74560. }
  74561. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74562. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74563. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74564. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74565. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74566. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74567. }
  74568. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74569. /** @hidden */
  74570. export var stereoscopicInterlacePixelShader: {
  74571. name: string;
  74572. shader: string;
  74573. };
  74574. }
  74575. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74576. import { Camera } from "babylonjs/Cameras/camera";
  74577. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74578. import { Engine } from "babylonjs/Engines/engine";
  74579. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74580. /**
  74581. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74582. */
  74583. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74584. private _stepSize;
  74585. private _passedProcess;
  74586. /**
  74587. * Initializes a StereoscopicInterlacePostProcessI
  74588. * @param name The name of the effect.
  74589. * @param rigCameras The rig cameras to be appled to the post process
  74590. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74591. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74593. * @param engine The engine which the post process will be applied. (default: current engine)
  74594. * @param reusable If the post process can be reused on the same frame. (default: false)
  74595. */
  74596. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74597. }
  74598. /**
  74599. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74600. */
  74601. export class StereoscopicInterlacePostProcess extends PostProcess {
  74602. private _stepSize;
  74603. private _passedProcess;
  74604. /**
  74605. * Initializes a StereoscopicInterlacePostProcess
  74606. * @param name The name of the effect.
  74607. * @param rigCameras The rig cameras to be appled to the post process
  74608. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74610. * @param engine The engine which the post process will be applied. (default: current engine)
  74611. * @param reusable If the post process can be reused on the same frame. (default: false)
  74612. */
  74613. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74614. }
  74615. }
  74616. declare module "babylonjs/Shaders/tonemap.fragment" {
  74617. /** @hidden */
  74618. export var tonemapPixelShader: {
  74619. name: string;
  74620. shader: string;
  74621. };
  74622. }
  74623. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74624. import { Camera } from "babylonjs/Cameras/camera";
  74625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74626. import "babylonjs/Shaders/tonemap.fragment";
  74627. import { Engine } from "babylonjs/Engines/engine";
  74628. /** Defines operator used for tonemapping */
  74629. export enum TonemappingOperator {
  74630. /** Hable */
  74631. Hable = 0,
  74632. /** Reinhard */
  74633. Reinhard = 1,
  74634. /** HejiDawson */
  74635. HejiDawson = 2,
  74636. /** Photographic */
  74637. Photographic = 3
  74638. }
  74639. /**
  74640. * Defines a post process to apply tone mapping
  74641. */
  74642. export class TonemapPostProcess extends PostProcess {
  74643. private _operator;
  74644. /** Defines the required exposure adjustement */
  74645. exposureAdjustment: number;
  74646. /**
  74647. * Creates a new TonemapPostProcess
  74648. * @param name defines the name of the postprocess
  74649. * @param _operator defines the operator to use
  74650. * @param exposureAdjustment defines the required exposure adjustement
  74651. * @param camera defines the camera to use (can be null)
  74652. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74653. * @param engine defines the hosting engine (can be ignore if camera is set)
  74654. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74655. */
  74656. constructor(name: string, _operator: TonemappingOperator,
  74657. /** Defines the required exposure adjustement */
  74658. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74659. }
  74660. }
  74661. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74662. /** @hidden */
  74663. export var volumetricLightScatteringPixelShader: {
  74664. name: string;
  74665. shader: string;
  74666. };
  74667. }
  74668. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74669. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74670. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74671. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74672. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74674. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74675. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74676. /** @hidden */
  74677. export var volumetricLightScatteringPassVertexShader: {
  74678. name: string;
  74679. shader: string;
  74680. };
  74681. }
  74682. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74683. /** @hidden */
  74684. export var volumetricLightScatteringPassPixelShader: {
  74685. name: string;
  74686. shader: string;
  74687. };
  74688. }
  74689. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74690. import { Vector3 } from "babylonjs/Maths/math.vector";
  74691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74692. import { Mesh } from "babylonjs/Meshes/mesh";
  74693. import { Camera } from "babylonjs/Cameras/camera";
  74694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74695. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74696. import { Scene } from "babylonjs/scene";
  74697. import "babylonjs/Meshes/Builders/planeBuilder";
  74698. import "babylonjs/Shaders/depth.vertex";
  74699. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74700. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74701. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74702. import { Engine } from "babylonjs/Engines/engine";
  74703. /**
  74704. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74705. */
  74706. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74707. private _volumetricLightScatteringPass;
  74708. private _volumetricLightScatteringRTT;
  74709. private _viewPort;
  74710. private _screenCoordinates;
  74711. private _cachedDefines;
  74712. /**
  74713. * If not undefined, the mesh position is computed from the attached node position
  74714. */
  74715. attachedNode: {
  74716. position: Vector3;
  74717. };
  74718. /**
  74719. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74720. */
  74721. customMeshPosition: Vector3;
  74722. /**
  74723. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74724. */
  74725. useCustomMeshPosition: boolean;
  74726. /**
  74727. * If the post-process should inverse the light scattering direction
  74728. */
  74729. invert: boolean;
  74730. /**
  74731. * The internal mesh used by the post-process
  74732. */
  74733. mesh: Mesh;
  74734. /**
  74735. * @hidden
  74736. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74737. */
  74738. get useDiffuseColor(): boolean;
  74739. set useDiffuseColor(useDiffuseColor: boolean);
  74740. /**
  74741. * Array containing the excluded meshes not rendered in the internal pass
  74742. */
  74743. excludedMeshes: AbstractMesh[];
  74744. /**
  74745. * Controls the overall intensity of the post-process
  74746. */
  74747. exposure: number;
  74748. /**
  74749. * Dissipates each sample's contribution in range [0, 1]
  74750. */
  74751. decay: number;
  74752. /**
  74753. * Controls the overall intensity of each sample
  74754. */
  74755. weight: number;
  74756. /**
  74757. * Controls the density of each sample
  74758. */
  74759. density: number;
  74760. /**
  74761. * @constructor
  74762. * @param name The post-process name
  74763. * @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)
  74764. * @param camera The camera that the post-process will be attached to
  74765. * @param mesh The mesh used to create the light scattering
  74766. * @param samples The post-process quality, default 100
  74767. * @param samplingModeThe post-process filtering mode
  74768. * @param engine The babylon engine
  74769. * @param reusable If the post-process is reusable
  74770. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74771. */
  74772. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74773. /**
  74774. * Returns the string "VolumetricLightScatteringPostProcess"
  74775. * @returns "VolumetricLightScatteringPostProcess"
  74776. */
  74777. getClassName(): string;
  74778. private _isReady;
  74779. /**
  74780. * Sets the new light position for light scattering effect
  74781. * @param position The new custom light position
  74782. */
  74783. setCustomMeshPosition(position: Vector3): void;
  74784. /**
  74785. * Returns the light position for light scattering effect
  74786. * @return Vector3 The custom light position
  74787. */
  74788. getCustomMeshPosition(): Vector3;
  74789. /**
  74790. * Disposes the internal assets and detaches the post-process from the camera
  74791. */
  74792. dispose(camera: Camera): void;
  74793. /**
  74794. * Returns the render target texture used by the post-process
  74795. * @return the render target texture used by the post-process
  74796. */
  74797. getPass(): RenderTargetTexture;
  74798. private _meshExcluded;
  74799. private _createPass;
  74800. private _updateMeshScreenCoordinates;
  74801. /**
  74802. * Creates a default mesh for the Volumeric Light Scattering post-process
  74803. * @param name The mesh name
  74804. * @param scene The scene where to create the mesh
  74805. * @return the default mesh
  74806. */
  74807. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74808. }
  74809. }
  74810. declare module "babylonjs/PostProcesses/index" {
  74811. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74812. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74813. export * from "babylonjs/PostProcesses/bloomEffect";
  74814. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74815. export * from "babylonjs/PostProcesses/blurPostProcess";
  74816. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74817. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74818. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74819. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74820. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74821. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74822. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74823. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74824. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74825. export * from "babylonjs/PostProcesses/filterPostProcess";
  74826. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74827. export * from "babylonjs/PostProcesses/grainPostProcess";
  74828. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74829. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74830. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74831. export * from "babylonjs/PostProcesses/passPostProcess";
  74832. export * from "babylonjs/PostProcesses/postProcess";
  74833. export * from "babylonjs/PostProcesses/postProcessManager";
  74834. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74835. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74836. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74837. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74838. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74839. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74840. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74841. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74842. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74843. }
  74844. declare module "babylonjs/Probes/index" {
  74845. export * from "babylonjs/Probes/reflectionProbe";
  74846. }
  74847. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74848. import { Scene } from "babylonjs/scene";
  74849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74850. import { SmartArray } from "babylonjs/Misc/smartArray";
  74851. import { ISceneComponent } from "babylonjs/sceneComponent";
  74852. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74853. import "babylonjs/Meshes/Builders/boxBuilder";
  74854. import "babylonjs/Shaders/color.fragment";
  74855. import "babylonjs/Shaders/color.vertex";
  74856. import { Color3 } from "babylonjs/Maths/math.color";
  74857. import { Observable } from "babylonjs/Misc/observable";
  74858. module "babylonjs/scene" {
  74859. interface Scene {
  74860. /** @hidden (Backing field) */
  74861. _boundingBoxRenderer: BoundingBoxRenderer;
  74862. /** @hidden (Backing field) */
  74863. _forceShowBoundingBoxes: boolean;
  74864. /**
  74865. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74866. */
  74867. forceShowBoundingBoxes: boolean;
  74868. /**
  74869. * Gets the bounding box renderer associated with the scene
  74870. * @returns a BoundingBoxRenderer
  74871. */
  74872. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74873. }
  74874. }
  74875. module "babylonjs/Meshes/abstractMesh" {
  74876. interface AbstractMesh {
  74877. /** @hidden (Backing field) */
  74878. _showBoundingBox: boolean;
  74879. /**
  74880. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74881. */
  74882. showBoundingBox: boolean;
  74883. }
  74884. }
  74885. /**
  74886. * Component responsible of rendering the bounding box of the meshes in a scene.
  74887. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74888. */
  74889. export class BoundingBoxRenderer implements ISceneComponent {
  74890. /**
  74891. * The component name helpfull to identify the component in the list of scene components.
  74892. */
  74893. readonly name: string;
  74894. /**
  74895. * The scene the component belongs to.
  74896. */
  74897. scene: Scene;
  74898. /**
  74899. * Color of the bounding box lines placed in front of an object
  74900. */
  74901. frontColor: Color3;
  74902. /**
  74903. * Color of the bounding box lines placed behind an object
  74904. */
  74905. backColor: Color3;
  74906. /**
  74907. * Defines if the renderer should show the back lines or not
  74908. */
  74909. showBackLines: boolean;
  74910. /**
  74911. * Observable raised before rendering a bounding box
  74912. */
  74913. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74914. /**
  74915. * Observable raised after rendering a bounding box
  74916. */
  74917. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74918. /**
  74919. * @hidden
  74920. */
  74921. renderList: SmartArray<BoundingBox>;
  74922. private _colorShader;
  74923. private _vertexBuffers;
  74924. private _indexBuffer;
  74925. private _fillIndexBuffer;
  74926. private _fillIndexData;
  74927. /**
  74928. * Instantiates a new bounding box renderer in a scene.
  74929. * @param scene the scene the renderer renders in
  74930. */
  74931. constructor(scene: Scene);
  74932. /**
  74933. * Registers the component in a given scene
  74934. */
  74935. register(): void;
  74936. private _evaluateSubMesh;
  74937. private _activeMesh;
  74938. private _prepareRessources;
  74939. private _createIndexBuffer;
  74940. /**
  74941. * Rebuilds the elements related to this component in case of
  74942. * context lost for instance.
  74943. */
  74944. rebuild(): void;
  74945. /**
  74946. * @hidden
  74947. */
  74948. reset(): void;
  74949. /**
  74950. * Render the bounding boxes of a specific rendering group
  74951. * @param renderingGroupId defines the rendering group to render
  74952. */
  74953. render(renderingGroupId: number): void;
  74954. /**
  74955. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74956. * @param mesh Define the mesh to render the occlusion bounding box for
  74957. */
  74958. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74959. /**
  74960. * Dispose and release the resources attached to this renderer.
  74961. */
  74962. dispose(): void;
  74963. }
  74964. }
  74965. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74966. import { Nullable } from "babylonjs/types";
  74967. import { Scene } from "babylonjs/scene";
  74968. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74969. import { Camera } from "babylonjs/Cameras/camera";
  74970. import { ISceneComponent } from "babylonjs/sceneComponent";
  74971. module "babylonjs/scene" {
  74972. interface Scene {
  74973. /** @hidden (Backing field) */
  74974. _depthRenderer: {
  74975. [id: string]: DepthRenderer;
  74976. };
  74977. /**
  74978. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74979. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74980. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74981. * @returns the created depth renderer
  74982. */
  74983. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74984. /**
  74985. * Disables a depth renderer for a given camera
  74986. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74987. */
  74988. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74989. }
  74990. }
  74991. /**
  74992. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74993. * in several rendering techniques.
  74994. */
  74995. export class DepthRendererSceneComponent implements ISceneComponent {
  74996. /**
  74997. * The component name helpfull to identify the component in the list of scene components.
  74998. */
  74999. readonly name: string;
  75000. /**
  75001. * The scene the component belongs to.
  75002. */
  75003. scene: Scene;
  75004. /**
  75005. * Creates a new instance of the component for the given scene
  75006. * @param scene Defines the scene to register the component in
  75007. */
  75008. constructor(scene: Scene);
  75009. /**
  75010. * Registers the component in a given scene
  75011. */
  75012. register(): void;
  75013. /**
  75014. * Rebuilds the elements related to this component in case of
  75015. * context lost for instance.
  75016. */
  75017. rebuild(): void;
  75018. /**
  75019. * Disposes the component and the associated ressources
  75020. */
  75021. dispose(): void;
  75022. private _gatherRenderTargets;
  75023. private _gatherActiveCameraRenderTargets;
  75024. }
  75025. }
  75026. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75027. import { Nullable } from "babylonjs/types";
  75028. import { Scene } from "babylonjs/scene";
  75029. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75030. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75031. import { AbstractScene } from "babylonjs/abstractScene";
  75032. module "babylonjs/abstractScene" {
  75033. interface AbstractScene {
  75034. /** @hidden (Backing field) */
  75035. _prePassRenderer: Nullable<PrePassRenderer>;
  75036. /**
  75037. * Gets or Sets the current prepass renderer associated to the scene.
  75038. */
  75039. prePassRenderer: Nullable<PrePassRenderer>;
  75040. /**
  75041. * Enables the prepass and associates it with the scene
  75042. * @returns the PrePassRenderer
  75043. */
  75044. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75045. /**
  75046. * Disables the prepass associated with the scene
  75047. */
  75048. disablePrePassRenderer(): void;
  75049. }
  75050. }
  75051. /**
  75052. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75053. * in several rendering techniques.
  75054. */
  75055. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75056. /**
  75057. * The component name helpful to identify the component in the list of scene components.
  75058. */
  75059. readonly name: string;
  75060. /**
  75061. * The scene the component belongs to.
  75062. */
  75063. scene: Scene;
  75064. /**
  75065. * Creates a new instance of the component for the given scene
  75066. * @param scene Defines the scene to register the component in
  75067. */
  75068. constructor(scene: Scene);
  75069. /**
  75070. * Registers the component in a given scene
  75071. */
  75072. register(): void;
  75073. private _beforeCameraDraw;
  75074. private _afterCameraDraw;
  75075. private _beforeClearStage;
  75076. /**
  75077. * Serializes the component data to the specified json object
  75078. * @param serializationObject The object to serialize to
  75079. */
  75080. serialize(serializationObject: any): void;
  75081. /**
  75082. * Adds all the elements from the container to the scene
  75083. * @param container the container holding the elements
  75084. */
  75085. addFromContainer(container: AbstractScene): void;
  75086. /**
  75087. * Removes all the elements in the container from the scene
  75088. * @param container contains the elements to remove
  75089. * @param dispose if the removed element should be disposed (default: false)
  75090. */
  75091. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75092. /**
  75093. * Rebuilds the elements related to this component in case of
  75094. * context lost for instance.
  75095. */
  75096. rebuild(): void;
  75097. /**
  75098. * Disposes the component and the associated ressources
  75099. */
  75100. dispose(): void;
  75101. }
  75102. }
  75103. declare module "babylonjs/Shaders/outline.fragment" {
  75104. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75105. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75106. /** @hidden */
  75107. export var outlinePixelShader: {
  75108. name: string;
  75109. shader: string;
  75110. };
  75111. }
  75112. declare module "babylonjs/Shaders/outline.vertex" {
  75113. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75114. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75115. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75116. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75117. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75118. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75119. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75120. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75121. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75122. /** @hidden */
  75123. export var outlineVertexShader: {
  75124. name: string;
  75125. shader: string;
  75126. };
  75127. }
  75128. declare module "babylonjs/Rendering/outlineRenderer" {
  75129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75130. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75131. import { Scene } from "babylonjs/scene";
  75132. import { ISceneComponent } from "babylonjs/sceneComponent";
  75133. import "babylonjs/Shaders/outline.fragment";
  75134. import "babylonjs/Shaders/outline.vertex";
  75135. module "babylonjs/scene" {
  75136. interface Scene {
  75137. /** @hidden */
  75138. _outlineRenderer: OutlineRenderer;
  75139. /**
  75140. * Gets the outline renderer associated with the scene
  75141. * @returns a OutlineRenderer
  75142. */
  75143. getOutlineRenderer(): OutlineRenderer;
  75144. }
  75145. }
  75146. module "babylonjs/Meshes/abstractMesh" {
  75147. interface AbstractMesh {
  75148. /** @hidden (Backing field) */
  75149. _renderOutline: boolean;
  75150. /**
  75151. * Gets or sets a boolean indicating if the outline must be rendered as well
  75152. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75153. */
  75154. renderOutline: boolean;
  75155. /** @hidden (Backing field) */
  75156. _renderOverlay: boolean;
  75157. /**
  75158. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75159. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75160. */
  75161. renderOverlay: boolean;
  75162. }
  75163. }
  75164. /**
  75165. * This class is responsible to draw bothe outline/overlay of meshes.
  75166. * It should not be used directly but through the available method on mesh.
  75167. */
  75168. export class OutlineRenderer implements ISceneComponent {
  75169. /**
  75170. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75171. */
  75172. private static _StencilReference;
  75173. /**
  75174. * The name of the component. Each component must have a unique name.
  75175. */
  75176. name: string;
  75177. /**
  75178. * The scene the component belongs to.
  75179. */
  75180. scene: Scene;
  75181. /**
  75182. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75183. */
  75184. zOffset: number;
  75185. private _engine;
  75186. private _effect;
  75187. private _cachedDefines;
  75188. private _savedDepthWrite;
  75189. /**
  75190. * Instantiates a new outline renderer. (There could be only one per scene).
  75191. * @param scene Defines the scene it belongs to
  75192. */
  75193. constructor(scene: Scene);
  75194. /**
  75195. * Register the component to one instance of a scene.
  75196. */
  75197. register(): void;
  75198. /**
  75199. * Rebuilds the elements related to this component in case of
  75200. * context lost for instance.
  75201. */
  75202. rebuild(): void;
  75203. /**
  75204. * Disposes the component and the associated ressources.
  75205. */
  75206. dispose(): void;
  75207. /**
  75208. * Renders the outline in the canvas.
  75209. * @param subMesh Defines the sumesh to render
  75210. * @param batch Defines the batch of meshes in case of instances
  75211. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75212. */
  75213. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75214. /**
  75215. * Returns whether or not the outline renderer is ready for a given submesh.
  75216. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75217. * @param subMesh Defines the submesh to check readyness for
  75218. * @param useInstances Defines wheter wee are trying to render instances or not
  75219. * @returns true if ready otherwise false
  75220. */
  75221. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75222. private _beforeRenderingMesh;
  75223. private _afterRenderingMesh;
  75224. }
  75225. }
  75226. declare module "babylonjs/Rendering/index" {
  75227. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75228. export * from "babylonjs/Rendering/depthRenderer";
  75229. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75230. export * from "babylonjs/Rendering/edgesRenderer";
  75231. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75232. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75233. export * from "babylonjs/Rendering/prePassRenderer";
  75234. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75235. export * from "babylonjs/Rendering/outlineRenderer";
  75236. export * from "babylonjs/Rendering/renderingGroup";
  75237. export * from "babylonjs/Rendering/renderingManager";
  75238. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75239. }
  75240. declare module "babylonjs/Sprites/ISprites" {
  75241. /**
  75242. * Defines the basic options interface of a Sprite Frame Source Size.
  75243. */
  75244. export interface ISpriteJSONSpriteSourceSize {
  75245. /**
  75246. * number of the original width of the Frame
  75247. */
  75248. w: number;
  75249. /**
  75250. * number of the original height of the Frame
  75251. */
  75252. h: number;
  75253. }
  75254. /**
  75255. * Defines the basic options interface of a Sprite Frame Data.
  75256. */
  75257. export interface ISpriteJSONSpriteFrameData {
  75258. /**
  75259. * number of the x offset of the Frame
  75260. */
  75261. x: number;
  75262. /**
  75263. * number of the y offset of the Frame
  75264. */
  75265. y: number;
  75266. /**
  75267. * number of the width of the Frame
  75268. */
  75269. w: number;
  75270. /**
  75271. * number of the height of the Frame
  75272. */
  75273. h: number;
  75274. }
  75275. /**
  75276. * Defines the basic options interface of a JSON Sprite.
  75277. */
  75278. export interface ISpriteJSONSprite {
  75279. /**
  75280. * string name of the Frame
  75281. */
  75282. filename: string;
  75283. /**
  75284. * ISpriteJSONSpriteFrame basic object of the frame data
  75285. */
  75286. frame: ISpriteJSONSpriteFrameData;
  75287. /**
  75288. * boolean to flag is the frame was rotated.
  75289. */
  75290. rotated: boolean;
  75291. /**
  75292. * boolean to flag is the frame was trimmed.
  75293. */
  75294. trimmed: boolean;
  75295. /**
  75296. * ISpriteJSONSpriteFrame basic object of the source data
  75297. */
  75298. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75299. /**
  75300. * ISpriteJSONSpriteFrame basic object of the source data
  75301. */
  75302. sourceSize: ISpriteJSONSpriteSourceSize;
  75303. }
  75304. /**
  75305. * Defines the basic options interface of a JSON atlas.
  75306. */
  75307. export interface ISpriteJSONAtlas {
  75308. /**
  75309. * Array of objects that contain the frame data.
  75310. */
  75311. frames: Array<ISpriteJSONSprite>;
  75312. /**
  75313. * object basic object containing the sprite meta data.
  75314. */
  75315. meta?: object;
  75316. }
  75317. }
  75318. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75319. /** @hidden */
  75320. export var spriteMapPixelShader: {
  75321. name: string;
  75322. shader: string;
  75323. };
  75324. }
  75325. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75326. /** @hidden */
  75327. export var spriteMapVertexShader: {
  75328. name: string;
  75329. shader: string;
  75330. };
  75331. }
  75332. declare module "babylonjs/Sprites/spriteMap" {
  75333. import { IDisposable, Scene } from "babylonjs/scene";
  75334. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75335. import { Texture } from "babylonjs/Materials/Textures/texture";
  75336. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75337. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75338. import "babylonjs/Meshes/Builders/planeBuilder";
  75339. import "babylonjs/Shaders/spriteMap.fragment";
  75340. import "babylonjs/Shaders/spriteMap.vertex";
  75341. /**
  75342. * Defines the basic options interface of a SpriteMap
  75343. */
  75344. export interface ISpriteMapOptions {
  75345. /**
  75346. * Vector2 of the number of cells in the grid.
  75347. */
  75348. stageSize?: Vector2;
  75349. /**
  75350. * Vector2 of the size of the output plane in World Units.
  75351. */
  75352. outputSize?: Vector2;
  75353. /**
  75354. * Vector3 of the position of the output plane in World Units.
  75355. */
  75356. outputPosition?: Vector3;
  75357. /**
  75358. * Vector3 of the rotation of the output plane.
  75359. */
  75360. outputRotation?: Vector3;
  75361. /**
  75362. * number of layers that the system will reserve in resources.
  75363. */
  75364. layerCount?: number;
  75365. /**
  75366. * number of max animation frames a single cell will reserve in resources.
  75367. */
  75368. maxAnimationFrames?: number;
  75369. /**
  75370. * number cell index of the base tile when the system compiles.
  75371. */
  75372. baseTile?: number;
  75373. /**
  75374. * boolean flip the sprite after its been repositioned by the framing data.
  75375. */
  75376. flipU?: boolean;
  75377. /**
  75378. * Vector3 scalar of the global RGB values of the SpriteMap.
  75379. */
  75380. colorMultiply?: Vector3;
  75381. }
  75382. /**
  75383. * Defines the IDisposable interface in order to be cleanable from resources.
  75384. */
  75385. export interface ISpriteMap extends IDisposable {
  75386. /**
  75387. * String name of the SpriteMap.
  75388. */
  75389. name: string;
  75390. /**
  75391. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75392. */
  75393. atlasJSON: ISpriteJSONAtlas;
  75394. /**
  75395. * Texture of the SpriteMap.
  75396. */
  75397. spriteSheet: Texture;
  75398. /**
  75399. * The parameters to initialize the SpriteMap with.
  75400. */
  75401. options: ISpriteMapOptions;
  75402. }
  75403. /**
  75404. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75405. */
  75406. export class SpriteMap implements ISpriteMap {
  75407. /** The Name of the spriteMap */
  75408. name: string;
  75409. /** The JSON file with the frame and meta data */
  75410. atlasJSON: ISpriteJSONAtlas;
  75411. /** The systems Sprite Sheet Texture */
  75412. spriteSheet: Texture;
  75413. /** Arguments passed with the Constructor */
  75414. options: ISpriteMapOptions;
  75415. /** Public Sprite Storage array, parsed from atlasJSON */
  75416. sprites: Array<ISpriteJSONSprite>;
  75417. /** Returns the Number of Sprites in the System */
  75418. get spriteCount(): number;
  75419. /** Returns the Position of Output Plane*/
  75420. get position(): Vector3;
  75421. /** Returns the Position of Output Plane*/
  75422. set position(v: Vector3);
  75423. /** Returns the Rotation of Output Plane*/
  75424. get rotation(): Vector3;
  75425. /** Returns the Rotation of Output Plane*/
  75426. set rotation(v: Vector3);
  75427. /** Sets the AnimationMap*/
  75428. get animationMap(): RawTexture;
  75429. /** Sets the AnimationMap*/
  75430. set animationMap(v: RawTexture);
  75431. /** Scene that the SpriteMap was created in */
  75432. private _scene;
  75433. /** Texture Buffer of Float32 that holds tile frame data*/
  75434. private _frameMap;
  75435. /** Texture Buffers of Float32 that holds tileMap data*/
  75436. private _tileMaps;
  75437. /** Texture Buffer of Float32 that holds Animation Data*/
  75438. private _animationMap;
  75439. /** Custom ShaderMaterial Central to the System*/
  75440. private _material;
  75441. /** Custom ShaderMaterial Central to the System*/
  75442. private _output;
  75443. /** Systems Time Ticker*/
  75444. private _time;
  75445. /**
  75446. * Creates a new SpriteMap
  75447. * @param name defines the SpriteMaps Name
  75448. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75449. * @param spriteSheet is the Texture that the Sprites are on.
  75450. * @param options a basic deployment configuration
  75451. * @param scene The Scene that the map is deployed on
  75452. */
  75453. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75454. /**
  75455. * Returns tileID location
  75456. * @returns Vector2 the cell position ID
  75457. */
  75458. getTileID(): Vector2;
  75459. /**
  75460. * Gets the UV location of the mouse over the SpriteMap.
  75461. * @returns Vector2 the UV position of the mouse interaction
  75462. */
  75463. getMousePosition(): Vector2;
  75464. /**
  75465. * Creates the "frame" texture Buffer
  75466. * -------------------------------------
  75467. * Structure of frames
  75468. * "filename": "Falling-Water-2.png",
  75469. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75470. * "rotated": true,
  75471. * "trimmed": true,
  75472. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75473. * "sourceSize": {"w":32,"h":32}
  75474. * @returns RawTexture of the frameMap
  75475. */
  75476. private _createFrameBuffer;
  75477. /**
  75478. * Creates the tileMap texture Buffer
  75479. * @param buffer normally and array of numbers, or a false to generate from scratch
  75480. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75481. * @returns RawTexture of the tileMap
  75482. */
  75483. private _createTileBuffer;
  75484. /**
  75485. * Modifies the data of the tileMaps
  75486. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75487. * @param pos is the iVector2 Coordinates of the Tile
  75488. * @param tile The SpriteIndex of the new Tile
  75489. */
  75490. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75491. /**
  75492. * Creates the animationMap texture Buffer
  75493. * @param buffer normally and array of numbers, or a false to generate from scratch
  75494. * @returns RawTexture of the animationMap
  75495. */
  75496. private _createTileAnimationBuffer;
  75497. /**
  75498. * Modifies the data of the animationMap
  75499. * @param cellID is the Index of the Sprite
  75500. * @param _frame is the target Animation frame
  75501. * @param toCell is the Target Index of the next frame of the animation
  75502. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75503. * @param speed is a global scalar of the time variable on the map.
  75504. */
  75505. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75506. /**
  75507. * Exports the .tilemaps file
  75508. */
  75509. saveTileMaps(): void;
  75510. /**
  75511. * Imports the .tilemaps file
  75512. * @param url of the .tilemaps file
  75513. */
  75514. loadTileMaps(url: string): void;
  75515. /**
  75516. * Release associated resources
  75517. */
  75518. dispose(): void;
  75519. }
  75520. }
  75521. declare module "babylonjs/Sprites/spritePackedManager" {
  75522. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75523. import { Scene } from "babylonjs/scene";
  75524. /**
  75525. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75526. * @see https://doc.babylonjs.com/babylon101/sprites
  75527. */
  75528. export class SpritePackedManager extends SpriteManager {
  75529. /** defines the packed manager's name */
  75530. name: string;
  75531. /**
  75532. * Creates a new sprite manager from a packed sprite sheet
  75533. * @param name defines the manager's name
  75534. * @param imgUrl defines the sprite sheet url
  75535. * @param capacity defines the maximum allowed number of sprites
  75536. * @param scene defines the hosting scene
  75537. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75538. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75539. * @param samplingMode defines the smapling mode to use with spritesheet
  75540. * @param fromPacked set to true; do not alter
  75541. */
  75542. constructor(
  75543. /** defines the packed manager's name */
  75544. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75545. }
  75546. }
  75547. declare module "babylonjs/Sprites/index" {
  75548. export * from "babylonjs/Sprites/sprite";
  75549. export * from "babylonjs/Sprites/ISprites";
  75550. export * from "babylonjs/Sprites/spriteManager";
  75551. export * from "babylonjs/Sprites/spriteMap";
  75552. export * from "babylonjs/Sprites/spritePackedManager";
  75553. export * from "babylonjs/Sprites/spriteSceneComponent";
  75554. }
  75555. declare module "babylonjs/States/index" {
  75556. export * from "babylonjs/States/alphaCullingState";
  75557. export * from "babylonjs/States/depthCullingState";
  75558. export * from "babylonjs/States/stencilState";
  75559. }
  75560. declare module "babylonjs/Misc/assetsManager" {
  75561. import { Scene } from "babylonjs/scene";
  75562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75563. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75564. import { Skeleton } from "babylonjs/Bones/skeleton";
  75565. import { Observable } from "babylonjs/Misc/observable";
  75566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75567. import { Texture } from "babylonjs/Materials/Textures/texture";
  75568. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75569. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75570. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75571. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75572. /**
  75573. * Defines the list of states available for a task inside a AssetsManager
  75574. */
  75575. export enum AssetTaskState {
  75576. /**
  75577. * Initialization
  75578. */
  75579. INIT = 0,
  75580. /**
  75581. * Running
  75582. */
  75583. RUNNING = 1,
  75584. /**
  75585. * Done
  75586. */
  75587. DONE = 2,
  75588. /**
  75589. * Error
  75590. */
  75591. ERROR = 3
  75592. }
  75593. /**
  75594. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75595. */
  75596. export abstract class AbstractAssetTask {
  75597. /**
  75598. * Task name
  75599. */ name: string;
  75600. /**
  75601. * Callback called when the task is successful
  75602. */
  75603. onSuccess: (task: any) => void;
  75604. /**
  75605. * Callback called when the task is not successful
  75606. */
  75607. onError: (task: any, message?: string, exception?: any) => void;
  75608. /**
  75609. * Creates a new AssetsManager
  75610. * @param name defines the name of the task
  75611. */
  75612. constructor(
  75613. /**
  75614. * Task name
  75615. */ name: string);
  75616. private _isCompleted;
  75617. private _taskState;
  75618. private _errorObject;
  75619. /**
  75620. * Get if the task is completed
  75621. */
  75622. get isCompleted(): boolean;
  75623. /**
  75624. * Gets the current state of the task
  75625. */
  75626. get taskState(): AssetTaskState;
  75627. /**
  75628. * Gets the current error object (if task is in error)
  75629. */
  75630. get errorObject(): {
  75631. message?: string;
  75632. exception?: any;
  75633. };
  75634. /**
  75635. * Internal only
  75636. * @hidden
  75637. */
  75638. _setErrorObject(message?: string, exception?: any): void;
  75639. /**
  75640. * Execute the current task
  75641. * @param scene defines the scene where you want your assets to be loaded
  75642. * @param onSuccess is a callback called when the task is successfully executed
  75643. * @param onError is a callback called if an error occurs
  75644. */
  75645. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75646. /**
  75647. * Execute the current task
  75648. * @param scene defines the scene where you want your assets to be loaded
  75649. * @param onSuccess is a callback called when the task is successfully executed
  75650. * @param onError is a callback called if an error occurs
  75651. */
  75652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75653. /**
  75654. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75655. * This can be used with failed tasks that have the reason for failure fixed.
  75656. */
  75657. reset(): void;
  75658. private onErrorCallback;
  75659. private onDoneCallback;
  75660. }
  75661. /**
  75662. * Define the interface used by progress events raised during assets loading
  75663. */
  75664. export interface IAssetsProgressEvent {
  75665. /**
  75666. * Defines the number of remaining tasks to process
  75667. */
  75668. remainingCount: number;
  75669. /**
  75670. * Defines the total number of tasks
  75671. */
  75672. totalCount: number;
  75673. /**
  75674. * Defines the task that was just processed
  75675. */
  75676. task: AbstractAssetTask;
  75677. }
  75678. /**
  75679. * Class used to share progress information about assets loading
  75680. */
  75681. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75682. /**
  75683. * Defines the number of remaining tasks to process
  75684. */
  75685. remainingCount: number;
  75686. /**
  75687. * Defines the total number of tasks
  75688. */
  75689. totalCount: number;
  75690. /**
  75691. * Defines the task that was just processed
  75692. */
  75693. task: AbstractAssetTask;
  75694. /**
  75695. * Creates a AssetsProgressEvent
  75696. * @param remainingCount defines the number of remaining tasks to process
  75697. * @param totalCount defines the total number of tasks
  75698. * @param task defines the task that was just processed
  75699. */
  75700. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75701. }
  75702. /**
  75703. * Define a task used by AssetsManager to load meshes
  75704. */
  75705. export class MeshAssetTask extends AbstractAssetTask {
  75706. /**
  75707. * Defines the name of the task
  75708. */
  75709. name: string;
  75710. /**
  75711. * Defines the list of mesh's names you want to load
  75712. */
  75713. meshesNames: any;
  75714. /**
  75715. * Defines the root url to use as a base to load your meshes and associated resources
  75716. */
  75717. rootUrl: string;
  75718. /**
  75719. * Defines the filename or File of the scene to load from
  75720. */
  75721. sceneFilename: string | File;
  75722. /**
  75723. * Gets the list of loaded meshes
  75724. */
  75725. loadedMeshes: Array<AbstractMesh>;
  75726. /**
  75727. * Gets the list of loaded particle systems
  75728. */
  75729. loadedParticleSystems: Array<IParticleSystem>;
  75730. /**
  75731. * Gets the list of loaded skeletons
  75732. */
  75733. loadedSkeletons: Array<Skeleton>;
  75734. /**
  75735. * Gets the list of loaded animation groups
  75736. */
  75737. loadedAnimationGroups: Array<AnimationGroup>;
  75738. /**
  75739. * Callback called when the task is successful
  75740. */
  75741. onSuccess: (task: MeshAssetTask) => void;
  75742. /**
  75743. * Callback called when the task is successful
  75744. */
  75745. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75746. /**
  75747. * Creates a new MeshAssetTask
  75748. * @param name defines the name of the task
  75749. * @param meshesNames defines the list of mesh's names you want to load
  75750. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75751. * @param sceneFilename defines the filename or File of the scene to load from
  75752. */
  75753. constructor(
  75754. /**
  75755. * Defines the name of the task
  75756. */
  75757. name: string,
  75758. /**
  75759. * Defines the list of mesh's names you want to load
  75760. */
  75761. meshesNames: any,
  75762. /**
  75763. * Defines the root url to use as a base to load your meshes and associated resources
  75764. */
  75765. rootUrl: string,
  75766. /**
  75767. * Defines the filename or File of the scene to load from
  75768. */
  75769. sceneFilename: string | File);
  75770. /**
  75771. * Execute the current task
  75772. * @param scene defines the scene where you want your assets to be loaded
  75773. * @param onSuccess is a callback called when the task is successfully executed
  75774. * @param onError is a callback called if an error occurs
  75775. */
  75776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75777. }
  75778. /**
  75779. * Define a task used by AssetsManager to load text content
  75780. */
  75781. export class TextFileAssetTask extends AbstractAssetTask {
  75782. /**
  75783. * Defines the name of the task
  75784. */
  75785. name: string;
  75786. /**
  75787. * Defines the location of the file to load
  75788. */
  75789. url: string;
  75790. /**
  75791. * Gets the loaded text string
  75792. */
  75793. text: string;
  75794. /**
  75795. * Callback called when the task is successful
  75796. */
  75797. onSuccess: (task: TextFileAssetTask) => void;
  75798. /**
  75799. * Callback called when the task is successful
  75800. */
  75801. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75802. /**
  75803. * Creates a new TextFileAssetTask object
  75804. * @param name defines the name of the task
  75805. * @param url defines the location of the file to load
  75806. */
  75807. constructor(
  75808. /**
  75809. * Defines the name of the task
  75810. */
  75811. name: string,
  75812. /**
  75813. * Defines the location of the file to load
  75814. */
  75815. url: string);
  75816. /**
  75817. * Execute the current task
  75818. * @param scene defines the scene where you want your assets to be loaded
  75819. * @param onSuccess is a callback called when the task is successfully executed
  75820. * @param onError is a callback called if an error occurs
  75821. */
  75822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75823. }
  75824. /**
  75825. * Define a task used by AssetsManager to load binary data
  75826. */
  75827. export class BinaryFileAssetTask extends AbstractAssetTask {
  75828. /**
  75829. * Defines the name of the task
  75830. */
  75831. name: string;
  75832. /**
  75833. * Defines the location of the file to load
  75834. */
  75835. url: string;
  75836. /**
  75837. * Gets the lodaded data (as an array buffer)
  75838. */
  75839. data: ArrayBuffer;
  75840. /**
  75841. * Callback called when the task is successful
  75842. */
  75843. onSuccess: (task: BinaryFileAssetTask) => void;
  75844. /**
  75845. * Callback called when the task is successful
  75846. */
  75847. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75848. /**
  75849. * Creates a new BinaryFileAssetTask object
  75850. * @param name defines the name of the new task
  75851. * @param url defines the location of the file to load
  75852. */
  75853. constructor(
  75854. /**
  75855. * Defines the name of the task
  75856. */
  75857. name: string,
  75858. /**
  75859. * Defines the location of the file to load
  75860. */
  75861. url: string);
  75862. /**
  75863. * Execute the current task
  75864. * @param scene defines the scene where you want your assets to be loaded
  75865. * @param onSuccess is a callback called when the task is successfully executed
  75866. * @param onError is a callback called if an error occurs
  75867. */
  75868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75869. }
  75870. /**
  75871. * Define a task used by AssetsManager to load images
  75872. */
  75873. export class ImageAssetTask extends AbstractAssetTask {
  75874. /**
  75875. * Defines the name of the task
  75876. */
  75877. name: string;
  75878. /**
  75879. * Defines the location of the image to load
  75880. */
  75881. url: string;
  75882. /**
  75883. * Gets the loaded images
  75884. */
  75885. image: HTMLImageElement;
  75886. /**
  75887. * Callback called when the task is successful
  75888. */
  75889. onSuccess: (task: ImageAssetTask) => void;
  75890. /**
  75891. * Callback called when the task is successful
  75892. */
  75893. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75894. /**
  75895. * Creates a new ImageAssetTask
  75896. * @param name defines the name of the task
  75897. * @param url defines the location of the image to load
  75898. */
  75899. constructor(
  75900. /**
  75901. * Defines the name of the task
  75902. */
  75903. name: string,
  75904. /**
  75905. * Defines the location of the image to load
  75906. */
  75907. url: string);
  75908. /**
  75909. * Execute the current task
  75910. * @param scene defines the scene where you want your assets to be loaded
  75911. * @param onSuccess is a callback called when the task is successfully executed
  75912. * @param onError is a callback called if an error occurs
  75913. */
  75914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75915. }
  75916. /**
  75917. * Defines the interface used by texture loading tasks
  75918. */
  75919. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75920. /**
  75921. * Gets the loaded texture
  75922. */
  75923. texture: TEX;
  75924. }
  75925. /**
  75926. * Define a task used by AssetsManager to load 2D textures
  75927. */
  75928. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75929. /**
  75930. * Defines the name of the task
  75931. */
  75932. name: string;
  75933. /**
  75934. * Defines the location of the file to load
  75935. */
  75936. url: string;
  75937. /**
  75938. * Defines if mipmap should not be generated (default is false)
  75939. */
  75940. noMipmap?: boolean | undefined;
  75941. /**
  75942. * Defines if texture must be inverted on Y axis (default is true)
  75943. */
  75944. invertY: boolean;
  75945. /**
  75946. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75947. */
  75948. samplingMode: number;
  75949. /**
  75950. * Gets the loaded texture
  75951. */
  75952. texture: Texture;
  75953. /**
  75954. * Callback called when the task is successful
  75955. */
  75956. onSuccess: (task: TextureAssetTask) => void;
  75957. /**
  75958. * Callback called when the task is successful
  75959. */
  75960. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75961. /**
  75962. * Creates a new TextureAssetTask object
  75963. * @param name defines the name of the task
  75964. * @param url defines the location of the file to load
  75965. * @param noMipmap defines if mipmap should not be generated (default is false)
  75966. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75967. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75968. */
  75969. constructor(
  75970. /**
  75971. * Defines the name of the task
  75972. */
  75973. name: string,
  75974. /**
  75975. * Defines the location of the file to load
  75976. */
  75977. url: string,
  75978. /**
  75979. * Defines if mipmap should not be generated (default is false)
  75980. */
  75981. noMipmap?: boolean | undefined,
  75982. /**
  75983. * Defines if texture must be inverted on Y axis (default is true)
  75984. */
  75985. invertY?: boolean,
  75986. /**
  75987. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75988. */
  75989. samplingMode?: number);
  75990. /**
  75991. * Execute the current task
  75992. * @param scene defines the scene where you want your assets to be loaded
  75993. * @param onSuccess is a callback called when the task is successfully executed
  75994. * @param onError is a callback called if an error occurs
  75995. */
  75996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75997. }
  75998. /**
  75999. * Define a task used by AssetsManager to load cube textures
  76000. */
  76001. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76002. /**
  76003. * Defines the name of the task
  76004. */
  76005. name: string;
  76006. /**
  76007. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76008. */
  76009. url: string;
  76010. /**
  76011. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76012. */
  76013. extensions?: string[] | undefined;
  76014. /**
  76015. * Defines if mipmaps should not be generated (default is false)
  76016. */
  76017. noMipmap?: boolean | undefined;
  76018. /**
  76019. * Defines the explicit list of files (undefined by default)
  76020. */
  76021. files?: string[] | undefined;
  76022. /**
  76023. * Gets the loaded texture
  76024. */
  76025. texture: CubeTexture;
  76026. /**
  76027. * Callback called when the task is successful
  76028. */
  76029. onSuccess: (task: CubeTextureAssetTask) => void;
  76030. /**
  76031. * Callback called when the task is successful
  76032. */
  76033. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76034. /**
  76035. * Creates a new CubeTextureAssetTask
  76036. * @param name defines the name of the task
  76037. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76038. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76039. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76040. * @param files defines the explicit list of files (undefined by default)
  76041. */
  76042. constructor(
  76043. /**
  76044. * Defines the name of the task
  76045. */
  76046. name: string,
  76047. /**
  76048. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76049. */
  76050. url: string,
  76051. /**
  76052. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76053. */
  76054. extensions?: string[] | undefined,
  76055. /**
  76056. * Defines if mipmaps should not be generated (default is false)
  76057. */
  76058. noMipmap?: boolean | undefined,
  76059. /**
  76060. * Defines the explicit list of files (undefined by default)
  76061. */
  76062. files?: string[] | undefined);
  76063. /**
  76064. * Execute the current task
  76065. * @param scene defines the scene where you want your assets to be loaded
  76066. * @param onSuccess is a callback called when the task is successfully executed
  76067. * @param onError is a callback called if an error occurs
  76068. */
  76069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76070. }
  76071. /**
  76072. * Define a task used by AssetsManager to load HDR cube textures
  76073. */
  76074. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76075. /**
  76076. * Defines the name of the task
  76077. */
  76078. name: string;
  76079. /**
  76080. * Defines the location of the file to load
  76081. */
  76082. url: string;
  76083. /**
  76084. * Defines the desired size (the more it increases the longer the generation will be)
  76085. */
  76086. size: number;
  76087. /**
  76088. * Defines if mipmaps should not be generated (default is false)
  76089. */
  76090. noMipmap: boolean;
  76091. /**
  76092. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76093. */
  76094. generateHarmonics: boolean;
  76095. /**
  76096. * 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)
  76097. */
  76098. gammaSpace: boolean;
  76099. /**
  76100. * Internal Use Only
  76101. */
  76102. reserved: boolean;
  76103. /**
  76104. * Gets the loaded texture
  76105. */
  76106. texture: HDRCubeTexture;
  76107. /**
  76108. * Callback called when the task is successful
  76109. */
  76110. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76111. /**
  76112. * Callback called when the task is successful
  76113. */
  76114. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76115. /**
  76116. * Creates a new HDRCubeTextureAssetTask object
  76117. * @param name defines the name of the task
  76118. * @param url defines the location of the file to load
  76119. * @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.
  76120. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76121. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76122. * @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)
  76123. * @param reserved Internal use only
  76124. */
  76125. constructor(
  76126. /**
  76127. * Defines the name of the task
  76128. */
  76129. name: string,
  76130. /**
  76131. * Defines the location of the file to load
  76132. */
  76133. url: string,
  76134. /**
  76135. * Defines the desired size (the more it increases the longer the generation will be)
  76136. */
  76137. size: number,
  76138. /**
  76139. * Defines if mipmaps should not be generated (default is false)
  76140. */
  76141. noMipmap?: boolean,
  76142. /**
  76143. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76144. */
  76145. generateHarmonics?: boolean,
  76146. /**
  76147. * 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)
  76148. */
  76149. gammaSpace?: boolean,
  76150. /**
  76151. * Internal Use Only
  76152. */
  76153. reserved?: boolean);
  76154. /**
  76155. * Execute the current task
  76156. * @param scene defines the scene where you want your assets to be loaded
  76157. * @param onSuccess is a callback called when the task is successfully executed
  76158. * @param onError is a callback called if an error occurs
  76159. */
  76160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76161. }
  76162. /**
  76163. * Define a task used by AssetsManager to load Equirectangular cube textures
  76164. */
  76165. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76166. /**
  76167. * Defines the name of the task
  76168. */
  76169. name: string;
  76170. /**
  76171. * Defines the location of the file to load
  76172. */
  76173. url: string;
  76174. /**
  76175. * Defines the desired size (the more it increases the longer the generation will be)
  76176. */
  76177. size: number;
  76178. /**
  76179. * Defines if mipmaps should not be generated (default is false)
  76180. */
  76181. noMipmap: boolean;
  76182. /**
  76183. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76184. * but the standard material would require them in Gamma space) (default is true)
  76185. */
  76186. gammaSpace: boolean;
  76187. /**
  76188. * Gets the loaded texture
  76189. */
  76190. texture: EquiRectangularCubeTexture;
  76191. /**
  76192. * Callback called when the task is successful
  76193. */
  76194. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76195. /**
  76196. * Callback called when the task is successful
  76197. */
  76198. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76199. /**
  76200. * Creates a new EquiRectangularCubeTextureAssetTask object
  76201. * @param name defines the name of the task
  76202. * @param url defines the location of the file to load
  76203. * @param size defines the desired size (the more it increases the longer the generation will be)
  76204. * If the size is omitted this implies you are using a preprocessed cubemap.
  76205. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76206. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76207. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76208. * (default is true)
  76209. */
  76210. constructor(
  76211. /**
  76212. * Defines the name of the task
  76213. */
  76214. name: string,
  76215. /**
  76216. * Defines the location of the file to load
  76217. */
  76218. url: string,
  76219. /**
  76220. * Defines the desired size (the more it increases the longer the generation will be)
  76221. */
  76222. size: number,
  76223. /**
  76224. * Defines if mipmaps should not be generated (default is false)
  76225. */
  76226. noMipmap?: boolean,
  76227. /**
  76228. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76229. * but the standard material would require them in Gamma space) (default is true)
  76230. */
  76231. gammaSpace?: boolean);
  76232. /**
  76233. * Execute the current task
  76234. * @param scene defines the scene where you want your assets to be loaded
  76235. * @param onSuccess is a callback called when the task is successfully executed
  76236. * @param onError is a callback called if an error occurs
  76237. */
  76238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76239. }
  76240. /**
  76241. * This class can be used to easily import assets into a scene
  76242. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76243. */
  76244. export class AssetsManager {
  76245. private _scene;
  76246. private _isLoading;
  76247. protected _tasks: AbstractAssetTask[];
  76248. protected _waitingTasksCount: number;
  76249. protected _totalTasksCount: number;
  76250. /**
  76251. * Callback called when all tasks are processed
  76252. */
  76253. onFinish: (tasks: AbstractAssetTask[]) => void;
  76254. /**
  76255. * Callback called when a task is successful
  76256. */
  76257. onTaskSuccess: (task: AbstractAssetTask) => void;
  76258. /**
  76259. * Callback called when a task had an error
  76260. */
  76261. onTaskError: (task: AbstractAssetTask) => void;
  76262. /**
  76263. * Callback called when a task is done (whatever the result is)
  76264. */
  76265. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76266. /**
  76267. * Observable called when all tasks are processed
  76268. */
  76269. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76270. /**
  76271. * Observable called when a task had an error
  76272. */
  76273. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76274. /**
  76275. * Observable called when all tasks were executed
  76276. */
  76277. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76278. /**
  76279. * Observable called when a task is done (whatever the result is)
  76280. */
  76281. onProgressObservable: Observable<IAssetsProgressEvent>;
  76282. /**
  76283. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76284. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76285. */
  76286. useDefaultLoadingScreen: boolean;
  76287. /**
  76288. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76289. * when all assets have been downloaded.
  76290. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76291. */
  76292. autoHideLoadingUI: boolean;
  76293. /**
  76294. * Creates a new AssetsManager
  76295. * @param scene defines the scene to work on
  76296. */
  76297. constructor(scene: Scene);
  76298. /**
  76299. * Add a MeshAssetTask to the list of active tasks
  76300. * @param taskName defines the name of the new task
  76301. * @param meshesNames defines the name of meshes to load
  76302. * @param rootUrl defines the root url to use to locate files
  76303. * @param sceneFilename defines the filename of the scene file
  76304. * @returns a new MeshAssetTask object
  76305. */
  76306. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76307. /**
  76308. * Add a TextFileAssetTask to the list of active tasks
  76309. * @param taskName defines the name of the new task
  76310. * @param url defines the url of the file to load
  76311. * @returns a new TextFileAssetTask object
  76312. */
  76313. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76314. /**
  76315. * Add a BinaryFileAssetTask to the list of active tasks
  76316. * @param taskName defines the name of the new task
  76317. * @param url defines the url of the file to load
  76318. * @returns a new BinaryFileAssetTask object
  76319. */
  76320. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76321. /**
  76322. * Add a ImageAssetTask to the list of active tasks
  76323. * @param taskName defines the name of the new task
  76324. * @param url defines the url of the file to load
  76325. * @returns a new ImageAssetTask object
  76326. */
  76327. addImageTask(taskName: string, url: string): ImageAssetTask;
  76328. /**
  76329. * Add a TextureAssetTask to the list of active tasks
  76330. * @param taskName defines the name of the new task
  76331. * @param url defines the url of the file to load
  76332. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76333. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76334. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76335. * @returns a new TextureAssetTask object
  76336. */
  76337. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76338. /**
  76339. * Add a CubeTextureAssetTask to the list of active tasks
  76340. * @param taskName defines the name of the new task
  76341. * @param url defines the url of the file to load
  76342. * @param extensions defines the extension to use to load the cube map (can be null)
  76343. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76344. * @param files defines the list of files to load (can be null)
  76345. * @returns a new CubeTextureAssetTask object
  76346. */
  76347. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76348. /**
  76349. *
  76350. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76351. * @param taskName defines the name of the new task
  76352. * @param url defines the url of the file to load
  76353. * @param size defines the size you want for the cubemap (can be null)
  76354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76355. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76356. * @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)
  76357. * @param reserved Internal use only
  76358. * @returns a new HDRCubeTextureAssetTask object
  76359. */
  76360. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76361. /**
  76362. *
  76363. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76364. * @param taskName defines the name of the new task
  76365. * @param url defines the url of the file to load
  76366. * @param size defines the size you want for the cubemap (can be null)
  76367. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76368. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76369. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76370. * @returns a new EquiRectangularCubeTextureAssetTask object
  76371. */
  76372. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76373. /**
  76374. * Remove a task from the assets manager.
  76375. * @param task the task to remove
  76376. */
  76377. removeTask(task: AbstractAssetTask): void;
  76378. private _decreaseWaitingTasksCount;
  76379. private _runTask;
  76380. /**
  76381. * Reset the AssetsManager and remove all tasks
  76382. * @return the current instance of the AssetsManager
  76383. */
  76384. reset(): AssetsManager;
  76385. /**
  76386. * Start the loading process
  76387. * @return the current instance of the AssetsManager
  76388. */
  76389. load(): AssetsManager;
  76390. /**
  76391. * Start the loading process as an async operation
  76392. * @return a promise returning the list of failed tasks
  76393. */
  76394. loadAsync(): Promise<void>;
  76395. }
  76396. }
  76397. declare module "babylonjs/Misc/deferred" {
  76398. /**
  76399. * Wrapper class for promise with external resolve and reject.
  76400. */
  76401. export class Deferred<T> {
  76402. /**
  76403. * The promise associated with this deferred object.
  76404. */
  76405. readonly promise: Promise<T>;
  76406. private _resolve;
  76407. private _reject;
  76408. /**
  76409. * The resolve method of the promise associated with this deferred object.
  76410. */
  76411. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76412. /**
  76413. * The reject method of the promise associated with this deferred object.
  76414. */
  76415. get reject(): (reason?: any) => void;
  76416. /**
  76417. * Constructor for this deferred object.
  76418. */
  76419. constructor();
  76420. }
  76421. }
  76422. declare module "babylonjs/Misc/meshExploder" {
  76423. import { Mesh } from "babylonjs/Meshes/mesh";
  76424. /**
  76425. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76426. */
  76427. export class MeshExploder {
  76428. private _centerMesh;
  76429. private _meshes;
  76430. private _meshesOrigins;
  76431. private _toCenterVectors;
  76432. private _scaledDirection;
  76433. private _newPosition;
  76434. private _centerPosition;
  76435. /**
  76436. * Explodes meshes from a center mesh.
  76437. * @param meshes The meshes to explode.
  76438. * @param centerMesh The mesh to be center of explosion.
  76439. */
  76440. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76441. private _setCenterMesh;
  76442. /**
  76443. * Get class name
  76444. * @returns "MeshExploder"
  76445. */
  76446. getClassName(): string;
  76447. /**
  76448. * "Exploded meshes"
  76449. * @returns Array of meshes with the centerMesh at index 0.
  76450. */
  76451. getMeshes(): Array<Mesh>;
  76452. /**
  76453. * Explodes meshes giving a specific direction
  76454. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76455. */
  76456. explode(direction?: number): void;
  76457. }
  76458. }
  76459. declare module "babylonjs/Misc/filesInput" {
  76460. import { Engine } from "babylonjs/Engines/engine";
  76461. import { Scene } from "babylonjs/scene";
  76462. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76463. import { Nullable } from "babylonjs/types";
  76464. /**
  76465. * Class used to help managing file picking and drag'n'drop
  76466. */
  76467. export class FilesInput {
  76468. /**
  76469. * List of files ready to be loaded
  76470. */
  76471. static get FilesToLoad(): {
  76472. [key: string]: File;
  76473. };
  76474. /**
  76475. * Callback called when a file is processed
  76476. */
  76477. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76478. private _engine;
  76479. private _currentScene;
  76480. private _sceneLoadedCallback;
  76481. private _progressCallback;
  76482. private _additionalRenderLoopLogicCallback;
  76483. private _textureLoadingCallback;
  76484. private _startingProcessingFilesCallback;
  76485. private _onReloadCallback;
  76486. private _errorCallback;
  76487. private _elementToMonitor;
  76488. private _sceneFileToLoad;
  76489. private _filesToLoad;
  76490. /**
  76491. * Creates a new FilesInput
  76492. * @param engine defines the rendering engine
  76493. * @param scene defines the hosting scene
  76494. * @param sceneLoadedCallback callback called when scene is loaded
  76495. * @param progressCallback callback called to track progress
  76496. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76497. * @param textureLoadingCallback callback called when a texture is loading
  76498. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76499. * @param onReloadCallback callback called when a reload is requested
  76500. * @param errorCallback callback call if an error occurs
  76501. */
  76502. 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>);
  76503. private _dragEnterHandler;
  76504. private _dragOverHandler;
  76505. private _dropHandler;
  76506. /**
  76507. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76508. * @param elementToMonitor defines the DOM element to track
  76509. */
  76510. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76511. /** Gets the current list of files to load */
  76512. get filesToLoad(): File[];
  76513. /**
  76514. * Release all associated resources
  76515. */
  76516. dispose(): void;
  76517. private renderFunction;
  76518. private drag;
  76519. private drop;
  76520. private _traverseFolder;
  76521. private _processFiles;
  76522. /**
  76523. * Load files from a drop event
  76524. * @param event defines the drop event to use as source
  76525. */
  76526. loadFiles(event: any): void;
  76527. private _processReload;
  76528. /**
  76529. * Reload the current scene from the loaded files
  76530. */
  76531. reload(): void;
  76532. }
  76533. }
  76534. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76535. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76536. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76537. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76538. }
  76539. declare module "babylonjs/Misc/sceneOptimizer" {
  76540. import { Scene, IDisposable } from "babylonjs/scene";
  76541. import { Observable } from "babylonjs/Misc/observable";
  76542. /**
  76543. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76545. */
  76546. export class SceneOptimization {
  76547. /**
  76548. * Defines the priority of this optimization (0 by default which means first in the list)
  76549. */
  76550. priority: number;
  76551. /**
  76552. * Gets a string describing the action executed by the current optimization
  76553. * @returns description string
  76554. */
  76555. getDescription(): string;
  76556. /**
  76557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76558. * @param scene defines the current scene where to apply this optimization
  76559. * @param optimizer defines the current optimizer
  76560. * @returns true if everything that can be done was applied
  76561. */
  76562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76563. /**
  76564. * Creates the SceneOptimization object
  76565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76566. * @param desc defines the description associated with the optimization
  76567. */
  76568. constructor(
  76569. /**
  76570. * Defines the priority of this optimization (0 by default which means first in the list)
  76571. */
  76572. priority?: number);
  76573. }
  76574. /**
  76575. * Defines an optimization used to reduce the size of render target textures
  76576. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76577. */
  76578. export class TextureOptimization extends SceneOptimization {
  76579. /**
  76580. * Defines the priority of this optimization (0 by default which means first in the list)
  76581. */
  76582. priority: number;
  76583. /**
  76584. * 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
  76585. */
  76586. maximumSize: number;
  76587. /**
  76588. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76589. */
  76590. step: number;
  76591. /**
  76592. * Gets a string describing the action executed by the current optimization
  76593. * @returns description string
  76594. */
  76595. getDescription(): string;
  76596. /**
  76597. * Creates the TextureOptimization object
  76598. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76599. * @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
  76600. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76601. */
  76602. constructor(
  76603. /**
  76604. * Defines the priority of this optimization (0 by default which means first in the list)
  76605. */
  76606. priority?: number,
  76607. /**
  76608. * 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
  76609. */
  76610. maximumSize?: number,
  76611. /**
  76612. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76613. */
  76614. step?: number);
  76615. /**
  76616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76617. * @param scene defines the current scene where to apply this optimization
  76618. * @param optimizer defines the current optimizer
  76619. * @returns true if everything that can be done was applied
  76620. */
  76621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76622. }
  76623. /**
  76624. * Defines an optimization used to increase or decrease the rendering resolution
  76625. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76626. */
  76627. export class HardwareScalingOptimization extends SceneOptimization {
  76628. /**
  76629. * Defines the priority of this optimization (0 by default which means first in the list)
  76630. */
  76631. priority: number;
  76632. /**
  76633. * Defines the maximum scale to use (2 by default)
  76634. */
  76635. maximumScale: number;
  76636. /**
  76637. * Defines the step to use between two passes (0.5 by default)
  76638. */
  76639. step: number;
  76640. private _currentScale;
  76641. private _directionOffset;
  76642. /**
  76643. * Gets a string describing the action executed by the current optimization
  76644. * @return description string
  76645. */
  76646. getDescription(): string;
  76647. /**
  76648. * Creates the HardwareScalingOptimization object
  76649. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76650. * @param maximumScale defines the maximum scale to use (2 by default)
  76651. * @param step defines the step to use between two passes (0.5 by default)
  76652. */
  76653. constructor(
  76654. /**
  76655. * Defines the priority of this optimization (0 by default which means first in the list)
  76656. */
  76657. priority?: number,
  76658. /**
  76659. * Defines the maximum scale to use (2 by default)
  76660. */
  76661. maximumScale?: number,
  76662. /**
  76663. * Defines the step to use between two passes (0.5 by default)
  76664. */
  76665. step?: number);
  76666. /**
  76667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76668. * @param scene defines the current scene where to apply this optimization
  76669. * @param optimizer defines the current optimizer
  76670. * @returns true if everything that can be done was applied
  76671. */
  76672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76673. }
  76674. /**
  76675. * Defines an optimization used to remove shadows
  76676. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76677. */
  76678. export class ShadowsOptimization extends SceneOptimization {
  76679. /**
  76680. * Gets a string describing the action executed by the current optimization
  76681. * @return description string
  76682. */
  76683. getDescription(): string;
  76684. /**
  76685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76686. * @param scene defines the current scene where to apply this optimization
  76687. * @param optimizer defines the current optimizer
  76688. * @returns true if everything that can be done was applied
  76689. */
  76690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76691. }
  76692. /**
  76693. * Defines an optimization used to turn post-processes off
  76694. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76695. */
  76696. export class PostProcessesOptimization extends SceneOptimization {
  76697. /**
  76698. * Gets a string describing the action executed by the current optimization
  76699. * @return description string
  76700. */
  76701. getDescription(): string;
  76702. /**
  76703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76704. * @param scene defines the current scene where to apply this optimization
  76705. * @param optimizer defines the current optimizer
  76706. * @returns true if everything that can be done was applied
  76707. */
  76708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76709. }
  76710. /**
  76711. * Defines an optimization used to turn lens flares off
  76712. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76713. */
  76714. export class LensFlaresOptimization extends SceneOptimization {
  76715. /**
  76716. * Gets a string describing the action executed by the current optimization
  76717. * @return description string
  76718. */
  76719. getDescription(): string;
  76720. /**
  76721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76722. * @param scene defines the current scene where to apply this optimization
  76723. * @param optimizer defines the current optimizer
  76724. * @returns true if everything that can be done was applied
  76725. */
  76726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76727. }
  76728. /**
  76729. * Defines an optimization based on user defined callback.
  76730. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76731. */
  76732. export class CustomOptimization extends SceneOptimization {
  76733. /**
  76734. * Callback called to apply the custom optimization.
  76735. */
  76736. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76737. /**
  76738. * Callback called to get custom description
  76739. */
  76740. onGetDescription: () => string;
  76741. /**
  76742. * Gets a string describing the action executed by the current optimization
  76743. * @returns description string
  76744. */
  76745. getDescription(): string;
  76746. /**
  76747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76748. * @param scene defines the current scene where to apply this optimization
  76749. * @param optimizer defines the current optimizer
  76750. * @returns true if everything that can be done was applied
  76751. */
  76752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76753. }
  76754. /**
  76755. * Defines an optimization used to turn particles off
  76756. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76757. */
  76758. export class ParticlesOptimization extends SceneOptimization {
  76759. /**
  76760. * Gets a string describing the action executed by the current optimization
  76761. * @return description string
  76762. */
  76763. getDescription(): string;
  76764. /**
  76765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76766. * @param scene defines the current scene where to apply this optimization
  76767. * @param optimizer defines the current optimizer
  76768. * @returns true if everything that can be done was applied
  76769. */
  76770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76771. }
  76772. /**
  76773. * Defines an optimization used to turn render targets off
  76774. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76775. */
  76776. export class RenderTargetsOptimization extends SceneOptimization {
  76777. /**
  76778. * Gets a string describing the action executed by the current optimization
  76779. * @return description string
  76780. */
  76781. getDescription(): string;
  76782. /**
  76783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76784. * @param scene defines the current scene where to apply this optimization
  76785. * @param optimizer defines the current optimizer
  76786. * @returns true if everything that can be done was applied
  76787. */
  76788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76789. }
  76790. /**
  76791. * Defines an optimization used to merge meshes with compatible materials
  76792. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76793. */
  76794. export class MergeMeshesOptimization extends SceneOptimization {
  76795. private static _UpdateSelectionTree;
  76796. /**
  76797. * Gets or sets a boolean which defines if optimization octree has to be updated
  76798. */
  76799. static get UpdateSelectionTree(): boolean;
  76800. /**
  76801. * Gets or sets a boolean which defines if optimization octree has to be updated
  76802. */
  76803. static set UpdateSelectionTree(value: boolean);
  76804. /**
  76805. * Gets a string describing the action executed by the current optimization
  76806. * @return description string
  76807. */
  76808. getDescription(): string;
  76809. private _canBeMerged;
  76810. /**
  76811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76812. * @param scene defines the current scene where to apply this optimization
  76813. * @param optimizer defines the current optimizer
  76814. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76815. * @returns true if everything that can be done was applied
  76816. */
  76817. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76818. }
  76819. /**
  76820. * Defines a list of options used by SceneOptimizer
  76821. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76822. */
  76823. export class SceneOptimizerOptions {
  76824. /**
  76825. * Defines the target frame rate to reach (60 by default)
  76826. */
  76827. targetFrameRate: number;
  76828. /**
  76829. * Defines the interval between two checkes (2000ms by default)
  76830. */
  76831. trackerDuration: number;
  76832. /**
  76833. * Gets the list of optimizations to apply
  76834. */
  76835. optimizations: SceneOptimization[];
  76836. /**
  76837. * Creates a new list of options used by SceneOptimizer
  76838. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76839. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76840. */
  76841. constructor(
  76842. /**
  76843. * Defines the target frame rate to reach (60 by default)
  76844. */
  76845. targetFrameRate?: number,
  76846. /**
  76847. * Defines the interval between two checkes (2000ms by default)
  76848. */
  76849. trackerDuration?: number);
  76850. /**
  76851. * Add a new optimization
  76852. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76853. * @returns the current SceneOptimizerOptions
  76854. */
  76855. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76856. /**
  76857. * Add a new custom optimization
  76858. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76859. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76861. * @returns the current SceneOptimizerOptions
  76862. */
  76863. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76864. /**
  76865. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76866. * @param targetFrameRate defines the target frame rate (60 by default)
  76867. * @returns a SceneOptimizerOptions object
  76868. */
  76869. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76870. /**
  76871. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76872. * @param targetFrameRate defines the target frame rate (60 by default)
  76873. * @returns a SceneOptimizerOptions object
  76874. */
  76875. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76876. /**
  76877. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76878. * @param targetFrameRate defines the target frame rate (60 by default)
  76879. * @returns a SceneOptimizerOptions object
  76880. */
  76881. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76882. }
  76883. /**
  76884. * Class used to run optimizations in order to reach a target frame rate
  76885. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76886. */
  76887. export class SceneOptimizer implements IDisposable {
  76888. private _isRunning;
  76889. private _options;
  76890. private _scene;
  76891. private _currentPriorityLevel;
  76892. private _targetFrameRate;
  76893. private _trackerDuration;
  76894. private _currentFrameRate;
  76895. private _sceneDisposeObserver;
  76896. private _improvementMode;
  76897. /**
  76898. * Defines an observable called when the optimizer reaches the target frame rate
  76899. */
  76900. onSuccessObservable: Observable<SceneOptimizer>;
  76901. /**
  76902. * Defines an observable called when the optimizer enables an optimization
  76903. */
  76904. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76905. /**
  76906. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76907. */
  76908. onFailureObservable: Observable<SceneOptimizer>;
  76909. /**
  76910. * Gets a boolean indicating if the optimizer is in improvement mode
  76911. */
  76912. get isInImprovementMode(): boolean;
  76913. /**
  76914. * Gets the current priority level (0 at start)
  76915. */
  76916. get currentPriorityLevel(): number;
  76917. /**
  76918. * Gets the current frame rate checked by the SceneOptimizer
  76919. */
  76920. get currentFrameRate(): number;
  76921. /**
  76922. * Gets or sets the current target frame rate (60 by default)
  76923. */
  76924. get targetFrameRate(): number;
  76925. /**
  76926. * Gets or sets the current target frame rate (60 by default)
  76927. */
  76928. set targetFrameRate(value: number);
  76929. /**
  76930. * Gets or sets the current interval between two checks (every 2000ms by default)
  76931. */
  76932. get trackerDuration(): number;
  76933. /**
  76934. * Gets or sets the current interval between two checks (every 2000ms by default)
  76935. */
  76936. set trackerDuration(value: number);
  76937. /**
  76938. * Gets the list of active optimizations
  76939. */
  76940. get optimizations(): SceneOptimization[];
  76941. /**
  76942. * Creates a new SceneOptimizer
  76943. * @param scene defines the scene to work on
  76944. * @param options defines the options to use with the SceneOptimizer
  76945. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76946. * @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)
  76947. */
  76948. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76949. /**
  76950. * Stops the current optimizer
  76951. */
  76952. stop(): void;
  76953. /**
  76954. * Reset the optimizer to initial step (current priority level = 0)
  76955. */
  76956. reset(): void;
  76957. /**
  76958. * Start the optimizer. By default it will try to reach a specific framerate
  76959. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76960. */
  76961. start(): void;
  76962. private _checkCurrentState;
  76963. /**
  76964. * Release all resources
  76965. */
  76966. dispose(): void;
  76967. /**
  76968. * Helper function to create a SceneOptimizer with one single line of code
  76969. * @param scene defines the scene to work on
  76970. * @param options defines the options to use with the SceneOptimizer
  76971. * @param onSuccess defines a callback to call on success
  76972. * @param onFailure defines a callback to call on failure
  76973. * @returns the new SceneOptimizer object
  76974. */
  76975. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76976. }
  76977. }
  76978. declare module "babylonjs/Misc/sceneSerializer" {
  76979. import { Scene } from "babylonjs/scene";
  76980. /**
  76981. * Class used to serialize a scene into a string
  76982. */
  76983. export class SceneSerializer {
  76984. /**
  76985. * Clear cache used by a previous serialization
  76986. */
  76987. static ClearCache(): void;
  76988. /**
  76989. * Serialize a scene into a JSON compatible object
  76990. * @param scene defines the scene to serialize
  76991. * @returns a JSON compatible object
  76992. */
  76993. static Serialize(scene: Scene): any;
  76994. /**
  76995. * Serialize a mesh into a JSON compatible object
  76996. * @param toSerialize defines the mesh to serialize
  76997. * @param withParents defines if parents must be serialized as well
  76998. * @param withChildren defines if children must be serialized as well
  76999. * @returns a JSON compatible object
  77000. */
  77001. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77002. }
  77003. }
  77004. declare module "babylonjs/Misc/textureTools" {
  77005. import { Texture } from "babylonjs/Materials/Textures/texture";
  77006. /**
  77007. * Class used to host texture specific utilities
  77008. */
  77009. export class TextureTools {
  77010. /**
  77011. * Uses the GPU to create a copy texture rescaled at a given size
  77012. * @param texture Texture to copy from
  77013. * @param width defines the desired width
  77014. * @param height defines the desired height
  77015. * @param useBilinearMode defines if bilinear mode has to be used
  77016. * @return the generated texture
  77017. */
  77018. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77019. }
  77020. }
  77021. declare module "babylonjs/Misc/videoRecorder" {
  77022. import { Nullable } from "babylonjs/types";
  77023. import { Engine } from "babylonjs/Engines/engine";
  77024. /**
  77025. * This represents the different options available for the video capture.
  77026. */
  77027. export interface VideoRecorderOptions {
  77028. /** Defines the mime type of the video. */
  77029. mimeType: string;
  77030. /** Defines the FPS the video should be recorded at. */
  77031. fps: number;
  77032. /** Defines the chunk size for the recording data. */
  77033. recordChunckSize: number;
  77034. /** The audio tracks to attach to the recording. */
  77035. audioTracks?: MediaStreamTrack[];
  77036. }
  77037. /**
  77038. * This can help with recording videos from BabylonJS.
  77039. * This is based on the available WebRTC functionalities of the browser.
  77040. *
  77041. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77042. */
  77043. export class VideoRecorder {
  77044. private static readonly _defaultOptions;
  77045. /**
  77046. * Returns whether or not the VideoRecorder is available in your browser.
  77047. * @param engine Defines the Babylon Engine.
  77048. * @returns true if supported otherwise false.
  77049. */
  77050. static IsSupported(engine: Engine): boolean;
  77051. private readonly _options;
  77052. private _canvas;
  77053. private _mediaRecorder;
  77054. private _recordedChunks;
  77055. private _fileName;
  77056. private _resolve;
  77057. private _reject;
  77058. /**
  77059. * True when a recording is already in progress.
  77060. */
  77061. get isRecording(): boolean;
  77062. /**
  77063. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77064. * @param engine Defines the BabylonJS Engine you wish to record.
  77065. * @param options Defines options that can be used to customize the capture.
  77066. */
  77067. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77068. /**
  77069. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77070. */
  77071. stopRecording(): void;
  77072. /**
  77073. * Starts recording the canvas for a max duration specified in parameters.
  77074. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77075. * If null no automatic download will start and you can rely on the promise to get the data back.
  77076. * @param maxDuration Defines the maximum recording time in seconds.
  77077. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77078. * @return A promise callback at the end of the recording with the video data in Blob.
  77079. */
  77080. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77081. /**
  77082. * Releases internal resources used during the recording.
  77083. */
  77084. dispose(): void;
  77085. private _handleDataAvailable;
  77086. private _handleError;
  77087. private _handleStop;
  77088. }
  77089. }
  77090. declare module "babylonjs/Misc/screenshotTools" {
  77091. import { Camera } from "babylonjs/Cameras/camera";
  77092. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77093. import { Engine } from "babylonjs/Engines/engine";
  77094. /**
  77095. * Class containing a set of static utilities functions for screenshots
  77096. */
  77097. export class ScreenshotTools {
  77098. /**
  77099. * Captures a screenshot of the current rendering
  77100. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77101. * @param engine defines the rendering engine
  77102. * @param camera defines the source camera
  77103. * @param size This parameter can be set to a single number or to an object with the
  77104. * following (optional) properties: precision, width, height. If a single number is passed,
  77105. * it will be used for both width and height. If an object is passed, the screenshot size
  77106. * will be derived from the parameters. The precision property is a multiplier allowing
  77107. * rendering at a higher or lower resolution
  77108. * @param successCallback defines the callback receives a single parameter which contains the
  77109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77110. * src parameter of an <img> to display it
  77111. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77112. * Check your browser for supported MIME types
  77113. */
  77114. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77115. /**
  77116. * Captures a screenshot of the current rendering
  77117. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77118. * @param engine defines the rendering engine
  77119. * @param camera defines the source camera
  77120. * @param size This parameter can be set to a single number or to an object with the
  77121. * following (optional) properties: precision, width, height. If a single number is passed,
  77122. * it will be used for both width and height. If an object is passed, the screenshot size
  77123. * will be derived from the parameters. The precision property is a multiplier allowing
  77124. * rendering at a higher or lower resolution
  77125. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77126. * Check your browser for supported MIME types
  77127. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77128. * to the src parameter of an <img> to display it
  77129. */
  77130. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77131. /**
  77132. * Generates an image screenshot from the specified camera.
  77133. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77134. * @param engine The engine to use for rendering
  77135. * @param camera The camera to use for rendering
  77136. * @param size This parameter can be set to a single number or to an object with the
  77137. * following (optional) properties: precision, width, height. If a single number is passed,
  77138. * it will be used for both width and height. If an object is passed, the screenshot size
  77139. * will be derived from the parameters. The precision property is a multiplier allowing
  77140. * rendering at a higher or lower resolution
  77141. * @param successCallback The callback receives a single parameter which contains the
  77142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77143. * src parameter of an <img> to display it
  77144. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77145. * Check your browser for supported MIME types
  77146. * @param samples Texture samples (default: 1)
  77147. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77148. * @param fileName A name for for the downloaded file.
  77149. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77150. */
  77151. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77152. /**
  77153. * Generates an image screenshot from the specified camera.
  77154. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77155. * @param engine The engine to use for rendering
  77156. * @param camera The camera to use for rendering
  77157. * @param size This parameter can be set to a single number or to an object with the
  77158. * following (optional) properties: precision, width, height. If a single number is passed,
  77159. * it will be used for both width and height. If an object is passed, the screenshot size
  77160. * will be derived from the parameters. The precision property is a multiplier allowing
  77161. * rendering at a higher or lower resolution
  77162. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77163. * Check your browser for supported MIME types
  77164. * @param samples Texture samples (default: 1)
  77165. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77166. * @param fileName A name for for the downloaded file.
  77167. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77168. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77169. * to the src parameter of an <img> to display it
  77170. */
  77171. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77172. /**
  77173. * Gets height and width for screenshot size
  77174. * @private
  77175. */
  77176. private static _getScreenshotSize;
  77177. }
  77178. }
  77179. declare module "babylonjs/Misc/dataReader" {
  77180. /**
  77181. * Interface for a data buffer
  77182. */
  77183. export interface IDataBuffer {
  77184. /**
  77185. * Reads bytes from the data buffer.
  77186. * @param byteOffset The byte offset to read
  77187. * @param byteLength The byte length to read
  77188. * @returns A promise that resolves when the bytes are read
  77189. */
  77190. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77191. /**
  77192. * The byte length of the buffer.
  77193. */
  77194. readonly byteLength: number;
  77195. }
  77196. /**
  77197. * Utility class for reading from a data buffer
  77198. */
  77199. export class DataReader {
  77200. /**
  77201. * The data buffer associated with this data reader.
  77202. */
  77203. readonly buffer: IDataBuffer;
  77204. /**
  77205. * The current byte offset from the beginning of the data buffer.
  77206. */
  77207. byteOffset: number;
  77208. private _dataView;
  77209. private _dataByteOffset;
  77210. /**
  77211. * Constructor
  77212. * @param buffer The buffer to read
  77213. */
  77214. constructor(buffer: IDataBuffer);
  77215. /**
  77216. * Loads the given byte length.
  77217. * @param byteLength The byte length to load
  77218. * @returns A promise that resolves when the load is complete
  77219. */
  77220. loadAsync(byteLength: number): Promise<void>;
  77221. /**
  77222. * Read a unsigned 32-bit integer from the currently loaded data range.
  77223. * @returns The 32-bit integer read
  77224. */
  77225. readUint32(): number;
  77226. /**
  77227. * Read a byte array from the currently loaded data range.
  77228. * @param byteLength The byte length to read
  77229. * @returns The byte array read
  77230. */
  77231. readUint8Array(byteLength: number): Uint8Array;
  77232. /**
  77233. * Read a string from the currently loaded data range.
  77234. * @param byteLength The byte length to read
  77235. * @returns The string read
  77236. */
  77237. readString(byteLength: number): string;
  77238. /**
  77239. * Skips the given byte length the currently loaded data range.
  77240. * @param byteLength The byte length to skip
  77241. */
  77242. skipBytes(byteLength: number): void;
  77243. }
  77244. }
  77245. declare module "babylonjs/Misc/dataStorage" {
  77246. /**
  77247. * Class for storing data to local storage if available or in-memory storage otherwise
  77248. */
  77249. export class DataStorage {
  77250. private static _Storage;
  77251. private static _GetStorage;
  77252. /**
  77253. * Reads a string from the data storage
  77254. * @param key The key to read
  77255. * @param defaultValue The value if the key doesn't exist
  77256. * @returns The string value
  77257. */
  77258. static ReadString(key: string, defaultValue: string): string;
  77259. /**
  77260. * Writes a string to the data storage
  77261. * @param key The key to write
  77262. * @param value The value to write
  77263. */
  77264. static WriteString(key: string, value: string): void;
  77265. /**
  77266. * Reads a boolean from the data storage
  77267. * @param key The key to read
  77268. * @param defaultValue The value if the key doesn't exist
  77269. * @returns The boolean value
  77270. */
  77271. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77272. /**
  77273. * Writes a boolean to the data storage
  77274. * @param key The key to write
  77275. * @param value The value to write
  77276. */
  77277. static WriteBoolean(key: string, value: boolean): void;
  77278. /**
  77279. * Reads a number from the data storage
  77280. * @param key The key to read
  77281. * @param defaultValue The value if the key doesn't exist
  77282. * @returns The number value
  77283. */
  77284. static ReadNumber(key: string, defaultValue: number): number;
  77285. /**
  77286. * Writes a number to the data storage
  77287. * @param key The key to write
  77288. * @param value The value to write
  77289. */
  77290. static WriteNumber(key: string, value: number): void;
  77291. }
  77292. }
  77293. declare module "babylonjs/Misc/index" {
  77294. export * from "babylonjs/Misc/andOrNotEvaluator";
  77295. export * from "babylonjs/Misc/assetsManager";
  77296. export * from "babylonjs/Misc/basis";
  77297. export * from "babylonjs/Misc/dds";
  77298. export * from "babylonjs/Misc/decorators";
  77299. export * from "babylonjs/Misc/deferred";
  77300. export * from "babylonjs/Misc/environmentTextureTools";
  77301. export * from "babylonjs/Misc/meshExploder";
  77302. export * from "babylonjs/Misc/filesInput";
  77303. export * from "babylonjs/Misc/HighDynamicRange/index";
  77304. export * from "babylonjs/Misc/khronosTextureContainer";
  77305. export * from "babylonjs/Misc/observable";
  77306. export * from "babylonjs/Misc/performanceMonitor";
  77307. export * from "babylonjs/Misc/promise";
  77308. export * from "babylonjs/Misc/sceneOptimizer";
  77309. export * from "babylonjs/Misc/sceneSerializer";
  77310. export * from "babylonjs/Misc/smartArray";
  77311. export * from "babylonjs/Misc/stringDictionary";
  77312. export * from "babylonjs/Misc/tags";
  77313. export * from "babylonjs/Misc/textureTools";
  77314. export * from "babylonjs/Misc/tga";
  77315. export * from "babylonjs/Misc/tools";
  77316. export * from "babylonjs/Misc/videoRecorder";
  77317. export * from "babylonjs/Misc/virtualJoystick";
  77318. export * from "babylonjs/Misc/workerPool";
  77319. export * from "babylonjs/Misc/logger";
  77320. export * from "babylonjs/Misc/typeStore";
  77321. export * from "babylonjs/Misc/filesInputStore";
  77322. export * from "babylonjs/Misc/deepCopier";
  77323. export * from "babylonjs/Misc/pivotTools";
  77324. export * from "babylonjs/Misc/precisionDate";
  77325. export * from "babylonjs/Misc/screenshotTools";
  77326. export * from "babylonjs/Misc/typeStore";
  77327. export * from "babylonjs/Misc/webRequest";
  77328. export * from "babylonjs/Misc/iInspectable";
  77329. export * from "babylonjs/Misc/brdfTextureTools";
  77330. export * from "babylonjs/Misc/rgbdTextureTools";
  77331. export * from "babylonjs/Misc/gradients";
  77332. export * from "babylonjs/Misc/perfCounter";
  77333. export * from "babylonjs/Misc/fileRequest";
  77334. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77335. export * from "babylonjs/Misc/retryStrategy";
  77336. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77337. export * from "babylonjs/Misc/canvasGenerator";
  77338. export * from "babylonjs/Misc/fileTools";
  77339. export * from "babylonjs/Misc/stringTools";
  77340. export * from "babylonjs/Misc/dataReader";
  77341. export * from "babylonjs/Misc/minMaxReducer";
  77342. export * from "babylonjs/Misc/depthReducer";
  77343. export * from "babylonjs/Misc/dataStorage";
  77344. }
  77345. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77346. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77347. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77348. import { Observable } from "babylonjs/Misc/observable";
  77349. import { Matrix } from "babylonjs/Maths/math.vector";
  77350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77351. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77352. /**
  77353. * An interface for all Hit test features
  77354. */
  77355. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77356. /**
  77357. * Triggered when new babylon (transformed) hit test results are available
  77358. */
  77359. onHitTestResultObservable: Observable<T[]>;
  77360. }
  77361. /**
  77362. * Options used for hit testing
  77363. */
  77364. export interface IWebXRLegacyHitTestOptions {
  77365. /**
  77366. * Only test when user interacted with the scene. Default - hit test every frame
  77367. */
  77368. testOnPointerDownOnly?: boolean;
  77369. /**
  77370. * The node to use to transform the local results to world coordinates
  77371. */
  77372. worldParentNode?: TransformNode;
  77373. }
  77374. /**
  77375. * Interface defining the babylon result of raycasting/hit-test
  77376. */
  77377. export interface IWebXRLegacyHitResult {
  77378. /**
  77379. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77380. */
  77381. transformationMatrix: Matrix;
  77382. /**
  77383. * The native hit test result
  77384. */
  77385. xrHitResult: XRHitResult | XRHitTestResult;
  77386. }
  77387. /**
  77388. * The currently-working hit-test module.
  77389. * Hit test (or Ray-casting) is used to interact with the real world.
  77390. * For further information read here - https://github.com/immersive-web/hit-test
  77391. */
  77392. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77393. /**
  77394. * options to use when constructing this feature
  77395. */
  77396. readonly options: IWebXRLegacyHitTestOptions;
  77397. private _direction;
  77398. private _mat;
  77399. private _onSelectEnabled;
  77400. private _origin;
  77401. /**
  77402. * The module's name
  77403. */
  77404. static readonly Name: string;
  77405. /**
  77406. * The (Babylon) version of this module.
  77407. * This is an integer representing the implementation version.
  77408. * This number does not correspond to the WebXR specs version
  77409. */
  77410. static readonly Version: number;
  77411. /**
  77412. * Populated with the last native XR Hit Results
  77413. */
  77414. lastNativeXRHitResults: XRHitResult[];
  77415. /**
  77416. * Triggered when new babylon (transformed) hit test results are available
  77417. */
  77418. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77419. /**
  77420. * Creates a new instance of the (legacy version) hit test feature
  77421. * @param _xrSessionManager an instance of WebXRSessionManager
  77422. * @param options options to use when constructing this feature
  77423. */
  77424. constructor(_xrSessionManager: WebXRSessionManager,
  77425. /**
  77426. * options to use when constructing this feature
  77427. */
  77428. options?: IWebXRLegacyHitTestOptions);
  77429. /**
  77430. * execute a hit test with an XR Ray
  77431. *
  77432. * @param xrSession a native xrSession that will execute this hit test
  77433. * @param xrRay the ray (position and direction) to use for ray-casting
  77434. * @param referenceSpace native XR reference space to use for the hit-test
  77435. * @param filter filter function that will filter the results
  77436. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77437. */
  77438. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77439. /**
  77440. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77441. * @param event the (select) event to use to select with
  77442. * @param referenceSpace the reference space to use for this hit test
  77443. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77444. */
  77445. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77446. /**
  77447. * attach this feature
  77448. * Will usually be called by the features manager
  77449. *
  77450. * @returns true if successful.
  77451. */
  77452. attach(): boolean;
  77453. /**
  77454. * detach this feature.
  77455. * Will usually be called by the features manager
  77456. *
  77457. * @returns true if successful.
  77458. */
  77459. detach(): boolean;
  77460. /**
  77461. * Dispose this feature and all of the resources attached
  77462. */
  77463. dispose(): void;
  77464. protected _onXRFrame(frame: XRFrame): void;
  77465. private _onHitTestResults;
  77466. private _onSelect;
  77467. }
  77468. }
  77469. declare module "babylonjs/XR/features/WebXRHitTest" {
  77470. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77471. import { Observable } from "babylonjs/Misc/observable";
  77472. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77473. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77474. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77475. /**
  77476. * Options used for hit testing (version 2)
  77477. */
  77478. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77479. /**
  77480. * Do not create a permanent hit test. Will usually be used when only
  77481. * transient inputs are needed.
  77482. */
  77483. disablePermanentHitTest?: boolean;
  77484. /**
  77485. * Enable transient (for example touch-based) hit test inspections
  77486. */
  77487. enableTransientHitTest?: boolean;
  77488. /**
  77489. * Offset ray for the permanent hit test
  77490. */
  77491. offsetRay?: Vector3;
  77492. /**
  77493. * Offset ray for the transient hit test
  77494. */
  77495. transientOffsetRay?: Vector3;
  77496. /**
  77497. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77498. */
  77499. useReferenceSpace?: boolean;
  77500. }
  77501. /**
  77502. * Interface defining the babylon result of hit-test
  77503. */
  77504. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77505. /**
  77506. * The input source that generated this hit test (if transient)
  77507. */
  77508. inputSource?: XRInputSource;
  77509. /**
  77510. * Is this a transient hit test
  77511. */
  77512. isTransient?: boolean;
  77513. /**
  77514. * Position of the hit test result
  77515. */
  77516. position: Vector3;
  77517. /**
  77518. * Rotation of the hit test result
  77519. */
  77520. rotationQuaternion: Quaternion;
  77521. /**
  77522. * The native hit test result
  77523. */
  77524. xrHitResult: XRHitTestResult;
  77525. }
  77526. /**
  77527. * The currently-working hit-test module.
  77528. * Hit test (or Ray-casting) is used to interact with the real world.
  77529. * For further information read here - https://github.com/immersive-web/hit-test
  77530. *
  77531. * Tested on chrome (mobile) 80.
  77532. */
  77533. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77534. /**
  77535. * options to use when constructing this feature
  77536. */
  77537. readonly options: IWebXRHitTestOptions;
  77538. private _tmpMat;
  77539. private _tmpPos;
  77540. private _tmpQuat;
  77541. private _transientXrHitTestSource;
  77542. private _xrHitTestSource;
  77543. private initHitTestSource;
  77544. /**
  77545. * The module's name
  77546. */
  77547. static readonly Name: string;
  77548. /**
  77549. * The (Babylon) version of this module.
  77550. * This is an integer representing the implementation version.
  77551. * This number does not correspond to the WebXR specs version
  77552. */
  77553. static readonly Version: number;
  77554. /**
  77555. * When set to true, each hit test will have its own position/rotation objects
  77556. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77557. * the developers will clone them or copy them as they see fit.
  77558. */
  77559. autoCloneTransformation: boolean;
  77560. /**
  77561. * Triggered when new babylon (transformed) hit test results are available
  77562. */
  77563. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77564. /**
  77565. * Use this to temporarily pause hit test checks.
  77566. */
  77567. paused: boolean;
  77568. /**
  77569. * Creates a new instance of the hit test feature
  77570. * @param _xrSessionManager an instance of WebXRSessionManager
  77571. * @param options options to use when constructing this feature
  77572. */
  77573. constructor(_xrSessionManager: WebXRSessionManager,
  77574. /**
  77575. * options to use when constructing this feature
  77576. */
  77577. options?: IWebXRHitTestOptions);
  77578. /**
  77579. * attach this feature
  77580. * Will usually be called by the features manager
  77581. *
  77582. * @returns true if successful.
  77583. */
  77584. attach(): boolean;
  77585. /**
  77586. * detach this feature.
  77587. * Will usually be called by the features manager
  77588. *
  77589. * @returns true if successful.
  77590. */
  77591. detach(): boolean;
  77592. /**
  77593. * Dispose this feature and all of the resources attached
  77594. */
  77595. dispose(): void;
  77596. protected _onXRFrame(frame: XRFrame): void;
  77597. private _processWebXRHitTestResult;
  77598. }
  77599. }
  77600. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77601. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77602. import { Observable } from "babylonjs/Misc/observable";
  77603. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77604. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77605. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77606. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77607. /**
  77608. * Configuration options of the anchor system
  77609. */
  77610. export interface IWebXRAnchorSystemOptions {
  77611. /**
  77612. * a node that will be used to convert local to world coordinates
  77613. */
  77614. worldParentNode?: TransformNode;
  77615. /**
  77616. * If set to true a reference of the created anchors will be kept until the next session starts
  77617. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77618. */
  77619. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77620. }
  77621. /**
  77622. * A babylon container for an XR Anchor
  77623. */
  77624. export interface IWebXRAnchor {
  77625. /**
  77626. * A babylon-assigned ID for this anchor
  77627. */
  77628. id: number;
  77629. /**
  77630. * Transformation matrix to apply to an object attached to this anchor
  77631. */
  77632. transformationMatrix: Matrix;
  77633. /**
  77634. * The native anchor object
  77635. */
  77636. xrAnchor: XRAnchor;
  77637. /**
  77638. * if defined, this object will be constantly updated by the anchor's position and rotation
  77639. */
  77640. attachedNode?: TransformNode;
  77641. }
  77642. /**
  77643. * An implementation of the anchor system for WebXR.
  77644. * For further information see https://github.com/immersive-web/anchors/
  77645. */
  77646. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77647. private _options;
  77648. private _lastFrameDetected;
  77649. private _trackedAnchors;
  77650. private _referenceSpaceForFrameAnchors;
  77651. private _futureAnchors;
  77652. /**
  77653. * The module's name
  77654. */
  77655. static readonly Name: string;
  77656. /**
  77657. * The (Babylon) version of this module.
  77658. * This is an integer representing the implementation version.
  77659. * This number does not correspond to the WebXR specs version
  77660. */
  77661. static readonly Version: number;
  77662. /**
  77663. * Observers registered here will be executed when a new anchor was added to the session
  77664. */
  77665. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77666. /**
  77667. * Observers registered here will be executed when an anchor was removed from the session
  77668. */
  77669. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77670. /**
  77671. * Observers registered here will be executed when an existing anchor updates
  77672. * This can execute N times every frame
  77673. */
  77674. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77675. /**
  77676. * Set the reference space to use for anchor creation, when not using a hit test.
  77677. * Will default to the session's reference space if not defined
  77678. */
  77679. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77680. /**
  77681. * constructs a new anchor system
  77682. * @param _xrSessionManager an instance of WebXRSessionManager
  77683. * @param _options configuration object for this feature
  77684. */
  77685. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77686. private _tmpVector;
  77687. private _tmpQuaternion;
  77688. private _populateTmpTransformation;
  77689. /**
  77690. * Create a new anchor point using a hit test result at a specific point in the scene
  77691. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77692. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77693. *
  77694. * @param hitTestResult The hit test result to use for this anchor creation
  77695. * @param position an optional position offset for this anchor
  77696. * @param rotationQuaternion an optional rotation offset for this anchor
  77697. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77698. */
  77699. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77700. /**
  77701. * Add a new anchor at a specific position and rotation
  77702. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77703. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77704. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77705. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77706. *
  77707. * @param position the position in which to add an anchor
  77708. * @param rotationQuaternion an optional rotation for the anchor transformation
  77709. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77710. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77711. */
  77712. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77713. /**
  77714. * detach this feature.
  77715. * Will usually be called by the features manager
  77716. *
  77717. * @returns true if successful.
  77718. */
  77719. detach(): boolean;
  77720. /**
  77721. * Dispose this feature and all of the resources attached
  77722. */
  77723. dispose(): void;
  77724. protected _onXRFrame(frame: XRFrame): void;
  77725. /**
  77726. * avoiding using Array.find for global support.
  77727. * @param xrAnchor the plane to find in the array
  77728. */
  77729. private _findIndexInAnchorArray;
  77730. private _updateAnchorWithXRFrame;
  77731. private _createAnchorAtTransformation;
  77732. }
  77733. }
  77734. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77735. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77736. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77737. import { Observable } from "babylonjs/Misc/observable";
  77738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77739. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77740. /**
  77741. * Options used in the plane detector module
  77742. */
  77743. export interface IWebXRPlaneDetectorOptions {
  77744. /**
  77745. * The node to use to transform the local results to world coordinates
  77746. */
  77747. worldParentNode?: TransformNode;
  77748. /**
  77749. * If set to true a reference of the created planes will be kept until the next session starts
  77750. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77751. */
  77752. doNotRemovePlanesOnSessionEnded?: boolean;
  77753. }
  77754. /**
  77755. * A babylon interface for a WebXR plane.
  77756. * A Plane is actually a polygon, built from N points in space
  77757. *
  77758. * Supported in chrome 79, not supported in canary 81 ATM
  77759. */
  77760. export interface IWebXRPlane {
  77761. /**
  77762. * a babylon-assigned ID for this polygon
  77763. */
  77764. id: number;
  77765. /**
  77766. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77767. */
  77768. polygonDefinition: Array<Vector3>;
  77769. /**
  77770. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77771. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77772. */
  77773. transformationMatrix: Matrix;
  77774. /**
  77775. * the native xr-plane object
  77776. */
  77777. xrPlane: XRPlane;
  77778. }
  77779. /**
  77780. * The plane detector is used to detect planes in the real world when in AR
  77781. * For more information see https://github.com/immersive-web/real-world-geometry/
  77782. */
  77783. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77784. private _options;
  77785. private _detectedPlanes;
  77786. private _enabled;
  77787. private _lastFrameDetected;
  77788. /**
  77789. * The module's name
  77790. */
  77791. static readonly Name: string;
  77792. /**
  77793. * The (Babylon) version of this module.
  77794. * This is an integer representing the implementation version.
  77795. * This number does not correspond to the WebXR specs version
  77796. */
  77797. static readonly Version: number;
  77798. /**
  77799. * Observers registered here will be executed when a new plane was added to the session
  77800. */
  77801. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77802. /**
  77803. * Observers registered here will be executed when a plane is no longer detected in the session
  77804. */
  77805. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77806. /**
  77807. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77808. * This can execute N times every frame
  77809. */
  77810. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77811. /**
  77812. * construct a new Plane Detector
  77813. * @param _xrSessionManager an instance of xr Session manager
  77814. * @param _options configuration to use when constructing this feature
  77815. */
  77816. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77817. /**
  77818. * detach this feature.
  77819. * Will usually be called by the features manager
  77820. *
  77821. * @returns true if successful.
  77822. */
  77823. detach(): boolean;
  77824. /**
  77825. * Dispose this feature and all of the resources attached
  77826. */
  77827. dispose(): void;
  77828. protected _onXRFrame(frame: XRFrame): void;
  77829. private _init;
  77830. private _updatePlaneWithXRPlane;
  77831. /**
  77832. * avoiding using Array.find for global support.
  77833. * @param xrPlane the plane to find in the array
  77834. */
  77835. private findIndexInPlaneArray;
  77836. }
  77837. }
  77838. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77839. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77841. import { Observable } from "babylonjs/Misc/observable";
  77842. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77843. /**
  77844. * Options interface for the background remover plugin
  77845. */
  77846. export interface IWebXRBackgroundRemoverOptions {
  77847. /**
  77848. * Further background meshes to disable when entering AR
  77849. */
  77850. backgroundMeshes?: AbstractMesh[];
  77851. /**
  77852. * flags to configure the removal of the environment helper.
  77853. * If not set, the entire background will be removed. If set, flags should be set as well.
  77854. */
  77855. environmentHelperRemovalFlags?: {
  77856. /**
  77857. * Should the skybox be removed (default false)
  77858. */
  77859. skyBox?: boolean;
  77860. /**
  77861. * Should the ground be removed (default false)
  77862. */
  77863. ground?: boolean;
  77864. };
  77865. /**
  77866. * don't disable the environment helper
  77867. */
  77868. ignoreEnvironmentHelper?: boolean;
  77869. }
  77870. /**
  77871. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77872. */
  77873. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77874. /**
  77875. * read-only options to be used in this module
  77876. */
  77877. readonly options: IWebXRBackgroundRemoverOptions;
  77878. /**
  77879. * The module's name
  77880. */
  77881. static readonly Name: string;
  77882. /**
  77883. * The (Babylon) version of this module.
  77884. * This is an integer representing the implementation version.
  77885. * This number does not correspond to the WebXR specs version
  77886. */
  77887. static readonly Version: number;
  77888. /**
  77889. * registered observers will be triggered when the background state changes
  77890. */
  77891. onBackgroundStateChangedObservable: Observable<boolean>;
  77892. /**
  77893. * constructs a new background remover module
  77894. * @param _xrSessionManager the session manager for this module
  77895. * @param options read-only options to be used in this module
  77896. */
  77897. constructor(_xrSessionManager: WebXRSessionManager,
  77898. /**
  77899. * read-only options to be used in this module
  77900. */
  77901. options?: IWebXRBackgroundRemoverOptions);
  77902. /**
  77903. * attach this feature
  77904. * Will usually be called by the features manager
  77905. *
  77906. * @returns true if successful.
  77907. */
  77908. attach(): boolean;
  77909. /**
  77910. * detach this feature.
  77911. * Will usually be called by the features manager
  77912. *
  77913. * @returns true if successful.
  77914. */
  77915. detach(): boolean;
  77916. /**
  77917. * Dispose this feature and all of the resources attached
  77918. */
  77919. dispose(): void;
  77920. protected _onXRFrame(_xrFrame: XRFrame): void;
  77921. private _setBackgroundState;
  77922. }
  77923. }
  77924. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77925. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77926. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77927. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77928. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77929. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77930. import { Nullable } from "babylonjs/types";
  77931. /**
  77932. * Options for the controller physics feature
  77933. */
  77934. export class IWebXRControllerPhysicsOptions {
  77935. /**
  77936. * Should the headset get its own impostor
  77937. */
  77938. enableHeadsetImpostor?: boolean;
  77939. /**
  77940. * Optional parameters for the headset impostor
  77941. */
  77942. headsetImpostorParams?: {
  77943. /**
  77944. * The type of impostor to create. Default is sphere
  77945. */
  77946. impostorType: number;
  77947. /**
  77948. * the size of the impostor. Defaults to 10cm
  77949. */
  77950. impostorSize?: number | {
  77951. width: number;
  77952. height: number;
  77953. depth: number;
  77954. };
  77955. /**
  77956. * Friction definitions
  77957. */
  77958. friction?: number;
  77959. /**
  77960. * Restitution
  77961. */
  77962. restitution?: number;
  77963. };
  77964. /**
  77965. * The physics properties of the future impostors
  77966. */
  77967. physicsProperties?: {
  77968. /**
  77969. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77970. * Note that this requires a physics engine that supports mesh impostors!
  77971. */
  77972. useControllerMesh?: boolean;
  77973. /**
  77974. * The type of impostor to create. Default is sphere
  77975. */
  77976. impostorType?: number;
  77977. /**
  77978. * the size of the impostor. Defaults to 10cm
  77979. */
  77980. impostorSize?: number | {
  77981. width: number;
  77982. height: number;
  77983. depth: number;
  77984. };
  77985. /**
  77986. * Friction definitions
  77987. */
  77988. friction?: number;
  77989. /**
  77990. * Restitution
  77991. */
  77992. restitution?: number;
  77993. };
  77994. /**
  77995. * the xr input to use with this pointer selection
  77996. */
  77997. xrInput: WebXRInput;
  77998. }
  77999. /**
  78000. * Add physics impostor to your webxr controllers,
  78001. * including naive calculation of their linear and angular velocity
  78002. */
  78003. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78004. private readonly _options;
  78005. private _attachController;
  78006. private _controllers;
  78007. private _debugMode;
  78008. private _delta;
  78009. private _headsetImpostor?;
  78010. private _headsetMesh?;
  78011. private _lastTimestamp;
  78012. private _tmpQuaternion;
  78013. private _tmpVector;
  78014. /**
  78015. * The module's name
  78016. */
  78017. static readonly Name: string;
  78018. /**
  78019. * The (Babylon) version of this module.
  78020. * This is an integer representing the implementation version.
  78021. * This number does not correspond to the webxr specs version
  78022. */
  78023. static readonly Version: number;
  78024. /**
  78025. * Construct a new Controller Physics Feature
  78026. * @param _xrSessionManager the corresponding xr session manager
  78027. * @param _options options to create this feature with
  78028. */
  78029. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78030. /**
  78031. * @hidden
  78032. * enable debugging - will show console outputs and the impostor mesh
  78033. */
  78034. _enablePhysicsDebug(): void;
  78035. /**
  78036. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78037. * @param xrController the controller to add
  78038. */
  78039. addController(xrController: WebXRInputSource): void;
  78040. /**
  78041. * attach this feature
  78042. * Will usually be called by the features manager
  78043. *
  78044. * @returns true if successful.
  78045. */
  78046. attach(): boolean;
  78047. /**
  78048. * detach this feature.
  78049. * Will usually be called by the features manager
  78050. *
  78051. * @returns true if successful.
  78052. */
  78053. detach(): boolean;
  78054. /**
  78055. * Get the headset impostor, if enabled
  78056. * @returns the impostor
  78057. */
  78058. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78059. /**
  78060. * Get the physics impostor of a specific controller.
  78061. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78062. * @param controller the controller or the controller id of which to get the impostor
  78063. * @returns the impostor or null
  78064. */
  78065. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78066. /**
  78067. * Update the physics properties provided in the constructor
  78068. * @param newProperties the new properties object
  78069. */
  78070. setPhysicsProperties(newProperties: {
  78071. impostorType?: number;
  78072. impostorSize?: number | {
  78073. width: number;
  78074. height: number;
  78075. depth: number;
  78076. };
  78077. friction?: number;
  78078. restitution?: number;
  78079. }): void;
  78080. protected _onXRFrame(_xrFrame: any): void;
  78081. private _detachController;
  78082. }
  78083. }
  78084. declare module "babylonjs/XR/features/index" {
  78085. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78086. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78087. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78088. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78089. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78090. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78091. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78092. export * from "babylonjs/XR/features/WebXRHitTest";
  78093. }
  78094. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78095. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78097. import { Scene } from "babylonjs/scene";
  78098. /**
  78099. * The motion controller class for all microsoft mixed reality controllers
  78100. */
  78101. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78102. protected readonly _mapping: {
  78103. defaultButton: {
  78104. valueNodeName: string;
  78105. unpressedNodeName: string;
  78106. pressedNodeName: string;
  78107. };
  78108. defaultAxis: {
  78109. valueNodeName: string;
  78110. minNodeName: string;
  78111. maxNodeName: string;
  78112. };
  78113. buttons: {
  78114. "xr-standard-trigger": {
  78115. rootNodeName: string;
  78116. componentProperty: string;
  78117. states: string[];
  78118. };
  78119. "xr-standard-squeeze": {
  78120. rootNodeName: string;
  78121. componentProperty: string;
  78122. states: string[];
  78123. };
  78124. "xr-standard-touchpad": {
  78125. rootNodeName: string;
  78126. labelAnchorNodeName: string;
  78127. touchPointNodeName: string;
  78128. };
  78129. "xr-standard-thumbstick": {
  78130. rootNodeName: string;
  78131. componentProperty: string;
  78132. states: string[];
  78133. };
  78134. };
  78135. axes: {
  78136. "xr-standard-touchpad": {
  78137. "x-axis": {
  78138. rootNodeName: string;
  78139. };
  78140. "y-axis": {
  78141. rootNodeName: string;
  78142. };
  78143. };
  78144. "xr-standard-thumbstick": {
  78145. "x-axis": {
  78146. rootNodeName: string;
  78147. };
  78148. "y-axis": {
  78149. rootNodeName: string;
  78150. };
  78151. };
  78152. };
  78153. };
  78154. /**
  78155. * The base url used to load the left and right controller models
  78156. */
  78157. static MODEL_BASE_URL: string;
  78158. /**
  78159. * The name of the left controller model file
  78160. */
  78161. static MODEL_LEFT_FILENAME: string;
  78162. /**
  78163. * The name of the right controller model file
  78164. */
  78165. static MODEL_RIGHT_FILENAME: string;
  78166. profileId: string;
  78167. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78168. protected _getFilenameAndPath(): {
  78169. filename: string;
  78170. path: string;
  78171. };
  78172. protected _getModelLoadingConstraints(): boolean;
  78173. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78174. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78175. protected _updateModel(): void;
  78176. }
  78177. }
  78178. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78179. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78181. import { Scene } from "babylonjs/scene";
  78182. /**
  78183. * The motion controller class for oculus touch (quest, rift).
  78184. * This class supports legacy mapping as well the standard xr mapping
  78185. */
  78186. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78187. private _forceLegacyControllers;
  78188. private _modelRootNode;
  78189. /**
  78190. * The base url used to load the left and right controller models
  78191. */
  78192. static MODEL_BASE_URL: string;
  78193. /**
  78194. * The name of the left controller model file
  78195. */
  78196. static MODEL_LEFT_FILENAME: string;
  78197. /**
  78198. * The name of the right controller model file
  78199. */
  78200. static MODEL_RIGHT_FILENAME: string;
  78201. /**
  78202. * Base Url for the Quest controller model.
  78203. */
  78204. static QUEST_MODEL_BASE_URL: string;
  78205. profileId: string;
  78206. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78207. protected _getFilenameAndPath(): {
  78208. filename: string;
  78209. path: string;
  78210. };
  78211. protected _getModelLoadingConstraints(): boolean;
  78212. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78213. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78214. protected _updateModel(): void;
  78215. /**
  78216. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78217. * between the touch and touch 2.
  78218. */
  78219. private _isQuest;
  78220. }
  78221. }
  78222. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78223. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78224. import { Scene } from "babylonjs/scene";
  78225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78226. /**
  78227. * The motion controller class for the standard HTC-Vive controllers
  78228. */
  78229. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78230. private _modelRootNode;
  78231. /**
  78232. * The base url used to load the left and right controller models
  78233. */
  78234. static MODEL_BASE_URL: string;
  78235. /**
  78236. * File name for the controller model.
  78237. */
  78238. static MODEL_FILENAME: string;
  78239. profileId: string;
  78240. /**
  78241. * Create a new Vive motion controller object
  78242. * @param scene the scene to use to create this controller
  78243. * @param gamepadObject the corresponding gamepad object
  78244. * @param handedness the handedness of the controller
  78245. */
  78246. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78247. protected _getFilenameAndPath(): {
  78248. filename: string;
  78249. path: string;
  78250. };
  78251. protected _getModelLoadingConstraints(): boolean;
  78252. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78253. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78254. protected _updateModel(): void;
  78255. }
  78256. }
  78257. declare module "babylonjs/XR/motionController/index" {
  78258. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78259. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78260. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78261. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78262. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78263. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78264. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78265. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78266. }
  78267. declare module "babylonjs/XR/index" {
  78268. export * from "babylonjs/XR/webXRCamera";
  78269. export * from "babylonjs/XR/webXREnterExitUI";
  78270. export * from "babylonjs/XR/webXRExperienceHelper";
  78271. export * from "babylonjs/XR/webXRInput";
  78272. export * from "babylonjs/XR/webXRInputSource";
  78273. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78274. export * from "babylonjs/XR/webXRTypes";
  78275. export * from "babylonjs/XR/webXRSessionManager";
  78276. export * from "babylonjs/XR/webXRDefaultExperience";
  78277. export * from "babylonjs/XR/webXRFeaturesManager";
  78278. export * from "babylonjs/XR/features/index";
  78279. export * from "babylonjs/XR/motionController/index";
  78280. }
  78281. declare module "babylonjs/index" {
  78282. export * from "babylonjs/abstractScene";
  78283. export * from "babylonjs/Actions/index";
  78284. export * from "babylonjs/Animations/index";
  78285. export * from "babylonjs/assetContainer";
  78286. export * from "babylonjs/Audio/index";
  78287. export * from "babylonjs/Behaviors/index";
  78288. export * from "babylonjs/Bones/index";
  78289. export * from "babylonjs/Cameras/index";
  78290. export * from "babylonjs/Collisions/index";
  78291. export * from "babylonjs/Culling/index";
  78292. export * from "babylonjs/Debug/index";
  78293. export * from "babylonjs/DeviceInput/index";
  78294. export * from "babylonjs/Engines/index";
  78295. export * from "babylonjs/Events/index";
  78296. export * from "babylonjs/Gamepads/index";
  78297. export * from "babylonjs/Gizmos/index";
  78298. export * from "babylonjs/Helpers/index";
  78299. export * from "babylonjs/Instrumentation/index";
  78300. export * from "babylonjs/Layers/index";
  78301. export * from "babylonjs/LensFlares/index";
  78302. export * from "babylonjs/Lights/index";
  78303. export * from "babylonjs/Loading/index";
  78304. export * from "babylonjs/Materials/index";
  78305. export * from "babylonjs/Maths/index";
  78306. export * from "babylonjs/Meshes/index";
  78307. export * from "babylonjs/Morph/index";
  78308. export * from "babylonjs/Navigation/index";
  78309. export * from "babylonjs/node";
  78310. export * from "babylonjs/Offline/index";
  78311. export * from "babylonjs/Particles/index";
  78312. export * from "babylonjs/Physics/index";
  78313. export * from "babylonjs/PostProcesses/index";
  78314. export * from "babylonjs/Probes/index";
  78315. export * from "babylonjs/Rendering/index";
  78316. export * from "babylonjs/scene";
  78317. export * from "babylonjs/sceneComponent";
  78318. export * from "babylonjs/Sprites/index";
  78319. export * from "babylonjs/States/index";
  78320. export * from "babylonjs/Misc/index";
  78321. export * from "babylonjs/XR/index";
  78322. export * from "babylonjs/types";
  78323. }
  78324. declare module "babylonjs/Animations/pathCursor" {
  78325. import { Vector3 } from "babylonjs/Maths/math.vector";
  78326. import { Path2 } from "babylonjs/Maths/math.path";
  78327. /**
  78328. * A cursor which tracks a point on a path
  78329. */
  78330. export class PathCursor {
  78331. private path;
  78332. /**
  78333. * Stores path cursor callbacks for when an onchange event is triggered
  78334. */
  78335. private _onchange;
  78336. /**
  78337. * The value of the path cursor
  78338. */
  78339. value: number;
  78340. /**
  78341. * The animation array of the path cursor
  78342. */
  78343. animations: Animation[];
  78344. /**
  78345. * Initializes the path cursor
  78346. * @param path The path to track
  78347. */
  78348. constructor(path: Path2);
  78349. /**
  78350. * Gets the cursor point on the path
  78351. * @returns A point on the path cursor at the cursor location
  78352. */
  78353. getPoint(): Vector3;
  78354. /**
  78355. * Moves the cursor ahead by the step amount
  78356. * @param step The amount to move the cursor forward
  78357. * @returns This path cursor
  78358. */
  78359. moveAhead(step?: number): PathCursor;
  78360. /**
  78361. * Moves the cursor behind by the step amount
  78362. * @param step The amount to move the cursor back
  78363. * @returns This path cursor
  78364. */
  78365. moveBack(step?: number): PathCursor;
  78366. /**
  78367. * Moves the cursor by the step amount
  78368. * If the step amount is greater than one, an exception is thrown
  78369. * @param step The amount to move the cursor
  78370. * @returns This path cursor
  78371. */
  78372. move(step: number): PathCursor;
  78373. /**
  78374. * Ensures that the value is limited between zero and one
  78375. * @returns This path cursor
  78376. */
  78377. private ensureLimits;
  78378. /**
  78379. * Runs onchange callbacks on change (used by the animation engine)
  78380. * @returns This path cursor
  78381. */
  78382. private raiseOnChange;
  78383. /**
  78384. * Executes a function on change
  78385. * @param f A path cursor onchange callback
  78386. * @returns This path cursor
  78387. */
  78388. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78389. }
  78390. }
  78391. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78392. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78393. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78394. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78395. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78396. }
  78397. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78398. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78399. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78400. }
  78401. declare module "babylonjs/Engines/Processors/index" {
  78402. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78403. export * from "babylonjs/Engines/Processors/Expressions/index";
  78404. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78405. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78406. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78407. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78408. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78409. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78410. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78411. }
  78412. declare module "babylonjs/Legacy/legacy" {
  78413. import * as Babylon from "babylonjs/index";
  78414. export * from "babylonjs/index";
  78415. }
  78416. declare module "babylonjs/Shaders/blur.fragment" {
  78417. /** @hidden */
  78418. export var blurPixelShader: {
  78419. name: string;
  78420. shader: string;
  78421. };
  78422. }
  78423. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78424. /** @hidden */
  78425. export var pointCloudVertexDeclaration: {
  78426. name: string;
  78427. shader: string;
  78428. };
  78429. }
  78430. declare module "babylonjs" {
  78431. export * from "babylonjs/Legacy/legacy";
  78432. }
  78433. declare module BABYLON {
  78434. /** Alias type for value that can be null */
  78435. export type Nullable<T> = T | null;
  78436. /**
  78437. * Alias type for number that are floats
  78438. * @ignorenaming
  78439. */
  78440. export type float = number;
  78441. /**
  78442. * Alias type for number that are doubles.
  78443. * @ignorenaming
  78444. */
  78445. export type double = number;
  78446. /**
  78447. * Alias type for number that are integer
  78448. * @ignorenaming
  78449. */
  78450. export type int = number;
  78451. /** Alias type for number array or Float32Array */
  78452. export type FloatArray = number[] | Float32Array;
  78453. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78454. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78455. /**
  78456. * Alias for types that can be used by a Buffer or VertexBuffer.
  78457. */
  78458. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78459. /**
  78460. * Alias type for primitive types
  78461. * @ignorenaming
  78462. */
  78463. type Primitive = undefined | null | boolean | string | number | Function;
  78464. /**
  78465. * Type modifier to make all the properties of an object Readonly
  78466. */
  78467. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78468. /**
  78469. * Type modifier to make all the properties of an object Readonly recursively
  78470. */
  78471. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78472. /**
  78473. * Type modifier to make object properties readonly.
  78474. */
  78475. export type DeepImmutableObject<T> = {
  78476. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78477. };
  78478. /** @hidden */
  78479. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78480. }
  78481. }
  78482. declare module BABYLON {
  78483. /**
  78484. * A class serves as a medium between the observable and its observers
  78485. */
  78486. export class EventState {
  78487. /**
  78488. * Create a new EventState
  78489. * @param mask defines the mask associated with this state
  78490. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78491. * @param target defines the original target of the state
  78492. * @param currentTarget defines the current target of the state
  78493. */
  78494. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78495. /**
  78496. * Initialize the current event state
  78497. * @param mask defines the mask associated with this state
  78498. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78499. * @param target defines the original target of the state
  78500. * @param currentTarget defines the current target of the state
  78501. * @returns the current event state
  78502. */
  78503. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78504. /**
  78505. * An Observer can set this property to true to prevent subsequent observers of being notified
  78506. */
  78507. skipNextObservers: boolean;
  78508. /**
  78509. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78510. */
  78511. mask: number;
  78512. /**
  78513. * The object that originally notified the event
  78514. */
  78515. target?: any;
  78516. /**
  78517. * The current object in the bubbling phase
  78518. */
  78519. currentTarget?: any;
  78520. /**
  78521. * This will be populated with the return value of the last function that was executed.
  78522. * If it is the first function in the callback chain it will be the event data.
  78523. */
  78524. lastReturnValue?: any;
  78525. }
  78526. /**
  78527. * Represent an Observer registered to a given Observable object.
  78528. */
  78529. export class Observer<T> {
  78530. /**
  78531. * Defines the callback to call when the observer is notified
  78532. */
  78533. callback: (eventData: T, eventState: EventState) => void;
  78534. /**
  78535. * Defines the mask of the observer (used to filter notifications)
  78536. */
  78537. mask: number;
  78538. /**
  78539. * Defines the current scope used to restore the JS context
  78540. */
  78541. scope: any;
  78542. /** @hidden */
  78543. _willBeUnregistered: boolean;
  78544. /**
  78545. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78546. */
  78547. unregisterOnNextCall: boolean;
  78548. /**
  78549. * Creates a new observer
  78550. * @param callback defines the callback to call when the observer is notified
  78551. * @param mask defines the mask of the observer (used to filter notifications)
  78552. * @param scope defines the current scope used to restore the JS context
  78553. */
  78554. constructor(
  78555. /**
  78556. * Defines the callback to call when the observer is notified
  78557. */
  78558. callback: (eventData: T, eventState: EventState) => void,
  78559. /**
  78560. * Defines the mask of the observer (used to filter notifications)
  78561. */
  78562. mask: number,
  78563. /**
  78564. * Defines the current scope used to restore the JS context
  78565. */
  78566. scope?: any);
  78567. }
  78568. /**
  78569. * Represent a list of observers registered to multiple Observables object.
  78570. */
  78571. export class MultiObserver<T> {
  78572. private _observers;
  78573. private _observables;
  78574. /**
  78575. * Release associated resources
  78576. */
  78577. dispose(): void;
  78578. /**
  78579. * Raise a callback when one of the observable will notify
  78580. * @param observables defines a list of observables to watch
  78581. * @param callback defines the callback to call on notification
  78582. * @param mask defines the mask used to filter notifications
  78583. * @param scope defines the current scope used to restore the JS context
  78584. * @returns the new MultiObserver
  78585. */
  78586. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78587. }
  78588. /**
  78589. * The Observable class is a simple implementation of the Observable pattern.
  78590. *
  78591. * 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.
  78592. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78593. * 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).
  78594. * 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.
  78595. */
  78596. export class Observable<T> {
  78597. private _observers;
  78598. private _eventState;
  78599. private _onObserverAdded;
  78600. /**
  78601. * Gets the list of observers
  78602. */
  78603. get observers(): Array<Observer<T>>;
  78604. /**
  78605. * Creates a new observable
  78606. * @param onObserverAdded defines a callback to call when a new observer is added
  78607. */
  78608. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78609. /**
  78610. * Create a new Observer with the specified callback
  78611. * @param callback the callback that will be executed for that Observer
  78612. * @param mask the mask used to filter observers
  78613. * @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.
  78614. * @param scope optional scope for the callback to be called from
  78615. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78616. * @returns the new observer created for the callback
  78617. */
  78618. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78619. /**
  78620. * Create a new Observer with the specified callback and unregisters after the next notification
  78621. * @param callback the callback that will be executed for that Observer
  78622. * @returns the new observer created for the callback
  78623. */
  78624. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78625. /**
  78626. * Remove an Observer from the Observable object
  78627. * @param observer the instance of the Observer to remove
  78628. * @returns false if it doesn't belong to this Observable
  78629. */
  78630. remove(observer: Nullable<Observer<T>>): boolean;
  78631. /**
  78632. * Remove a callback from the Observable object
  78633. * @param callback the callback to remove
  78634. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78635. * @returns false if it doesn't belong to this Observable
  78636. */
  78637. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78638. private _deferUnregister;
  78639. private _remove;
  78640. /**
  78641. * Moves the observable to the top of the observer list making it get called first when notified
  78642. * @param observer the observer to move
  78643. */
  78644. makeObserverTopPriority(observer: Observer<T>): void;
  78645. /**
  78646. * Moves the observable to the bottom of the observer list making it get called last when notified
  78647. * @param observer the observer to move
  78648. */
  78649. makeObserverBottomPriority(observer: Observer<T>): void;
  78650. /**
  78651. * Notify all Observers by calling their respective callback with the given data
  78652. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78653. * @param eventData defines the data to send to all observers
  78654. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78655. * @param target defines the original target of the state
  78656. * @param currentTarget defines the current target of the state
  78657. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78658. */
  78659. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78660. /**
  78661. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78662. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78663. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78664. * and it is crucial that all callbacks will be executed.
  78665. * The order of the callbacks is kept, callbacks are not executed parallel.
  78666. *
  78667. * @param eventData The data to be sent to each callback
  78668. * @param mask is used to filter observers defaults to -1
  78669. * @param target defines the callback target (see EventState)
  78670. * @param currentTarget defines he current object in the bubbling phase
  78671. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78672. */
  78673. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78674. /**
  78675. * Notify a specific observer
  78676. * @param observer defines the observer to notify
  78677. * @param eventData defines the data to be sent to each callback
  78678. * @param mask is used to filter observers defaults to -1
  78679. */
  78680. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78681. /**
  78682. * Gets a boolean indicating if the observable has at least one observer
  78683. * @returns true is the Observable has at least one Observer registered
  78684. */
  78685. hasObservers(): boolean;
  78686. /**
  78687. * Clear the list of observers
  78688. */
  78689. clear(): void;
  78690. /**
  78691. * Clone the current observable
  78692. * @returns a new observable
  78693. */
  78694. clone(): Observable<T>;
  78695. /**
  78696. * Does this observable handles observer registered with a given mask
  78697. * @param mask defines the mask to be tested
  78698. * @return whether or not one observer registered with the given mask is handeled
  78699. **/
  78700. hasSpecificMask(mask?: number): boolean;
  78701. }
  78702. }
  78703. declare module BABYLON {
  78704. /**
  78705. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78706. * Babylon.js
  78707. */
  78708. export class DomManagement {
  78709. /**
  78710. * Checks if the window object exists
  78711. * @returns true if the window object exists
  78712. */
  78713. static IsWindowObjectExist(): boolean;
  78714. /**
  78715. * Checks if the navigator object exists
  78716. * @returns true if the navigator object exists
  78717. */
  78718. static IsNavigatorAvailable(): boolean;
  78719. /**
  78720. * Check if the document object exists
  78721. * @returns true if the document object exists
  78722. */
  78723. static IsDocumentAvailable(): boolean;
  78724. /**
  78725. * Extracts text content from a DOM element hierarchy
  78726. * @param element defines the root element
  78727. * @returns a string
  78728. */
  78729. static GetDOMTextContent(element: HTMLElement): string;
  78730. }
  78731. }
  78732. declare module BABYLON {
  78733. /**
  78734. * Logger used througouht the application to allow configuration of
  78735. * the log level required for the messages.
  78736. */
  78737. export class Logger {
  78738. /**
  78739. * No log
  78740. */
  78741. static readonly NoneLogLevel: number;
  78742. /**
  78743. * Only message logs
  78744. */
  78745. static readonly MessageLogLevel: number;
  78746. /**
  78747. * Only warning logs
  78748. */
  78749. static readonly WarningLogLevel: number;
  78750. /**
  78751. * Only error logs
  78752. */
  78753. static readonly ErrorLogLevel: number;
  78754. /**
  78755. * All logs
  78756. */
  78757. static readonly AllLogLevel: number;
  78758. private static _LogCache;
  78759. /**
  78760. * Gets a value indicating the number of loading errors
  78761. * @ignorenaming
  78762. */
  78763. static errorsCount: number;
  78764. /**
  78765. * Callback called when a new log is added
  78766. */
  78767. static OnNewCacheEntry: (entry: string) => void;
  78768. private static _AddLogEntry;
  78769. private static _FormatMessage;
  78770. private static _LogDisabled;
  78771. private static _LogEnabled;
  78772. private static _WarnDisabled;
  78773. private static _WarnEnabled;
  78774. private static _ErrorDisabled;
  78775. private static _ErrorEnabled;
  78776. /**
  78777. * Log a message to the console
  78778. */
  78779. static Log: (message: string) => void;
  78780. /**
  78781. * Write a warning message to the console
  78782. */
  78783. static Warn: (message: string) => void;
  78784. /**
  78785. * Write an error message to the console
  78786. */
  78787. static Error: (message: string) => void;
  78788. /**
  78789. * Gets current log cache (list of logs)
  78790. */
  78791. static get LogCache(): string;
  78792. /**
  78793. * Clears the log cache
  78794. */
  78795. static ClearLogCache(): void;
  78796. /**
  78797. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78798. */
  78799. static set LogLevels(level: number);
  78800. }
  78801. }
  78802. declare module BABYLON {
  78803. /** @hidden */
  78804. export class _TypeStore {
  78805. /** @hidden */
  78806. static RegisteredTypes: {
  78807. [key: string]: Object;
  78808. };
  78809. /** @hidden */
  78810. static GetClass(fqdn: string): any;
  78811. }
  78812. }
  78813. declare module BABYLON {
  78814. /**
  78815. * Helper to manipulate strings
  78816. */
  78817. export class StringTools {
  78818. /**
  78819. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78820. * @param str Source string
  78821. * @param suffix Suffix to search for in the source string
  78822. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78823. */
  78824. static EndsWith(str: string, suffix: string): boolean;
  78825. /**
  78826. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78827. * @param str Source string
  78828. * @param suffix Suffix to search for in the source string
  78829. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78830. */
  78831. static StartsWith(str: string, suffix: string): boolean;
  78832. /**
  78833. * Decodes a buffer into a string
  78834. * @param buffer The buffer to decode
  78835. * @returns The decoded string
  78836. */
  78837. static Decode(buffer: Uint8Array | Uint16Array): string;
  78838. /**
  78839. * Encode a buffer to a base64 string
  78840. * @param buffer defines the buffer to encode
  78841. * @returns the encoded string
  78842. */
  78843. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78844. /**
  78845. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78846. * @param num the number to convert and pad
  78847. * @param length the expected length of the string
  78848. * @returns the padded string
  78849. */
  78850. static PadNumber(num: number, length: number): string;
  78851. }
  78852. }
  78853. declare module BABYLON {
  78854. /**
  78855. * Class containing a set of static utilities functions for deep copy.
  78856. */
  78857. export class DeepCopier {
  78858. /**
  78859. * Tries to copy an object by duplicating every property
  78860. * @param source defines the source object
  78861. * @param destination defines the target object
  78862. * @param doNotCopyList defines a list of properties to avoid
  78863. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78864. */
  78865. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78866. }
  78867. }
  78868. declare module BABYLON {
  78869. /**
  78870. * Class containing a set of static utilities functions for precision date
  78871. */
  78872. export class PrecisionDate {
  78873. /**
  78874. * Gets either window.performance.now() if supported or Date.now() else
  78875. */
  78876. static get Now(): number;
  78877. }
  78878. }
  78879. declare module BABYLON {
  78880. /** @hidden */
  78881. export class _DevTools {
  78882. static WarnImport(name: string): string;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * Interface used to define the mechanism to get data from the network
  78888. */
  78889. export interface IWebRequest {
  78890. /**
  78891. * Returns client's response url
  78892. */
  78893. responseURL: string;
  78894. /**
  78895. * Returns client's status
  78896. */
  78897. status: number;
  78898. /**
  78899. * Returns client's status as a text
  78900. */
  78901. statusText: string;
  78902. }
  78903. }
  78904. declare module BABYLON {
  78905. /**
  78906. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78907. */
  78908. export class WebRequest implements IWebRequest {
  78909. private _xhr;
  78910. /**
  78911. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78912. * i.e. when loading files, where the server/service expects an Authorization header
  78913. */
  78914. static CustomRequestHeaders: {
  78915. [key: string]: string;
  78916. };
  78917. /**
  78918. * Add callback functions in this array to update all the requests before they get sent to the network
  78919. */
  78920. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78921. private _injectCustomRequestHeaders;
  78922. /**
  78923. * Gets or sets a function to be called when loading progress changes
  78924. */
  78925. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78926. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78927. /**
  78928. * Returns client's state
  78929. */
  78930. get readyState(): number;
  78931. /**
  78932. * Returns client's status
  78933. */
  78934. get status(): number;
  78935. /**
  78936. * Returns client's status as a text
  78937. */
  78938. get statusText(): string;
  78939. /**
  78940. * Returns client's response
  78941. */
  78942. get response(): any;
  78943. /**
  78944. * Returns client's response url
  78945. */
  78946. get responseURL(): string;
  78947. /**
  78948. * Returns client's response as text
  78949. */
  78950. get responseText(): string;
  78951. /**
  78952. * Gets or sets the expected response type
  78953. */
  78954. get responseType(): XMLHttpRequestResponseType;
  78955. set responseType(value: XMLHttpRequestResponseType);
  78956. /** @hidden */
  78957. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78958. /** @hidden */
  78959. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78960. /**
  78961. * Cancels any network activity
  78962. */
  78963. abort(): void;
  78964. /**
  78965. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78966. * @param body defines an optional request body
  78967. */
  78968. send(body?: Document | BodyInit | null): void;
  78969. /**
  78970. * Sets the request method, request URL
  78971. * @param method defines the method to use (GET, POST, etc..)
  78972. * @param url defines the url to connect with
  78973. */
  78974. open(method: string, url: string): void;
  78975. /**
  78976. * Sets the value of a request header.
  78977. * @param name The name of the header whose value is to be set
  78978. * @param value The value to set as the body of the header
  78979. */
  78980. setRequestHeader(name: string, value: string): void;
  78981. /**
  78982. * Get the string containing the text of a particular header's value.
  78983. * @param name The name of the header
  78984. * @returns The string containing the text of the given header name
  78985. */
  78986. getResponseHeader(name: string): Nullable<string>;
  78987. }
  78988. }
  78989. declare module BABYLON {
  78990. /**
  78991. * File request interface
  78992. */
  78993. export interface IFileRequest {
  78994. /**
  78995. * Raised when the request is complete (success or error).
  78996. */
  78997. onCompleteObservable: Observable<IFileRequest>;
  78998. /**
  78999. * Aborts the request for a file.
  79000. */
  79001. abort: () => void;
  79002. }
  79003. }
  79004. declare module BABYLON {
  79005. /**
  79006. * Define options used to create a render target texture
  79007. */
  79008. export class RenderTargetCreationOptions {
  79009. /**
  79010. * Specifies is mipmaps must be generated
  79011. */
  79012. generateMipMaps?: boolean;
  79013. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79014. generateDepthBuffer?: boolean;
  79015. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79016. generateStencilBuffer?: boolean;
  79017. /** Defines texture type (int by default) */
  79018. type?: number;
  79019. /** Defines sampling mode (trilinear by default) */
  79020. samplingMode?: number;
  79021. /** Defines format (RGBA by default) */
  79022. format?: number;
  79023. }
  79024. }
  79025. declare module BABYLON {
  79026. /** Defines the cross module used constants to avoid circular dependncies */
  79027. export class Constants {
  79028. /** Defines that alpha blending is disabled */
  79029. static readonly ALPHA_DISABLE: number;
  79030. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79031. static readonly ALPHA_ADD: number;
  79032. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79033. static readonly ALPHA_COMBINE: number;
  79034. /** Defines that alpha blending is DEST - SRC * DEST */
  79035. static readonly ALPHA_SUBTRACT: number;
  79036. /** Defines that alpha blending is SRC * DEST */
  79037. static readonly ALPHA_MULTIPLY: number;
  79038. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79039. static readonly ALPHA_MAXIMIZED: number;
  79040. /** Defines that alpha blending is SRC + DEST */
  79041. static readonly ALPHA_ONEONE: number;
  79042. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79043. static readonly ALPHA_PREMULTIPLIED: number;
  79044. /**
  79045. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79046. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79047. */
  79048. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79049. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79050. static readonly ALPHA_INTERPOLATE: number;
  79051. /**
  79052. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79053. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79054. */
  79055. static readonly ALPHA_SCREENMODE: number;
  79056. /**
  79057. * Defines that alpha blending is SRC + DST
  79058. * Alpha will be set to SRC ALPHA + DST ALPHA
  79059. */
  79060. static readonly ALPHA_ONEONE_ONEONE: number;
  79061. /**
  79062. * Defines that alpha blending is SRC * DST ALPHA + DST
  79063. * Alpha will be set to 0
  79064. */
  79065. static readonly ALPHA_ALPHATOCOLOR: number;
  79066. /**
  79067. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79068. */
  79069. static readonly ALPHA_REVERSEONEMINUS: number;
  79070. /**
  79071. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79072. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79073. */
  79074. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79075. /**
  79076. * Defines that alpha blending is SRC + DST
  79077. * Alpha will be set to SRC ALPHA
  79078. */
  79079. static readonly ALPHA_ONEONE_ONEZERO: number;
  79080. /**
  79081. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79082. * Alpha will be set to DST ALPHA
  79083. */
  79084. static readonly ALPHA_EXCLUSION: number;
  79085. /** Defines that alpha blending equation a SUM */
  79086. static readonly ALPHA_EQUATION_ADD: number;
  79087. /** Defines that alpha blending equation a SUBSTRACTION */
  79088. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79089. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79090. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79091. /** Defines that alpha blending equation a MAX operation */
  79092. static readonly ALPHA_EQUATION_MAX: number;
  79093. /** Defines that alpha blending equation a MIN operation */
  79094. static readonly ALPHA_EQUATION_MIN: number;
  79095. /**
  79096. * Defines that alpha blending equation a DARKEN operation:
  79097. * It takes the min of the src and sums the alpha channels.
  79098. */
  79099. static readonly ALPHA_EQUATION_DARKEN: number;
  79100. /** Defines that the ressource is not delayed*/
  79101. static readonly DELAYLOADSTATE_NONE: number;
  79102. /** Defines that the ressource was successfully delay loaded */
  79103. static readonly DELAYLOADSTATE_LOADED: number;
  79104. /** Defines that the ressource is currently delay loading */
  79105. static readonly DELAYLOADSTATE_LOADING: number;
  79106. /** Defines that the ressource is delayed and has not started loading */
  79107. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79109. static readonly NEVER: number;
  79110. /** 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 */
  79111. static readonly ALWAYS: number;
  79112. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79113. static readonly LESS: number;
  79114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79115. static readonly EQUAL: number;
  79116. /** 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 */
  79117. static readonly LEQUAL: number;
  79118. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79119. static readonly GREATER: number;
  79120. /** 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 */
  79121. static readonly GEQUAL: number;
  79122. /** 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 */
  79123. static readonly NOTEQUAL: number;
  79124. /** Passed to stencilOperation to specify that stencil value must be kept */
  79125. static readonly KEEP: number;
  79126. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79127. static readonly REPLACE: number;
  79128. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79129. static readonly INCR: number;
  79130. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79131. static readonly DECR: number;
  79132. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79133. static readonly INVERT: number;
  79134. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79135. static readonly INCR_WRAP: number;
  79136. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79137. static readonly DECR_WRAP: number;
  79138. /** Texture is not repeating outside of 0..1 UVs */
  79139. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79140. /** Texture is repeating outside of 0..1 UVs */
  79141. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79142. /** Texture is repeating and mirrored */
  79143. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79144. /** ALPHA */
  79145. static readonly TEXTUREFORMAT_ALPHA: number;
  79146. /** LUMINANCE */
  79147. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79148. /** LUMINANCE_ALPHA */
  79149. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79150. /** RGB */
  79151. static readonly TEXTUREFORMAT_RGB: number;
  79152. /** RGBA */
  79153. static readonly TEXTUREFORMAT_RGBA: number;
  79154. /** RED */
  79155. static readonly TEXTUREFORMAT_RED: number;
  79156. /** RED (2nd reference) */
  79157. static readonly TEXTUREFORMAT_R: number;
  79158. /** RG */
  79159. static readonly TEXTUREFORMAT_RG: number;
  79160. /** RED_INTEGER */
  79161. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79162. /** RED_INTEGER (2nd reference) */
  79163. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79164. /** RG_INTEGER */
  79165. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79166. /** RGB_INTEGER */
  79167. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79168. /** RGBA_INTEGER */
  79169. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79170. /** UNSIGNED_BYTE */
  79171. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79172. /** UNSIGNED_BYTE (2nd reference) */
  79173. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79174. /** FLOAT */
  79175. static readonly TEXTURETYPE_FLOAT: number;
  79176. /** HALF_FLOAT */
  79177. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79178. /** BYTE */
  79179. static readonly TEXTURETYPE_BYTE: number;
  79180. /** SHORT */
  79181. static readonly TEXTURETYPE_SHORT: number;
  79182. /** UNSIGNED_SHORT */
  79183. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79184. /** INT */
  79185. static readonly TEXTURETYPE_INT: number;
  79186. /** UNSIGNED_INT */
  79187. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79188. /** UNSIGNED_SHORT_4_4_4_4 */
  79189. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79190. /** UNSIGNED_SHORT_5_5_5_1 */
  79191. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79192. /** UNSIGNED_SHORT_5_6_5 */
  79193. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79194. /** UNSIGNED_INT_2_10_10_10_REV */
  79195. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79196. /** UNSIGNED_INT_24_8 */
  79197. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79198. /** UNSIGNED_INT_10F_11F_11F_REV */
  79199. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79200. /** UNSIGNED_INT_5_9_9_9_REV */
  79201. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79202. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79203. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79204. /** nearest is mag = nearest and min = nearest and no mip */
  79205. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79206. /** mag = nearest and min = nearest and mip = none */
  79207. static readonly TEXTURE_NEAREST_NEAREST: number;
  79208. /** Bilinear is mag = linear and min = linear and no mip */
  79209. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79210. /** mag = linear and min = linear and mip = none */
  79211. static readonly TEXTURE_LINEAR_LINEAR: number;
  79212. /** Trilinear is mag = linear and min = linear and mip = linear */
  79213. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79214. /** Trilinear is mag = linear and min = linear and mip = linear */
  79215. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79216. /** mag = nearest and min = nearest and mip = nearest */
  79217. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79218. /** mag = nearest and min = linear and mip = nearest */
  79219. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79220. /** mag = nearest and min = linear and mip = linear */
  79221. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79222. /** mag = nearest and min = linear and mip = none */
  79223. static readonly TEXTURE_NEAREST_LINEAR: number;
  79224. /** nearest is mag = nearest and min = nearest and mip = linear */
  79225. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79226. /** mag = linear and min = nearest and mip = nearest */
  79227. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79228. /** mag = linear and min = nearest and mip = linear */
  79229. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79231. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79232. /** mag = linear and min = nearest and mip = none */
  79233. static readonly TEXTURE_LINEAR_NEAREST: number;
  79234. /** Explicit coordinates mode */
  79235. static readonly TEXTURE_EXPLICIT_MODE: number;
  79236. /** Spherical coordinates mode */
  79237. static readonly TEXTURE_SPHERICAL_MODE: number;
  79238. /** Planar coordinates mode */
  79239. static readonly TEXTURE_PLANAR_MODE: number;
  79240. /** Cubic coordinates mode */
  79241. static readonly TEXTURE_CUBIC_MODE: number;
  79242. /** Projection coordinates mode */
  79243. static readonly TEXTURE_PROJECTION_MODE: number;
  79244. /** Skybox coordinates mode */
  79245. static readonly TEXTURE_SKYBOX_MODE: number;
  79246. /** Inverse Cubic coordinates mode */
  79247. static readonly TEXTURE_INVCUBIC_MODE: number;
  79248. /** Equirectangular coordinates mode */
  79249. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79250. /** Equirectangular Fixed coordinates mode */
  79251. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79252. /** Equirectangular Fixed Mirrored coordinates mode */
  79253. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79254. /** Offline (baking) quality for texture filtering */
  79255. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79256. /** High quality for texture filtering */
  79257. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79258. /** Medium quality for texture filtering */
  79259. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79260. /** Low quality for texture filtering */
  79261. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79262. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79263. static readonly SCALEMODE_FLOOR: number;
  79264. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79265. static readonly SCALEMODE_NEAREST: number;
  79266. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79267. static readonly SCALEMODE_CEILING: number;
  79268. /**
  79269. * The dirty texture flag value
  79270. */
  79271. static readonly MATERIAL_TextureDirtyFlag: number;
  79272. /**
  79273. * The dirty light flag value
  79274. */
  79275. static readonly MATERIAL_LightDirtyFlag: number;
  79276. /**
  79277. * The dirty fresnel flag value
  79278. */
  79279. static readonly MATERIAL_FresnelDirtyFlag: number;
  79280. /**
  79281. * The dirty attribute flag value
  79282. */
  79283. static readonly MATERIAL_AttributesDirtyFlag: number;
  79284. /**
  79285. * The dirty misc flag value
  79286. */
  79287. static readonly MATERIAL_MiscDirtyFlag: number;
  79288. /**
  79289. * The all dirty flag value
  79290. */
  79291. static readonly MATERIAL_AllDirtyFlag: number;
  79292. /**
  79293. * Returns the triangle fill mode
  79294. */
  79295. static readonly MATERIAL_TriangleFillMode: number;
  79296. /**
  79297. * Returns the wireframe mode
  79298. */
  79299. static readonly MATERIAL_WireFrameFillMode: number;
  79300. /**
  79301. * Returns the point fill mode
  79302. */
  79303. static readonly MATERIAL_PointFillMode: number;
  79304. /**
  79305. * Returns the point list draw mode
  79306. */
  79307. static readonly MATERIAL_PointListDrawMode: number;
  79308. /**
  79309. * Returns the line list draw mode
  79310. */
  79311. static readonly MATERIAL_LineListDrawMode: number;
  79312. /**
  79313. * Returns the line loop draw mode
  79314. */
  79315. static readonly MATERIAL_LineLoopDrawMode: number;
  79316. /**
  79317. * Returns the line strip draw mode
  79318. */
  79319. static readonly MATERIAL_LineStripDrawMode: number;
  79320. /**
  79321. * Returns the triangle strip draw mode
  79322. */
  79323. static readonly MATERIAL_TriangleStripDrawMode: number;
  79324. /**
  79325. * Returns the triangle fan draw mode
  79326. */
  79327. static readonly MATERIAL_TriangleFanDrawMode: number;
  79328. /**
  79329. * Stores the clock-wise side orientation
  79330. */
  79331. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79332. /**
  79333. * Stores the counter clock-wise side orientation
  79334. */
  79335. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79336. /**
  79337. * Nothing
  79338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79339. */
  79340. static readonly ACTION_NothingTrigger: number;
  79341. /**
  79342. * On pick
  79343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79344. */
  79345. static readonly ACTION_OnPickTrigger: number;
  79346. /**
  79347. * On left pick
  79348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79349. */
  79350. static readonly ACTION_OnLeftPickTrigger: number;
  79351. /**
  79352. * On right pick
  79353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79354. */
  79355. static readonly ACTION_OnRightPickTrigger: number;
  79356. /**
  79357. * On center pick
  79358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79359. */
  79360. static readonly ACTION_OnCenterPickTrigger: number;
  79361. /**
  79362. * On pick down
  79363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79364. */
  79365. static readonly ACTION_OnPickDownTrigger: number;
  79366. /**
  79367. * On double pick
  79368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79369. */
  79370. static readonly ACTION_OnDoublePickTrigger: number;
  79371. /**
  79372. * On pick up
  79373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79374. */
  79375. static readonly ACTION_OnPickUpTrigger: number;
  79376. /**
  79377. * On pick out.
  79378. * This trigger will only be raised if you also declared a OnPickDown
  79379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79380. */
  79381. static readonly ACTION_OnPickOutTrigger: number;
  79382. /**
  79383. * On long press
  79384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79385. */
  79386. static readonly ACTION_OnLongPressTrigger: number;
  79387. /**
  79388. * On pointer over
  79389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79390. */
  79391. static readonly ACTION_OnPointerOverTrigger: number;
  79392. /**
  79393. * On pointer out
  79394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79395. */
  79396. static readonly ACTION_OnPointerOutTrigger: number;
  79397. /**
  79398. * On every frame
  79399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79400. */
  79401. static readonly ACTION_OnEveryFrameTrigger: number;
  79402. /**
  79403. * On intersection enter
  79404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79405. */
  79406. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79407. /**
  79408. * On intersection exit
  79409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79410. */
  79411. static readonly ACTION_OnIntersectionExitTrigger: number;
  79412. /**
  79413. * On key down
  79414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79415. */
  79416. static readonly ACTION_OnKeyDownTrigger: number;
  79417. /**
  79418. * On key up
  79419. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79420. */
  79421. static readonly ACTION_OnKeyUpTrigger: number;
  79422. /**
  79423. * Billboard mode will only apply to Y axis
  79424. */
  79425. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79426. /**
  79427. * Billboard mode will apply to all axes
  79428. */
  79429. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79430. /**
  79431. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79432. */
  79433. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79434. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79435. * Test order :
  79436. * Is the bounding sphere outside the frustum ?
  79437. * If not, are the bounding box vertices outside the frustum ?
  79438. * It not, then the cullable object is in the frustum.
  79439. */
  79440. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79441. /** Culling strategy : Bounding Sphere Only.
  79442. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79443. * It's also less accurate than the standard because some not visible objects can still be selected.
  79444. * Test : is the bounding sphere outside the frustum ?
  79445. * If not, then the cullable object is in the frustum.
  79446. */
  79447. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79448. /** Culling strategy : Optimistic Inclusion.
  79449. * This in an inclusion test first, then the standard exclusion test.
  79450. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79451. * 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.
  79452. * Anyway, it's as accurate as the standard strategy.
  79453. * Test :
  79454. * Is the cullable object bounding sphere center in the frustum ?
  79455. * If not, apply the default culling strategy.
  79456. */
  79457. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79458. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79459. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79460. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79461. * 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.
  79462. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79463. * Test :
  79464. * Is the cullable object bounding sphere center in the frustum ?
  79465. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79466. */
  79467. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79468. /**
  79469. * No logging while loading
  79470. */
  79471. static readonly SCENELOADER_NO_LOGGING: number;
  79472. /**
  79473. * Minimal logging while loading
  79474. */
  79475. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79476. /**
  79477. * Summary logging while loading
  79478. */
  79479. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79480. /**
  79481. * Detailled logging while loading
  79482. */
  79483. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79484. /**
  79485. * Prepass texture index for color
  79486. */
  79487. static readonly PREPASS_COLOR_INDEX: number;
  79488. /**
  79489. * Prepass texture index for irradiance
  79490. */
  79491. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79492. /**
  79493. * Prepass texture index for depth + normal
  79494. */
  79495. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79496. /**
  79497. * Prepass texture index for albedo
  79498. */
  79499. static readonly PREPASS_ALBEDO_INDEX: number;
  79500. }
  79501. }
  79502. declare module BABYLON {
  79503. /**
  79504. * This represents the required contract to create a new type of texture loader.
  79505. */
  79506. export interface IInternalTextureLoader {
  79507. /**
  79508. * Defines wether the loader supports cascade loading the different faces.
  79509. */
  79510. supportCascades: boolean;
  79511. /**
  79512. * This returns if the loader support the current file information.
  79513. * @param extension defines the file extension of the file being loaded
  79514. * @param mimeType defines the optional mime type of the file being loaded
  79515. * @returns true if the loader can load the specified file
  79516. */
  79517. canLoad(extension: string, mimeType?: string): boolean;
  79518. /**
  79519. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79520. * @param data contains the texture data
  79521. * @param texture defines the BabylonJS internal texture
  79522. * @param createPolynomials will be true if polynomials have been requested
  79523. * @param onLoad defines the callback to trigger once the texture is ready
  79524. * @param onError defines the callback to trigger in case of error
  79525. */
  79526. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79527. /**
  79528. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79529. * @param data contains the texture data
  79530. * @param texture defines the BabylonJS internal texture
  79531. * @param callback defines the method to call once ready to upload
  79532. */
  79533. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79534. }
  79535. }
  79536. declare module BABYLON {
  79537. /**
  79538. * Class used to store and describe the pipeline context associated with an effect
  79539. */
  79540. export interface IPipelineContext {
  79541. /**
  79542. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79543. */
  79544. isAsync: boolean;
  79545. /**
  79546. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79547. */
  79548. isReady: boolean;
  79549. /** @hidden */
  79550. _getVertexShaderCode(): string | null;
  79551. /** @hidden */
  79552. _getFragmentShaderCode(): string | null;
  79553. /** @hidden */
  79554. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79555. }
  79556. }
  79557. declare module BABYLON {
  79558. /**
  79559. * Class used to store gfx data (like WebGLBuffer)
  79560. */
  79561. export class DataBuffer {
  79562. /**
  79563. * Gets or sets the number of objects referencing this buffer
  79564. */
  79565. references: number;
  79566. /** Gets or sets the size of the underlying buffer */
  79567. capacity: number;
  79568. /**
  79569. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79570. */
  79571. is32Bits: boolean;
  79572. /**
  79573. * Gets the underlying buffer
  79574. */
  79575. get underlyingResource(): any;
  79576. }
  79577. }
  79578. declare module BABYLON {
  79579. /** @hidden */
  79580. export interface IShaderProcessor {
  79581. attributeProcessor?: (attribute: string) => string;
  79582. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79583. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79584. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79585. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79586. lineProcessor?: (line: string, isFragment: boolean) => string;
  79587. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79588. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79589. }
  79590. }
  79591. declare module BABYLON {
  79592. /** @hidden */
  79593. export interface ProcessingOptions {
  79594. defines: string[];
  79595. indexParameters: any;
  79596. isFragment: boolean;
  79597. shouldUseHighPrecisionShader: boolean;
  79598. supportsUniformBuffers: boolean;
  79599. shadersRepository: string;
  79600. includesShadersStore: {
  79601. [key: string]: string;
  79602. };
  79603. processor?: IShaderProcessor;
  79604. version: string;
  79605. platformName: string;
  79606. lookForClosingBracketForUniformBuffer?: boolean;
  79607. }
  79608. }
  79609. declare module BABYLON {
  79610. /** @hidden */
  79611. export class ShaderCodeNode {
  79612. line: string;
  79613. children: ShaderCodeNode[];
  79614. additionalDefineKey?: string;
  79615. additionalDefineValue?: string;
  79616. isValid(preprocessors: {
  79617. [key: string]: string;
  79618. }): boolean;
  79619. process(preprocessors: {
  79620. [key: string]: string;
  79621. }, options: ProcessingOptions): string;
  79622. }
  79623. }
  79624. declare module BABYLON {
  79625. /** @hidden */
  79626. export class ShaderCodeCursor {
  79627. private _lines;
  79628. lineIndex: number;
  79629. get currentLine(): string;
  79630. get canRead(): boolean;
  79631. set lines(value: string[]);
  79632. }
  79633. }
  79634. declare module BABYLON {
  79635. /** @hidden */
  79636. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79637. process(preprocessors: {
  79638. [key: string]: string;
  79639. }, options: ProcessingOptions): string;
  79640. }
  79641. }
  79642. declare module BABYLON {
  79643. /** @hidden */
  79644. export class ShaderDefineExpression {
  79645. isTrue(preprocessors: {
  79646. [key: string]: string;
  79647. }): boolean;
  79648. private static _OperatorPriority;
  79649. private static _Stack;
  79650. static postfixToInfix(postfix: string[]): string;
  79651. static infixToPostfix(infix: string): string[];
  79652. }
  79653. }
  79654. declare module BABYLON {
  79655. /** @hidden */
  79656. export class ShaderCodeTestNode extends ShaderCodeNode {
  79657. testExpression: ShaderDefineExpression;
  79658. isValid(preprocessors: {
  79659. [key: string]: string;
  79660. }): boolean;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. /** @hidden */
  79665. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79666. define: string;
  79667. not: boolean;
  79668. constructor(define: string, not?: boolean);
  79669. isTrue(preprocessors: {
  79670. [key: string]: string;
  79671. }): boolean;
  79672. }
  79673. }
  79674. declare module BABYLON {
  79675. /** @hidden */
  79676. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79677. leftOperand: ShaderDefineExpression;
  79678. rightOperand: ShaderDefineExpression;
  79679. isTrue(preprocessors: {
  79680. [key: string]: string;
  79681. }): boolean;
  79682. }
  79683. }
  79684. declare module BABYLON {
  79685. /** @hidden */
  79686. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79687. leftOperand: ShaderDefineExpression;
  79688. rightOperand: ShaderDefineExpression;
  79689. isTrue(preprocessors: {
  79690. [key: string]: string;
  79691. }): boolean;
  79692. }
  79693. }
  79694. declare module BABYLON {
  79695. /** @hidden */
  79696. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79697. define: string;
  79698. operand: string;
  79699. testValue: string;
  79700. constructor(define: string, operand: string, testValue: string);
  79701. isTrue(preprocessors: {
  79702. [key: string]: string;
  79703. }): boolean;
  79704. }
  79705. }
  79706. declare module BABYLON {
  79707. /**
  79708. * Class used to enable access to offline support
  79709. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79710. */
  79711. export interface IOfflineProvider {
  79712. /**
  79713. * Gets a boolean indicating if scene must be saved in the database
  79714. */
  79715. enableSceneOffline: boolean;
  79716. /**
  79717. * Gets a boolean indicating if textures must be saved in the database
  79718. */
  79719. enableTexturesOffline: boolean;
  79720. /**
  79721. * Open the offline support and make it available
  79722. * @param successCallback defines the callback to call on success
  79723. * @param errorCallback defines the callback to call on error
  79724. */
  79725. open(successCallback: () => void, errorCallback: () => void): void;
  79726. /**
  79727. * Loads an image from the offline support
  79728. * @param url defines the url to load from
  79729. * @param image defines the target DOM image
  79730. */
  79731. loadImage(url: string, image: HTMLImageElement): void;
  79732. /**
  79733. * Loads a file from offline support
  79734. * @param url defines the URL to load from
  79735. * @param sceneLoaded defines a callback to call on success
  79736. * @param progressCallBack defines a callback to call when progress changed
  79737. * @param errorCallback defines a callback to call on error
  79738. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79739. */
  79740. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79741. }
  79742. }
  79743. declare module BABYLON {
  79744. /**
  79745. * Class used to help managing file picking and drag'n'drop
  79746. * File Storage
  79747. */
  79748. export class FilesInputStore {
  79749. /**
  79750. * List of files ready to be loaded
  79751. */
  79752. static FilesToLoad: {
  79753. [key: string]: File;
  79754. };
  79755. }
  79756. }
  79757. declare module BABYLON {
  79758. /**
  79759. * Class used to define a retry strategy when error happens while loading assets
  79760. */
  79761. export class RetryStrategy {
  79762. /**
  79763. * Function used to defines an exponential back off strategy
  79764. * @param maxRetries defines the maximum number of retries (3 by default)
  79765. * @param baseInterval defines the interval between retries
  79766. * @returns the strategy function to use
  79767. */
  79768. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79769. }
  79770. }
  79771. declare module BABYLON {
  79772. /**
  79773. * @ignore
  79774. * Application error to support additional information when loading a file
  79775. */
  79776. export abstract class BaseError extends Error {
  79777. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79778. }
  79779. }
  79780. declare module BABYLON {
  79781. /** @ignore */
  79782. export class LoadFileError extends BaseError {
  79783. request?: WebRequest;
  79784. file?: File;
  79785. /**
  79786. * Creates a new LoadFileError
  79787. * @param message defines the message of the error
  79788. * @param request defines the optional web request
  79789. * @param file defines the optional file
  79790. */
  79791. constructor(message: string, object?: WebRequest | File);
  79792. }
  79793. /** @ignore */
  79794. export class RequestFileError extends BaseError {
  79795. request: WebRequest;
  79796. /**
  79797. * Creates a new LoadFileError
  79798. * @param message defines the message of the error
  79799. * @param request defines the optional web request
  79800. */
  79801. constructor(message: string, request: WebRequest);
  79802. }
  79803. /** @ignore */
  79804. export class ReadFileError extends BaseError {
  79805. file: File;
  79806. /**
  79807. * Creates a new ReadFileError
  79808. * @param message defines the message of the error
  79809. * @param file defines the optional file
  79810. */
  79811. constructor(message: string, file: File);
  79812. }
  79813. /**
  79814. * @hidden
  79815. */
  79816. export class FileTools {
  79817. /**
  79818. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79819. */
  79820. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79821. /**
  79822. * Gets or sets the base URL to use to load assets
  79823. */
  79824. static BaseUrl: string;
  79825. /**
  79826. * Default behaviour for cors in the application.
  79827. * It can be a string if the expected behavior is identical in the entire app.
  79828. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79829. */
  79830. static CorsBehavior: string | ((url: string | string[]) => string);
  79831. /**
  79832. * Gets or sets a function used to pre-process url before using them to load assets
  79833. */
  79834. static PreprocessUrl: (url: string) => string;
  79835. /**
  79836. * Removes unwanted characters from an url
  79837. * @param url defines the url to clean
  79838. * @returns the cleaned url
  79839. */
  79840. private static _CleanUrl;
  79841. /**
  79842. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79843. * @param url define the url we are trying
  79844. * @param element define the dom element where to configure the cors policy
  79845. */
  79846. static SetCorsBehavior(url: string | string[], element: {
  79847. crossOrigin: string | null;
  79848. }): void;
  79849. /**
  79850. * Loads an image as an HTMLImageElement.
  79851. * @param input url string, ArrayBuffer, or Blob to load
  79852. * @param onLoad callback called when the image successfully loads
  79853. * @param onError callback called when the image fails to load
  79854. * @param offlineProvider offline provider for caching
  79855. * @param mimeType optional mime type
  79856. * @returns the HTMLImageElement of the loaded image
  79857. */
  79858. 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>;
  79859. /**
  79860. * Reads a file from a File object
  79861. * @param file defines the file to load
  79862. * @param onSuccess defines the callback to call when data is loaded
  79863. * @param onProgress defines the callback to call during loading process
  79864. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79865. * @param onError defines the callback to call when an error occurs
  79866. * @returns a file request object
  79867. */
  79868. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79869. /**
  79870. * Loads a file from a url
  79871. * @param url url to load
  79872. * @param onSuccess callback called when the file successfully loads
  79873. * @param onProgress callback called while file is loading (if the server supports this mode)
  79874. * @param offlineProvider defines the offline provider for caching
  79875. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79876. * @param onError callback called when the file fails to load
  79877. * @returns a file request object
  79878. */
  79879. 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;
  79880. /**
  79881. * Loads a file
  79882. * @param url url to load
  79883. * @param onSuccess callback called when the file successfully loads
  79884. * @param onProgress callback called while file is loading (if the server supports this mode)
  79885. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79886. * @param onError callback called when the file fails to load
  79887. * @param onOpened callback called when the web request is opened
  79888. * @returns a file request object
  79889. */
  79890. 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;
  79891. /**
  79892. * Checks if the loaded document was accessed via `file:`-Protocol.
  79893. * @returns boolean
  79894. */
  79895. static IsFileURL(): boolean;
  79896. }
  79897. }
  79898. declare module BABYLON {
  79899. /** @hidden */
  79900. export class ShaderProcessor {
  79901. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79902. private static _ProcessPrecision;
  79903. private static _ExtractOperation;
  79904. private static _BuildSubExpression;
  79905. private static _BuildExpression;
  79906. private static _MoveCursorWithinIf;
  79907. private static _MoveCursor;
  79908. private static _EvaluatePreProcessors;
  79909. private static _PreparePreProcessors;
  79910. private static _ProcessShaderConversion;
  79911. private static _ProcessIncludes;
  79912. /**
  79913. * Loads a file from a url
  79914. * @param url url to load
  79915. * @param onSuccess callback called when the file successfully loads
  79916. * @param onProgress callback called while file is loading (if the server supports this mode)
  79917. * @param offlineProvider defines the offline provider for caching
  79918. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79919. * @param onError callback called when the file fails to load
  79920. * @returns a file request object
  79921. * @hidden
  79922. */
  79923. 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;
  79924. }
  79925. }
  79926. declare module BABYLON {
  79927. /**
  79928. * @hidden
  79929. */
  79930. export interface IColor4Like {
  79931. r: float;
  79932. g: float;
  79933. b: float;
  79934. a: float;
  79935. }
  79936. /**
  79937. * @hidden
  79938. */
  79939. export interface IColor3Like {
  79940. r: float;
  79941. g: float;
  79942. b: float;
  79943. }
  79944. /**
  79945. * @hidden
  79946. */
  79947. export interface IVector4Like {
  79948. x: float;
  79949. y: float;
  79950. z: float;
  79951. w: float;
  79952. }
  79953. /**
  79954. * @hidden
  79955. */
  79956. export interface IVector3Like {
  79957. x: float;
  79958. y: float;
  79959. z: float;
  79960. }
  79961. /**
  79962. * @hidden
  79963. */
  79964. export interface IVector2Like {
  79965. x: float;
  79966. y: float;
  79967. }
  79968. /**
  79969. * @hidden
  79970. */
  79971. export interface IMatrixLike {
  79972. toArray(): DeepImmutable<Float32Array | Array<number>>;
  79973. updateFlag: int;
  79974. }
  79975. /**
  79976. * @hidden
  79977. */
  79978. export interface IViewportLike {
  79979. x: float;
  79980. y: float;
  79981. width: float;
  79982. height: float;
  79983. }
  79984. /**
  79985. * @hidden
  79986. */
  79987. export interface IPlaneLike {
  79988. normal: IVector3Like;
  79989. d: float;
  79990. normalize(): void;
  79991. }
  79992. }
  79993. declare module BABYLON {
  79994. /**
  79995. * Interface used to define common properties for effect fallbacks
  79996. */
  79997. export interface IEffectFallbacks {
  79998. /**
  79999. * Removes the defines that should be removed when falling back.
  80000. * @param currentDefines defines the current define statements for the shader.
  80001. * @param effect defines the current effect we try to compile
  80002. * @returns The resulting defines with defines of the current rank removed.
  80003. */
  80004. reduce(currentDefines: string, effect: Effect): string;
  80005. /**
  80006. * Removes the fallback from the bound mesh.
  80007. */
  80008. unBindMesh(): void;
  80009. /**
  80010. * Checks to see if more fallbacks are still availible.
  80011. */
  80012. hasMoreFallbacks: boolean;
  80013. }
  80014. }
  80015. declare module BABYLON {
  80016. /**
  80017. * Class used to evalaute queries containing `and` and `or` operators
  80018. */
  80019. export class AndOrNotEvaluator {
  80020. /**
  80021. * Evaluate a query
  80022. * @param query defines the query to evaluate
  80023. * @param evaluateCallback defines the callback used to filter result
  80024. * @returns true if the query matches
  80025. */
  80026. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80027. private static _HandleParenthesisContent;
  80028. private static _SimplifyNegation;
  80029. }
  80030. }
  80031. declare module BABYLON {
  80032. /**
  80033. * Class used to store custom tags
  80034. */
  80035. export class Tags {
  80036. /**
  80037. * Adds support for tags on the given object
  80038. * @param obj defines the object to use
  80039. */
  80040. static EnableFor(obj: any): void;
  80041. /**
  80042. * Removes tags support
  80043. * @param obj defines the object to use
  80044. */
  80045. static DisableFor(obj: any): void;
  80046. /**
  80047. * Gets a boolean indicating if the given object has tags
  80048. * @param obj defines the object to use
  80049. * @returns a boolean
  80050. */
  80051. static HasTags(obj: any): boolean;
  80052. /**
  80053. * Gets the tags available on a given object
  80054. * @param obj defines the object to use
  80055. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80056. * @returns the tags
  80057. */
  80058. static GetTags(obj: any, asString?: boolean): any;
  80059. /**
  80060. * Adds tags to an object
  80061. * @param obj defines the object to use
  80062. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80063. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80064. */
  80065. static AddTagsTo(obj: any, tagsString: string): void;
  80066. /**
  80067. * @hidden
  80068. */
  80069. static _AddTagTo(obj: any, tag: string): void;
  80070. /**
  80071. * Removes specific tags from a specific object
  80072. * @param obj defines the object to use
  80073. * @param tagsString defines the tags to remove
  80074. */
  80075. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80076. /**
  80077. * @hidden
  80078. */
  80079. static _RemoveTagFrom(obj: any, tag: string): void;
  80080. /**
  80081. * Defines if tags hosted on an object match a given query
  80082. * @param obj defines the object to use
  80083. * @param tagsQuery defines the tag query
  80084. * @returns a boolean
  80085. */
  80086. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80087. }
  80088. }
  80089. declare module BABYLON {
  80090. /**
  80091. * Scalar computation library
  80092. */
  80093. export class Scalar {
  80094. /**
  80095. * Two pi constants convenient for computation.
  80096. */
  80097. static TwoPi: number;
  80098. /**
  80099. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80100. * @param a number
  80101. * @param b number
  80102. * @param epsilon (default = 1.401298E-45)
  80103. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80104. */
  80105. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80106. /**
  80107. * Returns a string : the upper case translation of the number i to hexadecimal.
  80108. * @param i number
  80109. * @returns the upper case translation of the number i to hexadecimal.
  80110. */
  80111. static ToHex(i: number): string;
  80112. /**
  80113. * Returns -1 if value is negative and +1 is value is positive.
  80114. * @param value the value
  80115. * @returns the value itself if it's equal to zero.
  80116. */
  80117. static Sign(value: number): number;
  80118. /**
  80119. * Returns the value itself if it's between min and max.
  80120. * Returns min if the value is lower than min.
  80121. * Returns max if the value is greater than max.
  80122. * @param value the value to clmap
  80123. * @param min the min value to clamp to (default: 0)
  80124. * @param max the max value to clamp to (default: 1)
  80125. * @returns the clamped value
  80126. */
  80127. static Clamp(value: number, min?: number, max?: number): number;
  80128. /**
  80129. * the log2 of value.
  80130. * @param value the value to compute log2 of
  80131. * @returns the log2 of value.
  80132. */
  80133. static Log2(value: number): number;
  80134. /**
  80135. * Loops the value, so that it is never larger than length and never smaller than 0.
  80136. *
  80137. * This is similar to the modulo operator but it works with floating point numbers.
  80138. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80139. * With t = 5 and length = 2.5, the result would be 0.0.
  80140. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80141. * @param value the value
  80142. * @param length the length
  80143. * @returns the looped value
  80144. */
  80145. static Repeat(value: number, length: number): number;
  80146. /**
  80147. * Normalize the value between 0.0 and 1.0 using min and max values
  80148. * @param value value to normalize
  80149. * @param min max to normalize between
  80150. * @param max min to normalize between
  80151. * @returns the normalized value
  80152. */
  80153. static Normalize(value: number, min: number, max: number): number;
  80154. /**
  80155. * Denormalize the value from 0.0 and 1.0 using min and max values
  80156. * @param normalized value to denormalize
  80157. * @param min max to denormalize between
  80158. * @param max min to denormalize between
  80159. * @returns the denormalized value
  80160. */
  80161. static Denormalize(normalized: number, min: number, max: number): number;
  80162. /**
  80163. * Calculates the shortest difference between two given angles given in degrees.
  80164. * @param current current angle in degrees
  80165. * @param target target angle in degrees
  80166. * @returns the delta
  80167. */
  80168. static DeltaAngle(current: number, target: number): number;
  80169. /**
  80170. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80171. * @param tx value
  80172. * @param length length
  80173. * @returns The returned value will move back and forth between 0 and length
  80174. */
  80175. static PingPong(tx: number, length: number): number;
  80176. /**
  80177. * Interpolates between min and max with smoothing at the limits.
  80178. *
  80179. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80180. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80181. * @param from from
  80182. * @param to to
  80183. * @param tx value
  80184. * @returns the smooth stepped value
  80185. */
  80186. static SmoothStep(from: number, to: number, tx: number): number;
  80187. /**
  80188. * Moves a value current towards target.
  80189. *
  80190. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80191. * Negative values of maxDelta pushes the value away from target.
  80192. * @param current current value
  80193. * @param target target value
  80194. * @param maxDelta max distance to move
  80195. * @returns resulting value
  80196. */
  80197. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80198. /**
  80199. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80200. *
  80201. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80202. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80203. * @param current current value
  80204. * @param target target value
  80205. * @param maxDelta max distance to move
  80206. * @returns resulting angle
  80207. */
  80208. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80209. /**
  80210. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80211. * @param start start value
  80212. * @param end target value
  80213. * @param amount amount to lerp between
  80214. * @returns the lerped value
  80215. */
  80216. static Lerp(start: number, end: number, amount: number): number;
  80217. /**
  80218. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80219. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80220. * @param start start value
  80221. * @param end target value
  80222. * @param amount amount to lerp between
  80223. * @returns the lerped value
  80224. */
  80225. static LerpAngle(start: number, end: number, amount: number): number;
  80226. /**
  80227. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80228. * @param a start value
  80229. * @param b target value
  80230. * @param value value between a and b
  80231. * @returns the inverseLerp value
  80232. */
  80233. static InverseLerp(a: number, b: number, value: number): number;
  80234. /**
  80235. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80236. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80237. * @param value1 spline value
  80238. * @param tangent1 spline value
  80239. * @param value2 spline value
  80240. * @param tangent2 spline value
  80241. * @param amount input value
  80242. * @returns hermite result
  80243. */
  80244. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80245. /**
  80246. * Returns a random float number between and min and max values
  80247. * @param min min value of random
  80248. * @param max max value of random
  80249. * @returns random value
  80250. */
  80251. static RandomRange(min: number, max: number): number;
  80252. /**
  80253. * This function returns percentage of a number in a given range.
  80254. *
  80255. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80256. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80257. * @param number to convert to percentage
  80258. * @param min min range
  80259. * @param max max range
  80260. * @returns the percentage
  80261. */
  80262. static RangeToPercent(number: number, min: number, max: number): number;
  80263. /**
  80264. * This function returns number that corresponds to the percentage in a given range.
  80265. *
  80266. * PercentToRange(0.34,0,100) will return 34.
  80267. * @param percent to convert to number
  80268. * @param min min range
  80269. * @param max max range
  80270. * @returns the number
  80271. */
  80272. static PercentToRange(percent: number, min: number, max: number): number;
  80273. /**
  80274. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80275. * @param angle The angle to normalize in radian.
  80276. * @return The converted angle.
  80277. */
  80278. static NormalizeRadians(angle: number): number;
  80279. }
  80280. }
  80281. declare module BABYLON {
  80282. /**
  80283. * Constant used to convert a value to gamma space
  80284. * @ignorenaming
  80285. */
  80286. export const ToGammaSpace: number;
  80287. /**
  80288. * Constant used to convert a value to linear space
  80289. * @ignorenaming
  80290. */
  80291. export const ToLinearSpace = 2.2;
  80292. /**
  80293. * Constant used to define the minimal number value in Babylon.js
  80294. * @ignorenaming
  80295. */
  80296. let Epsilon: number;
  80297. }
  80298. declare module BABYLON {
  80299. /**
  80300. * Class used to represent a viewport on screen
  80301. */
  80302. export class Viewport {
  80303. /** viewport left coordinate */
  80304. x: number;
  80305. /** viewport top coordinate */
  80306. y: number;
  80307. /**viewport width */
  80308. width: number;
  80309. /** viewport height */
  80310. height: number;
  80311. /**
  80312. * Creates a Viewport object located at (x, y) and sized (width, height)
  80313. * @param x defines viewport left coordinate
  80314. * @param y defines viewport top coordinate
  80315. * @param width defines the viewport width
  80316. * @param height defines the viewport height
  80317. */
  80318. constructor(
  80319. /** viewport left coordinate */
  80320. x: number,
  80321. /** viewport top coordinate */
  80322. y: number,
  80323. /**viewport width */
  80324. width: number,
  80325. /** viewport height */
  80326. height: number);
  80327. /**
  80328. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80329. * @param renderWidth defines the rendering width
  80330. * @param renderHeight defines the rendering height
  80331. * @returns a new Viewport
  80332. */
  80333. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80334. /**
  80335. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80336. * @param renderWidth defines the rendering width
  80337. * @param renderHeight defines the rendering height
  80338. * @param ref defines the target viewport
  80339. * @returns the current viewport
  80340. */
  80341. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80342. /**
  80343. * Returns a new Viewport copied from the current one
  80344. * @returns a new Viewport
  80345. */
  80346. clone(): Viewport;
  80347. }
  80348. }
  80349. declare module BABYLON {
  80350. /**
  80351. * Class containing a set of static utilities functions for arrays.
  80352. */
  80353. export class ArrayTools {
  80354. /**
  80355. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80356. * @param size the number of element to construct and put in the array
  80357. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80358. * @returns a new array filled with new objects
  80359. */
  80360. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80361. }
  80362. }
  80363. declare module BABYLON {
  80364. /**
  80365. * Represents a plane by the equation ax + by + cz + d = 0
  80366. */
  80367. export class Plane {
  80368. private static _TmpMatrix;
  80369. /**
  80370. * Normal of the plane (a,b,c)
  80371. */
  80372. normal: Vector3;
  80373. /**
  80374. * d component of the plane
  80375. */
  80376. d: number;
  80377. /**
  80378. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80379. * @param a a component of the plane
  80380. * @param b b component of the plane
  80381. * @param c c component of the plane
  80382. * @param d d component of the plane
  80383. */
  80384. constructor(a: number, b: number, c: number, d: number);
  80385. /**
  80386. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80387. */
  80388. asArray(): number[];
  80389. /**
  80390. * @returns a new plane copied from the current Plane.
  80391. */
  80392. clone(): Plane;
  80393. /**
  80394. * @returns the string "Plane".
  80395. */
  80396. getClassName(): string;
  80397. /**
  80398. * @returns the Plane hash code.
  80399. */
  80400. getHashCode(): number;
  80401. /**
  80402. * Normalize the current Plane in place.
  80403. * @returns the updated Plane.
  80404. */
  80405. normalize(): Plane;
  80406. /**
  80407. * Applies a transformation the plane and returns the result
  80408. * @param transformation the transformation matrix to be applied to the plane
  80409. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80410. */
  80411. transform(transformation: DeepImmutable<Matrix>): Plane;
  80412. /**
  80413. * Compute the dot product between the point and the plane normal
  80414. * @param point point to calculate the dot product with
  80415. * @returns the dot product (float) of the point coordinates and the plane normal.
  80416. */
  80417. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80418. /**
  80419. * Updates the current Plane from the plane defined by the three given points.
  80420. * @param point1 one of the points used to contruct the plane
  80421. * @param point2 one of the points used to contruct the plane
  80422. * @param point3 one of the points used to contruct the plane
  80423. * @returns the updated Plane.
  80424. */
  80425. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80426. /**
  80427. * Checks if the plane is facing a given direction
  80428. * @param direction the direction to check if the plane is facing
  80429. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80430. * @returns True is the vector "direction" is the same side than the plane normal.
  80431. */
  80432. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80433. /**
  80434. * Calculates the distance to a point
  80435. * @param point point to calculate distance to
  80436. * @returns the signed distance (float) from the given point to the Plane.
  80437. */
  80438. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80439. /**
  80440. * Creates a plane from an array
  80441. * @param array the array to create a plane from
  80442. * @returns a new Plane from the given array.
  80443. */
  80444. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80445. /**
  80446. * Creates a plane from three points
  80447. * @param point1 point used to create the plane
  80448. * @param point2 point used to create the plane
  80449. * @param point3 point used to create the plane
  80450. * @returns a new Plane defined by the three given points.
  80451. */
  80452. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80453. /**
  80454. * Creates a plane from an origin point and a normal
  80455. * @param origin origin of the plane to be constructed
  80456. * @param normal normal of the plane to be constructed
  80457. * @returns a new Plane the normal vector to this plane at the given origin point.
  80458. * Note : the vector "normal" is updated because normalized.
  80459. */
  80460. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80461. /**
  80462. * Calculates the distance from a plane and a point
  80463. * @param origin origin of the plane to be constructed
  80464. * @param normal normal of the plane to be constructed
  80465. * @param point point to calculate distance to
  80466. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80467. */
  80468. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80469. }
  80470. }
  80471. declare module BABYLON {
  80472. /** @hidden */
  80473. export class PerformanceConfigurator {
  80474. /** @hidden */
  80475. static MatrixUse64Bits: boolean;
  80476. /** @hidden */
  80477. static MatrixTrackPrecisionChange: boolean;
  80478. /** @hidden */
  80479. static MatrixCurrentType: any;
  80480. /** @hidden */
  80481. static MatrixTrackedMatrices: Array<any> | null;
  80482. /** @hidden */
  80483. static SetMatrixPrecision(use64bits: boolean): void;
  80484. }
  80485. }
  80486. declare module BABYLON {
  80487. /**
  80488. * Class representing a vector containing 2 coordinates
  80489. */
  80490. export class Vector2 {
  80491. /** defines the first coordinate */
  80492. x: number;
  80493. /** defines the second coordinate */
  80494. y: number;
  80495. /**
  80496. * Creates a new Vector2 from the given x and y coordinates
  80497. * @param x defines the first coordinate
  80498. * @param y defines the second coordinate
  80499. */
  80500. constructor(
  80501. /** defines the first coordinate */
  80502. x?: number,
  80503. /** defines the second coordinate */
  80504. y?: number);
  80505. /**
  80506. * Gets a string with the Vector2 coordinates
  80507. * @returns a string with the Vector2 coordinates
  80508. */
  80509. toString(): string;
  80510. /**
  80511. * Gets class name
  80512. * @returns the string "Vector2"
  80513. */
  80514. getClassName(): string;
  80515. /**
  80516. * Gets current vector hash code
  80517. * @returns the Vector2 hash code as a number
  80518. */
  80519. getHashCode(): number;
  80520. /**
  80521. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80522. * @param array defines the source array
  80523. * @param index defines the offset in source array
  80524. * @returns the current Vector2
  80525. */
  80526. toArray(array: FloatArray, index?: number): Vector2;
  80527. /**
  80528. * Copy the current vector to an array
  80529. * @returns a new array with 2 elements: the Vector2 coordinates.
  80530. */
  80531. asArray(): number[];
  80532. /**
  80533. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80534. * @param source defines the source Vector2
  80535. * @returns the current updated Vector2
  80536. */
  80537. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80538. /**
  80539. * Sets the Vector2 coordinates with the given floats
  80540. * @param x defines the first coordinate
  80541. * @param y defines the second coordinate
  80542. * @returns the current updated Vector2
  80543. */
  80544. copyFromFloats(x: number, y: number): Vector2;
  80545. /**
  80546. * Sets the Vector2 coordinates with the given floats
  80547. * @param x defines the first coordinate
  80548. * @param y defines the second coordinate
  80549. * @returns the current updated Vector2
  80550. */
  80551. set(x: number, y: number): Vector2;
  80552. /**
  80553. * Add another vector with the current one
  80554. * @param otherVector defines the other vector
  80555. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80556. */
  80557. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80558. /**
  80559. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80560. * @param otherVector defines the other vector
  80561. * @param result defines the target vector
  80562. * @returns the unmodified current Vector2
  80563. */
  80564. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80565. /**
  80566. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80567. * @param otherVector defines the other vector
  80568. * @returns the current updated Vector2
  80569. */
  80570. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80571. /**
  80572. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80573. * @param otherVector defines the other vector
  80574. * @returns a new Vector2
  80575. */
  80576. addVector3(otherVector: Vector3): Vector2;
  80577. /**
  80578. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80579. * @param otherVector defines the other vector
  80580. * @returns a new Vector2
  80581. */
  80582. subtract(otherVector: Vector2): Vector2;
  80583. /**
  80584. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80585. * @param otherVector defines the other vector
  80586. * @param result defines the target vector
  80587. * @returns the unmodified current Vector2
  80588. */
  80589. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80590. /**
  80591. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80592. * @param otherVector defines the other vector
  80593. * @returns the current updated Vector2
  80594. */
  80595. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80596. /**
  80597. * Multiplies in place the current Vector2 coordinates by the given ones
  80598. * @param otherVector defines the other vector
  80599. * @returns the current updated Vector2
  80600. */
  80601. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80602. /**
  80603. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80604. * @param otherVector defines the other vector
  80605. * @returns a new Vector2
  80606. */
  80607. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80608. /**
  80609. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80610. * @param otherVector defines the other vector
  80611. * @param result defines the target vector
  80612. * @returns the unmodified current Vector2
  80613. */
  80614. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80615. /**
  80616. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80617. * @param x defines the first coordinate
  80618. * @param y defines the second coordinate
  80619. * @returns a new Vector2
  80620. */
  80621. multiplyByFloats(x: number, y: number): Vector2;
  80622. /**
  80623. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80624. * @param otherVector defines the other vector
  80625. * @returns a new Vector2
  80626. */
  80627. divide(otherVector: Vector2): Vector2;
  80628. /**
  80629. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80630. * @param otherVector defines the other vector
  80631. * @param result defines the target vector
  80632. * @returns the unmodified current Vector2
  80633. */
  80634. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80635. /**
  80636. * Divides the current Vector2 coordinates by the given ones
  80637. * @param otherVector defines the other vector
  80638. * @returns the current updated Vector2
  80639. */
  80640. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80641. /**
  80642. * Gets a new Vector2 with current Vector2 negated coordinates
  80643. * @returns a new Vector2
  80644. */
  80645. negate(): Vector2;
  80646. /**
  80647. * Negate this vector in place
  80648. * @returns this
  80649. */
  80650. negateInPlace(): Vector2;
  80651. /**
  80652. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80653. * @param result defines the Vector3 object where to store the result
  80654. * @returns the current Vector2
  80655. */
  80656. negateToRef(result: Vector2): Vector2;
  80657. /**
  80658. * Multiply the Vector2 coordinates by scale
  80659. * @param scale defines the scaling factor
  80660. * @returns the current updated Vector2
  80661. */
  80662. scaleInPlace(scale: number): Vector2;
  80663. /**
  80664. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80665. * @param scale defines the scaling factor
  80666. * @returns a new Vector2
  80667. */
  80668. scale(scale: number): Vector2;
  80669. /**
  80670. * Scale the current Vector2 values by a factor to a given Vector2
  80671. * @param scale defines the scale factor
  80672. * @param result defines the Vector2 object where to store the result
  80673. * @returns the unmodified current Vector2
  80674. */
  80675. scaleToRef(scale: number, result: Vector2): Vector2;
  80676. /**
  80677. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80678. * @param scale defines the scale factor
  80679. * @param result defines the Vector2 object where to store the result
  80680. * @returns the unmodified current Vector2
  80681. */
  80682. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80683. /**
  80684. * Gets a boolean if two vectors are equals
  80685. * @param otherVector defines the other vector
  80686. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80687. */
  80688. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80689. /**
  80690. * Gets a boolean if two vectors are equals (using an epsilon value)
  80691. * @param otherVector defines the other vector
  80692. * @param epsilon defines the minimal distance to consider equality
  80693. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80694. */
  80695. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80696. /**
  80697. * Gets a new Vector2 from current Vector2 floored values
  80698. * @returns a new Vector2
  80699. */
  80700. floor(): Vector2;
  80701. /**
  80702. * Gets a new Vector2 from current Vector2 floored values
  80703. * @returns a new Vector2
  80704. */
  80705. fract(): Vector2;
  80706. /**
  80707. * Gets the length of the vector
  80708. * @returns the vector length (float)
  80709. */
  80710. length(): number;
  80711. /**
  80712. * Gets the vector squared length
  80713. * @returns the vector squared length (float)
  80714. */
  80715. lengthSquared(): number;
  80716. /**
  80717. * Normalize the vector
  80718. * @returns the current updated Vector2
  80719. */
  80720. normalize(): Vector2;
  80721. /**
  80722. * Gets a new Vector2 copied from the Vector2
  80723. * @returns a new Vector2
  80724. */
  80725. clone(): Vector2;
  80726. /**
  80727. * Gets a new Vector2(0, 0)
  80728. * @returns a new Vector2
  80729. */
  80730. static Zero(): Vector2;
  80731. /**
  80732. * Gets a new Vector2(1, 1)
  80733. * @returns a new Vector2
  80734. */
  80735. static One(): Vector2;
  80736. /**
  80737. * Gets a new Vector2 set from the given index element of the given array
  80738. * @param array defines the data source
  80739. * @param offset defines the offset in the data source
  80740. * @returns a new Vector2
  80741. */
  80742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80743. /**
  80744. * Sets "result" from the given index element of the given array
  80745. * @param array defines the data source
  80746. * @param offset defines the offset in the data source
  80747. * @param result defines the target vector
  80748. */
  80749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80750. /**
  80751. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80752. * @param value1 defines 1st point of control
  80753. * @param value2 defines 2nd point of control
  80754. * @param value3 defines 3rd point of control
  80755. * @param value4 defines 4th point of control
  80756. * @param amount defines the interpolation factor
  80757. * @returns a new Vector2
  80758. */
  80759. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80760. /**
  80761. * 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".
  80762. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80763. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80764. * @param value defines the value to clamp
  80765. * @param min defines the lower limit
  80766. * @param max defines the upper limit
  80767. * @returns a new Vector2
  80768. */
  80769. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80770. /**
  80771. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80772. * @param value1 defines the 1st control point
  80773. * @param tangent1 defines the outgoing tangent
  80774. * @param value2 defines the 2nd control point
  80775. * @param tangent2 defines the incoming tangent
  80776. * @param amount defines the interpolation factor
  80777. * @returns a new Vector2
  80778. */
  80779. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80780. /**
  80781. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80782. * @param start defines the start vector
  80783. * @param end defines the end vector
  80784. * @param amount defines the interpolation factor
  80785. * @returns a new Vector2
  80786. */
  80787. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80788. /**
  80789. * Gets the dot product of the vector "left" and the vector "right"
  80790. * @param left defines first vector
  80791. * @param right defines second vector
  80792. * @returns the dot product (float)
  80793. */
  80794. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80795. /**
  80796. * Returns a new Vector2 equal to the normalized given vector
  80797. * @param vector defines the vector to normalize
  80798. * @returns a new Vector2
  80799. */
  80800. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80801. /**
  80802. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80803. * @param left defines 1st vector
  80804. * @param right defines 2nd vector
  80805. * @returns a new Vector2
  80806. */
  80807. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80808. /**
  80809. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80810. * @param left defines 1st vector
  80811. * @param right defines 2nd vector
  80812. * @returns a new Vector2
  80813. */
  80814. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80815. /**
  80816. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80817. * @param vector defines the vector to transform
  80818. * @param transformation defines the matrix to apply
  80819. * @returns a new Vector2
  80820. */
  80821. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80822. /**
  80823. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80824. * @param vector defines the vector to transform
  80825. * @param transformation defines the matrix to apply
  80826. * @param result defines the target vector
  80827. */
  80828. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80829. /**
  80830. * Determines if a given vector is included in a triangle
  80831. * @param p defines the vector to test
  80832. * @param p0 defines 1st triangle point
  80833. * @param p1 defines 2nd triangle point
  80834. * @param p2 defines 3rd triangle point
  80835. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80836. */
  80837. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80838. /**
  80839. * Gets the distance between the vectors "value1" and "value2"
  80840. * @param value1 defines first vector
  80841. * @param value2 defines second vector
  80842. * @returns the distance between vectors
  80843. */
  80844. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80845. /**
  80846. * Returns the squared distance between the vectors "value1" and "value2"
  80847. * @param value1 defines first vector
  80848. * @param value2 defines second vector
  80849. * @returns the squared distance between vectors
  80850. */
  80851. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80852. /**
  80853. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80854. * @param value1 defines first vector
  80855. * @param value2 defines second vector
  80856. * @returns a new Vector2
  80857. */
  80858. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80859. /**
  80860. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80861. * @param p defines the middle point
  80862. * @param segA defines one point of the segment
  80863. * @param segB defines the other point of the segment
  80864. * @returns the shortest distance
  80865. */
  80866. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80867. }
  80868. /**
  80869. * Class used to store (x,y,z) vector representation
  80870. * A Vector3 is the main object used in 3D geometry
  80871. * It can represent etiher the coordinates of a point the space, either a direction
  80872. * Reminder: js uses a left handed forward facing system
  80873. */
  80874. export class Vector3 {
  80875. private static _UpReadOnly;
  80876. private static _ZeroReadOnly;
  80877. /** @hidden */
  80878. _x: number;
  80879. /** @hidden */
  80880. _y: number;
  80881. /** @hidden */
  80882. _z: number;
  80883. /** @hidden */
  80884. _isDirty: boolean;
  80885. /** Gets or sets the x coordinate */
  80886. get x(): number;
  80887. set x(value: number);
  80888. /** Gets or sets the y coordinate */
  80889. get y(): number;
  80890. set y(value: number);
  80891. /** Gets or sets the z coordinate */
  80892. get z(): number;
  80893. set z(value: number);
  80894. /**
  80895. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80896. * @param x defines the first coordinates (on X axis)
  80897. * @param y defines the second coordinates (on Y axis)
  80898. * @param z defines the third coordinates (on Z axis)
  80899. */
  80900. constructor(x?: number, y?: number, z?: number);
  80901. /**
  80902. * Creates a string representation of the Vector3
  80903. * @returns a string with the Vector3 coordinates.
  80904. */
  80905. toString(): string;
  80906. /**
  80907. * Gets the class name
  80908. * @returns the string "Vector3"
  80909. */
  80910. getClassName(): string;
  80911. /**
  80912. * Creates the Vector3 hash code
  80913. * @returns a number which tends to be unique between Vector3 instances
  80914. */
  80915. getHashCode(): number;
  80916. /**
  80917. * Creates an array containing three elements : the coordinates of the Vector3
  80918. * @returns a new array of numbers
  80919. */
  80920. asArray(): number[];
  80921. /**
  80922. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80923. * @param array defines the destination array
  80924. * @param index defines the offset in the destination array
  80925. * @returns the current Vector3
  80926. */
  80927. toArray(array: FloatArray, index?: number): Vector3;
  80928. /**
  80929. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80930. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80931. */
  80932. toQuaternion(): Quaternion;
  80933. /**
  80934. * Adds the given vector to the current Vector3
  80935. * @param otherVector defines the second operand
  80936. * @returns the current updated Vector3
  80937. */
  80938. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80939. /**
  80940. * Adds the given coordinates to the current Vector3
  80941. * @param x defines the x coordinate of the operand
  80942. * @param y defines the y coordinate of the operand
  80943. * @param z defines the z coordinate of the operand
  80944. * @returns the current updated Vector3
  80945. */
  80946. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80947. /**
  80948. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80949. * @param otherVector defines the second operand
  80950. * @returns the resulting Vector3
  80951. */
  80952. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80953. /**
  80954. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80955. * @param otherVector defines the second operand
  80956. * @param result defines the Vector3 object where to store the result
  80957. * @returns the current Vector3
  80958. */
  80959. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80960. /**
  80961. * Subtract the given vector from the current Vector3
  80962. * @param otherVector defines the second operand
  80963. * @returns the current updated Vector3
  80964. */
  80965. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80966. /**
  80967. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80968. * @param otherVector defines the second operand
  80969. * @returns the resulting Vector3
  80970. */
  80971. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80972. /**
  80973. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80974. * @param otherVector defines the second operand
  80975. * @param result defines the Vector3 object where to store the result
  80976. * @returns the current Vector3
  80977. */
  80978. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80979. /**
  80980. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80981. * @param x defines the x coordinate of the operand
  80982. * @param y defines the y coordinate of the operand
  80983. * @param z defines the z coordinate of the operand
  80984. * @returns the resulting Vector3
  80985. */
  80986. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80987. /**
  80988. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80989. * @param x defines the x coordinate of the operand
  80990. * @param y defines the y coordinate of the operand
  80991. * @param z defines the z coordinate of the operand
  80992. * @param result defines the Vector3 object where to store the result
  80993. * @returns the current Vector3
  80994. */
  80995. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80996. /**
  80997. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80998. * @returns a new Vector3
  80999. */
  81000. negate(): Vector3;
  81001. /**
  81002. * Negate this vector in place
  81003. * @returns this
  81004. */
  81005. negateInPlace(): Vector3;
  81006. /**
  81007. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81008. * @param result defines the Vector3 object where to store the result
  81009. * @returns the current Vector3
  81010. */
  81011. negateToRef(result: Vector3): Vector3;
  81012. /**
  81013. * Multiplies the Vector3 coordinates by the float "scale"
  81014. * @param scale defines the multiplier factor
  81015. * @returns the current updated Vector3
  81016. */
  81017. scaleInPlace(scale: number): Vector3;
  81018. /**
  81019. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81020. * @param scale defines the multiplier factor
  81021. * @returns a new Vector3
  81022. */
  81023. scale(scale: number): Vector3;
  81024. /**
  81025. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81026. * @param scale defines the multiplier factor
  81027. * @param result defines the Vector3 object where to store the result
  81028. * @returns the current Vector3
  81029. */
  81030. scaleToRef(scale: number, result: Vector3): Vector3;
  81031. /**
  81032. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81033. * @param scale defines the scale factor
  81034. * @param result defines the Vector3 object where to store the result
  81035. * @returns the unmodified current Vector3
  81036. */
  81037. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81038. /**
  81039. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81040. * @param origin defines the origin of the projection ray
  81041. * @param plane defines the plane to project to
  81042. * @returns the projected vector3
  81043. */
  81044. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81045. /**
  81046. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81047. * @param origin defines the origin of the projection ray
  81048. * @param plane defines the plane to project to
  81049. * @param result defines the Vector3 where to store the result
  81050. */
  81051. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81052. /**
  81053. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81054. * @param otherVector defines the second operand
  81055. * @returns true if both vectors are equals
  81056. */
  81057. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81058. /**
  81059. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81060. * @param otherVector defines the second operand
  81061. * @param epsilon defines the minimal distance to define values as equals
  81062. * @returns true if both vectors are distant less than epsilon
  81063. */
  81064. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81065. /**
  81066. * Returns true if the current Vector3 coordinates equals the given floats
  81067. * @param x defines the x coordinate of the operand
  81068. * @param y defines the y coordinate of the operand
  81069. * @param z defines the z coordinate of the operand
  81070. * @returns true if both vectors are equals
  81071. */
  81072. equalsToFloats(x: number, y: number, z: number): boolean;
  81073. /**
  81074. * Multiplies the current Vector3 coordinates by the given ones
  81075. * @param otherVector defines the second operand
  81076. * @returns the current updated Vector3
  81077. */
  81078. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81079. /**
  81080. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81081. * @param otherVector defines the second operand
  81082. * @returns the new Vector3
  81083. */
  81084. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81085. /**
  81086. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81087. * @param otherVector defines the second operand
  81088. * @param result defines the Vector3 object where to store the result
  81089. * @returns the current Vector3
  81090. */
  81091. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81092. /**
  81093. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81094. * @param x defines the x coordinate of the operand
  81095. * @param y defines the y coordinate of the operand
  81096. * @param z defines the z coordinate of the operand
  81097. * @returns the new Vector3
  81098. */
  81099. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81100. /**
  81101. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81102. * @param otherVector defines the second operand
  81103. * @returns the new Vector3
  81104. */
  81105. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81106. /**
  81107. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81108. * @param otherVector defines the second operand
  81109. * @param result defines the Vector3 object where to store the result
  81110. * @returns the current Vector3
  81111. */
  81112. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81113. /**
  81114. * Divides the current Vector3 coordinates by the given ones.
  81115. * @param otherVector defines the second operand
  81116. * @returns the current updated Vector3
  81117. */
  81118. divideInPlace(otherVector: Vector3): Vector3;
  81119. /**
  81120. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81121. * @param other defines the second operand
  81122. * @returns the current updated Vector3
  81123. */
  81124. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81125. /**
  81126. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81127. * @param other defines the second operand
  81128. * @returns the current updated Vector3
  81129. */
  81130. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81131. /**
  81132. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81133. * @param x defines the x coordinate of the operand
  81134. * @param y defines the y coordinate of the operand
  81135. * @param z defines the z coordinate of the operand
  81136. * @returns the current updated Vector3
  81137. */
  81138. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81139. /**
  81140. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81141. * @param x defines the x coordinate of the operand
  81142. * @param y defines the y coordinate of the operand
  81143. * @param z defines the z coordinate of the operand
  81144. * @returns the current updated Vector3
  81145. */
  81146. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81147. /**
  81148. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81149. * Check if is non uniform within a certain amount of decimal places to account for this
  81150. * @param epsilon the amount the values can differ
  81151. * @returns if the the vector is non uniform to a certain number of decimal places
  81152. */
  81153. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81154. /**
  81155. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81156. */
  81157. get isNonUniform(): boolean;
  81158. /**
  81159. * Gets a new Vector3 from current Vector3 floored values
  81160. * @returns a new Vector3
  81161. */
  81162. floor(): Vector3;
  81163. /**
  81164. * Gets a new Vector3 from current Vector3 floored values
  81165. * @returns a new Vector3
  81166. */
  81167. fract(): Vector3;
  81168. /**
  81169. * Gets the length of the Vector3
  81170. * @returns the length of the Vector3
  81171. */
  81172. length(): number;
  81173. /**
  81174. * Gets the squared length of the Vector3
  81175. * @returns squared length of the Vector3
  81176. */
  81177. lengthSquared(): number;
  81178. /**
  81179. * Normalize the current Vector3.
  81180. * Please note that this is an in place operation.
  81181. * @returns the current updated Vector3
  81182. */
  81183. normalize(): Vector3;
  81184. /**
  81185. * Reorders the x y z properties of the vector in place
  81186. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81187. * @returns the current updated vector
  81188. */
  81189. reorderInPlace(order: string): this;
  81190. /**
  81191. * Rotates the vector around 0,0,0 by a quaternion
  81192. * @param quaternion the rotation quaternion
  81193. * @param result vector to store the result
  81194. * @returns the resulting vector
  81195. */
  81196. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81197. /**
  81198. * Rotates a vector around a given point
  81199. * @param quaternion the rotation quaternion
  81200. * @param point the point to rotate around
  81201. * @param result vector to store the result
  81202. * @returns the resulting vector
  81203. */
  81204. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81205. /**
  81206. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81207. * The cross product is then orthogonal to both current and "other"
  81208. * @param other defines the right operand
  81209. * @returns the cross product
  81210. */
  81211. cross(other: Vector3): Vector3;
  81212. /**
  81213. * Normalize the current Vector3 with the given input length.
  81214. * Please note that this is an in place operation.
  81215. * @param len the length of the vector
  81216. * @returns the current updated Vector3
  81217. */
  81218. normalizeFromLength(len: number): Vector3;
  81219. /**
  81220. * Normalize the current Vector3 to a new vector
  81221. * @returns the new Vector3
  81222. */
  81223. normalizeToNew(): Vector3;
  81224. /**
  81225. * Normalize the current Vector3 to the reference
  81226. * @param reference define the Vector3 to update
  81227. * @returns the updated Vector3
  81228. */
  81229. normalizeToRef(reference: Vector3): Vector3;
  81230. /**
  81231. * Creates a new Vector3 copied from the current Vector3
  81232. * @returns the new Vector3
  81233. */
  81234. clone(): Vector3;
  81235. /**
  81236. * Copies the given vector coordinates to the current Vector3 ones
  81237. * @param source defines the source Vector3
  81238. * @returns the current updated Vector3
  81239. */
  81240. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81241. /**
  81242. * Copies the given floats to the current Vector3 coordinates
  81243. * @param x defines the x coordinate of the operand
  81244. * @param y defines the y coordinate of the operand
  81245. * @param z defines the z coordinate of the operand
  81246. * @returns the current updated Vector3
  81247. */
  81248. copyFromFloats(x: number, y: number, z: number): Vector3;
  81249. /**
  81250. * Copies the given floats to the current Vector3 coordinates
  81251. * @param x defines the x coordinate of the operand
  81252. * @param y defines the y coordinate of the operand
  81253. * @param z defines the z coordinate of the operand
  81254. * @returns the current updated Vector3
  81255. */
  81256. set(x: number, y: number, z: number): Vector3;
  81257. /**
  81258. * Copies the given float to the current Vector3 coordinates
  81259. * @param v defines the x, y and z coordinates of the operand
  81260. * @returns the current updated Vector3
  81261. */
  81262. setAll(v: number): Vector3;
  81263. /**
  81264. * Get the clip factor between two vectors
  81265. * @param vector0 defines the first operand
  81266. * @param vector1 defines the second operand
  81267. * @param axis defines the axis to use
  81268. * @param size defines the size along the axis
  81269. * @returns the clip factor
  81270. */
  81271. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81272. /**
  81273. * Get angle between two vectors
  81274. * @param vector0 angle between vector0 and vector1
  81275. * @param vector1 angle between vector0 and vector1
  81276. * @param normal direction of the normal
  81277. * @return the angle between vector0 and vector1
  81278. */
  81279. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81280. /**
  81281. * Returns a new Vector3 set from the index "offset" of the given array
  81282. * @param array defines the source array
  81283. * @param offset defines the offset in the source array
  81284. * @returns the new Vector3
  81285. */
  81286. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81287. /**
  81288. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81289. * @param array defines the source array
  81290. * @param offset defines the offset in the source array
  81291. * @returns the new Vector3
  81292. * @deprecated Please use FromArray instead.
  81293. */
  81294. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81295. /**
  81296. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81297. * @param array defines the source array
  81298. * @param offset defines the offset in the source array
  81299. * @param result defines the Vector3 where to store the result
  81300. */
  81301. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81302. /**
  81303. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81304. * @param array defines the source array
  81305. * @param offset defines the offset in the source array
  81306. * @param result defines the Vector3 where to store the result
  81307. * @deprecated Please use FromArrayToRef instead.
  81308. */
  81309. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81310. /**
  81311. * Sets the given vector "result" with the given floats.
  81312. * @param x defines the x coordinate of the source
  81313. * @param y defines the y coordinate of the source
  81314. * @param z defines the z coordinate of the source
  81315. * @param result defines the Vector3 where to store the result
  81316. */
  81317. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81318. /**
  81319. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81320. * @returns a new empty Vector3
  81321. */
  81322. static Zero(): Vector3;
  81323. /**
  81324. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81325. * @returns a new unit Vector3
  81326. */
  81327. static One(): Vector3;
  81328. /**
  81329. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81330. * @returns a new up Vector3
  81331. */
  81332. static Up(): Vector3;
  81333. /**
  81334. * Gets a up Vector3 that must not be updated
  81335. */
  81336. static get UpReadOnly(): DeepImmutable<Vector3>;
  81337. /**
  81338. * Gets a zero Vector3 that must not be updated
  81339. */
  81340. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81341. /**
  81342. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81343. * @returns a new down Vector3
  81344. */
  81345. static Down(): Vector3;
  81346. /**
  81347. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81348. * @param rightHandedSystem is the scene right-handed (negative z)
  81349. * @returns a new forward Vector3
  81350. */
  81351. static Forward(rightHandedSystem?: boolean): Vector3;
  81352. /**
  81353. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81354. * @param rightHandedSystem is the scene right-handed (negative-z)
  81355. * @returns a new forward Vector3
  81356. */
  81357. static Backward(rightHandedSystem?: boolean): Vector3;
  81358. /**
  81359. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81360. * @returns a new right Vector3
  81361. */
  81362. static Right(): Vector3;
  81363. /**
  81364. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81365. * @returns a new left Vector3
  81366. */
  81367. static Left(): Vector3;
  81368. /**
  81369. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81370. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81371. * @param vector defines the Vector3 to transform
  81372. * @param transformation defines the transformation matrix
  81373. * @returns the transformed Vector3
  81374. */
  81375. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81376. /**
  81377. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81378. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81379. * @param vector defines the Vector3 to transform
  81380. * @param transformation defines the transformation matrix
  81381. * @param result defines the Vector3 where to store the result
  81382. */
  81383. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81384. /**
  81385. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81386. * This method computes tranformed coordinates only, not transformed direction vectors
  81387. * @param x define the x coordinate of the source vector
  81388. * @param y define the y coordinate of the source vector
  81389. * @param z define the z coordinate of the source vector
  81390. * @param transformation defines the transformation matrix
  81391. * @param result defines the Vector3 where to store the result
  81392. */
  81393. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81394. /**
  81395. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81396. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81397. * @param vector defines the Vector3 to transform
  81398. * @param transformation defines the transformation matrix
  81399. * @returns the new Vector3
  81400. */
  81401. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81402. /**
  81403. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81404. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81405. * @param vector defines the Vector3 to transform
  81406. * @param transformation defines the transformation matrix
  81407. * @param result defines the Vector3 where to store the result
  81408. */
  81409. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81410. /**
  81411. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81412. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81413. * @param x define the x coordinate of the source vector
  81414. * @param y define the y coordinate of the source vector
  81415. * @param z define the z coordinate of the source vector
  81416. * @param transformation defines the transformation matrix
  81417. * @param result defines the Vector3 where to store the result
  81418. */
  81419. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81420. /**
  81421. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81422. * @param value1 defines the first control point
  81423. * @param value2 defines the second control point
  81424. * @param value3 defines the third control point
  81425. * @param value4 defines the fourth control point
  81426. * @param amount defines the amount on the spline to use
  81427. * @returns the new Vector3
  81428. */
  81429. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81430. /**
  81431. * 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"
  81432. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81433. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81434. * @param value defines the current value
  81435. * @param min defines the lower range value
  81436. * @param max defines the upper range value
  81437. * @returns the new Vector3
  81438. */
  81439. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81440. /**
  81441. * 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"
  81442. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81443. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81444. * @param value defines the current value
  81445. * @param min defines the lower range value
  81446. * @param max defines the upper range value
  81447. * @param result defines the Vector3 where to store the result
  81448. */
  81449. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81450. /**
  81451. * Checks if a given vector is inside a specific range
  81452. * @param v defines the vector to test
  81453. * @param min defines the minimum range
  81454. * @param max defines the maximum range
  81455. */
  81456. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81457. /**
  81458. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81459. * @param value1 defines the first control point
  81460. * @param tangent1 defines the first tangent vector
  81461. * @param value2 defines the second control point
  81462. * @param tangent2 defines the second tangent vector
  81463. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81464. * @returns the new Vector3
  81465. */
  81466. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81467. /**
  81468. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81469. * @param start defines the start value
  81470. * @param end defines the end value
  81471. * @param amount max defines amount between both (between 0 and 1)
  81472. * @returns the new Vector3
  81473. */
  81474. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81475. /**
  81476. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81477. * @param start defines the start value
  81478. * @param end defines the end value
  81479. * @param amount max defines amount between both (between 0 and 1)
  81480. * @param result defines the Vector3 where to store the result
  81481. */
  81482. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81483. /**
  81484. * Returns the dot product (float) between the vectors "left" and "right"
  81485. * @param left defines the left operand
  81486. * @param right defines the right operand
  81487. * @returns the dot product
  81488. */
  81489. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81490. /**
  81491. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81492. * The cross product is then orthogonal to both "left" and "right"
  81493. * @param left defines the left operand
  81494. * @param right defines the right operand
  81495. * @returns the cross product
  81496. */
  81497. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81498. /**
  81499. * Sets the given vector "result" with the cross product of "left" and "right"
  81500. * The cross product is then orthogonal to both "left" and "right"
  81501. * @param left defines the left operand
  81502. * @param right defines the right operand
  81503. * @param result defines the Vector3 where to store the result
  81504. */
  81505. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81506. /**
  81507. * Returns a new Vector3 as the normalization of the given vector
  81508. * @param vector defines the Vector3 to normalize
  81509. * @returns the new Vector3
  81510. */
  81511. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81512. /**
  81513. * Sets the given vector "result" with the normalization of the given first vector
  81514. * @param vector defines the Vector3 to normalize
  81515. * @param result defines the Vector3 where to store the result
  81516. */
  81517. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81518. /**
  81519. * Project a Vector3 onto screen space
  81520. * @param vector defines the Vector3 to project
  81521. * @param world defines the world matrix to use
  81522. * @param transform defines the transform (view x projection) matrix to use
  81523. * @param viewport defines the screen viewport to use
  81524. * @returns the new Vector3
  81525. */
  81526. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81527. /** @hidden */
  81528. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81529. /**
  81530. * Unproject from screen space to object space
  81531. * @param source defines the screen space Vector3 to use
  81532. * @param viewportWidth defines the current width of the viewport
  81533. * @param viewportHeight defines the current height of the viewport
  81534. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81535. * @param transform defines the transform (view x projection) matrix to use
  81536. * @returns the new Vector3
  81537. */
  81538. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81539. /**
  81540. * Unproject from screen space to object space
  81541. * @param source defines the screen space Vector3 to use
  81542. * @param viewportWidth defines the current width of the viewport
  81543. * @param viewportHeight defines the current height of the viewport
  81544. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81545. * @param view defines the view matrix to use
  81546. * @param projection defines the projection matrix to use
  81547. * @returns the new Vector3
  81548. */
  81549. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81550. /**
  81551. * Unproject from screen space to object space
  81552. * @param source defines the screen space Vector3 to use
  81553. * @param viewportWidth defines the current width of the viewport
  81554. * @param viewportHeight defines the current height of the viewport
  81555. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81556. * @param view defines the view matrix to use
  81557. * @param projection defines the projection matrix to use
  81558. * @param result defines the Vector3 where to store the result
  81559. */
  81560. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81561. /**
  81562. * Unproject from screen space to object space
  81563. * @param sourceX defines the screen space x coordinate to use
  81564. * @param sourceY defines the screen space y coordinate to use
  81565. * @param sourceZ defines the screen space z coordinate to use
  81566. * @param viewportWidth defines the current width of the viewport
  81567. * @param viewportHeight defines the current height of the viewport
  81568. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81569. * @param view defines the view matrix to use
  81570. * @param projection defines the projection matrix to use
  81571. * @param result defines the Vector3 where to store the result
  81572. */
  81573. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81574. /**
  81575. * Gets the minimal coordinate values between two Vector3
  81576. * @param left defines the first operand
  81577. * @param right defines the second operand
  81578. * @returns the new Vector3
  81579. */
  81580. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81581. /**
  81582. * Gets the maximal coordinate values between two Vector3
  81583. * @param left defines the first operand
  81584. * @param right defines the second operand
  81585. * @returns the new Vector3
  81586. */
  81587. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81588. /**
  81589. * Returns the distance between the vectors "value1" and "value2"
  81590. * @param value1 defines the first operand
  81591. * @param value2 defines the second operand
  81592. * @returns the distance
  81593. */
  81594. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81595. /**
  81596. * Returns the squared distance between the vectors "value1" and "value2"
  81597. * @param value1 defines the first operand
  81598. * @param value2 defines the second operand
  81599. * @returns the squared distance
  81600. */
  81601. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81602. /**
  81603. * Returns a new Vector3 located at the center between "value1" and "value2"
  81604. * @param value1 defines the first operand
  81605. * @param value2 defines the second operand
  81606. * @returns the new Vector3
  81607. */
  81608. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81609. /**
  81610. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81611. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81612. * to something in order to rotate it from its local system to the given target system
  81613. * Note: axis1, axis2 and axis3 are normalized during this operation
  81614. * @param axis1 defines the first axis
  81615. * @param axis2 defines the second axis
  81616. * @param axis3 defines the third axis
  81617. * @returns a new Vector3
  81618. */
  81619. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81620. /**
  81621. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81622. * @param axis1 defines the first axis
  81623. * @param axis2 defines the second axis
  81624. * @param axis3 defines the third axis
  81625. * @param ref defines the Vector3 where to store the result
  81626. */
  81627. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81628. }
  81629. /**
  81630. * Vector4 class created for EulerAngle class conversion to Quaternion
  81631. */
  81632. export class Vector4 {
  81633. /** x value of the vector */
  81634. x: number;
  81635. /** y value of the vector */
  81636. y: number;
  81637. /** z value of the vector */
  81638. z: number;
  81639. /** w value of the vector */
  81640. w: number;
  81641. /**
  81642. * Creates a Vector4 object from the given floats.
  81643. * @param x x value of the vector
  81644. * @param y y value of the vector
  81645. * @param z z value of the vector
  81646. * @param w w value of the vector
  81647. */
  81648. constructor(
  81649. /** x value of the vector */
  81650. x: number,
  81651. /** y value of the vector */
  81652. y: number,
  81653. /** z value of the vector */
  81654. z: number,
  81655. /** w value of the vector */
  81656. w: number);
  81657. /**
  81658. * Returns the string with the Vector4 coordinates.
  81659. * @returns a string containing all the vector values
  81660. */
  81661. toString(): string;
  81662. /**
  81663. * Returns the string "Vector4".
  81664. * @returns "Vector4"
  81665. */
  81666. getClassName(): string;
  81667. /**
  81668. * Returns the Vector4 hash code.
  81669. * @returns a unique hash code
  81670. */
  81671. getHashCode(): number;
  81672. /**
  81673. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81674. * @returns the resulting array
  81675. */
  81676. asArray(): number[];
  81677. /**
  81678. * Populates the given array from the given index with the Vector4 coordinates.
  81679. * @param array array to populate
  81680. * @param index index of the array to start at (default: 0)
  81681. * @returns the Vector4.
  81682. */
  81683. toArray(array: FloatArray, index?: number): Vector4;
  81684. /**
  81685. * Adds the given vector to the current Vector4.
  81686. * @param otherVector the vector to add
  81687. * @returns the updated Vector4.
  81688. */
  81689. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81690. /**
  81691. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81692. * @param otherVector the vector to add
  81693. * @returns the resulting vector
  81694. */
  81695. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81696. /**
  81697. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81698. * @param otherVector the vector to add
  81699. * @param result the vector to store the result
  81700. * @returns the current Vector4.
  81701. */
  81702. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81703. /**
  81704. * Subtract in place the given vector from the current Vector4.
  81705. * @param otherVector the vector to subtract
  81706. * @returns the updated Vector4.
  81707. */
  81708. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81709. /**
  81710. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81711. * @param otherVector the vector to add
  81712. * @returns the new vector with the result
  81713. */
  81714. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81715. /**
  81716. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81717. * @param otherVector the vector to subtract
  81718. * @param result the vector to store the result
  81719. * @returns the current Vector4.
  81720. */
  81721. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81722. /**
  81723. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81724. */
  81725. /**
  81726. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81727. * @param x value to subtract
  81728. * @param y value to subtract
  81729. * @param z value to subtract
  81730. * @param w value to subtract
  81731. * @returns new vector containing the result
  81732. */
  81733. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81734. /**
  81735. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81736. * @param x value to subtract
  81737. * @param y value to subtract
  81738. * @param z value to subtract
  81739. * @param w value to subtract
  81740. * @param result the vector to store the result in
  81741. * @returns the current Vector4.
  81742. */
  81743. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81744. /**
  81745. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81746. * @returns a new vector with the negated values
  81747. */
  81748. negate(): Vector4;
  81749. /**
  81750. * Negate this vector in place
  81751. * @returns this
  81752. */
  81753. negateInPlace(): Vector4;
  81754. /**
  81755. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81756. * @param result defines the Vector3 object where to store the result
  81757. * @returns the current Vector4
  81758. */
  81759. negateToRef(result: Vector4): Vector4;
  81760. /**
  81761. * Multiplies the current Vector4 coordinates by scale (float).
  81762. * @param scale the number to scale with
  81763. * @returns the updated Vector4.
  81764. */
  81765. scaleInPlace(scale: number): Vector4;
  81766. /**
  81767. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81768. * @param scale the number to scale with
  81769. * @returns a new vector with the result
  81770. */
  81771. scale(scale: number): Vector4;
  81772. /**
  81773. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81774. * @param scale the number to scale with
  81775. * @param result a vector to store the result in
  81776. * @returns the current Vector4.
  81777. */
  81778. scaleToRef(scale: number, result: Vector4): Vector4;
  81779. /**
  81780. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81781. * @param scale defines the scale factor
  81782. * @param result defines the Vector4 object where to store the result
  81783. * @returns the unmodified current Vector4
  81784. */
  81785. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81786. /**
  81787. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81788. * @param otherVector the vector to compare against
  81789. * @returns true if they are equal
  81790. */
  81791. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81792. /**
  81793. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81794. * @param otherVector vector to compare against
  81795. * @param epsilon (Default: very small number)
  81796. * @returns true if they are equal
  81797. */
  81798. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81799. /**
  81800. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81801. * @param x x value to compare against
  81802. * @param y y value to compare against
  81803. * @param z z value to compare against
  81804. * @param w w value to compare against
  81805. * @returns true if equal
  81806. */
  81807. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81808. /**
  81809. * Multiplies in place the current Vector4 by the given one.
  81810. * @param otherVector vector to multiple with
  81811. * @returns the updated Vector4.
  81812. */
  81813. multiplyInPlace(otherVector: Vector4): Vector4;
  81814. /**
  81815. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81816. * @param otherVector vector to multiple with
  81817. * @returns resulting new vector
  81818. */
  81819. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81820. /**
  81821. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81822. * @param otherVector vector to multiple with
  81823. * @param result vector to store the result
  81824. * @returns the current Vector4.
  81825. */
  81826. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81827. /**
  81828. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81829. * @param x x value multiply with
  81830. * @param y y value multiply with
  81831. * @param z z value multiply with
  81832. * @param w w value multiply with
  81833. * @returns resulting new vector
  81834. */
  81835. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81836. /**
  81837. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81838. * @param otherVector vector to devide with
  81839. * @returns resulting new vector
  81840. */
  81841. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81842. /**
  81843. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81844. * @param otherVector vector to devide with
  81845. * @param result vector to store the result
  81846. * @returns the current Vector4.
  81847. */
  81848. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81849. /**
  81850. * Divides the current Vector3 coordinates by the given ones.
  81851. * @param otherVector vector to devide with
  81852. * @returns the updated Vector3.
  81853. */
  81854. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81855. /**
  81856. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81857. * @param other defines the second operand
  81858. * @returns the current updated Vector4
  81859. */
  81860. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81861. /**
  81862. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81863. * @param other defines the second operand
  81864. * @returns the current updated Vector4
  81865. */
  81866. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81867. /**
  81868. * Gets a new Vector4 from current Vector4 floored values
  81869. * @returns a new Vector4
  81870. */
  81871. floor(): Vector4;
  81872. /**
  81873. * Gets a new Vector4 from current Vector3 floored values
  81874. * @returns a new Vector4
  81875. */
  81876. fract(): Vector4;
  81877. /**
  81878. * Returns the Vector4 length (float).
  81879. * @returns the length
  81880. */
  81881. length(): number;
  81882. /**
  81883. * Returns the Vector4 squared length (float).
  81884. * @returns the length squared
  81885. */
  81886. lengthSquared(): number;
  81887. /**
  81888. * Normalizes in place the Vector4.
  81889. * @returns the updated Vector4.
  81890. */
  81891. normalize(): Vector4;
  81892. /**
  81893. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81894. * @returns this converted to a new vector3
  81895. */
  81896. toVector3(): Vector3;
  81897. /**
  81898. * Returns a new Vector4 copied from the current one.
  81899. * @returns the new cloned vector
  81900. */
  81901. clone(): Vector4;
  81902. /**
  81903. * Updates the current Vector4 with the given one coordinates.
  81904. * @param source the source vector to copy from
  81905. * @returns the updated Vector4.
  81906. */
  81907. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81908. /**
  81909. * Updates the current Vector4 coordinates with the given floats.
  81910. * @param x float to copy from
  81911. * @param y float to copy from
  81912. * @param z float to copy from
  81913. * @param w float to copy from
  81914. * @returns the updated Vector4.
  81915. */
  81916. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81917. /**
  81918. * Updates the current Vector4 coordinates with the given floats.
  81919. * @param x float to set from
  81920. * @param y float to set from
  81921. * @param z float to set from
  81922. * @param w float to set from
  81923. * @returns the updated Vector4.
  81924. */
  81925. set(x: number, y: number, z: number, w: number): Vector4;
  81926. /**
  81927. * Copies the given float to the current Vector3 coordinates
  81928. * @param v defines the x, y, z and w coordinates of the operand
  81929. * @returns the current updated Vector3
  81930. */
  81931. setAll(v: number): Vector4;
  81932. /**
  81933. * Returns a new Vector4 set from the starting index of the given array.
  81934. * @param array the array to pull values from
  81935. * @param offset the offset into the array to start at
  81936. * @returns the new vector
  81937. */
  81938. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81939. /**
  81940. * Updates the given vector "result" from the starting index of the given array.
  81941. * @param array the array to pull values from
  81942. * @param offset the offset into the array to start at
  81943. * @param result the vector to store the result in
  81944. */
  81945. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81946. /**
  81947. * Updates the given vector "result" from the starting index of the given Float32Array.
  81948. * @param array the array to pull values from
  81949. * @param offset the offset into the array to start at
  81950. * @param result the vector to store the result in
  81951. */
  81952. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81953. /**
  81954. * Updates the given vector "result" coordinates from the given floats.
  81955. * @param x float to set from
  81956. * @param y float to set from
  81957. * @param z float to set from
  81958. * @param w float to set from
  81959. * @param result the vector to the floats in
  81960. */
  81961. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81962. /**
  81963. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81964. * @returns the new vector
  81965. */
  81966. static Zero(): Vector4;
  81967. /**
  81968. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81969. * @returns the new vector
  81970. */
  81971. static One(): Vector4;
  81972. /**
  81973. * Returns a new normalized Vector4 from the given one.
  81974. * @param vector the vector to normalize
  81975. * @returns the vector
  81976. */
  81977. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81978. /**
  81979. * Updates the given vector "result" from the normalization of the given one.
  81980. * @param vector the vector to normalize
  81981. * @param result the vector to store the result in
  81982. */
  81983. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81984. /**
  81985. * Returns a vector with the minimum values from the left and right vectors
  81986. * @param left left vector to minimize
  81987. * @param right right vector to minimize
  81988. * @returns a new vector with the minimum of the left and right vector values
  81989. */
  81990. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81991. /**
  81992. * Returns a vector with the maximum values from the left and right vectors
  81993. * @param left left vector to maximize
  81994. * @param right right vector to maximize
  81995. * @returns a new vector with the maximum of the left and right vector values
  81996. */
  81997. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81998. /**
  81999. * Returns the distance (float) between the vectors "value1" and "value2".
  82000. * @param value1 value to calulate the distance between
  82001. * @param value2 value to calulate the distance between
  82002. * @return the distance between the two vectors
  82003. */
  82004. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82005. /**
  82006. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82007. * @param value1 value to calulate the distance between
  82008. * @param value2 value to calulate the distance between
  82009. * @return the distance between the two vectors squared
  82010. */
  82011. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82012. /**
  82013. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82014. * @param value1 value to calulate the center between
  82015. * @param value2 value to calulate the center between
  82016. * @return the center between the two vectors
  82017. */
  82018. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82019. /**
  82020. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82021. * This methods computes transformed normalized direction vectors only.
  82022. * @param vector the vector to transform
  82023. * @param transformation the transformation matrix to apply
  82024. * @returns the new vector
  82025. */
  82026. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82027. /**
  82028. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82029. * This methods computes transformed normalized direction vectors only.
  82030. * @param vector the vector to transform
  82031. * @param transformation the transformation matrix to apply
  82032. * @param result the vector to store the result in
  82033. */
  82034. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82035. /**
  82036. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82037. * This methods computes transformed normalized direction vectors only.
  82038. * @param x value to transform
  82039. * @param y value to transform
  82040. * @param z value to transform
  82041. * @param w value to transform
  82042. * @param transformation the transformation matrix to apply
  82043. * @param result the vector to store the results in
  82044. */
  82045. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82046. /**
  82047. * Creates a new Vector4 from a Vector3
  82048. * @param source defines the source data
  82049. * @param w defines the 4th component (default is 0)
  82050. * @returns a new Vector4
  82051. */
  82052. static FromVector3(source: Vector3, w?: number): Vector4;
  82053. }
  82054. /**
  82055. * Class used to store quaternion data
  82056. * @see https://en.wikipedia.org/wiki/Quaternion
  82057. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82058. */
  82059. export class Quaternion {
  82060. /** @hidden */
  82061. _x: number;
  82062. /** @hidden */
  82063. _y: number;
  82064. /** @hidden */
  82065. _z: number;
  82066. /** @hidden */
  82067. _w: number;
  82068. /** @hidden */
  82069. _isDirty: boolean;
  82070. /** Gets or sets the x coordinate */
  82071. get x(): number;
  82072. set x(value: number);
  82073. /** Gets or sets the y coordinate */
  82074. get y(): number;
  82075. set y(value: number);
  82076. /** Gets or sets the z coordinate */
  82077. get z(): number;
  82078. set z(value: number);
  82079. /** Gets or sets the w coordinate */
  82080. get w(): number;
  82081. set w(value: number);
  82082. /**
  82083. * Creates a new Quaternion from the given floats
  82084. * @param x defines the first component (0 by default)
  82085. * @param y defines the second component (0 by default)
  82086. * @param z defines the third component (0 by default)
  82087. * @param w defines the fourth component (1.0 by default)
  82088. */
  82089. constructor(x?: number, y?: number, z?: number, w?: number);
  82090. /**
  82091. * Gets a string representation for the current quaternion
  82092. * @returns a string with the Quaternion coordinates
  82093. */
  82094. toString(): string;
  82095. /**
  82096. * Gets the class name of the quaternion
  82097. * @returns the string "Quaternion"
  82098. */
  82099. getClassName(): string;
  82100. /**
  82101. * Gets a hash code for this quaternion
  82102. * @returns the quaternion hash code
  82103. */
  82104. getHashCode(): number;
  82105. /**
  82106. * Copy the quaternion to an array
  82107. * @returns a new array populated with 4 elements from the quaternion coordinates
  82108. */
  82109. asArray(): number[];
  82110. /**
  82111. * Check if two quaternions are equals
  82112. * @param otherQuaternion defines the second operand
  82113. * @return true if the current quaternion and the given one coordinates are strictly equals
  82114. */
  82115. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82116. /**
  82117. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82118. * @param otherQuaternion defines the other quaternion
  82119. * @param epsilon defines the minimal distance to consider equality
  82120. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82121. */
  82122. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82123. /**
  82124. * Clone the current quaternion
  82125. * @returns a new quaternion copied from the current one
  82126. */
  82127. clone(): Quaternion;
  82128. /**
  82129. * Copy a quaternion to the current one
  82130. * @param other defines the other quaternion
  82131. * @returns the updated current quaternion
  82132. */
  82133. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82134. /**
  82135. * Updates the current quaternion with the given float coordinates
  82136. * @param x defines the x coordinate
  82137. * @param y defines the y coordinate
  82138. * @param z defines the z coordinate
  82139. * @param w defines the w coordinate
  82140. * @returns the updated current quaternion
  82141. */
  82142. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82143. /**
  82144. * Updates the current quaternion from the given float coordinates
  82145. * @param x defines the x coordinate
  82146. * @param y defines the y coordinate
  82147. * @param z defines the z coordinate
  82148. * @param w defines the w coordinate
  82149. * @returns the updated current quaternion
  82150. */
  82151. set(x: number, y: number, z: number, w: number): Quaternion;
  82152. /**
  82153. * Adds two quaternions
  82154. * @param other defines the second operand
  82155. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82156. */
  82157. add(other: DeepImmutable<Quaternion>): Quaternion;
  82158. /**
  82159. * Add a quaternion to the current one
  82160. * @param other defines the quaternion to add
  82161. * @returns the current quaternion
  82162. */
  82163. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82164. /**
  82165. * Subtract two quaternions
  82166. * @param other defines the second operand
  82167. * @returns a new quaternion as the subtraction result of the given one from the current one
  82168. */
  82169. subtract(other: Quaternion): Quaternion;
  82170. /**
  82171. * Multiplies the current quaternion by a scale factor
  82172. * @param value defines the scale factor
  82173. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82174. */
  82175. scale(value: number): Quaternion;
  82176. /**
  82177. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82178. * @param scale defines the scale factor
  82179. * @param result defines the Quaternion object where to store the result
  82180. * @returns the unmodified current quaternion
  82181. */
  82182. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82183. /**
  82184. * Multiplies in place the current quaternion by a scale factor
  82185. * @param value defines the scale factor
  82186. * @returns the current modified quaternion
  82187. */
  82188. scaleInPlace(value: number): Quaternion;
  82189. /**
  82190. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82191. * @param scale defines the scale factor
  82192. * @param result defines the Quaternion object where to store the result
  82193. * @returns the unmodified current quaternion
  82194. */
  82195. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82196. /**
  82197. * Multiplies two quaternions
  82198. * @param q1 defines the second operand
  82199. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82200. */
  82201. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82202. /**
  82203. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82204. * @param q1 defines the second operand
  82205. * @param result defines the target quaternion
  82206. * @returns the current quaternion
  82207. */
  82208. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82209. /**
  82210. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82211. * @param q1 defines the second operand
  82212. * @returns the currentupdated quaternion
  82213. */
  82214. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82215. /**
  82216. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82217. * @param ref defines the target quaternion
  82218. * @returns the current quaternion
  82219. */
  82220. conjugateToRef(ref: Quaternion): Quaternion;
  82221. /**
  82222. * Conjugates in place (1-q) the current quaternion
  82223. * @returns the current updated quaternion
  82224. */
  82225. conjugateInPlace(): Quaternion;
  82226. /**
  82227. * Conjugates in place (1-q) the current quaternion
  82228. * @returns a new quaternion
  82229. */
  82230. conjugate(): Quaternion;
  82231. /**
  82232. * Gets length of current quaternion
  82233. * @returns the quaternion length (float)
  82234. */
  82235. length(): number;
  82236. /**
  82237. * Normalize in place the current quaternion
  82238. * @returns the current updated quaternion
  82239. */
  82240. normalize(): Quaternion;
  82241. /**
  82242. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82243. * @param order is a reserved parameter and is ignore for now
  82244. * @returns a new Vector3 containing the Euler angles
  82245. */
  82246. toEulerAngles(order?: string): Vector3;
  82247. /**
  82248. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82249. * @param result defines the vector which will be filled with the Euler angles
  82250. * @param order is a reserved parameter and is ignore for now
  82251. * @returns the current unchanged quaternion
  82252. */
  82253. toEulerAnglesToRef(result: Vector3): Quaternion;
  82254. /**
  82255. * Updates the given rotation matrix with the current quaternion values
  82256. * @param result defines the target matrix
  82257. * @returns the current unchanged quaternion
  82258. */
  82259. toRotationMatrix(result: Matrix): Quaternion;
  82260. /**
  82261. * Updates the current quaternion from the given rotation matrix values
  82262. * @param matrix defines the source matrix
  82263. * @returns the current updated quaternion
  82264. */
  82265. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82266. /**
  82267. * Creates a new quaternion from a rotation matrix
  82268. * @param matrix defines the source matrix
  82269. * @returns a new quaternion created from the given rotation matrix values
  82270. */
  82271. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82272. /**
  82273. * Updates the given quaternion with the given rotation matrix values
  82274. * @param matrix defines the source matrix
  82275. * @param result defines the target quaternion
  82276. */
  82277. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82278. /**
  82279. * Returns the dot product (float) between the quaternions "left" and "right"
  82280. * @param left defines the left operand
  82281. * @param right defines the right operand
  82282. * @returns the dot product
  82283. */
  82284. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82285. /**
  82286. * Checks if the two quaternions are close to each other
  82287. * @param quat0 defines the first quaternion to check
  82288. * @param quat1 defines the second quaternion to check
  82289. * @returns true if the two quaternions are close to each other
  82290. */
  82291. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82292. /**
  82293. * Creates an empty quaternion
  82294. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82295. */
  82296. static Zero(): Quaternion;
  82297. /**
  82298. * Inverse a given quaternion
  82299. * @param q defines the source quaternion
  82300. * @returns a new quaternion as the inverted current quaternion
  82301. */
  82302. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82303. /**
  82304. * Inverse a given quaternion
  82305. * @param q defines the source quaternion
  82306. * @param result the quaternion the result will be stored in
  82307. * @returns the result quaternion
  82308. */
  82309. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82310. /**
  82311. * Creates an identity quaternion
  82312. * @returns the identity quaternion
  82313. */
  82314. static Identity(): Quaternion;
  82315. /**
  82316. * Gets a boolean indicating if the given quaternion is identity
  82317. * @param quaternion defines the quaternion to check
  82318. * @returns true if the quaternion is identity
  82319. */
  82320. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82321. /**
  82322. * Creates a quaternion from a rotation around an axis
  82323. * @param axis defines the axis to use
  82324. * @param angle defines the angle to use
  82325. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82326. */
  82327. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82328. /**
  82329. * Creates a rotation around an axis and stores it into the given quaternion
  82330. * @param axis defines the axis to use
  82331. * @param angle defines the angle to use
  82332. * @param result defines the target quaternion
  82333. * @returns the target quaternion
  82334. */
  82335. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82336. /**
  82337. * Creates a new quaternion from data stored into an array
  82338. * @param array defines the data source
  82339. * @param offset defines the offset in the source array where the data starts
  82340. * @returns a new quaternion
  82341. */
  82342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82343. /**
  82344. * Updates the given quaternion "result" from the starting index of the given array.
  82345. * @param array the array to pull values from
  82346. * @param offset the offset into the array to start at
  82347. * @param result the quaternion to store the result in
  82348. */
  82349. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82350. /**
  82351. * Create a quaternion from Euler rotation angles
  82352. * @param x Pitch
  82353. * @param y Yaw
  82354. * @param z Roll
  82355. * @returns the new Quaternion
  82356. */
  82357. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82358. /**
  82359. * Updates a quaternion from Euler rotation angles
  82360. * @param x Pitch
  82361. * @param y Yaw
  82362. * @param z Roll
  82363. * @param result the quaternion to store the result
  82364. * @returns the updated quaternion
  82365. */
  82366. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82367. /**
  82368. * Create a quaternion from Euler rotation vector
  82369. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82370. * @returns the new Quaternion
  82371. */
  82372. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82373. /**
  82374. * Updates a quaternion from Euler rotation vector
  82375. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82376. * @param result the quaternion to store the result
  82377. * @returns the updated quaternion
  82378. */
  82379. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82380. /**
  82381. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82382. * @param yaw defines the rotation around Y axis
  82383. * @param pitch defines the rotation around X axis
  82384. * @param roll defines the rotation around Z axis
  82385. * @returns the new quaternion
  82386. */
  82387. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82388. /**
  82389. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82390. * @param yaw defines the rotation around Y axis
  82391. * @param pitch defines the rotation around X axis
  82392. * @param roll defines the rotation around Z axis
  82393. * @param result defines the target quaternion
  82394. */
  82395. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82396. /**
  82397. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82398. * @param alpha defines the rotation around first axis
  82399. * @param beta defines the rotation around second axis
  82400. * @param gamma defines the rotation around third axis
  82401. * @returns the new quaternion
  82402. */
  82403. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82404. /**
  82405. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82406. * @param alpha defines the rotation around first axis
  82407. * @param beta defines the rotation around second axis
  82408. * @param gamma defines the rotation around third axis
  82409. * @param result defines the target quaternion
  82410. */
  82411. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82412. /**
  82413. * 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)
  82414. * @param axis1 defines the first axis
  82415. * @param axis2 defines the second axis
  82416. * @param axis3 defines the third axis
  82417. * @returns the new quaternion
  82418. */
  82419. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82420. /**
  82421. * 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
  82422. * @param axis1 defines the first axis
  82423. * @param axis2 defines the second axis
  82424. * @param axis3 defines the third axis
  82425. * @param ref defines the target quaternion
  82426. */
  82427. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82428. /**
  82429. * Interpolates between two quaternions
  82430. * @param left defines first quaternion
  82431. * @param right defines second quaternion
  82432. * @param amount defines the gradient to use
  82433. * @returns the new interpolated quaternion
  82434. */
  82435. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82436. /**
  82437. * Interpolates between two quaternions and stores it into a target quaternion
  82438. * @param left defines first quaternion
  82439. * @param right defines second quaternion
  82440. * @param amount defines the gradient to use
  82441. * @param result defines the target quaternion
  82442. */
  82443. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82444. /**
  82445. * Interpolate between two quaternions using Hermite interpolation
  82446. * @param value1 defines first quaternion
  82447. * @param tangent1 defines the incoming tangent
  82448. * @param value2 defines second quaternion
  82449. * @param tangent2 defines the outgoing tangent
  82450. * @param amount defines the target quaternion
  82451. * @returns the new interpolated quaternion
  82452. */
  82453. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82454. }
  82455. /**
  82456. * Class used to store matrix data (4x4)
  82457. */
  82458. export class Matrix {
  82459. /**
  82460. * Gets the precision of matrix computations
  82461. */
  82462. static get Use64Bits(): boolean;
  82463. private static _updateFlagSeed;
  82464. private static _identityReadOnly;
  82465. private _isIdentity;
  82466. private _isIdentityDirty;
  82467. private _isIdentity3x2;
  82468. private _isIdentity3x2Dirty;
  82469. /**
  82470. * Gets the update flag of the matrix which is an unique number for the matrix.
  82471. * It will be incremented every time the matrix data change.
  82472. * You can use it to speed the comparison between two versions of the same matrix.
  82473. */
  82474. updateFlag: number;
  82475. private readonly _m;
  82476. /**
  82477. * Gets the internal data of the matrix
  82478. */
  82479. get m(): DeepImmutable<Float32Array | Array<number>>;
  82480. /** @hidden */
  82481. _markAsUpdated(): void;
  82482. /** @hidden */
  82483. private _updateIdentityStatus;
  82484. /**
  82485. * Creates an empty matrix (filled with zeros)
  82486. */
  82487. constructor();
  82488. /**
  82489. * Check if the current matrix is identity
  82490. * @returns true is the matrix is the identity matrix
  82491. */
  82492. isIdentity(): boolean;
  82493. /**
  82494. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82495. * @returns true is the matrix is the identity matrix
  82496. */
  82497. isIdentityAs3x2(): boolean;
  82498. /**
  82499. * Gets the determinant of the matrix
  82500. * @returns the matrix determinant
  82501. */
  82502. determinant(): number;
  82503. /**
  82504. * Returns the matrix as a Float32Array or Array<number>
  82505. * @returns the matrix underlying array
  82506. */
  82507. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82508. /**
  82509. * Returns the matrix as a Float32Array or Array<number>
  82510. * @returns the matrix underlying array.
  82511. */
  82512. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82513. /**
  82514. * Inverts the current matrix in place
  82515. * @returns the current inverted matrix
  82516. */
  82517. invert(): Matrix;
  82518. /**
  82519. * Sets all the matrix elements to zero
  82520. * @returns the current matrix
  82521. */
  82522. reset(): Matrix;
  82523. /**
  82524. * Adds the current matrix with a second one
  82525. * @param other defines the matrix to add
  82526. * @returns a new matrix as the addition of the current matrix and the given one
  82527. */
  82528. add(other: DeepImmutable<Matrix>): Matrix;
  82529. /**
  82530. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82531. * @param other defines the matrix to add
  82532. * @param result defines the target matrix
  82533. * @returns the current matrix
  82534. */
  82535. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82536. /**
  82537. * Adds in place the given matrix to the current matrix
  82538. * @param other defines the second operand
  82539. * @returns the current updated matrix
  82540. */
  82541. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82542. /**
  82543. * Sets the given matrix to the current inverted Matrix
  82544. * @param other defines the target matrix
  82545. * @returns the unmodified current matrix
  82546. */
  82547. invertToRef(other: Matrix): Matrix;
  82548. /**
  82549. * add a value at the specified position in the current Matrix
  82550. * @param index the index of the value within the matrix. between 0 and 15.
  82551. * @param value the value to be added
  82552. * @returns the current updated matrix
  82553. */
  82554. addAtIndex(index: number, value: number): Matrix;
  82555. /**
  82556. * mutiply the specified position in the current Matrix by a value
  82557. * @param index the index of the value within the matrix. between 0 and 15.
  82558. * @param value the value to be added
  82559. * @returns the current updated matrix
  82560. */
  82561. multiplyAtIndex(index: number, value: number): Matrix;
  82562. /**
  82563. * Inserts the translation vector (using 3 floats) in the current matrix
  82564. * @param x defines the 1st component of the translation
  82565. * @param y defines the 2nd component of the translation
  82566. * @param z defines the 3rd component of the translation
  82567. * @returns the current updated matrix
  82568. */
  82569. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82570. /**
  82571. * Adds the translation vector (using 3 floats) in the current matrix
  82572. * @param x defines the 1st component of the translation
  82573. * @param y defines the 2nd component of the translation
  82574. * @param z defines the 3rd component of the translation
  82575. * @returns the current updated matrix
  82576. */
  82577. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82578. /**
  82579. * Inserts the translation vector in the current matrix
  82580. * @param vector3 defines the translation to insert
  82581. * @returns the current updated matrix
  82582. */
  82583. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82584. /**
  82585. * Gets the translation value of the current matrix
  82586. * @returns a new Vector3 as the extracted translation from the matrix
  82587. */
  82588. getTranslation(): Vector3;
  82589. /**
  82590. * Fill a Vector3 with the extracted translation from the matrix
  82591. * @param result defines the Vector3 where to store the translation
  82592. * @returns the current matrix
  82593. */
  82594. getTranslationToRef(result: Vector3): Matrix;
  82595. /**
  82596. * Remove rotation and scaling part from the matrix
  82597. * @returns the updated matrix
  82598. */
  82599. removeRotationAndScaling(): Matrix;
  82600. /**
  82601. * Multiply two matrices
  82602. * @param other defines the second operand
  82603. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82604. */
  82605. multiply(other: DeepImmutable<Matrix>): Matrix;
  82606. /**
  82607. * Copy the current matrix from the given one
  82608. * @param other defines the source matrix
  82609. * @returns the current updated matrix
  82610. */
  82611. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82612. /**
  82613. * Populates the given array from the starting index with the current matrix values
  82614. * @param array defines the target array
  82615. * @param offset defines the offset in the target array where to start storing values
  82616. * @returns the current matrix
  82617. */
  82618. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  82619. /**
  82620. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82621. * @param other defines the second operand
  82622. * @param result defines the matrix where to store the multiplication
  82623. * @returns the current matrix
  82624. */
  82625. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82626. /**
  82627. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82628. * @param other defines the second operand
  82629. * @param result defines the array where to store the multiplication
  82630. * @param offset defines the offset in the target array where to start storing values
  82631. * @returns the current matrix
  82632. */
  82633. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  82634. /**
  82635. * Check equality between this matrix and a second one
  82636. * @param value defines the second matrix to compare
  82637. * @returns true is the current matrix and the given one values are strictly equal
  82638. */
  82639. equals(value: DeepImmutable<Matrix>): boolean;
  82640. /**
  82641. * Clone the current matrix
  82642. * @returns a new matrix from the current matrix
  82643. */
  82644. clone(): Matrix;
  82645. /**
  82646. * Returns the name of the current matrix class
  82647. * @returns the string "Matrix"
  82648. */
  82649. getClassName(): string;
  82650. /**
  82651. * Gets the hash code of the current matrix
  82652. * @returns the hash code
  82653. */
  82654. getHashCode(): number;
  82655. /**
  82656. * Decomposes the current Matrix into a translation, rotation and scaling components
  82657. * @param scale defines the scale vector3 given as a reference to update
  82658. * @param rotation defines the rotation quaternion given as a reference to update
  82659. * @param translation defines the translation vector3 given as a reference to update
  82660. * @returns true if operation was successful
  82661. */
  82662. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82663. /**
  82664. * Gets specific row of the matrix
  82665. * @param index defines the number of the row to get
  82666. * @returns the index-th row of the current matrix as a new Vector4
  82667. */
  82668. getRow(index: number): Nullable<Vector4>;
  82669. /**
  82670. * Sets the index-th row of the current matrix to the vector4 values
  82671. * @param index defines the number of the row to set
  82672. * @param row defines the target vector4
  82673. * @returns the updated current matrix
  82674. */
  82675. setRow(index: number, row: Vector4): Matrix;
  82676. /**
  82677. * Compute the transpose of the matrix
  82678. * @returns the new transposed matrix
  82679. */
  82680. transpose(): Matrix;
  82681. /**
  82682. * Compute the transpose of the matrix and store it in a given matrix
  82683. * @param result defines the target matrix
  82684. * @returns the current matrix
  82685. */
  82686. transposeToRef(result: Matrix): Matrix;
  82687. /**
  82688. * Sets the index-th row of the current matrix with the given 4 x float values
  82689. * @param index defines the row index
  82690. * @param x defines the x component to set
  82691. * @param y defines the y component to set
  82692. * @param z defines the z component to set
  82693. * @param w defines the w component to set
  82694. * @returns the updated current matrix
  82695. */
  82696. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82697. /**
  82698. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82699. * @param scale defines the scale factor
  82700. * @returns a new matrix
  82701. */
  82702. scale(scale: number): Matrix;
  82703. /**
  82704. * Scale the current matrix values by a factor to a given result matrix
  82705. * @param scale defines the scale factor
  82706. * @param result defines the matrix to store the result
  82707. * @returns the current matrix
  82708. */
  82709. scaleToRef(scale: number, result: Matrix): Matrix;
  82710. /**
  82711. * Scale the current matrix values by a factor and add the result to a given matrix
  82712. * @param scale defines the scale factor
  82713. * @param result defines the Matrix to store the result
  82714. * @returns the current matrix
  82715. */
  82716. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82717. /**
  82718. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82719. * @param ref matrix to store the result
  82720. */
  82721. toNormalMatrix(ref: Matrix): void;
  82722. /**
  82723. * Gets only rotation part of the current matrix
  82724. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82725. */
  82726. getRotationMatrix(): Matrix;
  82727. /**
  82728. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82729. * @param result defines the target matrix to store data to
  82730. * @returns the current matrix
  82731. */
  82732. getRotationMatrixToRef(result: Matrix): Matrix;
  82733. /**
  82734. * Toggles model matrix from being right handed to left handed in place and vice versa
  82735. */
  82736. toggleModelMatrixHandInPlace(): void;
  82737. /**
  82738. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82739. */
  82740. toggleProjectionMatrixHandInPlace(): void;
  82741. /**
  82742. * Creates a matrix from an array
  82743. * @param array defines the source array
  82744. * @param offset defines an offset in the source array
  82745. * @returns a new Matrix set from the starting index of the given array
  82746. */
  82747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82748. /**
  82749. * Copy the content of an array into a given matrix
  82750. * @param array defines the source array
  82751. * @param offset defines an offset in the source array
  82752. * @param result defines the target matrix
  82753. */
  82754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82755. /**
  82756. * Stores an array into a matrix after having multiplied each component by a given factor
  82757. * @param array defines the source array
  82758. * @param offset defines the offset in the source array
  82759. * @param scale defines the scaling factor
  82760. * @param result defines the target matrix
  82761. */
  82762. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  82763. /**
  82764. * Gets an identity matrix that must not be updated
  82765. */
  82766. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82767. /**
  82768. * Stores a list of values (16) inside a given matrix
  82769. * @param initialM11 defines 1st value of 1st row
  82770. * @param initialM12 defines 2nd value of 1st row
  82771. * @param initialM13 defines 3rd value of 1st row
  82772. * @param initialM14 defines 4th value of 1st row
  82773. * @param initialM21 defines 1st value of 2nd row
  82774. * @param initialM22 defines 2nd value of 2nd row
  82775. * @param initialM23 defines 3rd value of 2nd row
  82776. * @param initialM24 defines 4th value of 2nd row
  82777. * @param initialM31 defines 1st value of 3rd row
  82778. * @param initialM32 defines 2nd value of 3rd row
  82779. * @param initialM33 defines 3rd value of 3rd row
  82780. * @param initialM34 defines 4th value of 3rd row
  82781. * @param initialM41 defines 1st value of 4th row
  82782. * @param initialM42 defines 2nd value of 4th row
  82783. * @param initialM43 defines 3rd value of 4th row
  82784. * @param initialM44 defines 4th value of 4th row
  82785. * @param result defines the target matrix
  82786. */
  82787. 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;
  82788. /**
  82789. * Creates new matrix from a list of values (16)
  82790. * @param initialM11 defines 1st value of 1st row
  82791. * @param initialM12 defines 2nd value of 1st row
  82792. * @param initialM13 defines 3rd value of 1st row
  82793. * @param initialM14 defines 4th value of 1st row
  82794. * @param initialM21 defines 1st value of 2nd row
  82795. * @param initialM22 defines 2nd value of 2nd row
  82796. * @param initialM23 defines 3rd value of 2nd row
  82797. * @param initialM24 defines 4th value of 2nd row
  82798. * @param initialM31 defines 1st value of 3rd row
  82799. * @param initialM32 defines 2nd value of 3rd row
  82800. * @param initialM33 defines 3rd value of 3rd row
  82801. * @param initialM34 defines 4th value of 3rd row
  82802. * @param initialM41 defines 1st value of 4th row
  82803. * @param initialM42 defines 2nd value of 4th row
  82804. * @param initialM43 defines 3rd value of 4th row
  82805. * @param initialM44 defines 4th value of 4th row
  82806. * @returns the new matrix
  82807. */
  82808. 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;
  82809. /**
  82810. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82811. * @param scale defines the scale vector3
  82812. * @param rotation defines the rotation quaternion
  82813. * @param translation defines the translation vector3
  82814. * @returns a new matrix
  82815. */
  82816. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82817. /**
  82818. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82819. * @param scale defines the scale vector3
  82820. * @param rotation defines the rotation quaternion
  82821. * @param translation defines the translation vector3
  82822. * @param result defines the target matrix
  82823. */
  82824. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82825. /**
  82826. * Creates a new identity matrix
  82827. * @returns a new identity matrix
  82828. */
  82829. static Identity(): Matrix;
  82830. /**
  82831. * Creates a new identity matrix and stores the result in a given matrix
  82832. * @param result defines the target matrix
  82833. */
  82834. static IdentityToRef(result: Matrix): void;
  82835. /**
  82836. * Creates a new zero matrix
  82837. * @returns a new zero matrix
  82838. */
  82839. static Zero(): Matrix;
  82840. /**
  82841. * Creates a new rotation matrix for "angle" radians around the X axis
  82842. * @param angle defines the angle (in radians) to use
  82843. * @return the new matrix
  82844. */
  82845. static RotationX(angle: number): Matrix;
  82846. /**
  82847. * Creates a new matrix as the invert of a given matrix
  82848. * @param source defines the source matrix
  82849. * @returns the new matrix
  82850. */
  82851. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82852. /**
  82853. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82854. * @param angle defines the angle (in radians) to use
  82855. * @param result defines the target matrix
  82856. */
  82857. static RotationXToRef(angle: number, result: Matrix): void;
  82858. /**
  82859. * Creates a new rotation matrix for "angle" radians around the Y axis
  82860. * @param angle defines the angle (in radians) to use
  82861. * @return the new matrix
  82862. */
  82863. static RotationY(angle: number): Matrix;
  82864. /**
  82865. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82866. * @param angle defines the angle (in radians) to use
  82867. * @param result defines the target matrix
  82868. */
  82869. static RotationYToRef(angle: number, result: Matrix): void;
  82870. /**
  82871. * Creates a new rotation matrix for "angle" radians around the Z axis
  82872. * @param angle defines the angle (in radians) to use
  82873. * @return the new matrix
  82874. */
  82875. static RotationZ(angle: number): Matrix;
  82876. /**
  82877. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82878. * @param angle defines the angle (in radians) to use
  82879. * @param result defines the target matrix
  82880. */
  82881. static RotationZToRef(angle: number, result: Matrix): void;
  82882. /**
  82883. * Creates a new rotation matrix for "angle" radians around the given axis
  82884. * @param axis defines the axis to use
  82885. * @param angle defines the angle (in radians) to use
  82886. * @return the new matrix
  82887. */
  82888. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82889. /**
  82890. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82891. * @param axis defines the axis to use
  82892. * @param angle defines the angle (in radians) to use
  82893. * @param result defines the target matrix
  82894. */
  82895. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82896. /**
  82897. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82898. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82899. * @param from defines the vector to align
  82900. * @param to defines the vector to align to
  82901. * @param result defines the target matrix
  82902. */
  82903. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82904. /**
  82905. * Creates a rotation matrix
  82906. * @param yaw defines the yaw angle in radians (Y axis)
  82907. * @param pitch defines the pitch angle in radians (X axis)
  82908. * @param roll defines the roll angle in radians (X axis)
  82909. * @returns the new rotation matrix
  82910. */
  82911. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82912. /**
  82913. * Creates a rotation matrix and stores it in a given matrix
  82914. * @param yaw defines the yaw angle in radians (Y axis)
  82915. * @param pitch defines the pitch angle in radians (X axis)
  82916. * @param roll defines the roll angle in radians (X axis)
  82917. * @param result defines the target matrix
  82918. */
  82919. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82920. /**
  82921. * Creates a scaling matrix
  82922. * @param x defines the scale factor on X axis
  82923. * @param y defines the scale factor on Y axis
  82924. * @param z defines the scale factor on Z axis
  82925. * @returns the new matrix
  82926. */
  82927. static Scaling(x: number, y: number, z: number): Matrix;
  82928. /**
  82929. * Creates a scaling matrix and stores it in a given matrix
  82930. * @param x defines the scale factor on X axis
  82931. * @param y defines the scale factor on Y axis
  82932. * @param z defines the scale factor on Z axis
  82933. * @param result defines the target matrix
  82934. */
  82935. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82936. /**
  82937. * Creates a translation matrix
  82938. * @param x defines the translation on X axis
  82939. * @param y defines the translation on Y axis
  82940. * @param z defines the translationon Z axis
  82941. * @returns the new matrix
  82942. */
  82943. static Translation(x: number, y: number, z: number): Matrix;
  82944. /**
  82945. * Creates a translation matrix and stores it in a given matrix
  82946. * @param x defines the translation on X axis
  82947. * @param y defines the translation on Y axis
  82948. * @param z defines the translationon Z axis
  82949. * @param result defines the target matrix
  82950. */
  82951. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82952. /**
  82953. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82954. * @param startValue defines the start value
  82955. * @param endValue defines the end value
  82956. * @param gradient defines the gradient factor
  82957. * @returns the new matrix
  82958. */
  82959. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82960. /**
  82961. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82962. * @param startValue defines the start value
  82963. * @param endValue defines the end value
  82964. * @param gradient defines the gradient factor
  82965. * @param result defines the Matrix object where to store data
  82966. */
  82967. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82968. /**
  82969. * Builds a new matrix whose values are computed by:
  82970. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82971. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82972. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82973. * @param startValue defines the first matrix
  82974. * @param endValue defines the second matrix
  82975. * @param gradient defines the gradient between the two matrices
  82976. * @returns the new matrix
  82977. */
  82978. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82979. /**
  82980. * Update a matrix to values which are computed by:
  82981. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82982. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82983. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82984. * @param startValue defines the first matrix
  82985. * @param endValue defines the second matrix
  82986. * @param gradient defines the gradient between the two matrices
  82987. * @param result defines the target matrix
  82988. */
  82989. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82990. /**
  82991. * 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"
  82992. * This function works in left handed mode
  82993. * @param eye defines the final position of the entity
  82994. * @param target defines where the entity should look at
  82995. * @param up defines the up vector for the entity
  82996. * @returns the new matrix
  82997. */
  82998. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82999. /**
  83000. * 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".
  83001. * This function works in left handed mode
  83002. * @param eye defines the final position of the entity
  83003. * @param target defines where the entity should look at
  83004. * @param up defines the up vector for the entity
  83005. * @param result defines the target matrix
  83006. */
  83007. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83008. /**
  83009. * 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"
  83010. * This function works in right handed mode
  83011. * @param eye defines the final position of the entity
  83012. * @param target defines where the entity should look at
  83013. * @param up defines the up vector for the entity
  83014. * @returns the new matrix
  83015. */
  83016. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83017. /**
  83018. * 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".
  83019. * This function works in right handed mode
  83020. * @param eye defines the final position of the entity
  83021. * @param target defines where the entity should look at
  83022. * @param up defines the up vector for the entity
  83023. * @param result defines the target matrix
  83024. */
  83025. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83026. /**
  83027. * Create a left-handed orthographic projection matrix
  83028. * @param width defines the viewport width
  83029. * @param height defines the viewport height
  83030. * @param znear defines the near clip plane
  83031. * @param zfar defines the far clip plane
  83032. * @returns a new matrix as a left-handed orthographic projection matrix
  83033. */
  83034. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83035. /**
  83036. * Store a left-handed orthographic projection to a given matrix
  83037. * @param width defines the viewport width
  83038. * @param height defines the viewport height
  83039. * @param znear defines the near clip plane
  83040. * @param zfar defines the far clip plane
  83041. * @param result defines the target matrix
  83042. */
  83043. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83044. /**
  83045. * Create a left-handed orthographic projection matrix
  83046. * @param left defines the viewport left coordinate
  83047. * @param right defines the viewport right coordinate
  83048. * @param bottom defines the viewport bottom coordinate
  83049. * @param top defines the viewport top coordinate
  83050. * @param znear defines the near clip plane
  83051. * @param zfar defines the far clip plane
  83052. * @returns a new matrix as a left-handed orthographic projection matrix
  83053. */
  83054. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83055. /**
  83056. * Stores a left-handed orthographic projection into a given matrix
  83057. * @param left defines the viewport left coordinate
  83058. * @param right defines the viewport right coordinate
  83059. * @param bottom defines the viewport bottom coordinate
  83060. * @param top defines the viewport top coordinate
  83061. * @param znear defines the near clip plane
  83062. * @param zfar defines the far clip plane
  83063. * @param result defines the target matrix
  83064. */
  83065. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83066. /**
  83067. * Creates a right-handed orthographic projection matrix
  83068. * @param left defines the viewport left coordinate
  83069. * @param right defines the viewport right coordinate
  83070. * @param bottom defines the viewport bottom coordinate
  83071. * @param top defines the viewport top coordinate
  83072. * @param znear defines the near clip plane
  83073. * @param zfar defines the far clip plane
  83074. * @returns a new matrix as a right-handed orthographic projection matrix
  83075. */
  83076. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83077. /**
  83078. * Stores a right-handed orthographic projection into a given matrix
  83079. * @param left defines the viewport left coordinate
  83080. * @param right defines the viewport right coordinate
  83081. * @param bottom defines the viewport bottom coordinate
  83082. * @param top defines the viewport top coordinate
  83083. * @param znear defines the near clip plane
  83084. * @param zfar defines the far clip plane
  83085. * @param result defines the target matrix
  83086. */
  83087. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83088. /**
  83089. * Creates a left-handed perspective projection matrix
  83090. * @param width defines the viewport width
  83091. * @param height defines the viewport height
  83092. * @param znear defines the near clip plane
  83093. * @param zfar defines the far clip plane
  83094. * @returns a new matrix as a left-handed perspective projection matrix
  83095. */
  83096. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83097. /**
  83098. * Creates a left-handed perspective projection matrix
  83099. * @param fov defines the horizontal field of view
  83100. * @param aspect defines the aspect ratio
  83101. * @param znear defines the near clip plane
  83102. * @param zfar defines the far clip plane
  83103. * @returns a new matrix as a left-handed perspective projection matrix
  83104. */
  83105. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83106. /**
  83107. * Stores a left-handed perspective projection into a given matrix
  83108. * @param fov defines the horizontal field of view
  83109. * @param aspect defines the aspect ratio
  83110. * @param znear defines the near clip plane
  83111. * @param zfar defines the far clip plane
  83112. * @param result defines the target matrix
  83113. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83114. */
  83115. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83116. /**
  83117. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83118. * @param fov defines the horizontal field of view
  83119. * @param aspect defines the aspect ratio
  83120. * @param znear defines the near clip plane
  83121. * @param zfar not used as infinity is used as far clip
  83122. * @param result defines the target matrix
  83123. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83124. */
  83125. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83126. /**
  83127. * Creates a right-handed perspective projection matrix
  83128. * @param fov defines the horizontal field of view
  83129. * @param aspect defines the aspect ratio
  83130. * @param znear defines the near clip plane
  83131. * @param zfar defines the far clip plane
  83132. * @returns a new matrix as a right-handed perspective projection matrix
  83133. */
  83134. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83135. /**
  83136. * Stores a right-handed perspective projection into a given matrix
  83137. * @param fov defines the horizontal field of view
  83138. * @param aspect defines the aspect ratio
  83139. * @param znear defines the near clip plane
  83140. * @param zfar defines the far clip plane
  83141. * @param result defines the target matrix
  83142. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83143. */
  83144. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83145. /**
  83146. * Stores a right-handed perspective projection into a given matrix
  83147. * @param fov defines the horizontal field of view
  83148. * @param aspect defines the aspect ratio
  83149. * @param znear defines the near clip plane
  83150. * @param zfar not used as infinity is used as far clip
  83151. * @param result defines the target matrix
  83152. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83153. */
  83154. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83155. /**
  83156. * Stores a perspective projection for WebVR info a given matrix
  83157. * @param fov defines the field of view
  83158. * @param znear defines the near clip plane
  83159. * @param zfar defines the far clip plane
  83160. * @param result defines the target matrix
  83161. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83162. */
  83163. static PerspectiveFovWebVRToRef(fov: {
  83164. upDegrees: number;
  83165. downDegrees: number;
  83166. leftDegrees: number;
  83167. rightDegrees: number;
  83168. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83169. /**
  83170. * Computes a complete transformation matrix
  83171. * @param viewport defines the viewport to use
  83172. * @param world defines the world matrix
  83173. * @param view defines the view matrix
  83174. * @param projection defines the projection matrix
  83175. * @param zmin defines the near clip plane
  83176. * @param zmax defines the far clip plane
  83177. * @returns the transformation matrix
  83178. */
  83179. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83180. /**
  83181. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83182. * @param matrix defines the matrix to use
  83183. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83184. */
  83185. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83186. /**
  83187. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83188. * @param matrix defines the matrix to use
  83189. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83190. */
  83191. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83192. /**
  83193. * Compute the transpose of a given matrix
  83194. * @param matrix defines the matrix to transpose
  83195. * @returns the new matrix
  83196. */
  83197. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83198. /**
  83199. * Compute the transpose of a matrix and store it in a target matrix
  83200. * @param matrix defines the matrix to transpose
  83201. * @param result defines the target matrix
  83202. */
  83203. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83204. /**
  83205. * Computes a reflection matrix from a plane
  83206. * @param plane defines the reflection plane
  83207. * @returns a new matrix
  83208. */
  83209. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83210. /**
  83211. * Computes a reflection matrix from a plane
  83212. * @param plane defines the reflection plane
  83213. * @param result defines the target matrix
  83214. */
  83215. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83216. /**
  83217. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83218. * @param xaxis defines the value of the 1st axis
  83219. * @param yaxis defines the value of the 2nd axis
  83220. * @param zaxis defines the value of the 3rd axis
  83221. * @param result defines the target matrix
  83222. */
  83223. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83224. /**
  83225. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83226. * @param quat defines the quaternion to use
  83227. * @param result defines the target matrix
  83228. */
  83229. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83230. }
  83231. /**
  83232. * @hidden
  83233. */
  83234. export class TmpVectors {
  83235. static Vector2: Vector2[];
  83236. static Vector3: Vector3[];
  83237. static Vector4: Vector4[];
  83238. static Quaternion: Quaternion[];
  83239. static Matrix: Matrix[];
  83240. }
  83241. }
  83242. declare module BABYLON {
  83243. /**
  83244. * Defines potential orientation for back face culling
  83245. */
  83246. export enum Orientation {
  83247. /**
  83248. * Clockwise
  83249. */
  83250. CW = 0,
  83251. /** Counter clockwise */
  83252. CCW = 1
  83253. }
  83254. /** Class used to represent a Bezier curve */
  83255. export class BezierCurve {
  83256. /**
  83257. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83258. * @param t defines the time
  83259. * @param x1 defines the left coordinate on X axis
  83260. * @param y1 defines the left coordinate on Y axis
  83261. * @param x2 defines the right coordinate on X axis
  83262. * @param y2 defines the right coordinate on Y axis
  83263. * @returns the interpolated value
  83264. */
  83265. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83266. }
  83267. /**
  83268. * Defines angle representation
  83269. */
  83270. export class Angle {
  83271. private _radians;
  83272. /**
  83273. * Creates an Angle object of "radians" radians (float).
  83274. * @param radians the angle in radians
  83275. */
  83276. constructor(radians: number);
  83277. /**
  83278. * Get value in degrees
  83279. * @returns the Angle value in degrees (float)
  83280. */
  83281. degrees(): number;
  83282. /**
  83283. * Get value in radians
  83284. * @returns the Angle value in radians (float)
  83285. */
  83286. radians(): number;
  83287. /**
  83288. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83289. * @param a defines first point as the origin
  83290. * @param b defines point
  83291. * @returns a new Angle
  83292. */
  83293. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83294. /**
  83295. * Gets a new Angle object from the given float in radians
  83296. * @param radians defines the angle value in radians
  83297. * @returns a new Angle
  83298. */
  83299. static FromRadians(radians: number): Angle;
  83300. /**
  83301. * Gets a new Angle object from the given float in degrees
  83302. * @param degrees defines the angle value in degrees
  83303. * @returns a new Angle
  83304. */
  83305. static FromDegrees(degrees: number): Angle;
  83306. }
  83307. /**
  83308. * This represents an arc in a 2d space.
  83309. */
  83310. export class Arc2 {
  83311. /** Defines the start point of the arc */
  83312. startPoint: Vector2;
  83313. /** Defines the mid point of the arc */
  83314. midPoint: Vector2;
  83315. /** Defines the end point of the arc */
  83316. endPoint: Vector2;
  83317. /**
  83318. * Defines the center point of the arc.
  83319. */
  83320. centerPoint: Vector2;
  83321. /**
  83322. * Defines the radius of the arc.
  83323. */
  83324. radius: number;
  83325. /**
  83326. * Defines the angle of the arc (from mid point to end point).
  83327. */
  83328. angle: Angle;
  83329. /**
  83330. * Defines the start angle of the arc (from start point to middle point).
  83331. */
  83332. startAngle: Angle;
  83333. /**
  83334. * Defines the orientation of the arc (clock wise/counter clock wise).
  83335. */
  83336. orientation: Orientation;
  83337. /**
  83338. * Creates an Arc object from the three given points : start, middle and end.
  83339. * @param startPoint Defines the start point of the arc
  83340. * @param midPoint Defines the midlle point of the arc
  83341. * @param endPoint Defines the end point of the arc
  83342. */
  83343. constructor(
  83344. /** Defines the start point of the arc */
  83345. startPoint: Vector2,
  83346. /** Defines the mid point of the arc */
  83347. midPoint: Vector2,
  83348. /** Defines the end point of the arc */
  83349. endPoint: Vector2);
  83350. }
  83351. /**
  83352. * Represents a 2D path made up of multiple 2D points
  83353. */
  83354. export class Path2 {
  83355. private _points;
  83356. private _length;
  83357. /**
  83358. * If the path start and end point are the same
  83359. */
  83360. closed: boolean;
  83361. /**
  83362. * Creates a Path2 object from the starting 2D coordinates x and y.
  83363. * @param x the starting points x value
  83364. * @param y the starting points y value
  83365. */
  83366. constructor(x: number, y: number);
  83367. /**
  83368. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83369. * @param x the added points x value
  83370. * @param y the added points y value
  83371. * @returns the updated Path2.
  83372. */
  83373. addLineTo(x: number, y: number): Path2;
  83374. /**
  83375. * 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.
  83376. * @param midX middle point x value
  83377. * @param midY middle point y value
  83378. * @param endX end point x value
  83379. * @param endY end point y value
  83380. * @param numberOfSegments (default: 36)
  83381. * @returns the updated Path2.
  83382. */
  83383. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83384. /**
  83385. * Closes the Path2.
  83386. * @returns the Path2.
  83387. */
  83388. close(): Path2;
  83389. /**
  83390. * Gets the sum of the distance between each sequential point in the path
  83391. * @returns the Path2 total length (float).
  83392. */
  83393. length(): number;
  83394. /**
  83395. * Gets the points which construct the path
  83396. * @returns the Path2 internal array of points.
  83397. */
  83398. getPoints(): Vector2[];
  83399. /**
  83400. * Retreives the point at the distance aways from the starting point
  83401. * @param normalizedLengthPosition the length along the path to retreive the point from
  83402. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83403. */
  83404. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83405. /**
  83406. * Creates a new path starting from an x and y position
  83407. * @param x starting x value
  83408. * @param y starting y value
  83409. * @returns a new Path2 starting at the coordinates (x, y).
  83410. */
  83411. static StartingAt(x: number, y: number): Path2;
  83412. }
  83413. /**
  83414. * Represents a 3D path made up of multiple 3D points
  83415. */
  83416. export class Path3D {
  83417. /**
  83418. * an array of Vector3, the curve axis of the Path3D
  83419. */
  83420. path: Vector3[];
  83421. private _curve;
  83422. private _distances;
  83423. private _tangents;
  83424. private _normals;
  83425. private _binormals;
  83426. private _raw;
  83427. private _alignTangentsWithPath;
  83428. private readonly _pointAtData;
  83429. /**
  83430. * new Path3D(path, normal, raw)
  83431. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83432. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83433. * @param path an array of Vector3, the curve axis of the Path3D
  83434. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83435. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83436. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83437. */
  83438. constructor(
  83439. /**
  83440. * an array of Vector3, the curve axis of the Path3D
  83441. */
  83442. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83443. /**
  83444. * Returns the Path3D array of successive Vector3 designing its curve.
  83445. * @returns the Path3D array of successive Vector3 designing its curve.
  83446. */
  83447. getCurve(): Vector3[];
  83448. /**
  83449. * Returns the Path3D array of successive Vector3 designing its curve.
  83450. * @returns the Path3D array of successive Vector3 designing its curve.
  83451. */
  83452. getPoints(): Vector3[];
  83453. /**
  83454. * @returns the computed length (float) of the path.
  83455. */
  83456. length(): number;
  83457. /**
  83458. * Returns an array populated with tangent vectors on each Path3D curve point.
  83459. * @returns an array populated with tangent vectors on each Path3D curve point.
  83460. */
  83461. getTangents(): Vector3[];
  83462. /**
  83463. * Returns an array populated with normal vectors on each Path3D curve point.
  83464. * @returns an array populated with normal vectors on each Path3D curve point.
  83465. */
  83466. getNormals(): Vector3[];
  83467. /**
  83468. * Returns an array populated with binormal vectors on each Path3D curve point.
  83469. * @returns an array populated with binormal vectors on each Path3D curve point.
  83470. */
  83471. getBinormals(): Vector3[];
  83472. /**
  83473. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83474. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83475. */
  83476. getDistances(): number[];
  83477. /**
  83478. * Returns an interpolated point along this path
  83479. * @param position the position of the point along this path, from 0.0 to 1.0
  83480. * @returns a new Vector3 as the point
  83481. */
  83482. getPointAt(position: number): Vector3;
  83483. /**
  83484. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83485. * @param position the position of the point along this path, from 0.0 to 1.0
  83486. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83487. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83488. */
  83489. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83490. /**
  83491. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83492. * @param position the position of the point along this path, from 0.0 to 1.0
  83493. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83494. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83495. */
  83496. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83497. /**
  83498. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83499. * @param position the position of the point along this path, from 0.0 to 1.0
  83500. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83501. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83502. */
  83503. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83504. /**
  83505. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83506. * @param position the position of the point along this path, from 0.0 to 1.0
  83507. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83508. */
  83509. getDistanceAt(position: number): number;
  83510. /**
  83511. * Returns the array index of the previous point of an interpolated point along this path
  83512. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83513. * @returns the array index
  83514. */
  83515. getPreviousPointIndexAt(position: number): number;
  83516. /**
  83517. * 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)
  83518. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83519. * @returns the sub position
  83520. */
  83521. getSubPositionAt(position: number): number;
  83522. /**
  83523. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83524. * @param target the vector of which to get the closest position to
  83525. * @returns the position of the closest virtual point on this path to the target vector
  83526. */
  83527. getClosestPositionTo(target: Vector3): number;
  83528. /**
  83529. * Returns a sub path (slice) of this path
  83530. * @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
  83531. * @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
  83532. * @returns a sub path (slice) of this path
  83533. */
  83534. slice(start?: number, end?: number): Path3D;
  83535. /**
  83536. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83537. * @param path path which all values are copied into the curves points
  83538. * @param firstNormal which should be projected onto the curve
  83539. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83540. * @returns the same object updated.
  83541. */
  83542. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83543. private _compute;
  83544. private _getFirstNonNullVector;
  83545. private _getLastNonNullVector;
  83546. private _normalVector;
  83547. /**
  83548. * Updates the point at data for an interpolated point along this curve
  83549. * @param position the position of the point along this curve, from 0.0 to 1.0
  83550. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83551. * @returns the (updated) point at data
  83552. */
  83553. private _updatePointAtData;
  83554. /**
  83555. * Updates the point at data from the specified parameters
  83556. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83557. * @param point the interpolated point
  83558. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83559. */
  83560. private _setPointAtData;
  83561. /**
  83562. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83563. */
  83564. private _updateInterpolationMatrix;
  83565. }
  83566. /**
  83567. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83568. * A Curve3 is designed from a series of successive Vector3.
  83569. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83570. */
  83571. export class Curve3 {
  83572. private _points;
  83573. private _length;
  83574. /**
  83575. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83576. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83577. * @param v1 (Vector3) the control point
  83578. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83579. * @param nbPoints (integer) the wanted number of points in the curve
  83580. * @returns the created Curve3
  83581. */
  83582. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83583. /**
  83584. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83585. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83586. * @param v1 (Vector3) the first control point
  83587. * @param v2 (Vector3) the second control point
  83588. * @param v3 (Vector3) the end point of the Cubic Bezier
  83589. * @param nbPoints (integer) the wanted number of points in the curve
  83590. * @returns the created Curve3
  83591. */
  83592. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83593. /**
  83594. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83595. * @param p1 (Vector3) the origin point of the Hermite Spline
  83596. * @param t1 (Vector3) the tangent vector at the origin point
  83597. * @param p2 (Vector3) the end point of the Hermite Spline
  83598. * @param t2 (Vector3) the tangent vector at the end point
  83599. * @param nbPoints (integer) the wanted number of points in the curve
  83600. * @returns the created Curve3
  83601. */
  83602. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83603. /**
  83604. * Returns a Curve3 object along a CatmullRom Spline curve :
  83605. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83606. * @param nbPoints (integer) the wanted number of points between each curve control points
  83607. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83608. * @returns the created Curve3
  83609. */
  83610. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83611. /**
  83612. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83613. * A Curve3 is designed from a series of successive Vector3.
  83614. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83615. * @param points points which make up the curve
  83616. */
  83617. constructor(points: Vector3[]);
  83618. /**
  83619. * @returns the Curve3 stored array of successive Vector3
  83620. */
  83621. getPoints(): Vector3[];
  83622. /**
  83623. * @returns the computed length (float) of the curve.
  83624. */
  83625. length(): number;
  83626. /**
  83627. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83628. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83629. * curveA and curveB keep unchanged.
  83630. * @param curve the curve to continue from this curve
  83631. * @returns the newly constructed curve
  83632. */
  83633. continue(curve: DeepImmutable<Curve3>): Curve3;
  83634. private _computeLength;
  83635. }
  83636. }
  83637. declare module BABYLON {
  83638. /**
  83639. * This represents the main contract an easing function should follow.
  83640. * Easing functions are used throughout the animation system.
  83641. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83642. */
  83643. export interface IEasingFunction {
  83644. /**
  83645. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83646. * of the easing function.
  83647. * The link below provides some of the most common examples of easing functions.
  83648. * @see https://easings.net/
  83649. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83650. * @returns the corresponding value on the curve defined by the easing function
  83651. */
  83652. ease(gradient: number): number;
  83653. }
  83654. /**
  83655. * Base class used for every default easing function.
  83656. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83657. */
  83658. export class EasingFunction implements IEasingFunction {
  83659. /**
  83660. * Interpolation follows the mathematical formula associated with the easing function.
  83661. */
  83662. static readonly EASINGMODE_EASEIN: number;
  83663. /**
  83664. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83665. */
  83666. static readonly EASINGMODE_EASEOUT: number;
  83667. /**
  83668. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83669. */
  83670. static readonly EASINGMODE_EASEINOUT: number;
  83671. private _easingMode;
  83672. /**
  83673. * Sets the easing mode of the current function.
  83674. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83675. */
  83676. setEasingMode(easingMode: number): void;
  83677. /**
  83678. * Gets the current easing mode.
  83679. * @returns the easing mode
  83680. */
  83681. getEasingMode(): number;
  83682. /**
  83683. * @hidden
  83684. */
  83685. easeInCore(gradient: number): number;
  83686. /**
  83687. * Given an input gradient between 0 and 1, this returns the corresponding value
  83688. * of the easing function.
  83689. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83690. * @returns the corresponding value on the curve defined by the easing function
  83691. */
  83692. ease(gradient: number): number;
  83693. }
  83694. /**
  83695. * Easing function with a circle shape (see link below).
  83696. * @see https://easings.net/#easeInCirc
  83697. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83698. */
  83699. export class CircleEase extends EasingFunction implements IEasingFunction {
  83700. /** @hidden */
  83701. easeInCore(gradient: number): number;
  83702. }
  83703. /**
  83704. * Easing function with a ease back shape (see link below).
  83705. * @see https://easings.net/#easeInBack
  83706. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83707. */
  83708. export class BackEase extends EasingFunction implements IEasingFunction {
  83709. /** Defines the amplitude of the function */
  83710. amplitude: number;
  83711. /**
  83712. * Instantiates a back ease easing
  83713. * @see https://easings.net/#easeInBack
  83714. * @param amplitude Defines the amplitude of the function
  83715. */
  83716. constructor(
  83717. /** Defines the amplitude of the function */
  83718. amplitude?: number);
  83719. /** @hidden */
  83720. easeInCore(gradient: number): number;
  83721. }
  83722. /**
  83723. * Easing function with a bouncing shape (see link below).
  83724. * @see https://easings.net/#easeInBounce
  83725. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83726. */
  83727. export class BounceEase extends EasingFunction implements IEasingFunction {
  83728. /** Defines the number of bounces */
  83729. bounces: number;
  83730. /** Defines the amplitude of the bounce */
  83731. bounciness: number;
  83732. /**
  83733. * Instantiates a bounce easing
  83734. * @see https://easings.net/#easeInBounce
  83735. * @param bounces Defines the number of bounces
  83736. * @param bounciness Defines the amplitude of the bounce
  83737. */
  83738. constructor(
  83739. /** Defines the number of bounces */
  83740. bounces?: number,
  83741. /** Defines the amplitude of the bounce */
  83742. bounciness?: number);
  83743. /** @hidden */
  83744. easeInCore(gradient: number): number;
  83745. }
  83746. /**
  83747. * Easing function with a power of 3 shape (see link below).
  83748. * @see https://easings.net/#easeInCubic
  83749. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83750. */
  83751. export class CubicEase extends EasingFunction implements IEasingFunction {
  83752. /** @hidden */
  83753. easeInCore(gradient: number): number;
  83754. }
  83755. /**
  83756. * Easing function with an elastic shape (see link below).
  83757. * @see https://easings.net/#easeInElastic
  83758. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83759. */
  83760. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83761. /** Defines the number of oscillations*/
  83762. oscillations: number;
  83763. /** Defines the amplitude of the oscillations*/
  83764. springiness: number;
  83765. /**
  83766. * Instantiates an elastic easing function
  83767. * @see https://easings.net/#easeInElastic
  83768. * @param oscillations Defines the number of oscillations
  83769. * @param springiness Defines the amplitude of the oscillations
  83770. */
  83771. constructor(
  83772. /** Defines the number of oscillations*/
  83773. oscillations?: number,
  83774. /** Defines the amplitude of the oscillations*/
  83775. springiness?: number);
  83776. /** @hidden */
  83777. easeInCore(gradient: number): number;
  83778. }
  83779. /**
  83780. * Easing function with an exponential shape (see link below).
  83781. * @see https://easings.net/#easeInExpo
  83782. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83783. */
  83784. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83785. /** Defines the exponent of the function */
  83786. exponent: number;
  83787. /**
  83788. * Instantiates an exponential easing function
  83789. * @see https://easings.net/#easeInExpo
  83790. * @param exponent Defines the exponent of the function
  83791. */
  83792. constructor(
  83793. /** Defines the exponent of the function */
  83794. exponent?: number);
  83795. /** @hidden */
  83796. easeInCore(gradient: number): number;
  83797. }
  83798. /**
  83799. * Easing function with a power shape (see link below).
  83800. * @see https://easings.net/#easeInQuad
  83801. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83802. */
  83803. export class PowerEase extends EasingFunction implements IEasingFunction {
  83804. /** Defines the power of the function */
  83805. power: number;
  83806. /**
  83807. * Instantiates an power base easing function
  83808. * @see https://easings.net/#easeInQuad
  83809. * @param power Defines the power of the function
  83810. */
  83811. constructor(
  83812. /** Defines the power of the function */
  83813. power?: number);
  83814. /** @hidden */
  83815. easeInCore(gradient: number): number;
  83816. }
  83817. /**
  83818. * Easing function with a power of 2 shape (see link below).
  83819. * @see https://easings.net/#easeInQuad
  83820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83821. */
  83822. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83823. /** @hidden */
  83824. easeInCore(gradient: number): number;
  83825. }
  83826. /**
  83827. * Easing function with a power of 4 shape (see link below).
  83828. * @see https://easings.net/#easeInQuart
  83829. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83830. */
  83831. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83832. /** @hidden */
  83833. easeInCore(gradient: number): number;
  83834. }
  83835. /**
  83836. * Easing function with a power of 5 shape (see link below).
  83837. * @see https://easings.net/#easeInQuint
  83838. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83839. */
  83840. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83841. /** @hidden */
  83842. easeInCore(gradient: number): number;
  83843. }
  83844. /**
  83845. * Easing function with a sin shape (see link below).
  83846. * @see https://easings.net/#easeInSine
  83847. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83848. */
  83849. export class SineEase extends EasingFunction implements IEasingFunction {
  83850. /** @hidden */
  83851. easeInCore(gradient: number): number;
  83852. }
  83853. /**
  83854. * Easing function with a bezier shape (see link below).
  83855. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83856. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83857. */
  83858. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83859. /** Defines the x component of the start tangent in the bezier curve */
  83860. x1: number;
  83861. /** Defines the y component of the start tangent in the bezier curve */
  83862. y1: number;
  83863. /** Defines the x component of the end tangent in the bezier curve */
  83864. x2: number;
  83865. /** Defines the y component of the end tangent in the bezier curve */
  83866. y2: number;
  83867. /**
  83868. * Instantiates a bezier function
  83869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83870. * @param x1 Defines the x component of the start tangent in the bezier curve
  83871. * @param y1 Defines the y component of the start tangent in the bezier curve
  83872. * @param x2 Defines the x component of the end tangent in the bezier curve
  83873. * @param y2 Defines the y component of the end tangent in the bezier curve
  83874. */
  83875. constructor(
  83876. /** Defines the x component of the start tangent in the bezier curve */
  83877. x1?: number,
  83878. /** Defines the y component of the start tangent in the bezier curve */
  83879. y1?: number,
  83880. /** Defines the x component of the end tangent in the bezier curve */
  83881. x2?: number,
  83882. /** Defines the y component of the end tangent in the bezier curve */
  83883. y2?: number);
  83884. /** @hidden */
  83885. easeInCore(gradient: number): number;
  83886. }
  83887. }
  83888. declare module BABYLON {
  83889. /**
  83890. * Class used to hold a RBG color
  83891. */
  83892. export class Color3 {
  83893. /**
  83894. * Defines the red component (between 0 and 1, default is 0)
  83895. */
  83896. r: number;
  83897. /**
  83898. * Defines the green component (between 0 and 1, default is 0)
  83899. */
  83900. g: number;
  83901. /**
  83902. * Defines the blue component (between 0 and 1, default is 0)
  83903. */
  83904. b: number;
  83905. /**
  83906. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83907. * @param r defines the red component (between 0 and 1, default is 0)
  83908. * @param g defines the green component (between 0 and 1, default is 0)
  83909. * @param b defines the blue component (between 0 and 1, default is 0)
  83910. */
  83911. constructor(
  83912. /**
  83913. * Defines the red component (between 0 and 1, default is 0)
  83914. */
  83915. r?: number,
  83916. /**
  83917. * Defines the green component (between 0 and 1, default is 0)
  83918. */
  83919. g?: number,
  83920. /**
  83921. * Defines the blue component (between 0 and 1, default is 0)
  83922. */
  83923. b?: number);
  83924. /**
  83925. * Creates a string with the Color3 current values
  83926. * @returns the string representation of the Color3 object
  83927. */
  83928. toString(): string;
  83929. /**
  83930. * Returns the string "Color3"
  83931. * @returns "Color3"
  83932. */
  83933. getClassName(): string;
  83934. /**
  83935. * Compute the Color3 hash code
  83936. * @returns an unique number that can be used to hash Color3 objects
  83937. */
  83938. getHashCode(): number;
  83939. /**
  83940. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83941. * @param array defines the array where to store the r,g,b components
  83942. * @param index defines an optional index in the target array to define where to start storing values
  83943. * @returns the current Color3 object
  83944. */
  83945. toArray(array: FloatArray, index?: number): Color3;
  83946. /**
  83947. * Returns a new Color4 object from the current Color3 and the given alpha
  83948. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83949. * @returns a new Color4 object
  83950. */
  83951. toColor4(alpha?: number): Color4;
  83952. /**
  83953. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83954. * @returns the new array
  83955. */
  83956. asArray(): number[];
  83957. /**
  83958. * Returns the luminance value
  83959. * @returns a float value
  83960. */
  83961. toLuminance(): number;
  83962. /**
  83963. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83964. * @param otherColor defines the second operand
  83965. * @returns the new Color3 object
  83966. */
  83967. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83968. /**
  83969. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83970. * @param otherColor defines the second operand
  83971. * @param result defines the Color3 object where to store the result
  83972. * @returns the current Color3
  83973. */
  83974. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83975. /**
  83976. * Determines equality between Color3 objects
  83977. * @param otherColor defines the second operand
  83978. * @returns true if the rgb values are equal to the given ones
  83979. */
  83980. equals(otherColor: DeepImmutable<Color3>): boolean;
  83981. /**
  83982. * Determines equality between the current Color3 object and a set of r,b,g values
  83983. * @param r defines the red component to check
  83984. * @param g defines the green component to check
  83985. * @param b defines the blue component to check
  83986. * @returns true if the rgb values are equal to the given ones
  83987. */
  83988. equalsFloats(r: number, g: number, b: number): boolean;
  83989. /**
  83990. * Multiplies in place each rgb value by scale
  83991. * @param scale defines the scaling factor
  83992. * @returns the updated Color3
  83993. */
  83994. scale(scale: number): Color3;
  83995. /**
  83996. * Multiplies the rgb values by scale and stores the result into "result"
  83997. * @param scale defines the scaling factor
  83998. * @param result defines the Color3 object where to store the result
  83999. * @returns the unmodified current Color3
  84000. */
  84001. scaleToRef(scale: number, result: Color3): Color3;
  84002. /**
  84003. * Scale the current Color3 values by a factor and add the result to a given Color3
  84004. * @param scale defines the scale factor
  84005. * @param result defines color to store the result into
  84006. * @returns the unmodified current Color3
  84007. */
  84008. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84009. /**
  84010. * Clamps the rgb values by the min and max values and stores the result into "result"
  84011. * @param min defines minimum clamping value (default is 0)
  84012. * @param max defines maximum clamping value (default is 1)
  84013. * @param result defines color to store the result into
  84014. * @returns the original Color3
  84015. */
  84016. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84017. /**
  84018. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84019. * @param otherColor defines the second operand
  84020. * @returns the new Color3
  84021. */
  84022. add(otherColor: DeepImmutable<Color3>): Color3;
  84023. /**
  84024. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84025. * @param otherColor defines the second operand
  84026. * @param result defines Color3 object to store the result into
  84027. * @returns the unmodified current Color3
  84028. */
  84029. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84030. /**
  84031. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84032. * @param otherColor defines the second operand
  84033. * @returns the new Color3
  84034. */
  84035. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84036. /**
  84037. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84038. * @param otherColor defines the second operand
  84039. * @param result defines Color3 object to store the result into
  84040. * @returns the unmodified current Color3
  84041. */
  84042. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84043. /**
  84044. * Copy the current object
  84045. * @returns a new Color3 copied the current one
  84046. */
  84047. clone(): Color3;
  84048. /**
  84049. * Copies the rgb values from the source in the current Color3
  84050. * @param source defines the source Color3 object
  84051. * @returns the updated Color3 object
  84052. */
  84053. copyFrom(source: DeepImmutable<Color3>): Color3;
  84054. /**
  84055. * Updates the Color3 rgb values from the given floats
  84056. * @param r defines the red component to read from
  84057. * @param g defines the green component to read from
  84058. * @param b defines the blue component to read from
  84059. * @returns the current Color3 object
  84060. */
  84061. copyFromFloats(r: number, g: number, b: number): Color3;
  84062. /**
  84063. * Updates the Color3 rgb values from the given floats
  84064. * @param r defines the red component to read from
  84065. * @param g defines the green component to read from
  84066. * @param b defines the blue component to read from
  84067. * @returns the current Color3 object
  84068. */
  84069. set(r: number, g: number, b: number): Color3;
  84070. /**
  84071. * Compute the Color3 hexadecimal code as a string
  84072. * @returns a string containing the hexadecimal representation of the Color3 object
  84073. */
  84074. toHexString(): string;
  84075. /**
  84076. * Computes a new Color3 converted from the current one to linear space
  84077. * @returns a new Color3 object
  84078. */
  84079. toLinearSpace(): Color3;
  84080. /**
  84081. * Converts current color in rgb space to HSV values
  84082. * @returns a new color3 representing the HSV values
  84083. */
  84084. toHSV(): Color3;
  84085. /**
  84086. * Converts current color in rgb space to HSV values
  84087. * @param result defines the Color3 where to store the HSV values
  84088. */
  84089. toHSVToRef(result: Color3): void;
  84090. /**
  84091. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84092. * @param convertedColor defines the Color3 object where to store the linear space version
  84093. * @returns the unmodified Color3
  84094. */
  84095. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84096. /**
  84097. * Computes a new Color3 converted from the current one to gamma space
  84098. * @returns a new Color3 object
  84099. */
  84100. toGammaSpace(): Color3;
  84101. /**
  84102. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84103. * @param convertedColor defines the Color3 object where to store the gamma space version
  84104. * @returns the unmodified Color3
  84105. */
  84106. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84107. private static _BlackReadOnly;
  84108. /**
  84109. * Convert Hue, saturation and value to a Color3 (RGB)
  84110. * @param hue defines the hue
  84111. * @param saturation defines the saturation
  84112. * @param value defines the value
  84113. * @param result defines the Color3 where to store the RGB values
  84114. */
  84115. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84116. /**
  84117. * Creates a new Color3 from the string containing valid hexadecimal values
  84118. * @param hex defines a string containing valid hexadecimal values
  84119. * @returns a new Color3 object
  84120. */
  84121. static FromHexString(hex: string): Color3;
  84122. /**
  84123. * Creates a new Color3 from the starting index of the given array
  84124. * @param array defines the source array
  84125. * @param offset defines an offset in the source array
  84126. * @returns a new Color3 object
  84127. */
  84128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84129. /**
  84130. * Creates a new Color3 from integer values (< 256)
  84131. * @param r defines the red component to read from (value between 0 and 255)
  84132. * @param g defines the green component to read from (value between 0 and 255)
  84133. * @param b defines the blue component to read from (value between 0 and 255)
  84134. * @returns a new Color3 object
  84135. */
  84136. static FromInts(r: number, g: number, b: number): Color3;
  84137. /**
  84138. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84139. * @param start defines the start Color3 value
  84140. * @param end defines the end Color3 value
  84141. * @param amount defines the gradient value between start and end
  84142. * @returns a new Color3 object
  84143. */
  84144. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84145. /**
  84146. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84147. * @param left defines the start value
  84148. * @param right defines the end value
  84149. * @param amount defines the gradient factor
  84150. * @param result defines the Color3 object where to store the result
  84151. */
  84152. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84153. /**
  84154. * Returns a Color3 value containing a red color
  84155. * @returns a new Color3 object
  84156. */
  84157. static Red(): Color3;
  84158. /**
  84159. * Returns a Color3 value containing a green color
  84160. * @returns a new Color3 object
  84161. */
  84162. static Green(): Color3;
  84163. /**
  84164. * Returns a Color3 value containing a blue color
  84165. * @returns a new Color3 object
  84166. */
  84167. static Blue(): Color3;
  84168. /**
  84169. * Returns a Color3 value containing a black color
  84170. * @returns a new Color3 object
  84171. */
  84172. static Black(): Color3;
  84173. /**
  84174. * Gets a Color3 value containing a black color that must not be updated
  84175. */
  84176. static get BlackReadOnly(): DeepImmutable<Color3>;
  84177. /**
  84178. * Returns a Color3 value containing a white color
  84179. * @returns a new Color3 object
  84180. */
  84181. static White(): Color3;
  84182. /**
  84183. * Returns a Color3 value containing a purple color
  84184. * @returns a new Color3 object
  84185. */
  84186. static Purple(): Color3;
  84187. /**
  84188. * Returns a Color3 value containing a magenta color
  84189. * @returns a new Color3 object
  84190. */
  84191. static Magenta(): Color3;
  84192. /**
  84193. * Returns a Color3 value containing a yellow color
  84194. * @returns a new Color3 object
  84195. */
  84196. static Yellow(): Color3;
  84197. /**
  84198. * Returns a Color3 value containing a gray color
  84199. * @returns a new Color3 object
  84200. */
  84201. static Gray(): Color3;
  84202. /**
  84203. * Returns a Color3 value containing a teal color
  84204. * @returns a new Color3 object
  84205. */
  84206. static Teal(): Color3;
  84207. /**
  84208. * Returns a Color3 value containing a random color
  84209. * @returns a new Color3 object
  84210. */
  84211. static Random(): Color3;
  84212. }
  84213. /**
  84214. * Class used to hold a RBGA color
  84215. */
  84216. export class Color4 {
  84217. /**
  84218. * Defines the red component (between 0 and 1, default is 0)
  84219. */
  84220. r: number;
  84221. /**
  84222. * Defines the green component (between 0 and 1, default is 0)
  84223. */
  84224. g: number;
  84225. /**
  84226. * Defines the blue component (between 0 and 1, default is 0)
  84227. */
  84228. b: number;
  84229. /**
  84230. * Defines the alpha component (between 0 and 1, default is 1)
  84231. */
  84232. a: number;
  84233. /**
  84234. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84235. * @param r defines the red component (between 0 and 1, default is 0)
  84236. * @param g defines the green component (between 0 and 1, default is 0)
  84237. * @param b defines the blue component (between 0 and 1, default is 0)
  84238. * @param a defines the alpha component (between 0 and 1, default is 1)
  84239. */
  84240. constructor(
  84241. /**
  84242. * Defines the red component (between 0 and 1, default is 0)
  84243. */
  84244. r?: number,
  84245. /**
  84246. * Defines the green component (between 0 and 1, default is 0)
  84247. */
  84248. g?: number,
  84249. /**
  84250. * Defines the blue component (between 0 and 1, default is 0)
  84251. */
  84252. b?: number,
  84253. /**
  84254. * Defines the alpha component (between 0 and 1, default is 1)
  84255. */
  84256. a?: number);
  84257. /**
  84258. * Adds in place the given Color4 values to the current Color4 object
  84259. * @param right defines the second operand
  84260. * @returns the current updated Color4 object
  84261. */
  84262. addInPlace(right: DeepImmutable<Color4>): Color4;
  84263. /**
  84264. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84265. * @returns the new array
  84266. */
  84267. asArray(): number[];
  84268. /**
  84269. * Stores from the starting index in the given array the Color4 successive values
  84270. * @param array defines the array where to store the r,g,b components
  84271. * @param index defines an optional index in the target array to define where to start storing values
  84272. * @returns the current Color4 object
  84273. */
  84274. toArray(array: number[], index?: number): Color4;
  84275. /**
  84276. * Determines equality between Color4 objects
  84277. * @param otherColor defines the second operand
  84278. * @returns true if the rgba values are equal to the given ones
  84279. */
  84280. equals(otherColor: DeepImmutable<Color4>): boolean;
  84281. /**
  84282. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84283. * @param right defines the second operand
  84284. * @returns a new Color4 object
  84285. */
  84286. add(right: DeepImmutable<Color4>): Color4;
  84287. /**
  84288. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84289. * @param right defines the second operand
  84290. * @returns a new Color4 object
  84291. */
  84292. subtract(right: DeepImmutable<Color4>): Color4;
  84293. /**
  84294. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84295. * @param right defines the second operand
  84296. * @param result defines the Color4 object where to store the result
  84297. * @returns the current Color4 object
  84298. */
  84299. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84300. /**
  84301. * Creates a new Color4 with the current Color4 values multiplied by scale
  84302. * @param scale defines the scaling factor to apply
  84303. * @returns a new Color4 object
  84304. */
  84305. scale(scale: number): Color4;
  84306. /**
  84307. * Multiplies the current Color4 values by scale and stores the result in "result"
  84308. * @param scale defines the scaling factor to apply
  84309. * @param result defines the Color4 object where to store the result
  84310. * @returns the current unmodified Color4
  84311. */
  84312. scaleToRef(scale: number, result: Color4): Color4;
  84313. /**
  84314. * Scale the current Color4 values by a factor and add the result to a given Color4
  84315. * @param scale defines the scale factor
  84316. * @param result defines the Color4 object where to store the result
  84317. * @returns the unmodified current Color4
  84318. */
  84319. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84320. /**
  84321. * Clamps the rgb values by the min and max values and stores the result into "result"
  84322. * @param min defines minimum clamping value (default is 0)
  84323. * @param max defines maximum clamping value (default is 1)
  84324. * @param result defines color to store the result into.
  84325. * @returns the cuurent Color4
  84326. */
  84327. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84328. /**
  84329. * Multipy an Color4 value by another and return a new Color4 object
  84330. * @param color defines the Color4 value to multiply by
  84331. * @returns a new Color4 object
  84332. */
  84333. multiply(color: Color4): Color4;
  84334. /**
  84335. * Multipy a Color4 value by another and push the result in a reference value
  84336. * @param color defines the Color4 value to multiply by
  84337. * @param result defines the Color4 to fill the result in
  84338. * @returns the result Color4
  84339. */
  84340. multiplyToRef(color: Color4, result: Color4): Color4;
  84341. /**
  84342. * Creates a string with the Color4 current values
  84343. * @returns the string representation of the Color4 object
  84344. */
  84345. toString(): string;
  84346. /**
  84347. * Returns the string "Color4"
  84348. * @returns "Color4"
  84349. */
  84350. getClassName(): string;
  84351. /**
  84352. * Compute the Color4 hash code
  84353. * @returns an unique number that can be used to hash Color4 objects
  84354. */
  84355. getHashCode(): number;
  84356. /**
  84357. * Creates a new Color4 copied from the current one
  84358. * @returns a new Color4 object
  84359. */
  84360. clone(): Color4;
  84361. /**
  84362. * Copies the given Color4 values into the current one
  84363. * @param source defines the source Color4 object
  84364. * @returns the current updated Color4 object
  84365. */
  84366. copyFrom(source: Color4): Color4;
  84367. /**
  84368. * Copies the given float values into the current one
  84369. * @param r defines the red component to read from
  84370. * @param g defines the green component to read from
  84371. * @param b defines the blue component to read from
  84372. * @param a defines the alpha component to read from
  84373. * @returns the current updated Color4 object
  84374. */
  84375. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84376. /**
  84377. * Copies the given float values into the current one
  84378. * @param r defines the red component to read from
  84379. * @param g defines the green component to read from
  84380. * @param b defines the blue component to read from
  84381. * @param a defines the alpha component to read from
  84382. * @returns the current updated Color4 object
  84383. */
  84384. set(r: number, g: number, b: number, a: number): Color4;
  84385. /**
  84386. * Compute the Color4 hexadecimal code as a string
  84387. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84388. * @returns a string containing the hexadecimal representation of the Color4 object
  84389. */
  84390. toHexString(returnAsColor3?: boolean): string;
  84391. /**
  84392. * Computes a new Color4 converted from the current one to linear space
  84393. * @returns a new Color4 object
  84394. */
  84395. toLinearSpace(): Color4;
  84396. /**
  84397. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84398. * @param convertedColor defines the Color4 object where to store the linear space version
  84399. * @returns the unmodified Color4
  84400. */
  84401. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84402. /**
  84403. * Computes a new Color4 converted from the current one to gamma space
  84404. * @returns a new Color4 object
  84405. */
  84406. toGammaSpace(): Color4;
  84407. /**
  84408. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84409. * @param convertedColor defines the Color4 object where to store the gamma space version
  84410. * @returns the unmodified Color4
  84411. */
  84412. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84413. /**
  84414. * Creates a new Color4 from the string containing valid hexadecimal values
  84415. * @param hex defines a string containing valid hexadecimal values
  84416. * @returns a new Color4 object
  84417. */
  84418. static FromHexString(hex: string): Color4;
  84419. /**
  84420. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84421. * @param left defines the start value
  84422. * @param right defines the end value
  84423. * @param amount defines the gradient factor
  84424. * @returns a new Color4 object
  84425. */
  84426. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84427. /**
  84428. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84429. * @param left defines the start value
  84430. * @param right defines the end value
  84431. * @param amount defines the gradient factor
  84432. * @param result defines the Color4 object where to store data
  84433. */
  84434. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84435. /**
  84436. * Creates a new Color4 from a Color3 and an alpha value
  84437. * @param color3 defines the source Color3 to read from
  84438. * @param alpha defines the alpha component (1.0 by default)
  84439. * @returns a new Color4 object
  84440. */
  84441. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84442. /**
  84443. * Creates a new Color4 from the starting index element of the given array
  84444. * @param array defines the source array to read from
  84445. * @param offset defines the offset in the source array
  84446. * @returns a new Color4 object
  84447. */
  84448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84449. /**
  84450. * Creates a new Color3 from integer values (< 256)
  84451. * @param r defines the red component to read from (value between 0 and 255)
  84452. * @param g defines the green component to read from (value between 0 and 255)
  84453. * @param b defines the blue component to read from (value between 0 and 255)
  84454. * @param a defines the alpha component to read from (value between 0 and 255)
  84455. * @returns a new Color3 object
  84456. */
  84457. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84458. /**
  84459. * Check the content of a given array and convert it to an array containing RGBA data
  84460. * If the original array was already containing count * 4 values then it is returned directly
  84461. * @param colors defines the array to check
  84462. * @param count defines the number of RGBA data to expect
  84463. * @returns an array containing count * 4 values (RGBA)
  84464. */
  84465. static CheckColors4(colors: number[], count: number): number[];
  84466. }
  84467. /**
  84468. * @hidden
  84469. */
  84470. export class TmpColors {
  84471. static Color3: Color3[];
  84472. static Color4: Color4[];
  84473. }
  84474. }
  84475. declare module BABYLON {
  84476. /**
  84477. * Defines an interface which represents an animation key frame
  84478. */
  84479. export interface IAnimationKey {
  84480. /**
  84481. * Frame of the key frame
  84482. */
  84483. frame: number;
  84484. /**
  84485. * Value at the specifies key frame
  84486. */
  84487. value: any;
  84488. /**
  84489. * The input tangent for the cubic hermite spline
  84490. */
  84491. inTangent?: any;
  84492. /**
  84493. * The output tangent for the cubic hermite spline
  84494. */
  84495. outTangent?: any;
  84496. /**
  84497. * The animation interpolation type
  84498. */
  84499. interpolation?: AnimationKeyInterpolation;
  84500. }
  84501. /**
  84502. * Enum for the animation key frame interpolation type
  84503. */
  84504. export enum AnimationKeyInterpolation {
  84505. /**
  84506. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84507. */
  84508. STEP = 1
  84509. }
  84510. }
  84511. declare module BABYLON {
  84512. /**
  84513. * Represents the range of an animation
  84514. */
  84515. export class AnimationRange {
  84516. /**The name of the animation range**/
  84517. name: string;
  84518. /**The starting frame of the animation */
  84519. from: number;
  84520. /**The ending frame of the animation*/
  84521. to: number;
  84522. /**
  84523. * Initializes the range of an animation
  84524. * @param name The name of the animation range
  84525. * @param from The starting frame of the animation
  84526. * @param to The ending frame of the animation
  84527. */
  84528. constructor(
  84529. /**The name of the animation range**/
  84530. name: string,
  84531. /**The starting frame of the animation */
  84532. from: number,
  84533. /**The ending frame of the animation*/
  84534. to: number);
  84535. /**
  84536. * Makes a copy of the animation range
  84537. * @returns A copy of the animation range
  84538. */
  84539. clone(): AnimationRange;
  84540. }
  84541. }
  84542. declare module BABYLON {
  84543. /**
  84544. * Composed of a frame, and an action function
  84545. */
  84546. export class AnimationEvent {
  84547. /** The frame for which the event is triggered **/
  84548. frame: number;
  84549. /** The event to perform when triggered **/
  84550. action: (currentFrame: number) => void;
  84551. /** Specifies if the event should be triggered only once**/
  84552. onlyOnce?: boolean | undefined;
  84553. /**
  84554. * Specifies if the animation event is done
  84555. */
  84556. isDone: boolean;
  84557. /**
  84558. * Initializes the animation event
  84559. * @param frame The frame for which the event is triggered
  84560. * @param action The event to perform when triggered
  84561. * @param onlyOnce Specifies if the event should be triggered only once
  84562. */
  84563. constructor(
  84564. /** The frame for which the event is triggered **/
  84565. frame: number,
  84566. /** The event to perform when triggered **/
  84567. action: (currentFrame: number) => void,
  84568. /** Specifies if the event should be triggered only once**/
  84569. onlyOnce?: boolean | undefined);
  84570. /** @hidden */
  84571. _clone(): AnimationEvent;
  84572. }
  84573. }
  84574. declare module BABYLON {
  84575. /**
  84576. * Interface used to define a behavior
  84577. */
  84578. export interface Behavior<T> {
  84579. /** gets or sets behavior's name */
  84580. name: string;
  84581. /**
  84582. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84583. */
  84584. init(): void;
  84585. /**
  84586. * Called when the behavior is attached to a target
  84587. * @param target defines the target where the behavior is attached to
  84588. */
  84589. attach(target: T): void;
  84590. /**
  84591. * Called when the behavior is detached from its target
  84592. */
  84593. detach(): void;
  84594. }
  84595. /**
  84596. * Interface implemented by classes supporting behaviors
  84597. */
  84598. export interface IBehaviorAware<T> {
  84599. /**
  84600. * Attach a behavior
  84601. * @param behavior defines the behavior to attach
  84602. * @returns the current host
  84603. */
  84604. addBehavior(behavior: Behavior<T>): T;
  84605. /**
  84606. * Remove a behavior from the current object
  84607. * @param behavior defines the behavior to detach
  84608. * @returns the current host
  84609. */
  84610. removeBehavior(behavior: Behavior<T>): T;
  84611. /**
  84612. * Gets a behavior using its name to search
  84613. * @param name defines the name to search
  84614. * @returns the behavior or null if not found
  84615. */
  84616. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84617. }
  84618. }
  84619. declare module BABYLON {
  84620. /**
  84621. * Defines an array and its length.
  84622. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84623. */
  84624. export interface ISmartArrayLike<T> {
  84625. /**
  84626. * The data of the array.
  84627. */
  84628. data: Array<T>;
  84629. /**
  84630. * The active length of the array.
  84631. */
  84632. length: number;
  84633. }
  84634. /**
  84635. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84636. */
  84637. export class SmartArray<T> implements ISmartArrayLike<T> {
  84638. /**
  84639. * The full set of data from the array.
  84640. */
  84641. data: Array<T>;
  84642. /**
  84643. * The active length of the array.
  84644. */
  84645. length: number;
  84646. protected _id: number;
  84647. /**
  84648. * Instantiates a Smart Array.
  84649. * @param capacity defines the default capacity of the array.
  84650. */
  84651. constructor(capacity: number);
  84652. /**
  84653. * Pushes a value at the end of the active data.
  84654. * @param value defines the object to push in the array.
  84655. */
  84656. push(value: T): void;
  84657. /**
  84658. * Iterates over the active data and apply the lambda to them.
  84659. * @param func defines the action to apply on each value.
  84660. */
  84661. forEach(func: (content: T) => void): void;
  84662. /**
  84663. * Sorts the full sets of data.
  84664. * @param compareFn defines the comparison function to apply.
  84665. */
  84666. sort(compareFn: (a: T, b: T) => number): void;
  84667. /**
  84668. * Resets the active data to an empty array.
  84669. */
  84670. reset(): void;
  84671. /**
  84672. * Releases all the data from the array as well as the array.
  84673. */
  84674. dispose(): void;
  84675. /**
  84676. * Concats the active data with a given array.
  84677. * @param array defines the data to concatenate with.
  84678. */
  84679. concat(array: any): void;
  84680. /**
  84681. * Returns the position of a value in the active data.
  84682. * @param value defines the value to find the index for
  84683. * @returns the index if found in the active data otherwise -1
  84684. */
  84685. indexOf(value: T): number;
  84686. /**
  84687. * Returns whether an element is part of the active data.
  84688. * @param value defines the value to look for
  84689. * @returns true if found in the active data otherwise false
  84690. */
  84691. contains(value: T): boolean;
  84692. private static _GlobalId;
  84693. }
  84694. /**
  84695. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84696. * The data in this array can only be present once
  84697. */
  84698. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84699. private _duplicateId;
  84700. /**
  84701. * Pushes a value at the end of the active data.
  84702. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84703. * @param value defines the object to push in the array.
  84704. */
  84705. push(value: T): void;
  84706. /**
  84707. * Pushes a value at the end of the active data.
  84708. * If the data is already present, it won t be added again
  84709. * @param value defines the object to push in the array.
  84710. * @returns true if added false if it was already present
  84711. */
  84712. pushNoDuplicate(value: T): boolean;
  84713. /**
  84714. * Resets the active data to an empty array.
  84715. */
  84716. reset(): void;
  84717. /**
  84718. * Concats the active data with a given array.
  84719. * This ensures no dupplicate will be present in the result.
  84720. * @param array defines the data to concatenate with.
  84721. */
  84722. concatWithNoDuplicate(array: any): void;
  84723. }
  84724. }
  84725. declare module BABYLON {
  84726. /**
  84727. * @ignore
  84728. * This is a list of all the different input types that are available in the application.
  84729. * Fo instance: ArcRotateCameraGamepadInput...
  84730. */
  84731. export var CameraInputTypes: {};
  84732. /**
  84733. * This is the contract to implement in order to create a new input class.
  84734. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84735. */
  84736. export interface ICameraInput<TCamera extends Camera> {
  84737. /**
  84738. * Defines the camera the input is attached to.
  84739. */
  84740. camera: Nullable<TCamera>;
  84741. /**
  84742. * Gets the class name of the current intput.
  84743. * @returns the class name
  84744. */
  84745. getClassName(): string;
  84746. /**
  84747. * Get the friendly name associated with the input class.
  84748. * @returns the input friendly name
  84749. */
  84750. getSimpleName(): string;
  84751. /**
  84752. * Attach the input controls to a specific dom element to get the input from.
  84753. * @param element Defines the element the controls should be listened from
  84754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84755. */
  84756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84757. /**
  84758. * Detach the current controls from the specified dom element.
  84759. * @param element Defines the element to stop listening the inputs from
  84760. */
  84761. detachControl(element: Nullable<HTMLElement>): void;
  84762. /**
  84763. * Update the current camera state depending on the inputs that have been used this frame.
  84764. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84765. */
  84766. checkInputs?: () => void;
  84767. }
  84768. /**
  84769. * Represents a map of input types to input instance or input index to input instance.
  84770. */
  84771. export interface CameraInputsMap<TCamera extends Camera> {
  84772. /**
  84773. * Accessor to the input by input type.
  84774. */
  84775. [name: string]: ICameraInput<TCamera>;
  84776. /**
  84777. * Accessor to the input by input index.
  84778. */
  84779. [idx: number]: ICameraInput<TCamera>;
  84780. }
  84781. /**
  84782. * This represents the input manager used within a camera.
  84783. * It helps dealing with all the different kind of input attached to a camera.
  84784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84785. */
  84786. export class CameraInputsManager<TCamera extends Camera> {
  84787. /**
  84788. * Defines the list of inputs attahed to the camera.
  84789. */
  84790. attached: CameraInputsMap<TCamera>;
  84791. /**
  84792. * Defines the dom element the camera is collecting inputs from.
  84793. * This is null if the controls have not been attached.
  84794. */
  84795. attachedElement: Nullable<HTMLElement>;
  84796. /**
  84797. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84798. */
  84799. noPreventDefault: boolean;
  84800. /**
  84801. * Defined the camera the input manager belongs to.
  84802. */
  84803. camera: TCamera;
  84804. /**
  84805. * Update the current camera state depending on the inputs that have been used this frame.
  84806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84807. */
  84808. checkInputs: () => void;
  84809. /**
  84810. * Instantiate a new Camera Input Manager.
  84811. * @param camera Defines the camera the input manager blongs to
  84812. */
  84813. constructor(camera: TCamera);
  84814. /**
  84815. * Add an input method to a camera
  84816. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84817. * @param input camera input method
  84818. */
  84819. add(input: ICameraInput<TCamera>): void;
  84820. /**
  84821. * Remove a specific input method from a camera
  84822. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84823. * @param inputToRemove camera input method
  84824. */
  84825. remove(inputToRemove: ICameraInput<TCamera>): void;
  84826. /**
  84827. * Remove a specific input type from a camera
  84828. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84829. * @param inputType the type of the input to remove
  84830. */
  84831. removeByType(inputType: string): void;
  84832. private _addCheckInputs;
  84833. /**
  84834. * Attach the input controls to the currently attached dom element to listen the events from.
  84835. * @param input Defines the input to attach
  84836. */
  84837. attachInput(input: ICameraInput<TCamera>): void;
  84838. /**
  84839. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84840. * @param element Defines the dom element to collect the events from
  84841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84842. */
  84843. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84844. /**
  84845. * Detach the current manager inputs controls from a specific dom element.
  84846. * @param element Defines the dom element to collect the events from
  84847. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84848. */
  84849. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84850. /**
  84851. * Rebuild the dynamic inputCheck function from the current list of
  84852. * defined inputs in the manager.
  84853. */
  84854. rebuildInputCheck(): void;
  84855. /**
  84856. * Remove all attached input methods from a camera
  84857. */
  84858. clear(): void;
  84859. /**
  84860. * Serialize the current input manager attached to a camera.
  84861. * This ensures than once parsed,
  84862. * the input associated to the camera will be identical to the current ones
  84863. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84864. */
  84865. serialize(serializedCamera: any): void;
  84866. /**
  84867. * Parses an input manager serialized JSON to restore the previous list of inputs
  84868. * and states associated to a camera.
  84869. * @param parsedCamera Defines the JSON to parse
  84870. */
  84871. parse(parsedCamera: any): void;
  84872. }
  84873. }
  84874. declare module BABYLON {
  84875. /**
  84876. * Class used to store data that will be store in GPU memory
  84877. */
  84878. export class Buffer {
  84879. private _engine;
  84880. private _buffer;
  84881. /** @hidden */
  84882. _data: Nullable<DataArray>;
  84883. private _updatable;
  84884. private _instanced;
  84885. private _divisor;
  84886. /**
  84887. * Gets the byte stride.
  84888. */
  84889. readonly byteStride: number;
  84890. /**
  84891. * Constructor
  84892. * @param engine the engine
  84893. * @param data the data to use for this buffer
  84894. * @param updatable whether the data is updatable
  84895. * @param stride the stride (optional)
  84896. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84897. * @param instanced whether the buffer is instanced (optional)
  84898. * @param useBytes set to true if the stride in in bytes (optional)
  84899. * @param divisor sets an optional divisor for instances (1 by default)
  84900. */
  84901. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84902. /**
  84903. * Create a new VertexBuffer based on the current buffer
  84904. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84905. * @param offset defines offset in the buffer (0 by default)
  84906. * @param size defines the size in floats of attributes (position is 3 for instance)
  84907. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84908. * @param instanced defines if the vertex buffer contains indexed data
  84909. * @param useBytes defines if the offset and stride are in bytes *
  84910. * @param divisor sets an optional divisor for instances (1 by default)
  84911. * @returns the new vertex buffer
  84912. */
  84913. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84914. /**
  84915. * Gets a boolean indicating if the Buffer is updatable?
  84916. * @returns true if the buffer is updatable
  84917. */
  84918. isUpdatable(): boolean;
  84919. /**
  84920. * Gets current buffer's data
  84921. * @returns a DataArray or null
  84922. */
  84923. getData(): Nullable<DataArray>;
  84924. /**
  84925. * Gets underlying native buffer
  84926. * @returns underlying native buffer
  84927. */
  84928. getBuffer(): Nullable<DataBuffer>;
  84929. /**
  84930. * Gets the stride in float32 units (i.e. byte stride / 4).
  84931. * May not be an integer if the byte stride is not divisible by 4.
  84932. * @returns the stride in float32 units
  84933. * @deprecated Please use byteStride instead.
  84934. */
  84935. getStrideSize(): number;
  84936. /**
  84937. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84938. * @param data defines the data to store
  84939. */
  84940. create(data?: Nullable<DataArray>): void;
  84941. /** @hidden */
  84942. _rebuild(): void;
  84943. /**
  84944. * Update current buffer data
  84945. * @param data defines the data to store
  84946. */
  84947. update(data: DataArray): void;
  84948. /**
  84949. * Updates the data directly.
  84950. * @param data the new data
  84951. * @param offset the new offset
  84952. * @param vertexCount the vertex count (optional)
  84953. * @param useBytes set to true if the offset is in bytes
  84954. */
  84955. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84956. /**
  84957. * Release all resources
  84958. */
  84959. dispose(): void;
  84960. }
  84961. /**
  84962. * Specialized buffer used to store vertex data
  84963. */
  84964. export class VertexBuffer {
  84965. /** @hidden */
  84966. _buffer: Buffer;
  84967. private _kind;
  84968. private _size;
  84969. private _ownsBuffer;
  84970. private _instanced;
  84971. private _instanceDivisor;
  84972. /**
  84973. * The byte type.
  84974. */
  84975. static readonly BYTE: number;
  84976. /**
  84977. * The unsigned byte type.
  84978. */
  84979. static readonly UNSIGNED_BYTE: number;
  84980. /**
  84981. * The short type.
  84982. */
  84983. static readonly SHORT: number;
  84984. /**
  84985. * The unsigned short type.
  84986. */
  84987. static readonly UNSIGNED_SHORT: number;
  84988. /**
  84989. * The integer type.
  84990. */
  84991. static readonly INT: number;
  84992. /**
  84993. * The unsigned integer type.
  84994. */
  84995. static readonly UNSIGNED_INT: number;
  84996. /**
  84997. * The float type.
  84998. */
  84999. static readonly FLOAT: number;
  85000. /**
  85001. * Gets or sets the instance divisor when in instanced mode
  85002. */
  85003. get instanceDivisor(): number;
  85004. set instanceDivisor(value: number);
  85005. /**
  85006. * Gets the byte stride.
  85007. */
  85008. readonly byteStride: number;
  85009. /**
  85010. * Gets the byte offset.
  85011. */
  85012. readonly byteOffset: number;
  85013. /**
  85014. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85015. */
  85016. readonly normalized: boolean;
  85017. /**
  85018. * Gets the data type of each component in the array.
  85019. */
  85020. readonly type: number;
  85021. /**
  85022. * Constructor
  85023. * @param engine the engine
  85024. * @param data the data to use for this vertex buffer
  85025. * @param kind the vertex buffer kind
  85026. * @param updatable whether the data is updatable
  85027. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85028. * @param stride the stride (optional)
  85029. * @param instanced whether the buffer is instanced (optional)
  85030. * @param offset the offset of the data (optional)
  85031. * @param size the number of components (optional)
  85032. * @param type the type of the component (optional)
  85033. * @param normalized whether the data contains normalized data (optional)
  85034. * @param useBytes set to true if stride and offset are in bytes (optional)
  85035. * @param divisor defines the instance divisor to use (1 by default)
  85036. */
  85037. 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);
  85038. /** @hidden */
  85039. _rebuild(): void;
  85040. /**
  85041. * Returns the kind of the VertexBuffer (string)
  85042. * @returns a string
  85043. */
  85044. getKind(): string;
  85045. /**
  85046. * Gets a boolean indicating if the VertexBuffer is updatable?
  85047. * @returns true if the buffer is updatable
  85048. */
  85049. isUpdatable(): boolean;
  85050. /**
  85051. * Gets current buffer's data
  85052. * @returns a DataArray or null
  85053. */
  85054. getData(): Nullable<DataArray>;
  85055. /**
  85056. * Gets underlying native buffer
  85057. * @returns underlying native buffer
  85058. */
  85059. getBuffer(): Nullable<DataBuffer>;
  85060. /**
  85061. * Gets the stride in float32 units (i.e. byte stride / 4).
  85062. * May not be an integer if the byte stride is not divisible by 4.
  85063. * @returns the stride in float32 units
  85064. * @deprecated Please use byteStride instead.
  85065. */
  85066. getStrideSize(): number;
  85067. /**
  85068. * Returns the offset as a multiple of the type byte length.
  85069. * @returns the offset in bytes
  85070. * @deprecated Please use byteOffset instead.
  85071. */
  85072. getOffset(): number;
  85073. /**
  85074. * Returns the number of components per vertex attribute (integer)
  85075. * @returns the size in float
  85076. */
  85077. getSize(): number;
  85078. /**
  85079. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85080. * @returns true if this buffer is instanced
  85081. */
  85082. getIsInstanced(): boolean;
  85083. /**
  85084. * Returns the instancing divisor, zero for non-instanced (integer).
  85085. * @returns a number
  85086. */
  85087. getInstanceDivisor(): number;
  85088. /**
  85089. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85090. * @param data defines the data to store
  85091. */
  85092. create(data?: DataArray): void;
  85093. /**
  85094. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85095. * This function will create a new buffer if the current one is not updatable
  85096. * @param data defines the data to store
  85097. */
  85098. update(data: DataArray): void;
  85099. /**
  85100. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85101. * Returns the directly updated WebGLBuffer.
  85102. * @param data the new data
  85103. * @param offset the new offset
  85104. * @param useBytes set to true if the offset is in bytes
  85105. */
  85106. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85107. /**
  85108. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85109. */
  85110. dispose(): void;
  85111. /**
  85112. * Enumerates each value of this vertex buffer as numbers.
  85113. * @param count the number of values to enumerate
  85114. * @param callback the callback function called for each value
  85115. */
  85116. forEach(count: number, callback: (value: number, index: number) => void): void;
  85117. /**
  85118. * Positions
  85119. */
  85120. static readonly PositionKind: string;
  85121. /**
  85122. * Normals
  85123. */
  85124. static readonly NormalKind: string;
  85125. /**
  85126. * Tangents
  85127. */
  85128. static readonly TangentKind: string;
  85129. /**
  85130. * Texture coordinates
  85131. */
  85132. static readonly UVKind: string;
  85133. /**
  85134. * Texture coordinates 2
  85135. */
  85136. static readonly UV2Kind: string;
  85137. /**
  85138. * Texture coordinates 3
  85139. */
  85140. static readonly UV3Kind: string;
  85141. /**
  85142. * Texture coordinates 4
  85143. */
  85144. static readonly UV4Kind: string;
  85145. /**
  85146. * Texture coordinates 5
  85147. */
  85148. static readonly UV5Kind: string;
  85149. /**
  85150. * Texture coordinates 6
  85151. */
  85152. static readonly UV6Kind: string;
  85153. /**
  85154. * Colors
  85155. */
  85156. static readonly ColorKind: string;
  85157. /**
  85158. * Matrix indices (for bones)
  85159. */
  85160. static readonly MatricesIndicesKind: string;
  85161. /**
  85162. * Matrix weights (for bones)
  85163. */
  85164. static readonly MatricesWeightsKind: string;
  85165. /**
  85166. * Additional matrix indices (for bones)
  85167. */
  85168. static readonly MatricesIndicesExtraKind: string;
  85169. /**
  85170. * Additional matrix weights (for bones)
  85171. */
  85172. static readonly MatricesWeightsExtraKind: string;
  85173. /**
  85174. * Deduces the stride given a kind.
  85175. * @param kind The kind string to deduce
  85176. * @returns The deduced stride
  85177. */
  85178. static DeduceStride(kind: string): number;
  85179. /**
  85180. * Gets the byte length of the given type.
  85181. * @param type the type
  85182. * @returns the number of bytes
  85183. */
  85184. static GetTypeByteLength(type: number): number;
  85185. /**
  85186. * Enumerates each value of the given parameters as numbers.
  85187. * @param data the data to enumerate
  85188. * @param byteOffset the byte offset of the data
  85189. * @param byteStride the byte stride of the data
  85190. * @param componentCount the number of components per element
  85191. * @param componentType the type of the component
  85192. * @param count the number of values to enumerate
  85193. * @param normalized whether the data is normalized
  85194. * @param callback the callback function called for each value
  85195. */
  85196. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85197. private static _GetFloatValue;
  85198. }
  85199. }
  85200. declare module BABYLON {
  85201. /**
  85202. * @hidden
  85203. */
  85204. export class IntersectionInfo {
  85205. bu: Nullable<number>;
  85206. bv: Nullable<number>;
  85207. distance: number;
  85208. faceId: number;
  85209. subMeshId: number;
  85210. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85211. }
  85212. }
  85213. declare module BABYLON {
  85214. /**
  85215. * Class used to store bounding sphere information
  85216. */
  85217. export class BoundingSphere {
  85218. /**
  85219. * Gets the center of the bounding sphere in local space
  85220. */
  85221. readonly center: Vector3;
  85222. /**
  85223. * Radius of the bounding sphere in local space
  85224. */
  85225. radius: number;
  85226. /**
  85227. * Gets the center of the bounding sphere in world space
  85228. */
  85229. readonly centerWorld: Vector3;
  85230. /**
  85231. * Radius of the bounding sphere in world space
  85232. */
  85233. radiusWorld: number;
  85234. /**
  85235. * Gets the minimum vector in local space
  85236. */
  85237. readonly minimum: Vector3;
  85238. /**
  85239. * Gets the maximum vector in local space
  85240. */
  85241. readonly maximum: Vector3;
  85242. private _worldMatrix;
  85243. private static readonly TmpVector3;
  85244. /**
  85245. * Creates a new bounding sphere
  85246. * @param min defines the minimum vector (in local space)
  85247. * @param max defines the maximum vector (in local space)
  85248. * @param worldMatrix defines the new world matrix
  85249. */
  85250. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85251. /**
  85252. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85253. * @param min defines the new minimum vector (in local space)
  85254. * @param max defines the new maximum vector (in local space)
  85255. * @param worldMatrix defines the new world matrix
  85256. */
  85257. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85258. /**
  85259. * Scale the current bounding sphere by applying a scale factor
  85260. * @param factor defines the scale factor to apply
  85261. * @returns the current bounding box
  85262. */
  85263. scale(factor: number): BoundingSphere;
  85264. /**
  85265. * Gets the world matrix of the bounding box
  85266. * @returns a matrix
  85267. */
  85268. getWorldMatrix(): DeepImmutable<Matrix>;
  85269. /** @hidden */
  85270. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85271. /**
  85272. * Tests if the bounding sphere is intersecting the frustum planes
  85273. * @param frustumPlanes defines the frustum planes to test
  85274. * @returns true if there is an intersection
  85275. */
  85276. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85277. /**
  85278. * Tests if the bounding sphere center is in between the frustum planes.
  85279. * Used for optimistic fast inclusion.
  85280. * @param frustumPlanes defines the frustum planes to test
  85281. * @returns true if the sphere center is in between the frustum planes
  85282. */
  85283. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85284. /**
  85285. * Tests if a point is inside the bounding sphere
  85286. * @param point defines the point to test
  85287. * @returns true if the point is inside the bounding sphere
  85288. */
  85289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85290. /**
  85291. * Checks if two sphere intersct
  85292. * @param sphere0 sphere 0
  85293. * @param sphere1 sphere 1
  85294. * @returns true if the speres intersect
  85295. */
  85296. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85297. }
  85298. }
  85299. declare module BABYLON {
  85300. /**
  85301. * Class used to store bounding box information
  85302. */
  85303. export class BoundingBox implements ICullable {
  85304. /**
  85305. * Gets the 8 vectors representing the bounding box in local space
  85306. */
  85307. readonly vectors: Vector3[];
  85308. /**
  85309. * Gets the center of the bounding box in local space
  85310. */
  85311. readonly center: Vector3;
  85312. /**
  85313. * Gets the center of the bounding box in world space
  85314. */
  85315. readonly centerWorld: Vector3;
  85316. /**
  85317. * Gets the extend size in local space
  85318. */
  85319. readonly extendSize: Vector3;
  85320. /**
  85321. * Gets the extend size in world space
  85322. */
  85323. readonly extendSizeWorld: Vector3;
  85324. /**
  85325. * Gets the OBB (object bounding box) directions
  85326. */
  85327. readonly directions: Vector3[];
  85328. /**
  85329. * Gets the 8 vectors representing the bounding box in world space
  85330. */
  85331. readonly vectorsWorld: Vector3[];
  85332. /**
  85333. * Gets the minimum vector in world space
  85334. */
  85335. readonly minimumWorld: Vector3;
  85336. /**
  85337. * Gets the maximum vector in world space
  85338. */
  85339. readonly maximumWorld: Vector3;
  85340. /**
  85341. * Gets the minimum vector in local space
  85342. */
  85343. readonly minimum: Vector3;
  85344. /**
  85345. * Gets the maximum vector in local space
  85346. */
  85347. readonly maximum: Vector3;
  85348. private _worldMatrix;
  85349. private static readonly TmpVector3;
  85350. /**
  85351. * @hidden
  85352. */
  85353. _tag: number;
  85354. /**
  85355. * Creates a new bounding box
  85356. * @param min defines the minimum vector (in local space)
  85357. * @param max defines the maximum vector (in local space)
  85358. * @param worldMatrix defines the new world matrix
  85359. */
  85360. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85361. /**
  85362. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85363. * @param min defines the new minimum vector (in local space)
  85364. * @param max defines the new maximum vector (in local space)
  85365. * @param worldMatrix defines the new world matrix
  85366. */
  85367. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85368. /**
  85369. * Scale the current bounding box by applying a scale factor
  85370. * @param factor defines the scale factor to apply
  85371. * @returns the current bounding box
  85372. */
  85373. scale(factor: number): BoundingBox;
  85374. /**
  85375. * Gets the world matrix of the bounding box
  85376. * @returns a matrix
  85377. */
  85378. getWorldMatrix(): DeepImmutable<Matrix>;
  85379. /** @hidden */
  85380. _update(world: DeepImmutable<Matrix>): void;
  85381. /**
  85382. * Tests if the bounding box is intersecting the frustum planes
  85383. * @param frustumPlanes defines the frustum planes to test
  85384. * @returns true if there is an intersection
  85385. */
  85386. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85387. /**
  85388. * Tests if the bounding box is entirely inside the frustum planes
  85389. * @param frustumPlanes defines the frustum planes to test
  85390. * @returns true if there is an inclusion
  85391. */
  85392. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85393. /**
  85394. * Tests if a point is inside the bounding box
  85395. * @param point defines the point to test
  85396. * @returns true if the point is inside the bounding box
  85397. */
  85398. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85399. /**
  85400. * Tests if the bounding box intersects with a bounding sphere
  85401. * @param sphere defines the sphere to test
  85402. * @returns true if there is an intersection
  85403. */
  85404. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85405. /**
  85406. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85407. * @param min defines the min vector to use
  85408. * @param max defines the max vector to use
  85409. * @returns true if there is an intersection
  85410. */
  85411. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85412. /**
  85413. * Tests if two bounding boxes are intersections
  85414. * @param box0 defines the first box to test
  85415. * @param box1 defines the second box to test
  85416. * @returns true if there is an intersection
  85417. */
  85418. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85419. /**
  85420. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85421. * @param minPoint defines the minimum vector of the bounding box
  85422. * @param maxPoint defines the maximum vector of the bounding box
  85423. * @param sphereCenter defines the sphere center
  85424. * @param sphereRadius defines the sphere radius
  85425. * @returns true if there is an intersection
  85426. */
  85427. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85428. /**
  85429. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85430. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85431. * @param frustumPlanes defines the frustum planes to test
  85432. * @return true if there is an inclusion
  85433. */
  85434. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85435. /**
  85436. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85437. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85438. * @param frustumPlanes defines the frustum planes to test
  85439. * @return true if there is an intersection
  85440. */
  85441. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85442. }
  85443. }
  85444. declare module BABYLON {
  85445. /** @hidden */
  85446. export class Collider {
  85447. /** Define if a collision was found */
  85448. collisionFound: boolean;
  85449. /**
  85450. * Define last intersection point in local space
  85451. */
  85452. intersectionPoint: Vector3;
  85453. /**
  85454. * Define last collided mesh
  85455. */
  85456. collidedMesh: Nullable<AbstractMesh>;
  85457. private _collisionPoint;
  85458. private _planeIntersectionPoint;
  85459. private _tempVector;
  85460. private _tempVector2;
  85461. private _tempVector3;
  85462. private _tempVector4;
  85463. private _edge;
  85464. private _baseToVertex;
  85465. private _destinationPoint;
  85466. private _slidePlaneNormal;
  85467. private _displacementVector;
  85468. /** @hidden */
  85469. _radius: Vector3;
  85470. /** @hidden */
  85471. _retry: number;
  85472. private _velocity;
  85473. private _basePoint;
  85474. private _epsilon;
  85475. /** @hidden */
  85476. _velocityWorldLength: number;
  85477. /** @hidden */
  85478. _basePointWorld: Vector3;
  85479. private _velocityWorld;
  85480. private _normalizedVelocity;
  85481. /** @hidden */
  85482. _initialVelocity: Vector3;
  85483. /** @hidden */
  85484. _initialPosition: Vector3;
  85485. private _nearestDistance;
  85486. private _collisionMask;
  85487. get collisionMask(): number;
  85488. set collisionMask(mask: number);
  85489. /**
  85490. * Gets the plane normal used to compute the sliding response (in local space)
  85491. */
  85492. get slidePlaneNormal(): Vector3;
  85493. /** @hidden */
  85494. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85495. /** @hidden */
  85496. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85497. /** @hidden */
  85498. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85499. /** @hidden */
  85500. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85501. /** @hidden */
  85502. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85503. /** @hidden */
  85504. _getResponse(pos: Vector3, vel: Vector3): void;
  85505. }
  85506. }
  85507. declare module BABYLON {
  85508. /**
  85509. * Interface for cullable objects
  85510. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85511. */
  85512. export interface ICullable {
  85513. /**
  85514. * Checks if the object or part of the object is in the frustum
  85515. * @param frustumPlanes Camera near/planes
  85516. * @returns true if the object is in frustum otherwise false
  85517. */
  85518. isInFrustum(frustumPlanes: Plane[]): boolean;
  85519. /**
  85520. * Checks if a cullable object (mesh...) is in the camera frustum
  85521. * Unlike isInFrustum this cheks the full bounding box
  85522. * @param frustumPlanes Camera near/planes
  85523. * @returns true if the object is in frustum otherwise false
  85524. */
  85525. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85526. }
  85527. /**
  85528. * Info for a bounding data of a mesh
  85529. */
  85530. export class BoundingInfo implements ICullable {
  85531. /**
  85532. * Bounding box for the mesh
  85533. */
  85534. readonly boundingBox: BoundingBox;
  85535. /**
  85536. * Bounding sphere for the mesh
  85537. */
  85538. readonly boundingSphere: BoundingSphere;
  85539. private _isLocked;
  85540. private static readonly TmpVector3;
  85541. /**
  85542. * Constructs bounding info
  85543. * @param minimum min vector of the bounding box/sphere
  85544. * @param maximum max vector of the bounding box/sphere
  85545. * @param worldMatrix defines the new world matrix
  85546. */
  85547. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85548. /**
  85549. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85550. * @param min defines the new minimum vector (in local space)
  85551. * @param max defines the new maximum vector (in local space)
  85552. * @param worldMatrix defines the new world matrix
  85553. */
  85554. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85555. /**
  85556. * min vector of the bounding box/sphere
  85557. */
  85558. get minimum(): Vector3;
  85559. /**
  85560. * max vector of the bounding box/sphere
  85561. */
  85562. get maximum(): Vector3;
  85563. /**
  85564. * If the info is locked and won't be updated to avoid perf overhead
  85565. */
  85566. get isLocked(): boolean;
  85567. set isLocked(value: boolean);
  85568. /**
  85569. * Updates the bounding sphere and box
  85570. * @param world world matrix to be used to update
  85571. */
  85572. update(world: DeepImmutable<Matrix>): void;
  85573. /**
  85574. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85575. * @param center New center of the bounding info
  85576. * @param extend New extend of the bounding info
  85577. * @returns the current bounding info
  85578. */
  85579. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85580. /**
  85581. * Scale the current bounding info by applying a scale factor
  85582. * @param factor defines the scale factor to apply
  85583. * @returns the current bounding info
  85584. */
  85585. scale(factor: number): BoundingInfo;
  85586. /**
  85587. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85588. * @param frustumPlanes defines the frustum to test
  85589. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85590. * @returns true if the bounding info is in the frustum planes
  85591. */
  85592. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85593. /**
  85594. * Gets the world distance between the min and max points of the bounding box
  85595. */
  85596. get diagonalLength(): number;
  85597. /**
  85598. * Checks if a cullable object (mesh...) is in the camera frustum
  85599. * Unlike isInFrustum this cheks the full bounding box
  85600. * @param frustumPlanes Camera near/planes
  85601. * @returns true if the object is in frustum otherwise false
  85602. */
  85603. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85604. /** @hidden */
  85605. _checkCollision(collider: Collider): boolean;
  85606. /**
  85607. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85608. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85609. * @param point the point to check intersection with
  85610. * @returns if the point intersects
  85611. */
  85612. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85613. /**
  85614. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85615. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85616. * @param boundingInfo the bounding info to check intersection with
  85617. * @param precise if the intersection should be done using OBB
  85618. * @returns if the bounding info intersects
  85619. */
  85620. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85621. }
  85622. }
  85623. declare module BABYLON {
  85624. /**
  85625. * Extracts minimum and maximum values from a list of indexed positions
  85626. * @param positions defines the positions to use
  85627. * @param indices defines the indices to the positions
  85628. * @param indexStart defines the start index
  85629. * @param indexCount defines the end index
  85630. * @param bias defines bias value to add to the result
  85631. * @return minimum and maximum values
  85632. */
  85633. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85634. minimum: Vector3;
  85635. maximum: Vector3;
  85636. };
  85637. /**
  85638. * Extracts minimum and maximum values from a list of positions
  85639. * @param positions defines the positions to use
  85640. * @param start defines the start index in the positions array
  85641. * @param count defines the number of positions to handle
  85642. * @param bias defines bias value to add to the result
  85643. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85644. * @return minimum and maximum values
  85645. */
  85646. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85647. minimum: Vector3;
  85648. maximum: Vector3;
  85649. };
  85650. }
  85651. declare module BABYLON {
  85652. /** @hidden */
  85653. export class WebGLDataBuffer extends DataBuffer {
  85654. private _buffer;
  85655. constructor(resource: WebGLBuffer);
  85656. get underlyingResource(): any;
  85657. }
  85658. }
  85659. declare module BABYLON {
  85660. /** @hidden */
  85661. export class WebGLPipelineContext implements IPipelineContext {
  85662. engine: ThinEngine;
  85663. program: Nullable<WebGLProgram>;
  85664. context?: WebGLRenderingContext;
  85665. vertexShader?: WebGLShader;
  85666. fragmentShader?: WebGLShader;
  85667. isParallelCompiled: boolean;
  85668. onCompiled?: () => void;
  85669. transformFeedback?: WebGLTransformFeedback | null;
  85670. vertexCompilationError: Nullable<string>;
  85671. fragmentCompilationError: Nullable<string>;
  85672. programLinkError: Nullable<string>;
  85673. programValidationError: Nullable<string>;
  85674. get isAsync(): boolean;
  85675. get isReady(): boolean;
  85676. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85677. _getVertexShaderCode(): string | null;
  85678. _getFragmentShaderCode(): string | null;
  85679. }
  85680. }
  85681. declare module BABYLON {
  85682. interface ThinEngine {
  85683. /**
  85684. * Create an uniform buffer
  85685. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85686. * @param elements defines the content of the uniform buffer
  85687. * @returns the webGL uniform buffer
  85688. */
  85689. createUniformBuffer(elements: FloatArray): DataBuffer;
  85690. /**
  85691. * Create a dynamic uniform buffer
  85692. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85693. * @param elements defines the content of the uniform buffer
  85694. * @returns the webGL uniform buffer
  85695. */
  85696. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85697. /**
  85698. * Update an existing uniform buffer
  85699. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85700. * @param uniformBuffer defines the target uniform buffer
  85701. * @param elements defines the content to update
  85702. * @param offset defines the offset in the uniform buffer where update should start
  85703. * @param count defines the size of the data to update
  85704. */
  85705. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85706. /**
  85707. * Bind an uniform buffer to the current webGL context
  85708. * @param buffer defines the buffer to bind
  85709. */
  85710. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85711. /**
  85712. * Bind a buffer to the current webGL context at a given location
  85713. * @param buffer defines the buffer to bind
  85714. * @param location defines the index where to bind the buffer
  85715. */
  85716. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85717. /**
  85718. * Bind a specific block at a given index in a specific shader program
  85719. * @param pipelineContext defines the pipeline context to use
  85720. * @param blockName defines the block name
  85721. * @param index defines the index where to bind the block
  85722. */
  85723. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85724. }
  85725. }
  85726. declare module BABYLON {
  85727. /**
  85728. * Uniform buffer objects.
  85729. *
  85730. * Handles blocks of uniform on the GPU.
  85731. *
  85732. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85733. *
  85734. * For more information, please refer to :
  85735. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85736. */
  85737. export class UniformBuffer {
  85738. private _engine;
  85739. private _buffer;
  85740. private _data;
  85741. private _bufferData;
  85742. private _dynamic?;
  85743. private _uniformLocations;
  85744. private _uniformSizes;
  85745. private _uniformLocationPointer;
  85746. private _needSync;
  85747. private _noUBO;
  85748. private _currentEffect;
  85749. /** @hidden */
  85750. _alreadyBound: boolean;
  85751. private static _MAX_UNIFORM_SIZE;
  85752. private static _tempBuffer;
  85753. /**
  85754. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85755. * This is dynamic to allow compat with webgl 1 and 2.
  85756. * You will need to pass the name of the uniform as well as the value.
  85757. */
  85758. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85759. /**
  85760. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85761. * This is dynamic to allow compat with webgl 1 and 2.
  85762. * You will need to pass the name of the uniform as well as the value.
  85763. */
  85764. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85765. /**
  85766. * Lambda to Update a single float in a uniform buffer.
  85767. * This is dynamic to allow compat with webgl 1 and 2.
  85768. * You will need to pass the name of the uniform as well as the value.
  85769. */
  85770. updateFloat: (name: string, x: number) => void;
  85771. /**
  85772. * Lambda to Update a vec2 of float in a uniform buffer.
  85773. * This is dynamic to allow compat with webgl 1 and 2.
  85774. * You will need to pass the name of the uniform as well as the value.
  85775. */
  85776. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85777. /**
  85778. * Lambda to Update a vec3 of float in a uniform buffer.
  85779. * This is dynamic to allow compat with webgl 1 and 2.
  85780. * You will need to pass the name of the uniform as well as the value.
  85781. */
  85782. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85783. /**
  85784. * Lambda to Update a vec4 of float in a uniform buffer.
  85785. * This is dynamic to allow compat with webgl 1 and 2.
  85786. * You will need to pass the name of the uniform as well as the value.
  85787. */
  85788. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85789. /**
  85790. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85791. * This is dynamic to allow compat with webgl 1 and 2.
  85792. * You will need to pass the name of the uniform as well as the value.
  85793. */
  85794. updateMatrix: (name: string, mat: Matrix) => void;
  85795. /**
  85796. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85797. * This is dynamic to allow compat with webgl 1 and 2.
  85798. * You will need to pass the name of the uniform as well as the value.
  85799. */
  85800. updateVector3: (name: string, vector: Vector3) => void;
  85801. /**
  85802. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85803. * This is dynamic to allow compat with webgl 1 and 2.
  85804. * You will need to pass the name of the uniform as well as the value.
  85805. */
  85806. updateVector4: (name: string, vector: Vector4) => void;
  85807. /**
  85808. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85809. * This is dynamic to allow compat with webgl 1 and 2.
  85810. * You will need to pass the name of the uniform as well as the value.
  85811. */
  85812. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85813. /**
  85814. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85815. * This is dynamic to allow compat with webgl 1 and 2.
  85816. * You will need to pass the name of the uniform as well as the value.
  85817. */
  85818. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85819. /**
  85820. * Instantiates a new Uniform buffer objects.
  85821. *
  85822. * Handles blocks of uniform on the GPU.
  85823. *
  85824. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85825. *
  85826. * For more information, please refer to :
  85827. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85828. * @param engine Define the engine the buffer is associated with
  85829. * @param data Define the data contained in the buffer
  85830. * @param dynamic Define if the buffer is updatable
  85831. */
  85832. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85833. /**
  85834. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85835. * or just falling back on setUniformXXX calls.
  85836. */
  85837. get useUbo(): boolean;
  85838. /**
  85839. * Indicates if the WebGL underlying uniform buffer is in sync
  85840. * with the javascript cache data.
  85841. */
  85842. get isSync(): boolean;
  85843. /**
  85844. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85845. * Also, a dynamic UniformBuffer will disable cache verification and always
  85846. * update the underlying WebGL uniform buffer to the GPU.
  85847. * @returns if Dynamic, otherwise false
  85848. */
  85849. isDynamic(): boolean;
  85850. /**
  85851. * The data cache on JS side.
  85852. * @returns the underlying data as a float array
  85853. */
  85854. getData(): Float32Array;
  85855. /**
  85856. * The underlying WebGL Uniform buffer.
  85857. * @returns the webgl buffer
  85858. */
  85859. getBuffer(): Nullable<DataBuffer>;
  85860. /**
  85861. * std140 layout specifies how to align data within an UBO structure.
  85862. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85863. * for specs.
  85864. */
  85865. private _fillAlignment;
  85866. /**
  85867. * Adds an uniform in the buffer.
  85868. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85869. * for the layout to be correct !
  85870. * @param name Name of the uniform, as used in the uniform block in the shader.
  85871. * @param size Data size, or data directly.
  85872. */
  85873. addUniform(name: string, size: number | number[]): void;
  85874. /**
  85875. * Adds a Matrix 4x4 to the uniform buffer.
  85876. * @param name Name of the uniform, as used in the uniform block in the shader.
  85877. * @param mat A 4x4 matrix.
  85878. */
  85879. addMatrix(name: string, mat: Matrix): void;
  85880. /**
  85881. * Adds a vec2 to the uniform buffer.
  85882. * @param name Name of the uniform, as used in the uniform block in the shader.
  85883. * @param x Define the x component value of the vec2
  85884. * @param y Define the y component value of the vec2
  85885. */
  85886. addFloat2(name: string, x: number, y: number): void;
  85887. /**
  85888. * Adds a vec3 to the uniform buffer.
  85889. * @param name Name of the uniform, as used in the uniform block in the shader.
  85890. * @param x Define the x component value of the vec3
  85891. * @param y Define the y component value of the vec3
  85892. * @param z Define the z component value of the vec3
  85893. */
  85894. addFloat3(name: string, x: number, y: number, z: number): void;
  85895. /**
  85896. * Adds a vec3 to the uniform buffer.
  85897. * @param name Name of the uniform, as used in the uniform block in the shader.
  85898. * @param color Define the vec3 from a Color
  85899. */
  85900. addColor3(name: string, color: Color3): void;
  85901. /**
  85902. * Adds a vec4 to the uniform buffer.
  85903. * @param name Name of the uniform, as used in the uniform block in the shader.
  85904. * @param color Define the rgb components from a Color
  85905. * @param alpha Define the a component of the vec4
  85906. */
  85907. addColor4(name: string, color: Color3, alpha: number): void;
  85908. /**
  85909. * Adds a vec3 to the uniform buffer.
  85910. * @param name Name of the uniform, as used in the uniform block in the shader.
  85911. * @param vector Define the vec3 components from a Vector
  85912. */
  85913. addVector3(name: string, vector: Vector3): void;
  85914. /**
  85915. * Adds a Matrix 3x3 to the uniform buffer.
  85916. * @param name Name of the uniform, as used in the uniform block in the shader.
  85917. */
  85918. addMatrix3x3(name: string): void;
  85919. /**
  85920. * Adds a Matrix 2x2 to the uniform buffer.
  85921. * @param name Name of the uniform, as used in the uniform block in the shader.
  85922. */
  85923. addMatrix2x2(name: string): void;
  85924. /**
  85925. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85926. */
  85927. create(): void;
  85928. /** @hidden */
  85929. _rebuild(): void;
  85930. /**
  85931. * Updates the WebGL Uniform Buffer on the GPU.
  85932. * If the `dynamic` flag is set to true, no cache comparison is done.
  85933. * Otherwise, the buffer will be updated only if the cache differs.
  85934. */
  85935. update(): void;
  85936. /**
  85937. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85938. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85939. * @param data Define the flattened data
  85940. * @param size Define the size of the data.
  85941. */
  85942. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85943. private _valueCache;
  85944. private _cacheMatrix;
  85945. private _updateMatrix3x3ForUniform;
  85946. private _updateMatrix3x3ForEffect;
  85947. private _updateMatrix2x2ForEffect;
  85948. private _updateMatrix2x2ForUniform;
  85949. private _updateFloatForEffect;
  85950. private _updateFloatForUniform;
  85951. private _updateFloat2ForEffect;
  85952. private _updateFloat2ForUniform;
  85953. private _updateFloat3ForEffect;
  85954. private _updateFloat3ForUniform;
  85955. private _updateFloat4ForEffect;
  85956. private _updateFloat4ForUniform;
  85957. private _updateMatrixForEffect;
  85958. private _updateMatrixForUniform;
  85959. private _updateVector3ForEffect;
  85960. private _updateVector3ForUniform;
  85961. private _updateVector4ForEffect;
  85962. private _updateVector4ForUniform;
  85963. private _updateColor3ForEffect;
  85964. private _updateColor3ForUniform;
  85965. private _updateColor4ForEffect;
  85966. private _updateColor4ForUniform;
  85967. /**
  85968. * Sets a sampler uniform on the effect.
  85969. * @param name Define the name of the sampler.
  85970. * @param texture Define the texture to set in the sampler
  85971. */
  85972. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85973. /**
  85974. * Directly updates the value of the uniform in the cache AND on the GPU.
  85975. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85976. * @param data Define the flattened data
  85977. */
  85978. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85979. /**
  85980. * Binds this uniform buffer to an effect.
  85981. * @param effect Define the effect to bind the buffer to
  85982. * @param name Name of the uniform block in the shader.
  85983. */
  85984. bindToEffect(effect: Effect, name: string): void;
  85985. /**
  85986. * Disposes the uniform buffer.
  85987. */
  85988. dispose(): void;
  85989. }
  85990. }
  85991. declare module BABYLON {
  85992. /**
  85993. * Enum that determines the text-wrapping mode to use.
  85994. */
  85995. export enum InspectableType {
  85996. /**
  85997. * Checkbox for booleans
  85998. */
  85999. Checkbox = 0,
  86000. /**
  86001. * Sliders for numbers
  86002. */
  86003. Slider = 1,
  86004. /**
  86005. * Vector3
  86006. */
  86007. Vector3 = 2,
  86008. /**
  86009. * Quaternions
  86010. */
  86011. Quaternion = 3,
  86012. /**
  86013. * Color3
  86014. */
  86015. Color3 = 4,
  86016. /**
  86017. * String
  86018. */
  86019. String = 5
  86020. }
  86021. /**
  86022. * Interface used to define custom inspectable properties.
  86023. * This interface is used by the inspector to display custom property grids
  86024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86025. */
  86026. export interface IInspectable {
  86027. /**
  86028. * Gets the label to display
  86029. */
  86030. label: string;
  86031. /**
  86032. * Gets the name of the property to edit
  86033. */
  86034. propertyName: string;
  86035. /**
  86036. * Gets the type of the editor to use
  86037. */
  86038. type: InspectableType;
  86039. /**
  86040. * Gets the minimum value of the property when using in "slider" mode
  86041. */
  86042. min?: number;
  86043. /**
  86044. * Gets the maximum value of the property when using in "slider" mode
  86045. */
  86046. max?: number;
  86047. /**
  86048. * Gets the setp to use when using in "slider" mode
  86049. */
  86050. step?: number;
  86051. }
  86052. }
  86053. declare module BABYLON {
  86054. /**
  86055. * Class used to provide helper for timing
  86056. */
  86057. export class TimingTools {
  86058. /**
  86059. * Polyfill for setImmediate
  86060. * @param action defines the action to execute after the current execution block
  86061. */
  86062. static SetImmediate(action: () => void): void;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /**
  86067. * Class used to enable instatition of objects by class name
  86068. */
  86069. export class InstantiationTools {
  86070. /**
  86071. * Use this object to register external classes like custom textures or material
  86072. * to allow the laoders to instantiate them
  86073. */
  86074. static RegisteredExternalClasses: {
  86075. [key: string]: Object;
  86076. };
  86077. /**
  86078. * Tries to instantiate a new object from a given class name
  86079. * @param className defines the class name to instantiate
  86080. * @returns the new object or null if the system was not able to do the instantiation
  86081. */
  86082. static Instantiate(className: string): any;
  86083. }
  86084. }
  86085. declare module BABYLON {
  86086. /**
  86087. * Define options used to create a depth texture
  86088. */
  86089. export class DepthTextureCreationOptions {
  86090. /** Specifies whether or not a stencil should be allocated in the texture */
  86091. generateStencil?: boolean;
  86092. /** Specifies whether or not bilinear filtering is enable on the texture */
  86093. bilinearFiltering?: boolean;
  86094. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86095. comparisonFunction?: number;
  86096. /** Specifies if the created texture is a cube texture */
  86097. isCube?: boolean;
  86098. }
  86099. }
  86100. declare module BABYLON {
  86101. interface ThinEngine {
  86102. /**
  86103. * Creates a depth stencil cube texture.
  86104. * This is only available in WebGL 2.
  86105. * @param size The size of face edge in the cube texture.
  86106. * @param options The options defining the cube texture.
  86107. * @returns The cube texture
  86108. */
  86109. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86110. /**
  86111. * Creates a cube texture
  86112. * @param rootUrl defines the url where the files to load is located
  86113. * @param scene defines the current scene
  86114. * @param files defines the list of files to load (1 per face)
  86115. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86116. * @param onLoad defines an optional callback raised when the texture is loaded
  86117. * @param onError defines an optional callback raised if there is an issue to load the texture
  86118. * @param format defines the format of the data
  86119. * @param forcedExtension defines the extension to use to pick the right loader
  86120. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86121. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86122. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86123. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86124. * @returns the cube texture as an InternalTexture
  86125. */
  86126. 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;
  86127. /**
  86128. * Creates a cube texture
  86129. * @param rootUrl defines the url where the files to load is located
  86130. * @param scene defines the current scene
  86131. * @param files defines the list of files to load (1 per face)
  86132. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86133. * @param onLoad defines an optional callback raised when the texture is loaded
  86134. * @param onError defines an optional callback raised if there is an issue to load the texture
  86135. * @param format defines the format of the data
  86136. * @param forcedExtension defines the extension to use to pick the right loader
  86137. * @returns the cube texture as an InternalTexture
  86138. */
  86139. 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;
  86140. /**
  86141. * Creates a cube texture
  86142. * @param rootUrl defines the url where the files to load is located
  86143. * @param scene defines the current scene
  86144. * @param files defines the list of files to load (1 per face)
  86145. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86146. * @param onLoad defines an optional callback raised when the texture is loaded
  86147. * @param onError defines an optional callback raised if there is an issue to load the texture
  86148. * @param format defines the format of the data
  86149. * @param forcedExtension defines the extension to use to pick the right loader
  86150. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86151. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86152. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86153. * @returns the cube texture as an InternalTexture
  86154. */
  86155. 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;
  86156. /** @hidden */
  86157. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86158. /** @hidden */
  86159. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86160. /** @hidden */
  86161. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86162. /** @hidden */
  86163. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86164. /**
  86165. * @hidden
  86166. */
  86167. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86168. }
  86169. }
  86170. declare module BABYLON {
  86171. /**
  86172. * Class for creating a cube texture
  86173. */
  86174. export class CubeTexture extends BaseTexture {
  86175. private _delayedOnLoad;
  86176. /**
  86177. * Observable triggered once the texture has been loaded.
  86178. */
  86179. onLoadObservable: Observable<CubeTexture>;
  86180. /**
  86181. * The url of the texture
  86182. */
  86183. url: string;
  86184. /**
  86185. * Gets or sets the center of the bounding box associated with the cube texture.
  86186. * It must define where the camera used to render the texture was set
  86187. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86188. */
  86189. boundingBoxPosition: Vector3;
  86190. private _boundingBoxSize;
  86191. /**
  86192. * Gets or sets the size of the bounding box associated with the cube texture
  86193. * When defined, the cubemap will switch to local mode
  86194. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86195. * @example https://www.babylonjs-playground.com/#RNASML
  86196. */
  86197. set boundingBoxSize(value: Vector3);
  86198. /**
  86199. * Returns the bounding box size
  86200. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86201. */
  86202. get boundingBoxSize(): Vector3;
  86203. protected _rotationY: number;
  86204. /**
  86205. * Sets texture matrix rotation angle around Y axis in radians.
  86206. */
  86207. set rotationY(value: number);
  86208. /**
  86209. * Gets texture matrix rotation angle around Y axis radians.
  86210. */
  86211. get rotationY(): number;
  86212. /**
  86213. * Are mip maps generated for this texture or not.
  86214. */
  86215. get noMipmap(): boolean;
  86216. private _noMipmap;
  86217. private _files;
  86218. protected _forcedExtension: Nullable<string>;
  86219. private _extensions;
  86220. private _textureMatrix;
  86221. private _format;
  86222. private _createPolynomials;
  86223. /**
  86224. * Creates a cube texture from an array of image urls
  86225. * @param files defines an array of image urls
  86226. * @param scene defines the hosting scene
  86227. * @param noMipmap specifies if mip maps are not used
  86228. * @returns a cube texture
  86229. */
  86230. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86231. /**
  86232. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86233. * @param url defines the url of the prefiltered texture
  86234. * @param scene defines the scene the texture is attached to
  86235. * @param forcedExtension defines the extension of the file if different from the url
  86236. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86237. * @return the prefiltered texture
  86238. */
  86239. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86240. /**
  86241. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86242. * as prefiltered data.
  86243. * @param rootUrl defines the url of the texture or the root name of the six images
  86244. * @param null defines the scene or engine the texture is attached to
  86245. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86246. * @param noMipmap defines if mipmaps should be created or not
  86247. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86248. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86249. * @param onError defines a callback triggered in case of error during load
  86250. * @param format defines the internal format to use for the texture once loaded
  86251. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86252. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86253. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86254. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86255. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86256. * @return the cube texture
  86257. */
  86258. 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);
  86259. /**
  86260. * Get the current class name of the texture useful for serialization or dynamic coding.
  86261. * @returns "CubeTexture"
  86262. */
  86263. getClassName(): string;
  86264. /**
  86265. * Update the url (and optional buffer) of this texture if url was null during construction.
  86266. * @param url the url of the texture
  86267. * @param forcedExtension defines the extension to use
  86268. * @param onLoad callback called when the texture is loaded (defaults to null)
  86269. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86270. */
  86271. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86272. /**
  86273. * Delays loading of the cube texture
  86274. * @param forcedExtension defines the extension to use
  86275. */
  86276. delayLoad(forcedExtension?: string): void;
  86277. /**
  86278. * Returns the reflection texture matrix
  86279. * @returns the reflection texture matrix
  86280. */
  86281. getReflectionTextureMatrix(): Matrix;
  86282. /**
  86283. * Sets the reflection texture matrix
  86284. * @param value Reflection texture matrix
  86285. */
  86286. setReflectionTextureMatrix(value: Matrix): void;
  86287. /**
  86288. * Parses text to create a cube texture
  86289. * @param parsedTexture define the serialized text to read from
  86290. * @param scene defines the hosting scene
  86291. * @param rootUrl defines the root url of the cube texture
  86292. * @returns a cube texture
  86293. */
  86294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86295. /**
  86296. * Makes a clone, or deep copy, of the cube texture
  86297. * @returns a new cube texture
  86298. */
  86299. clone(): CubeTexture;
  86300. }
  86301. }
  86302. declare module BABYLON {
  86303. /**
  86304. * Manages the defines for the Material
  86305. */
  86306. export class MaterialDefines {
  86307. /** @hidden */
  86308. protected _keys: string[];
  86309. private _isDirty;
  86310. /** @hidden */
  86311. _renderId: number;
  86312. /** @hidden */
  86313. _areLightsDirty: boolean;
  86314. /** @hidden */
  86315. _areLightsDisposed: boolean;
  86316. /** @hidden */
  86317. _areAttributesDirty: boolean;
  86318. /** @hidden */
  86319. _areTexturesDirty: boolean;
  86320. /** @hidden */
  86321. _areFresnelDirty: boolean;
  86322. /** @hidden */
  86323. _areMiscDirty: boolean;
  86324. /** @hidden */
  86325. _areImageProcessingDirty: boolean;
  86326. /** @hidden */
  86327. _normals: boolean;
  86328. /** @hidden */
  86329. _uvs: boolean;
  86330. /** @hidden */
  86331. _needNormals: boolean;
  86332. /** @hidden */
  86333. _needUVs: boolean;
  86334. [id: string]: any;
  86335. /**
  86336. * Specifies if the material needs to be re-calculated
  86337. */
  86338. get isDirty(): boolean;
  86339. /**
  86340. * Marks the material to indicate that it has been re-calculated
  86341. */
  86342. markAsProcessed(): void;
  86343. /**
  86344. * Marks the material to indicate that it needs to be re-calculated
  86345. */
  86346. markAsUnprocessed(): void;
  86347. /**
  86348. * Marks the material to indicate all of its defines need to be re-calculated
  86349. */
  86350. markAllAsDirty(): void;
  86351. /**
  86352. * Marks the material to indicate that image processing needs to be re-calculated
  86353. */
  86354. markAsImageProcessingDirty(): void;
  86355. /**
  86356. * Marks the material to indicate the lights need to be re-calculated
  86357. * @param disposed Defines whether the light is dirty due to dispose or not
  86358. */
  86359. markAsLightDirty(disposed?: boolean): void;
  86360. /**
  86361. * Marks the attribute state as changed
  86362. */
  86363. markAsAttributesDirty(): void;
  86364. /**
  86365. * Marks the texture state as changed
  86366. */
  86367. markAsTexturesDirty(): void;
  86368. /**
  86369. * Marks the fresnel state as changed
  86370. */
  86371. markAsFresnelDirty(): void;
  86372. /**
  86373. * Marks the misc state as changed
  86374. */
  86375. markAsMiscDirty(): void;
  86376. /**
  86377. * Rebuilds the material defines
  86378. */
  86379. rebuild(): void;
  86380. /**
  86381. * Specifies if two material defines are equal
  86382. * @param other - A material define instance to compare to
  86383. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86384. */
  86385. isEqual(other: MaterialDefines): boolean;
  86386. /**
  86387. * Clones this instance's defines to another instance
  86388. * @param other - material defines to clone values to
  86389. */
  86390. cloneTo(other: MaterialDefines): void;
  86391. /**
  86392. * Resets the material define values
  86393. */
  86394. reset(): void;
  86395. /**
  86396. * Converts the material define values to a string
  86397. * @returns - String of material define information
  86398. */
  86399. toString(): string;
  86400. }
  86401. }
  86402. declare module BABYLON {
  86403. /**
  86404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86406. * 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;
  86407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86408. */
  86409. export class ColorCurves {
  86410. private _dirty;
  86411. private _tempColor;
  86412. private _globalCurve;
  86413. private _highlightsCurve;
  86414. private _midtonesCurve;
  86415. private _shadowsCurve;
  86416. private _positiveCurve;
  86417. private _negativeCurve;
  86418. private _globalHue;
  86419. private _globalDensity;
  86420. private _globalSaturation;
  86421. private _globalExposure;
  86422. /**
  86423. * Gets the global Hue value.
  86424. * 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).
  86425. */
  86426. get globalHue(): number;
  86427. /**
  86428. * Sets the global Hue value.
  86429. * 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).
  86430. */
  86431. set globalHue(value: number);
  86432. /**
  86433. * Gets the global Density value.
  86434. * 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.
  86435. * Values less than zero provide a filter of opposite hue.
  86436. */
  86437. get globalDensity(): number;
  86438. /**
  86439. * Sets the global Density value.
  86440. * 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.
  86441. * Values less than zero provide a filter of opposite hue.
  86442. */
  86443. set globalDensity(value: number);
  86444. /**
  86445. * Gets the global Saturation value.
  86446. * 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.
  86447. */
  86448. get globalSaturation(): number;
  86449. /**
  86450. * Sets the global Saturation value.
  86451. * 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.
  86452. */
  86453. set globalSaturation(value: number);
  86454. /**
  86455. * Gets the global Exposure value.
  86456. * 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.
  86457. */
  86458. get globalExposure(): number;
  86459. /**
  86460. * Sets the global Exposure value.
  86461. * 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.
  86462. */
  86463. set globalExposure(value: number);
  86464. private _highlightsHue;
  86465. private _highlightsDensity;
  86466. private _highlightsSaturation;
  86467. private _highlightsExposure;
  86468. /**
  86469. * Gets the highlights Hue value.
  86470. * 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).
  86471. */
  86472. get highlightsHue(): number;
  86473. /**
  86474. * Sets the highlights Hue value.
  86475. * 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).
  86476. */
  86477. set highlightsHue(value: number);
  86478. /**
  86479. * Gets the highlights Density value.
  86480. * 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.
  86481. * Values less than zero provide a filter of opposite hue.
  86482. */
  86483. get highlightsDensity(): number;
  86484. /**
  86485. * Sets the highlights Density value.
  86486. * 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.
  86487. * Values less than zero provide a filter of opposite hue.
  86488. */
  86489. set highlightsDensity(value: number);
  86490. /**
  86491. * Gets the highlights Saturation value.
  86492. * 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.
  86493. */
  86494. get highlightsSaturation(): number;
  86495. /**
  86496. * Sets the highlights Saturation value.
  86497. * 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.
  86498. */
  86499. set highlightsSaturation(value: number);
  86500. /**
  86501. * Gets the highlights Exposure value.
  86502. * 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.
  86503. */
  86504. get highlightsExposure(): number;
  86505. /**
  86506. * Sets the highlights Exposure value.
  86507. * 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.
  86508. */
  86509. set highlightsExposure(value: number);
  86510. private _midtonesHue;
  86511. private _midtonesDensity;
  86512. private _midtonesSaturation;
  86513. private _midtonesExposure;
  86514. /**
  86515. * Gets the midtones Hue value.
  86516. * 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).
  86517. */
  86518. get midtonesHue(): number;
  86519. /**
  86520. * Sets the midtones Hue value.
  86521. * 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).
  86522. */
  86523. set midtonesHue(value: number);
  86524. /**
  86525. * Gets the midtones Density value.
  86526. * 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.
  86527. * Values less than zero provide a filter of opposite hue.
  86528. */
  86529. get midtonesDensity(): number;
  86530. /**
  86531. * Sets the midtones Density value.
  86532. * 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.
  86533. * Values less than zero provide a filter of opposite hue.
  86534. */
  86535. set midtonesDensity(value: number);
  86536. /**
  86537. * Gets the midtones Saturation value.
  86538. * 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.
  86539. */
  86540. get midtonesSaturation(): number;
  86541. /**
  86542. * Sets the midtones Saturation value.
  86543. * 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.
  86544. */
  86545. set midtonesSaturation(value: number);
  86546. /**
  86547. * Gets the midtones Exposure value.
  86548. * 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.
  86549. */
  86550. get midtonesExposure(): number;
  86551. /**
  86552. * Sets the midtones Exposure value.
  86553. * 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.
  86554. */
  86555. set midtonesExposure(value: number);
  86556. private _shadowsHue;
  86557. private _shadowsDensity;
  86558. private _shadowsSaturation;
  86559. private _shadowsExposure;
  86560. /**
  86561. * Gets the shadows Hue value.
  86562. * 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).
  86563. */
  86564. get shadowsHue(): number;
  86565. /**
  86566. * Sets the shadows Hue value.
  86567. * 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).
  86568. */
  86569. set shadowsHue(value: number);
  86570. /**
  86571. * Gets the shadows Density value.
  86572. * 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.
  86573. * Values less than zero provide a filter of opposite hue.
  86574. */
  86575. get shadowsDensity(): number;
  86576. /**
  86577. * Sets the shadows Density value.
  86578. * 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.
  86579. * Values less than zero provide a filter of opposite hue.
  86580. */
  86581. set shadowsDensity(value: number);
  86582. /**
  86583. * Gets the shadows Saturation value.
  86584. * 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.
  86585. */
  86586. get shadowsSaturation(): number;
  86587. /**
  86588. * Sets the shadows Saturation value.
  86589. * 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.
  86590. */
  86591. set shadowsSaturation(value: number);
  86592. /**
  86593. * Gets the shadows Exposure value.
  86594. * 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.
  86595. */
  86596. get shadowsExposure(): number;
  86597. /**
  86598. * Sets the shadows Exposure value.
  86599. * 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.
  86600. */
  86601. set shadowsExposure(value: number);
  86602. /**
  86603. * Returns the class name
  86604. * @returns The class name
  86605. */
  86606. getClassName(): string;
  86607. /**
  86608. * Binds the color curves to the shader.
  86609. * @param colorCurves The color curve to bind
  86610. * @param effect The effect to bind to
  86611. * @param positiveUniform The positive uniform shader parameter
  86612. * @param neutralUniform The neutral uniform shader parameter
  86613. * @param negativeUniform The negative uniform shader parameter
  86614. */
  86615. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86616. /**
  86617. * Prepare the list of uniforms associated with the ColorCurves effects.
  86618. * @param uniformsList The list of uniforms used in the effect
  86619. */
  86620. static PrepareUniforms(uniformsList: string[]): void;
  86621. /**
  86622. * Returns color grading data based on a hue, density, saturation and exposure value.
  86623. * @param filterHue The hue of the color filter.
  86624. * @param filterDensity The density of the color filter.
  86625. * @param saturation The saturation.
  86626. * @param exposure The exposure.
  86627. * @param result The result data container.
  86628. */
  86629. private getColorGradingDataToRef;
  86630. /**
  86631. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86632. * @param value The input slider value in range [-100,100].
  86633. * @returns Adjusted value.
  86634. */
  86635. private static applyColorGradingSliderNonlinear;
  86636. /**
  86637. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86638. * @param hue The hue (H) input.
  86639. * @param saturation The saturation (S) input.
  86640. * @param brightness The brightness (B) input.
  86641. * @result An RGBA color represented as Vector4.
  86642. */
  86643. private static fromHSBToRef;
  86644. /**
  86645. * Returns a value clamped between min and max
  86646. * @param value The value to clamp
  86647. * @param min The minimum of value
  86648. * @param max The maximum of value
  86649. * @returns The clamped value.
  86650. */
  86651. private static clamp;
  86652. /**
  86653. * Clones the current color curve instance.
  86654. * @return The cloned curves
  86655. */
  86656. clone(): ColorCurves;
  86657. /**
  86658. * Serializes the current color curve instance to a json representation.
  86659. * @return a JSON representation
  86660. */
  86661. serialize(): any;
  86662. /**
  86663. * Parses the color curve from a json representation.
  86664. * @param source the JSON source to parse
  86665. * @return The parsed curves
  86666. */
  86667. static Parse(source: any): ColorCurves;
  86668. }
  86669. }
  86670. declare module BABYLON {
  86671. /**
  86672. * Interface to follow in your material defines to integrate easily the
  86673. * Image proccessing functions.
  86674. * @hidden
  86675. */
  86676. export interface IImageProcessingConfigurationDefines {
  86677. IMAGEPROCESSING: boolean;
  86678. VIGNETTE: boolean;
  86679. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86680. VIGNETTEBLENDMODEOPAQUE: boolean;
  86681. TONEMAPPING: boolean;
  86682. TONEMAPPING_ACES: boolean;
  86683. CONTRAST: boolean;
  86684. EXPOSURE: boolean;
  86685. COLORCURVES: boolean;
  86686. COLORGRADING: boolean;
  86687. COLORGRADING3D: boolean;
  86688. SAMPLER3DGREENDEPTH: boolean;
  86689. SAMPLER3DBGRMAP: boolean;
  86690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86691. }
  86692. /**
  86693. * @hidden
  86694. */
  86695. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86696. IMAGEPROCESSING: boolean;
  86697. VIGNETTE: boolean;
  86698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86699. VIGNETTEBLENDMODEOPAQUE: boolean;
  86700. TONEMAPPING: boolean;
  86701. TONEMAPPING_ACES: boolean;
  86702. CONTRAST: boolean;
  86703. COLORCURVES: boolean;
  86704. COLORGRADING: boolean;
  86705. COLORGRADING3D: boolean;
  86706. SAMPLER3DGREENDEPTH: boolean;
  86707. SAMPLER3DBGRMAP: boolean;
  86708. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86709. EXPOSURE: boolean;
  86710. constructor();
  86711. }
  86712. /**
  86713. * This groups together the common properties used for image processing either in direct forward pass
  86714. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86715. * or not.
  86716. */
  86717. export class ImageProcessingConfiguration {
  86718. /**
  86719. * Default tone mapping applied in BabylonJS.
  86720. */
  86721. static readonly TONEMAPPING_STANDARD: number;
  86722. /**
  86723. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86724. * to other engines rendering to increase portability.
  86725. */
  86726. static readonly TONEMAPPING_ACES: number;
  86727. /**
  86728. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86729. */
  86730. colorCurves: Nullable<ColorCurves>;
  86731. private _colorCurvesEnabled;
  86732. /**
  86733. * Gets wether the color curves effect is enabled.
  86734. */
  86735. get colorCurvesEnabled(): boolean;
  86736. /**
  86737. * Sets wether the color curves effect is enabled.
  86738. */
  86739. set colorCurvesEnabled(value: boolean);
  86740. private _colorGradingTexture;
  86741. /**
  86742. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86743. */
  86744. get colorGradingTexture(): Nullable<BaseTexture>;
  86745. /**
  86746. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86747. */
  86748. set colorGradingTexture(value: Nullable<BaseTexture>);
  86749. private _colorGradingEnabled;
  86750. /**
  86751. * Gets wether the color grading effect is enabled.
  86752. */
  86753. get colorGradingEnabled(): boolean;
  86754. /**
  86755. * Sets wether the color grading effect is enabled.
  86756. */
  86757. set colorGradingEnabled(value: boolean);
  86758. private _colorGradingWithGreenDepth;
  86759. /**
  86760. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86761. */
  86762. get colorGradingWithGreenDepth(): boolean;
  86763. /**
  86764. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86765. */
  86766. set colorGradingWithGreenDepth(value: boolean);
  86767. private _colorGradingBGR;
  86768. /**
  86769. * Gets wether the color grading texture contains BGR values.
  86770. */
  86771. get colorGradingBGR(): boolean;
  86772. /**
  86773. * Sets wether the color grading texture contains BGR values.
  86774. */
  86775. set colorGradingBGR(value: boolean);
  86776. /** @hidden */
  86777. _exposure: number;
  86778. /**
  86779. * Gets the Exposure used in the effect.
  86780. */
  86781. get exposure(): number;
  86782. /**
  86783. * Sets the Exposure used in the effect.
  86784. */
  86785. set exposure(value: number);
  86786. private _toneMappingEnabled;
  86787. /**
  86788. * Gets wether the tone mapping effect is enabled.
  86789. */
  86790. get toneMappingEnabled(): boolean;
  86791. /**
  86792. * Sets wether the tone mapping effect is enabled.
  86793. */
  86794. set toneMappingEnabled(value: boolean);
  86795. private _toneMappingType;
  86796. /**
  86797. * Gets the type of tone mapping effect.
  86798. */
  86799. get toneMappingType(): number;
  86800. /**
  86801. * Sets the type of tone mapping effect used in BabylonJS.
  86802. */
  86803. set toneMappingType(value: number);
  86804. protected _contrast: number;
  86805. /**
  86806. * Gets the contrast used in the effect.
  86807. */
  86808. get contrast(): number;
  86809. /**
  86810. * Sets the contrast used in the effect.
  86811. */
  86812. set contrast(value: number);
  86813. /**
  86814. * Vignette stretch size.
  86815. */
  86816. vignetteStretch: number;
  86817. /**
  86818. * Vignette centre X Offset.
  86819. */
  86820. vignetteCentreX: number;
  86821. /**
  86822. * Vignette centre Y Offset.
  86823. */
  86824. vignetteCentreY: number;
  86825. /**
  86826. * Vignette weight or intensity of the vignette effect.
  86827. */
  86828. vignetteWeight: number;
  86829. /**
  86830. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86831. * if vignetteEnabled is set to true.
  86832. */
  86833. vignetteColor: Color4;
  86834. /**
  86835. * Camera field of view used by the Vignette effect.
  86836. */
  86837. vignetteCameraFov: number;
  86838. private _vignetteBlendMode;
  86839. /**
  86840. * Gets the vignette blend mode allowing different kind of effect.
  86841. */
  86842. get vignetteBlendMode(): number;
  86843. /**
  86844. * Sets the vignette blend mode allowing different kind of effect.
  86845. */
  86846. set vignetteBlendMode(value: number);
  86847. private _vignetteEnabled;
  86848. /**
  86849. * Gets wether the vignette effect is enabled.
  86850. */
  86851. get vignetteEnabled(): boolean;
  86852. /**
  86853. * Sets wether the vignette effect is enabled.
  86854. */
  86855. set vignetteEnabled(value: boolean);
  86856. private _applyByPostProcess;
  86857. /**
  86858. * Gets wether the image processing is applied through a post process or not.
  86859. */
  86860. get applyByPostProcess(): boolean;
  86861. /**
  86862. * Sets wether the image processing is applied through a post process or not.
  86863. */
  86864. set applyByPostProcess(value: boolean);
  86865. private _isEnabled;
  86866. /**
  86867. * Gets wether the image processing is enabled or not.
  86868. */
  86869. get isEnabled(): boolean;
  86870. /**
  86871. * Sets wether the image processing is enabled or not.
  86872. */
  86873. set isEnabled(value: boolean);
  86874. /**
  86875. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86876. */
  86877. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86878. /**
  86879. * Method called each time the image processing information changes requires to recompile the effect.
  86880. */
  86881. protected _updateParameters(): void;
  86882. /**
  86883. * Gets the current class name.
  86884. * @return "ImageProcessingConfiguration"
  86885. */
  86886. getClassName(): string;
  86887. /**
  86888. * Prepare the list of uniforms associated with the Image Processing effects.
  86889. * @param uniforms The list of uniforms used in the effect
  86890. * @param defines the list of defines currently in use
  86891. */
  86892. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86893. /**
  86894. * Prepare the list of samplers associated with the Image Processing effects.
  86895. * @param samplersList The list of uniforms used in the effect
  86896. * @param defines the list of defines currently in use
  86897. */
  86898. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86899. /**
  86900. * Prepare the list of defines associated to the shader.
  86901. * @param defines the list of defines to complete
  86902. * @param forPostProcess Define if we are currently in post process mode or not
  86903. */
  86904. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86905. /**
  86906. * Returns true if all the image processing information are ready.
  86907. * @returns True if ready, otherwise, false
  86908. */
  86909. isReady(): boolean;
  86910. /**
  86911. * Binds the image processing to the shader.
  86912. * @param effect The effect to bind to
  86913. * @param overrideAspectRatio Override the aspect ratio of the effect
  86914. */
  86915. bind(effect: Effect, overrideAspectRatio?: number): void;
  86916. /**
  86917. * Clones the current image processing instance.
  86918. * @return The cloned image processing
  86919. */
  86920. clone(): ImageProcessingConfiguration;
  86921. /**
  86922. * Serializes the current image processing instance to a json representation.
  86923. * @return a JSON representation
  86924. */
  86925. serialize(): any;
  86926. /**
  86927. * Parses the image processing from a json representation.
  86928. * @param source the JSON source to parse
  86929. * @return The parsed image processing
  86930. */
  86931. static Parse(source: any): ImageProcessingConfiguration;
  86932. private static _VIGNETTEMODE_MULTIPLY;
  86933. private static _VIGNETTEMODE_OPAQUE;
  86934. /**
  86935. * Used to apply the vignette as a mix with the pixel color.
  86936. */
  86937. static get VIGNETTEMODE_MULTIPLY(): number;
  86938. /**
  86939. * Used to apply the vignette as a replacement of the pixel color.
  86940. */
  86941. static get VIGNETTEMODE_OPAQUE(): number;
  86942. }
  86943. }
  86944. declare module BABYLON {
  86945. /** @hidden */
  86946. export var postprocessVertexShader: {
  86947. name: string;
  86948. shader: string;
  86949. };
  86950. }
  86951. declare module BABYLON {
  86952. interface ThinEngine {
  86953. /**
  86954. * Creates a new render target texture
  86955. * @param size defines the size of the texture
  86956. * @param options defines the options used to create the texture
  86957. * @returns a new render target texture stored in an InternalTexture
  86958. */
  86959. createRenderTargetTexture(size: number | {
  86960. width: number;
  86961. height: number;
  86962. layers?: number;
  86963. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86964. /**
  86965. * Creates a depth stencil texture.
  86966. * This is only available in WebGL 2 or with the depth texture extension available.
  86967. * @param size The size of face edge in the texture.
  86968. * @param options The options defining the texture.
  86969. * @returns The texture
  86970. */
  86971. createDepthStencilTexture(size: number | {
  86972. width: number;
  86973. height: number;
  86974. layers?: number;
  86975. }, options: DepthTextureCreationOptions): InternalTexture;
  86976. /** @hidden */
  86977. _createDepthStencilTexture(size: number | {
  86978. width: number;
  86979. height: number;
  86980. layers?: number;
  86981. }, options: DepthTextureCreationOptions): InternalTexture;
  86982. }
  86983. }
  86984. declare module BABYLON {
  86985. /**
  86986. * Defines the kind of connection point for node based material
  86987. */
  86988. export enum NodeMaterialBlockConnectionPointTypes {
  86989. /** Float */
  86990. Float = 1,
  86991. /** Int */
  86992. Int = 2,
  86993. /** Vector2 */
  86994. Vector2 = 4,
  86995. /** Vector3 */
  86996. Vector3 = 8,
  86997. /** Vector4 */
  86998. Vector4 = 16,
  86999. /** Color3 */
  87000. Color3 = 32,
  87001. /** Color4 */
  87002. Color4 = 64,
  87003. /** Matrix */
  87004. Matrix = 128,
  87005. /** Custom object */
  87006. Object = 256,
  87007. /** Detect type based on connection */
  87008. AutoDetect = 1024,
  87009. /** Output type that will be defined by input type */
  87010. BasedOnInput = 2048
  87011. }
  87012. }
  87013. declare module BABYLON {
  87014. /**
  87015. * Enum used to define the target of a block
  87016. */
  87017. export enum NodeMaterialBlockTargets {
  87018. /** Vertex shader */
  87019. Vertex = 1,
  87020. /** Fragment shader */
  87021. Fragment = 2,
  87022. /** Neutral */
  87023. Neutral = 4,
  87024. /** Vertex and Fragment */
  87025. VertexAndFragment = 3
  87026. }
  87027. }
  87028. declare module BABYLON {
  87029. /**
  87030. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87031. */
  87032. export enum NodeMaterialBlockConnectionPointMode {
  87033. /** Value is an uniform */
  87034. Uniform = 0,
  87035. /** Value is a mesh attribute */
  87036. Attribute = 1,
  87037. /** Value is a varying between vertex and fragment shaders */
  87038. Varying = 2,
  87039. /** Mode is undefined */
  87040. Undefined = 3
  87041. }
  87042. }
  87043. declare module BABYLON {
  87044. /**
  87045. * Enum used to define system values e.g. values automatically provided by the system
  87046. */
  87047. export enum NodeMaterialSystemValues {
  87048. /** World */
  87049. World = 1,
  87050. /** View */
  87051. View = 2,
  87052. /** Projection */
  87053. Projection = 3,
  87054. /** ViewProjection */
  87055. ViewProjection = 4,
  87056. /** WorldView */
  87057. WorldView = 5,
  87058. /** WorldViewProjection */
  87059. WorldViewProjection = 6,
  87060. /** CameraPosition */
  87061. CameraPosition = 7,
  87062. /** Fog Color */
  87063. FogColor = 8,
  87064. /** Delta time */
  87065. DeltaTime = 9
  87066. }
  87067. }
  87068. declare module BABYLON {
  87069. /** Defines supported spaces */
  87070. export enum Space {
  87071. /** Local (object) space */
  87072. LOCAL = 0,
  87073. /** World space */
  87074. WORLD = 1,
  87075. /** Bone space */
  87076. BONE = 2
  87077. }
  87078. /** Defines the 3 main axes */
  87079. export class Axis {
  87080. /** X axis */
  87081. static X: Vector3;
  87082. /** Y axis */
  87083. static Y: Vector3;
  87084. /** Z axis */
  87085. static Z: Vector3;
  87086. }
  87087. }
  87088. declare module BABYLON {
  87089. /**
  87090. * Represents a camera frustum
  87091. */
  87092. export class Frustum {
  87093. /**
  87094. * Gets the planes representing the frustum
  87095. * @param transform matrix to be applied to the returned planes
  87096. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87097. */
  87098. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87099. /**
  87100. * Gets the near frustum plane transformed by the transform matrix
  87101. * @param transform transformation matrix to be applied to the resulting frustum plane
  87102. * @param frustumPlane the resuling frustum plane
  87103. */
  87104. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87105. /**
  87106. * Gets the far frustum plane transformed by the transform matrix
  87107. * @param transform transformation matrix to be applied to the resulting frustum plane
  87108. * @param frustumPlane the resuling frustum plane
  87109. */
  87110. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87111. /**
  87112. * Gets the left frustum plane transformed by the transform matrix
  87113. * @param transform transformation matrix to be applied to the resulting frustum plane
  87114. * @param frustumPlane the resuling frustum plane
  87115. */
  87116. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87117. /**
  87118. * Gets the right frustum plane transformed by the transform matrix
  87119. * @param transform transformation matrix to be applied to the resulting frustum plane
  87120. * @param frustumPlane the resuling frustum plane
  87121. */
  87122. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87123. /**
  87124. * Gets the top frustum plane transformed by the transform matrix
  87125. * @param transform transformation matrix to be applied to the resulting frustum plane
  87126. * @param frustumPlane the resuling frustum plane
  87127. */
  87128. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87129. /**
  87130. * Gets the bottom frustum plane transformed by the transform matrix
  87131. * @param transform transformation matrix to be applied to the resulting frustum plane
  87132. * @param frustumPlane the resuling frustum plane
  87133. */
  87134. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87135. /**
  87136. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87137. * @param transform transformation matrix to be applied to the resulting frustum planes
  87138. * @param frustumPlanes the resuling frustum planes
  87139. */
  87140. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87141. }
  87142. }
  87143. declare module BABYLON {
  87144. /**
  87145. * Interface for the size containing width and height
  87146. */
  87147. export interface ISize {
  87148. /**
  87149. * Width
  87150. */
  87151. width: number;
  87152. /**
  87153. * Heighht
  87154. */
  87155. height: number;
  87156. }
  87157. /**
  87158. * Size containing widht and height
  87159. */
  87160. export class Size implements ISize {
  87161. /**
  87162. * Width
  87163. */
  87164. width: number;
  87165. /**
  87166. * Height
  87167. */
  87168. height: number;
  87169. /**
  87170. * Creates a Size object from the given width and height (floats).
  87171. * @param width width of the new size
  87172. * @param height height of the new size
  87173. */
  87174. constructor(width: number, height: number);
  87175. /**
  87176. * Returns a string with the Size width and height
  87177. * @returns a string with the Size width and height
  87178. */
  87179. toString(): string;
  87180. /**
  87181. * "Size"
  87182. * @returns the string "Size"
  87183. */
  87184. getClassName(): string;
  87185. /**
  87186. * Returns the Size hash code.
  87187. * @returns a hash code for a unique width and height
  87188. */
  87189. getHashCode(): number;
  87190. /**
  87191. * Updates the current size from the given one.
  87192. * @param src the given size
  87193. */
  87194. copyFrom(src: Size): void;
  87195. /**
  87196. * Updates in place the current Size from the given floats.
  87197. * @param width width of the new size
  87198. * @param height height of the new size
  87199. * @returns the updated Size.
  87200. */
  87201. copyFromFloats(width: number, height: number): Size;
  87202. /**
  87203. * Updates in place the current Size from the given floats.
  87204. * @param width width to set
  87205. * @param height height to set
  87206. * @returns the updated Size.
  87207. */
  87208. set(width: number, height: number): Size;
  87209. /**
  87210. * Multiplies the width and height by numbers
  87211. * @param w factor to multiple the width by
  87212. * @param h factor to multiple the height by
  87213. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87214. */
  87215. multiplyByFloats(w: number, h: number): Size;
  87216. /**
  87217. * Clones the size
  87218. * @returns a new Size copied from the given one.
  87219. */
  87220. clone(): Size;
  87221. /**
  87222. * True if the current Size and the given one width and height are strictly equal.
  87223. * @param other the other size to compare against
  87224. * @returns True if the current Size and the given one width and height are strictly equal.
  87225. */
  87226. equals(other: Size): boolean;
  87227. /**
  87228. * The surface of the Size : width * height (float).
  87229. */
  87230. get surface(): number;
  87231. /**
  87232. * Create a new size of zero
  87233. * @returns a new Size set to (0.0, 0.0)
  87234. */
  87235. static Zero(): Size;
  87236. /**
  87237. * Sums the width and height of two sizes
  87238. * @param otherSize size to add to this size
  87239. * @returns a new Size set as the addition result of the current Size and the given one.
  87240. */
  87241. add(otherSize: Size): Size;
  87242. /**
  87243. * Subtracts the width and height of two
  87244. * @param otherSize size to subtract to this size
  87245. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87246. */
  87247. subtract(otherSize: Size): Size;
  87248. /**
  87249. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87250. * @param start starting size to lerp between
  87251. * @param end end size to lerp between
  87252. * @param amount amount to lerp between the start and end values
  87253. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87254. */
  87255. static Lerp(start: Size, end: Size, amount: number): Size;
  87256. }
  87257. }
  87258. declare module BABYLON {
  87259. /**
  87260. * Contains position and normal vectors for a vertex
  87261. */
  87262. export class PositionNormalVertex {
  87263. /** the position of the vertex (defaut: 0,0,0) */
  87264. position: Vector3;
  87265. /** the normal of the vertex (defaut: 0,1,0) */
  87266. normal: Vector3;
  87267. /**
  87268. * Creates a PositionNormalVertex
  87269. * @param position the position of the vertex (defaut: 0,0,0)
  87270. * @param normal the normal of the vertex (defaut: 0,1,0)
  87271. */
  87272. constructor(
  87273. /** the position of the vertex (defaut: 0,0,0) */
  87274. position?: Vector3,
  87275. /** the normal of the vertex (defaut: 0,1,0) */
  87276. normal?: Vector3);
  87277. /**
  87278. * Clones the PositionNormalVertex
  87279. * @returns the cloned PositionNormalVertex
  87280. */
  87281. clone(): PositionNormalVertex;
  87282. }
  87283. /**
  87284. * Contains position, normal and uv vectors for a vertex
  87285. */
  87286. export class PositionNormalTextureVertex {
  87287. /** the position of the vertex (defaut: 0,0,0) */
  87288. position: Vector3;
  87289. /** the normal of the vertex (defaut: 0,1,0) */
  87290. normal: Vector3;
  87291. /** the uv of the vertex (default: 0,0) */
  87292. uv: Vector2;
  87293. /**
  87294. * Creates a PositionNormalTextureVertex
  87295. * @param position the position of the vertex (defaut: 0,0,0)
  87296. * @param normal the normal of the vertex (defaut: 0,1,0)
  87297. * @param uv the uv of the vertex (default: 0,0)
  87298. */
  87299. constructor(
  87300. /** the position of the vertex (defaut: 0,0,0) */
  87301. position?: Vector3,
  87302. /** the normal of the vertex (defaut: 0,1,0) */
  87303. normal?: Vector3,
  87304. /** the uv of the vertex (default: 0,0) */
  87305. uv?: Vector2);
  87306. /**
  87307. * Clones the PositionNormalTextureVertex
  87308. * @returns the cloned PositionNormalTextureVertex
  87309. */
  87310. clone(): PositionNormalTextureVertex;
  87311. }
  87312. }
  87313. declare module BABYLON {
  87314. /**
  87315. * Enum defining the type of animations supported by InputBlock
  87316. */
  87317. export enum AnimatedInputBlockTypes {
  87318. /** No animation */
  87319. None = 0,
  87320. /** Time based animation. Will only work for floats */
  87321. Time = 1
  87322. }
  87323. }
  87324. declare module BABYLON {
  87325. /**
  87326. * Interface describing all the common properties and methods a shadow light needs to implement.
  87327. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87328. * as well as binding the different shadow properties to the effects.
  87329. */
  87330. export interface IShadowLight extends Light {
  87331. /**
  87332. * The light id in the scene (used in scene.findLighById for instance)
  87333. */
  87334. id: string;
  87335. /**
  87336. * The position the shdow will be casted from.
  87337. */
  87338. position: Vector3;
  87339. /**
  87340. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87341. */
  87342. direction: Vector3;
  87343. /**
  87344. * The transformed position. Position of the light in world space taking parenting in account.
  87345. */
  87346. transformedPosition: Vector3;
  87347. /**
  87348. * The transformed direction. Direction of the light in world space taking parenting in account.
  87349. */
  87350. transformedDirection: Vector3;
  87351. /**
  87352. * The friendly name of the light in the scene.
  87353. */
  87354. name: string;
  87355. /**
  87356. * Defines the shadow projection clipping minimum z value.
  87357. */
  87358. shadowMinZ: number;
  87359. /**
  87360. * Defines the shadow projection clipping maximum z value.
  87361. */
  87362. shadowMaxZ: number;
  87363. /**
  87364. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87365. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87366. */
  87367. computeTransformedInformation(): boolean;
  87368. /**
  87369. * Gets the scene the light belongs to.
  87370. * @returns The scene
  87371. */
  87372. getScene(): Scene;
  87373. /**
  87374. * Callback defining a custom Projection Matrix Builder.
  87375. * This can be used to override the default projection matrix computation.
  87376. */
  87377. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87378. /**
  87379. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87380. * @param matrix The materix to updated with the projection information
  87381. * @param viewMatrix The transform matrix of the light
  87382. * @param renderList The list of mesh to render in the map
  87383. * @returns The current light
  87384. */
  87385. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87386. /**
  87387. * Gets the current depth scale used in ESM.
  87388. * @returns The scale
  87389. */
  87390. getDepthScale(): number;
  87391. /**
  87392. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87393. * @returns true if a cube texture needs to be use
  87394. */
  87395. needCube(): boolean;
  87396. /**
  87397. * Detects if the projection matrix requires to be recomputed this frame.
  87398. * @returns true if it requires to be recomputed otherwise, false.
  87399. */
  87400. needProjectionMatrixCompute(): boolean;
  87401. /**
  87402. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87403. */
  87404. forceProjectionMatrixCompute(): void;
  87405. /**
  87406. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87409. */
  87410. getShadowDirection(faceIndex?: number): Vector3;
  87411. /**
  87412. * Gets the minZ used for shadow according to both the scene and the light.
  87413. * @param activeCamera The camera we are returning the min for
  87414. * @returns the depth min z
  87415. */
  87416. getDepthMinZ(activeCamera: Camera): number;
  87417. /**
  87418. * Gets the maxZ used for shadow according to both the scene and the light.
  87419. * @param activeCamera The camera we are returning the max for
  87420. * @returns the depth max z
  87421. */
  87422. getDepthMaxZ(activeCamera: Camera): number;
  87423. }
  87424. /**
  87425. * Base implementation IShadowLight
  87426. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87427. */
  87428. export abstract class ShadowLight extends Light implements IShadowLight {
  87429. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87430. protected _position: Vector3;
  87431. protected _setPosition(value: Vector3): void;
  87432. /**
  87433. * Sets the position the shadow will be casted from. Also use as the light position for both
  87434. * point and spot lights.
  87435. */
  87436. get position(): Vector3;
  87437. /**
  87438. * Sets the position the shadow will be casted from. Also use as the light position for both
  87439. * point and spot lights.
  87440. */
  87441. set position(value: Vector3);
  87442. protected _direction: Vector3;
  87443. protected _setDirection(value: Vector3): void;
  87444. /**
  87445. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87446. * Also use as the light direction on spot and directional lights.
  87447. */
  87448. get direction(): Vector3;
  87449. /**
  87450. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87451. * Also use as the light direction on spot and directional lights.
  87452. */
  87453. set direction(value: Vector3);
  87454. protected _shadowMinZ: number;
  87455. /**
  87456. * Gets the shadow projection clipping minimum z value.
  87457. */
  87458. get shadowMinZ(): number;
  87459. /**
  87460. * Sets the shadow projection clipping minimum z value.
  87461. */
  87462. set shadowMinZ(value: number);
  87463. protected _shadowMaxZ: number;
  87464. /**
  87465. * Sets the shadow projection clipping maximum z value.
  87466. */
  87467. get shadowMaxZ(): number;
  87468. /**
  87469. * Gets the shadow projection clipping maximum z value.
  87470. */
  87471. set shadowMaxZ(value: number);
  87472. /**
  87473. * Callback defining a custom Projection Matrix Builder.
  87474. * This can be used to override the default projection matrix computation.
  87475. */
  87476. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87477. /**
  87478. * The transformed position. Position of the light in world space taking parenting in account.
  87479. */
  87480. transformedPosition: Vector3;
  87481. /**
  87482. * The transformed direction. Direction of the light in world space taking parenting in account.
  87483. */
  87484. transformedDirection: Vector3;
  87485. private _needProjectionMatrixCompute;
  87486. /**
  87487. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87488. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87489. */
  87490. computeTransformedInformation(): boolean;
  87491. /**
  87492. * Return the depth scale used for the shadow map.
  87493. * @returns the depth scale.
  87494. */
  87495. getDepthScale(): number;
  87496. /**
  87497. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87498. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87499. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87500. */
  87501. getShadowDirection(faceIndex?: number): Vector3;
  87502. /**
  87503. * Returns the ShadowLight absolute position in the World.
  87504. * @returns the position vector in world space
  87505. */
  87506. getAbsolutePosition(): Vector3;
  87507. /**
  87508. * Sets the ShadowLight direction toward the passed target.
  87509. * @param target The point to target in local space
  87510. * @returns the updated ShadowLight direction
  87511. */
  87512. setDirectionToTarget(target: Vector3): Vector3;
  87513. /**
  87514. * Returns the light rotation in euler definition.
  87515. * @returns the x y z rotation in local space.
  87516. */
  87517. getRotation(): Vector3;
  87518. /**
  87519. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87520. * @returns true if a cube texture needs to be use
  87521. */
  87522. needCube(): boolean;
  87523. /**
  87524. * Detects if the projection matrix requires to be recomputed this frame.
  87525. * @returns true if it requires to be recomputed otherwise, false.
  87526. */
  87527. needProjectionMatrixCompute(): boolean;
  87528. /**
  87529. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87530. */
  87531. forceProjectionMatrixCompute(): void;
  87532. /** @hidden */
  87533. _initCache(): void;
  87534. /** @hidden */
  87535. _isSynchronized(): boolean;
  87536. /**
  87537. * Computes the world matrix of the node
  87538. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87539. * @returns the world matrix
  87540. */
  87541. computeWorldMatrix(force?: boolean): Matrix;
  87542. /**
  87543. * Gets the minZ used for shadow according to both the scene and the light.
  87544. * @param activeCamera The camera we are returning the min for
  87545. * @returns the depth min z
  87546. */
  87547. getDepthMinZ(activeCamera: Camera): number;
  87548. /**
  87549. * Gets the maxZ used for shadow according to both the scene and the light.
  87550. * @param activeCamera The camera we are returning the max for
  87551. * @returns the depth max z
  87552. */
  87553. getDepthMaxZ(activeCamera: Camera): number;
  87554. /**
  87555. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87556. * @param matrix The materix to updated with the projection information
  87557. * @param viewMatrix The transform matrix of the light
  87558. * @param renderList The list of mesh to render in the map
  87559. * @returns The current light
  87560. */
  87561. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87562. }
  87563. }
  87564. declare module BABYLON {
  87565. /** @hidden */
  87566. export var packingFunctions: {
  87567. name: string;
  87568. shader: string;
  87569. };
  87570. }
  87571. declare module BABYLON {
  87572. /** @hidden */
  87573. export var bayerDitherFunctions: {
  87574. name: string;
  87575. shader: string;
  87576. };
  87577. }
  87578. declare module BABYLON {
  87579. /** @hidden */
  87580. export var shadowMapFragmentDeclaration: {
  87581. name: string;
  87582. shader: string;
  87583. };
  87584. }
  87585. declare module BABYLON {
  87586. /** @hidden */
  87587. export var clipPlaneFragmentDeclaration: {
  87588. name: string;
  87589. shader: string;
  87590. };
  87591. }
  87592. declare module BABYLON {
  87593. /** @hidden */
  87594. export var clipPlaneFragment: {
  87595. name: string;
  87596. shader: string;
  87597. };
  87598. }
  87599. declare module BABYLON {
  87600. /** @hidden */
  87601. export var shadowMapFragment: {
  87602. name: string;
  87603. shader: string;
  87604. };
  87605. }
  87606. declare module BABYLON {
  87607. /** @hidden */
  87608. export var shadowMapPixelShader: {
  87609. name: string;
  87610. shader: string;
  87611. };
  87612. }
  87613. declare module BABYLON {
  87614. /** @hidden */
  87615. export var bonesDeclaration: {
  87616. name: string;
  87617. shader: string;
  87618. };
  87619. }
  87620. declare module BABYLON {
  87621. /** @hidden */
  87622. export var morphTargetsVertexGlobalDeclaration: {
  87623. name: string;
  87624. shader: string;
  87625. };
  87626. }
  87627. declare module BABYLON {
  87628. /** @hidden */
  87629. export var morphTargetsVertexDeclaration: {
  87630. name: string;
  87631. shader: string;
  87632. };
  87633. }
  87634. declare module BABYLON {
  87635. /** @hidden */
  87636. export var instancesDeclaration: {
  87637. name: string;
  87638. shader: string;
  87639. };
  87640. }
  87641. declare module BABYLON {
  87642. /** @hidden */
  87643. export var helperFunctions: {
  87644. name: string;
  87645. shader: string;
  87646. };
  87647. }
  87648. declare module BABYLON {
  87649. /** @hidden */
  87650. export var shadowMapVertexDeclaration: {
  87651. name: string;
  87652. shader: string;
  87653. };
  87654. }
  87655. declare module BABYLON {
  87656. /** @hidden */
  87657. export var clipPlaneVertexDeclaration: {
  87658. name: string;
  87659. shader: string;
  87660. };
  87661. }
  87662. declare module BABYLON {
  87663. /** @hidden */
  87664. export var morphTargetsVertex: {
  87665. name: string;
  87666. shader: string;
  87667. };
  87668. }
  87669. declare module BABYLON {
  87670. /** @hidden */
  87671. export var instancesVertex: {
  87672. name: string;
  87673. shader: string;
  87674. };
  87675. }
  87676. declare module BABYLON {
  87677. /** @hidden */
  87678. export var bonesVertex: {
  87679. name: string;
  87680. shader: string;
  87681. };
  87682. }
  87683. declare module BABYLON {
  87684. /** @hidden */
  87685. export var shadowMapVertexNormalBias: {
  87686. name: string;
  87687. shader: string;
  87688. };
  87689. }
  87690. declare module BABYLON {
  87691. /** @hidden */
  87692. export var shadowMapVertexMetric: {
  87693. name: string;
  87694. shader: string;
  87695. };
  87696. }
  87697. declare module BABYLON {
  87698. /** @hidden */
  87699. export var clipPlaneVertex: {
  87700. name: string;
  87701. shader: string;
  87702. };
  87703. }
  87704. declare module BABYLON {
  87705. /** @hidden */
  87706. export var shadowMapVertexShader: {
  87707. name: string;
  87708. shader: string;
  87709. };
  87710. }
  87711. declare module BABYLON {
  87712. /** @hidden */
  87713. export var depthBoxBlurPixelShader: {
  87714. name: string;
  87715. shader: string;
  87716. };
  87717. }
  87718. declare module BABYLON {
  87719. /** @hidden */
  87720. export var shadowMapFragmentSoftTransparentShadow: {
  87721. name: string;
  87722. shader: string;
  87723. };
  87724. }
  87725. declare module BABYLON {
  87726. /**
  87727. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87728. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87729. */
  87730. export class EffectFallbacks implements IEffectFallbacks {
  87731. private _defines;
  87732. private _currentRank;
  87733. private _maxRank;
  87734. private _mesh;
  87735. /**
  87736. * Removes the fallback from the bound mesh.
  87737. */
  87738. unBindMesh(): void;
  87739. /**
  87740. * Adds a fallback on the specified property.
  87741. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87742. * @param define The name of the define in the shader
  87743. */
  87744. addFallback(rank: number, define: string): void;
  87745. /**
  87746. * Sets the mesh to use CPU skinning when needing to fallback.
  87747. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87748. * @param mesh The mesh to use the fallbacks.
  87749. */
  87750. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87751. /**
  87752. * Checks to see if more fallbacks are still availible.
  87753. */
  87754. get hasMoreFallbacks(): boolean;
  87755. /**
  87756. * Removes the defines that should be removed when falling back.
  87757. * @param currentDefines defines the current define statements for the shader.
  87758. * @param effect defines the current effect we try to compile
  87759. * @returns The resulting defines with defines of the current rank removed.
  87760. */
  87761. reduce(currentDefines: string, effect: Effect): string;
  87762. }
  87763. }
  87764. declare module BABYLON {
  87765. /**
  87766. * Interface used to define Action
  87767. */
  87768. export interface IAction {
  87769. /**
  87770. * Trigger for the action
  87771. */
  87772. trigger: number;
  87773. /** Options of the trigger */
  87774. triggerOptions: any;
  87775. /**
  87776. * Gets the trigger parameters
  87777. * @returns the trigger parameters
  87778. */
  87779. getTriggerParameter(): any;
  87780. /**
  87781. * Internal only - executes current action event
  87782. * @hidden
  87783. */
  87784. _executeCurrent(evt?: ActionEvent): void;
  87785. /**
  87786. * Serialize placeholder for child classes
  87787. * @param parent of child
  87788. * @returns the serialized object
  87789. */
  87790. serialize(parent: any): any;
  87791. /**
  87792. * Internal only
  87793. * @hidden
  87794. */
  87795. _prepare(): void;
  87796. /**
  87797. * Internal only - manager for action
  87798. * @hidden
  87799. */
  87800. _actionManager: AbstractActionManager;
  87801. /**
  87802. * Adds action to chain of actions, may be a DoNothingAction
  87803. * @param action defines the next action to execute
  87804. * @returns The action passed in
  87805. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87806. */
  87807. then(action: IAction): IAction;
  87808. }
  87809. /**
  87810. * The action to be carried out following a trigger
  87811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87812. */
  87813. export class Action implements IAction {
  87814. /** the trigger, with or without parameters, for the action */
  87815. triggerOptions: any;
  87816. /**
  87817. * Trigger for the action
  87818. */
  87819. trigger: number;
  87820. /**
  87821. * Internal only - manager for action
  87822. * @hidden
  87823. */
  87824. _actionManager: ActionManager;
  87825. private _nextActiveAction;
  87826. private _child;
  87827. private _condition?;
  87828. private _triggerParameter;
  87829. /**
  87830. * An event triggered prior to action being executed.
  87831. */
  87832. onBeforeExecuteObservable: Observable<Action>;
  87833. /**
  87834. * Creates a new Action
  87835. * @param triggerOptions the trigger, with or without parameters, for the action
  87836. * @param condition an optional determinant of action
  87837. */
  87838. constructor(
  87839. /** the trigger, with or without parameters, for the action */
  87840. triggerOptions: any, condition?: Condition);
  87841. /**
  87842. * Internal only
  87843. * @hidden
  87844. */
  87845. _prepare(): void;
  87846. /**
  87847. * Gets the trigger parameters
  87848. * @returns the trigger parameters
  87849. */
  87850. getTriggerParameter(): any;
  87851. /**
  87852. * Internal only - executes current action event
  87853. * @hidden
  87854. */
  87855. _executeCurrent(evt?: ActionEvent): void;
  87856. /**
  87857. * Execute placeholder for child classes
  87858. * @param evt optional action event
  87859. */
  87860. execute(evt?: ActionEvent): void;
  87861. /**
  87862. * Skips to next active action
  87863. */
  87864. skipToNextActiveAction(): void;
  87865. /**
  87866. * Adds action to chain of actions, may be a DoNothingAction
  87867. * @param action defines the next action to execute
  87868. * @returns The action passed in
  87869. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87870. */
  87871. then(action: Action): Action;
  87872. /**
  87873. * Internal only
  87874. * @hidden
  87875. */
  87876. _getProperty(propertyPath: string): string;
  87877. /**
  87878. * Internal only
  87879. * @hidden
  87880. */
  87881. _getEffectiveTarget(target: any, propertyPath: string): any;
  87882. /**
  87883. * Serialize placeholder for child classes
  87884. * @param parent of child
  87885. * @returns the serialized object
  87886. */
  87887. serialize(parent: any): any;
  87888. /**
  87889. * Internal only called by serialize
  87890. * @hidden
  87891. */
  87892. protected _serialize(serializedAction: any, parent?: any): any;
  87893. /**
  87894. * Internal only
  87895. * @hidden
  87896. */
  87897. static _SerializeValueAsString: (value: any) => string;
  87898. /**
  87899. * Internal only
  87900. * @hidden
  87901. */
  87902. static _GetTargetProperty: (target: Scene | Node) => {
  87903. name: string;
  87904. targetType: string;
  87905. value: string;
  87906. };
  87907. }
  87908. }
  87909. declare module BABYLON {
  87910. /**
  87911. * A Condition applied to an Action
  87912. */
  87913. export class Condition {
  87914. /**
  87915. * Internal only - manager for action
  87916. * @hidden
  87917. */
  87918. _actionManager: ActionManager;
  87919. /**
  87920. * Internal only
  87921. * @hidden
  87922. */
  87923. _evaluationId: number;
  87924. /**
  87925. * Internal only
  87926. * @hidden
  87927. */
  87928. _currentResult: boolean;
  87929. /**
  87930. * Creates a new Condition
  87931. * @param actionManager the manager of the action the condition is applied to
  87932. */
  87933. constructor(actionManager: ActionManager);
  87934. /**
  87935. * Check if the current condition is valid
  87936. * @returns a boolean
  87937. */
  87938. isValid(): boolean;
  87939. /**
  87940. * Internal only
  87941. * @hidden
  87942. */
  87943. _getProperty(propertyPath: string): string;
  87944. /**
  87945. * Internal only
  87946. * @hidden
  87947. */
  87948. _getEffectiveTarget(target: any, propertyPath: string): any;
  87949. /**
  87950. * Serialize placeholder for child classes
  87951. * @returns the serialized object
  87952. */
  87953. serialize(): any;
  87954. /**
  87955. * Internal only
  87956. * @hidden
  87957. */
  87958. protected _serialize(serializedCondition: any): any;
  87959. }
  87960. /**
  87961. * Defines specific conditional operators as extensions of Condition
  87962. */
  87963. export class ValueCondition extends Condition {
  87964. /** path to specify the property of the target the conditional operator uses */
  87965. propertyPath: string;
  87966. /** the value compared by the conditional operator against the current value of the property */
  87967. value: any;
  87968. /** the conditional operator, default ValueCondition.IsEqual */
  87969. operator: number;
  87970. /**
  87971. * Internal only
  87972. * @hidden
  87973. */
  87974. private static _IsEqual;
  87975. /**
  87976. * Internal only
  87977. * @hidden
  87978. */
  87979. private static _IsDifferent;
  87980. /**
  87981. * Internal only
  87982. * @hidden
  87983. */
  87984. private static _IsGreater;
  87985. /**
  87986. * Internal only
  87987. * @hidden
  87988. */
  87989. private static _IsLesser;
  87990. /**
  87991. * returns the number for IsEqual
  87992. */
  87993. static get IsEqual(): number;
  87994. /**
  87995. * Returns the number for IsDifferent
  87996. */
  87997. static get IsDifferent(): number;
  87998. /**
  87999. * Returns the number for IsGreater
  88000. */
  88001. static get IsGreater(): number;
  88002. /**
  88003. * Returns the number for IsLesser
  88004. */
  88005. static get IsLesser(): number;
  88006. /**
  88007. * Internal only The action manager for the condition
  88008. * @hidden
  88009. */
  88010. _actionManager: ActionManager;
  88011. /**
  88012. * Internal only
  88013. * @hidden
  88014. */
  88015. private _target;
  88016. /**
  88017. * Internal only
  88018. * @hidden
  88019. */
  88020. private _effectiveTarget;
  88021. /**
  88022. * Internal only
  88023. * @hidden
  88024. */
  88025. private _property;
  88026. /**
  88027. * Creates a new ValueCondition
  88028. * @param actionManager manager for the action the condition applies to
  88029. * @param target for the action
  88030. * @param propertyPath path to specify the property of the target the conditional operator uses
  88031. * @param value the value compared by the conditional operator against the current value of the property
  88032. * @param operator the conditional operator, default ValueCondition.IsEqual
  88033. */
  88034. constructor(actionManager: ActionManager, target: any,
  88035. /** path to specify the property of the target the conditional operator uses */
  88036. propertyPath: string,
  88037. /** the value compared by the conditional operator against the current value of the property */
  88038. value: any,
  88039. /** the conditional operator, default ValueCondition.IsEqual */
  88040. operator?: number);
  88041. /**
  88042. * Compares the given value with the property value for the specified conditional operator
  88043. * @returns the result of the comparison
  88044. */
  88045. isValid(): boolean;
  88046. /**
  88047. * Serialize the ValueCondition into a JSON compatible object
  88048. * @returns serialization object
  88049. */
  88050. serialize(): any;
  88051. /**
  88052. * Gets the name of the conditional operator for the ValueCondition
  88053. * @param operator the conditional operator
  88054. * @returns the name
  88055. */
  88056. static GetOperatorName(operator: number): string;
  88057. }
  88058. /**
  88059. * Defines a predicate condition as an extension of Condition
  88060. */
  88061. export class PredicateCondition extends Condition {
  88062. /** defines the predicate function used to validate the condition */
  88063. predicate: () => boolean;
  88064. /**
  88065. * Internal only - manager for action
  88066. * @hidden
  88067. */
  88068. _actionManager: ActionManager;
  88069. /**
  88070. * Creates a new PredicateCondition
  88071. * @param actionManager manager for the action the condition applies to
  88072. * @param predicate defines the predicate function used to validate the condition
  88073. */
  88074. constructor(actionManager: ActionManager,
  88075. /** defines the predicate function used to validate the condition */
  88076. predicate: () => boolean);
  88077. /**
  88078. * @returns the validity of the predicate condition
  88079. */
  88080. isValid(): boolean;
  88081. }
  88082. /**
  88083. * Defines a state condition as an extension of Condition
  88084. */
  88085. export class StateCondition extends Condition {
  88086. /** Value to compare with target state */
  88087. value: string;
  88088. /**
  88089. * Internal only - manager for action
  88090. * @hidden
  88091. */
  88092. _actionManager: ActionManager;
  88093. /**
  88094. * Internal only
  88095. * @hidden
  88096. */
  88097. private _target;
  88098. /**
  88099. * Creates a new StateCondition
  88100. * @param actionManager manager for the action the condition applies to
  88101. * @param target of the condition
  88102. * @param value to compare with target state
  88103. */
  88104. constructor(actionManager: ActionManager, target: any,
  88105. /** Value to compare with target state */
  88106. value: string);
  88107. /**
  88108. * Gets a boolean indicating if the current condition is met
  88109. * @returns the validity of the state
  88110. */
  88111. isValid(): boolean;
  88112. /**
  88113. * Serialize the StateCondition into a JSON compatible object
  88114. * @returns serialization object
  88115. */
  88116. serialize(): any;
  88117. }
  88118. }
  88119. declare module BABYLON {
  88120. /**
  88121. * This defines an action responsible to toggle a boolean once triggered.
  88122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88123. */
  88124. export class SwitchBooleanAction extends Action {
  88125. /**
  88126. * The path to the boolean property in the target object
  88127. */
  88128. propertyPath: string;
  88129. private _target;
  88130. private _effectiveTarget;
  88131. private _property;
  88132. /**
  88133. * Instantiate the action
  88134. * @param triggerOptions defines the trigger options
  88135. * @param target defines the object containing the boolean
  88136. * @param propertyPath defines the path to the boolean property in the target object
  88137. * @param condition defines the trigger related conditions
  88138. */
  88139. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88140. /** @hidden */
  88141. _prepare(): void;
  88142. /**
  88143. * Execute the action toggle the boolean value.
  88144. */
  88145. execute(): void;
  88146. /**
  88147. * Serializes the actions and its related information.
  88148. * @param parent defines the object to serialize in
  88149. * @returns the serialized object
  88150. */
  88151. serialize(parent: any): any;
  88152. }
  88153. /**
  88154. * This defines an action responsible to set a the state field of the target
  88155. * to a desired value once triggered.
  88156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88157. */
  88158. export class SetStateAction extends Action {
  88159. /**
  88160. * The value to store in the state field.
  88161. */
  88162. value: string;
  88163. private _target;
  88164. /**
  88165. * Instantiate the action
  88166. * @param triggerOptions defines the trigger options
  88167. * @param target defines the object containing the state property
  88168. * @param value defines the value to store in the state field
  88169. * @param condition defines the trigger related conditions
  88170. */
  88171. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88172. /**
  88173. * Execute the action and store the value on the target state property.
  88174. */
  88175. execute(): void;
  88176. /**
  88177. * Serializes the actions and its related information.
  88178. * @param parent defines the object to serialize in
  88179. * @returns the serialized object
  88180. */
  88181. serialize(parent: any): any;
  88182. }
  88183. /**
  88184. * This defines an action responsible to set a property of the target
  88185. * to a desired value once triggered.
  88186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88187. */
  88188. export class SetValueAction extends Action {
  88189. /**
  88190. * The path of the property to set in the target.
  88191. */
  88192. propertyPath: string;
  88193. /**
  88194. * The value to set in the property
  88195. */
  88196. value: any;
  88197. private _target;
  88198. private _effectiveTarget;
  88199. private _property;
  88200. /**
  88201. * Instantiate the action
  88202. * @param triggerOptions defines the trigger options
  88203. * @param target defines the object containing the property
  88204. * @param propertyPath defines the path of the property to set in the target
  88205. * @param value defines the value to set in the property
  88206. * @param condition defines the trigger related conditions
  88207. */
  88208. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88209. /** @hidden */
  88210. _prepare(): void;
  88211. /**
  88212. * Execute the action and set the targetted property to the desired value.
  88213. */
  88214. execute(): void;
  88215. /**
  88216. * Serializes the actions and its related information.
  88217. * @param parent defines the object to serialize in
  88218. * @returns the serialized object
  88219. */
  88220. serialize(parent: any): any;
  88221. }
  88222. /**
  88223. * This defines an action responsible to increment the target value
  88224. * to a desired value once triggered.
  88225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88226. */
  88227. export class IncrementValueAction extends Action {
  88228. /**
  88229. * The path of the property to increment in the target.
  88230. */
  88231. propertyPath: string;
  88232. /**
  88233. * The value we should increment the property by.
  88234. */
  88235. value: any;
  88236. private _target;
  88237. private _effectiveTarget;
  88238. private _property;
  88239. /**
  88240. * Instantiate the action
  88241. * @param triggerOptions defines the trigger options
  88242. * @param target defines the object containing the property
  88243. * @param propertyPath defines the path of the property to increment in the target
  88244. * @param value defines the value value we should increment the property by
  88245. * @param condition defines the trigger related conditions
  88246. */
  88247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88248. /** @hidden */
  88249. _prepare(): void;
  88250. /**
  88251. * Execute the action and increment the target of the value amount.
  88252. */
  88253. execute(): void;
  88254. /**
  88255. * Serializes the actions and its related information.
  88256. * @param parent defines the object to serialize in
  88257. * @returns the serialized object
  88258. */
  88259. serialize(parent: any): any;
  88260. }
  88261. /**
  88262. * This defines an action responsible to start an animation once triggered.
  88263. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88264. */
  88265. export class PlayAnimationAction extends Action {
  88266. /**
  88267. * Where the animation should start (animation frame)
  88268. */
  88269. from: number;
  88270. /**
  88271. * Where the animation should stop (animation frame)
  88272. */
  88273. to: number;
  88274. /**
  88275. * Define if the animation should loop or stop after the first play.
  88276. */
  88277. loop?: boolean;
  88278. private _target;
  88279. /**
  88280. * Instantiate the action
  88281. * @param triggerOptions defines the trigger options
  88282. * @param target defines the target animation or animation name
  88283. * @param from defines from where the animation should start (animation frame)
  88284. * @param end defines where the animation should stop (animation frame)
  88285. * @param loop defines if the animation should loop or stop after the first play
  88286. * @param condition defines the trigger related conditions
  88287. */
  88288. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88289. /** @hidden */
  88290. _prepare(): void;
  88291. /**
  88292. * Execute the action and play the animation.
  88293. */
  88294. execute(): void;
  88295. /**
  88296. * Serializes the actions and its related information.
  88297. * @param parent defines the object to serialize in
  88298. * @returns the serialized object
  88299. */
  88300. serialize(parent: any): any;
  88301. }
  88302. /**
  88303. * This defines an action responsible to stop an animation once triggered.
  88304. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88305. */
  88306. export class StopAnimationAction extends Action {
  88307. private _target;
  88308. /**
  88309. * Instantiate the action
  88310. * @param triggerOptions defines the trigger options
  88311. * @param target defines the target animation or animation name
  88312. * @param condition defines the trigger related conditions
  88313. */
  88314. constructor(triggerOptions: any, target: any, condition?: Condition);
  88315. /** @hidden */
  88316. _prepare(): void;
  88317. /**
  88318. * Execute the action and stop the animation.
  88319. */
  88320. execute(): void;
  88321. /**
  88322. * Serializes the actions and its related information.
  88323. * @param parent defines the object to serialize in
  88324. * @returns the serialized object
  88325. */
  88326. serialize(parent: any): any;
  88327. }
  88328. /**
  88329. * This defines an action responsible that does nothing once triggered.
  88330. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88331. */
  88332. export class DoNothingAction extends Action {
  88333. /**
  88334. * Instantiate the action
  88335. * @param triggerOptions defines the trigger options
  88336. * @param condition defines the trigger related conditions
  88337. */
  88338. constructor(triggerOptions?: any, condition?: Condition);
  88339. /**
  88340. * Execute the action and do nothing.
  88341. */
  88342. execute(): void;
  88343. /**
  88344. * Serializes the actions and its related information.
  88345. * @param parent defines the object to serialize in
  88346. * @returns the serialized object
  88347. */
  88348. serialize(parent: any): any;
  88349. }
  88350. /**
  88351. * This defines an action responsible to trigger several actions once triggered.
  88352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88353. */
  88354. export class CombineAction extends Action {
  88355. /**
  88356. * The list of aggregated animations to run.
  88357. */
  88358. children: Action[];
  88359. /**
  88360. * Instantiate the action
  88361. * @param triggerOptions defines the trigger options
  88362. * @param children defines the list of aggregated animations to run
  88363. * @param condition defines the trigger related conditions
  88364. */
  88365. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88366. /** @hidden */
  88367. _prepare(): void;
  88368. /**
  88369. * Execute the action and executes all the aggregated actions.
  88370. */
  88371. execute(evt: ActionEvent): void;
  88372. /**
  88373. * Serializes the actions and its related information.
  88374. * @param parent defines the object to serialize in
  88375. * @returns the serialized object
  88376. */
  88377. serialize(parent: any): any;
  88378. }
  88379. /**
  88380. * This defines an action responsible to run code (external event) once triggered.
  88381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88382. */
  88383. export class ExecuteCodeAction extends Action {
  88384. /**
  88385. * The callback function to run.
  88386. */
  88387. func: (evt: ActionEvent) => void;
  88388. /**
  88389. * Instantiate the action
  88390. * @param triggerOptions defines the trigger options
  88391. * @param func defines the callback function to run
  88392. * @param condition defines the trigger related conditions
  88393. */
  88394. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88395. /**
  88396. * Execute the action and run the attached code.
  88397. */
  88398. execute(evt: ActionEvent): void;
  88399. }
  88400. /**
  88401. * This defines an action responsible to set the parent property of the target once triggered.
  88402. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88403. */
  88404. export class SetParentAction extends Action {
  88405. private _parent;
  88406. private _target;
  88407. /**
  88408. * Instantiate the action
  88409. * @param triggerOptions defines the trigger options
  88410. * @param target defines the target containing the parent property
  88411. * @param parent defines from where the animation should start (animation frame)
  88412. * @param condition defines the trigger related conditions
  88413. */
  88414. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88415. /** @hidden */
  88416. _prepare(): void;
  88417. /**
  88418. * Execute the action and set the parent property.
  88419. */
  88420. execute(): void;
  88421. /**
  88422. * Serializes the actions and its related information.
  88423. * @param parent defines the object to serialize in
  88424. * @returns the serialized object
  88425. */
  88426. serialize(parent: any): any;
  88427. }
  88428. }
  88429. declare module BABYLON {
  88430. /**
  88431. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88432. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88434. */
  88435. export class ActionManager extends AbstractActionManager {
  88436. /**
  88437. * Nothing
  88438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88439. */
  88440. static readonly NothingTrigger: number;
  88441. /**
  88442. * On pick
  88443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88444. */
  88445. static readonly OnPickTrigger: number;
  88446. /**
  88447. * On left pick
  88448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88449. */
  88450. static readonly OnLeftPickTrigger: number;
  88451. /**
  88452. * On right pick
  88453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88454. */
  88455. static readonly OnRightPickTrigger: number;
  88456. /**
  88457. * On center pick
  88458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88459. */
  88460. static readonly OnCenterPickTrigger: number;
  88461. /**
  88462. * On pick down
  88463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88464. */
  88465. static readonly OnPickDownTrigger: number;
  88466. /**
  88467. * On double pick
  88468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88469. */
  88470. static readonly OnDoublePickTrigger: number;
  88471. /**
  88472. * On pick up
  88473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88474. */
  88475. static readonly OnPickUpTrigger: number;
  88476. /**
  88477. * On pick out.
  88478. * This trigger will only be raised if you also declared a OnPickDown
  88479. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88480. */
  88481. static readonly OnPickOutTrigger: number;
  88482. /**
  88483. * On long press
  88484. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88485. */
  88486. static readonly OnLongPressTrigger: number;
  88487. /**
  88488. * On pointer over
  88489. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88490. */
  88491. static readonly OnPointerOverTrigger: number;
  88492. /**
  88493. * On pointer out
  88494. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88495. */
  88496. static readonly OnPointerOutTrigger: number;
  88497. /**
  88498. * On every frame
  88499. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88500. */
  88501. static readonly OnEveryFrameTrigger: number;
  88502. /**
  88503. * On intersection enter
  88504. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88505. */
  88506. static readonly OnIntersectionEnterTrigger: number;
  88507. /**
  88508. * On intersection exit
  88509. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88510. */
  88511. static readonly OnIntersectionExitTrigger: number;
  88512. /**
  88513. * On key down
  88514. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88515. */
  88516. static readonly OnKeyDownTrigger: number;
  88517. /**
  88518. * On key up
  88519. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88520. */
  88521. static readonly OnKeyUpTrigger: number;
  88522. private _scene;
  88523. /**
  88524. * Creates a new action manager
  88525. * @param scene defines the hosting scene
  88526. */
  88527. constructor(scene: Scene);
  88528. /**
  88529. * Releases all associated resources
  88530. */
  88531. dispose(): void;
  88532. /**
  88533. * Gets hosting scene
  88534. * @returns the hosting scene
  88535. */
  88536. getScene(): Scene;
  88537. /**
  88538. * Does this action manager handles actions of any of the given triggers
  88539. * @param triggers defines the triggers to be tested
  88540. * @return a boolean indicating whether one (or more) of the triggers is handled
  88541. */
  88542. hasSpecificTriggers(triggers: number[]): boolean;
  88543. /**
  88544. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88545. * speed.
  88546. * @param triggerA defines the trigger to be tested
  88547. * @param triggerB defines the trigger to be tested
  88548. * @return a boolean indicating whether one (or more) of the triggers is handled
  88549. */
  88550. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88551. /**
  88552. * Does this action manager handles actions of a given trigger
  88553. * @param trigger defines the trigger to be tested
  88554. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88555. * @return whether the trigger is handled
  88556. */
  88557. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88558. /**
  88559. * Does this action manager has pointer triggers
  88560. */
  88561. get hasPointerTriggers(): boolean;
  88562. /**
  88563. * Does this action manager has pick triggers
  88564. */
  88565. get hasPickTriggers(): boolean;
  88566. /**
  88567. * Registers an action to this action manager
  88568. * @param action defines the action to be registered
  88569. * @return the action amended (prepared) after registration
  88570. */
  88571. registerAction(action: IAction): Nullable<IAction>;
  88572. /**
  88573. * Unregisters an action to this action manager
  88574. * @param action defines the action to be unregistered
  88575. * @return a boolean indicating whether the action has been unregistered
  88576. */
  88577. unregisterAction(action: IAction): Boolean;
  88578. /**
  88579. * Process a specific trigger
  88580. * @param trigger defines the trigger to process
  88581. * @param evt defines the event details to be processed
  88582. */
  88583. processTrigger(trigger: number, evt?: IActionEvent): void;
  88584. /** @hidden */
  88585. _getEffectiveTarget(target: any, propertyPath: string): any;
  88586. /** @hidden */
  88587. _getProperty(propertyPath: string): string;
  88588. /**
  88589. * Serialize this manager to a JSON object
  88590. * @param name defines the property name to store this manager
  88591. * @returns a JSON representation of this manager
  88592. */
  88593. serialize(name: string): any;
  88594. /**
  88595. * Creates a new ActionManager from a JSON data
  88596. * @param parsedActions defines the JSON data to read from
  88597. * @param object defines the hosting mesh
  88598. * @param scene defines the hosting scene
  88599. */
  88600. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88601. /**
  88602. * Get a trigger name by index
  88603. * @param trigger defines the trigger index
  88604. * @returns a trigger name
  88605. */
  88606. static GetTriggerName(trigger: number): string;
  88607. }
  88608. }
  88609. declare module BABYLON {
  88610. /**
  88611. * Class used to represent a sprite
  88612. * @see https://doc.babylonjs.com/babylon101/sprites
  88613. */
  88614. export class Sprite implements IAnimatable {
  88615. /** defines the name */
  88616. name: string;
  88617. /** Gets or sets the current world position */
  88618. position: Vector3;
  88619. /** Gets or sets the main color */
  88620. color: Color4;
  88621. /** Gets or sets the width */
  88622. width: number;
  88623. /** Gets or sets the height */
  88624. height: number;
  88625. /** Gets or sets rotation angle */
  88626. angle: number;
  88627. /** Gets or sets the cell index in the sprite sheet */
  88628. cellIndex: number;
  88629. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88630. cellRef: string;
  88631. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88632. invertU: boolean;
  88633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88634. invertV: boolean;
  88635. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88636. disposeWhenFinishedAnimating: boolean;
  88637. /** Gets the list of attached animations */
  88638. animations: Nullable<Array<Animation>>;
  88639. /** Gets or sets a boolean indicating if the sprite can be picked */
  88640. isPickable: boolean;
  88641. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88642. useAlphaForPicking: boolean;
  88643. /** @hidden */
  88644. _xOffset: number;
  88645. /** @hidden */
  88646. _yOffset: number;
  88647. /** @hidden */
  88648. _xSize: number;
  88649. /** @hidden */
  88650. _ySize: number;
  88651. /**
  88652. * Gets or sets the associated action manager
  88653. */
  88654. actionManager: Nullable<ActionManager>;
  88655. /**
  88656. * An event triggered when the control has been disposed
  88657. */
  88658. onDisposeObservable: Observable<Sprite>;
  88659. private _animationStarted;
  88660. private _loopAnimation;
  88661. private _fromIndex;
  88662. private _toIndex;
  88663. private _delay;
  88664. private _direction;
  88665. private _manager;
  88666. private _time;
  88667. private _onAnimationEnd;
  88668. /**
  88669. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88670. */
  88671. isVisible: boolean;
  88672. /**
  88673. * Gets or sets the sprite size
  88674. */
  88675. get size(): number;
  88676. set size(value: number);
  88677. /**
  88678. * Returns a boolean indicating if the animation is started
  88679. */
  88680. get animationStarted(): boolean;
  88681. /**
  88682. * Gets or sets the unique id of the sprite
  88683. */
  88684. uniqueId: number;
  88685. /**
  88686. * Gets the manager of this sprite
  88687. */
  88688. get manager(): ISpriteManager;
  88689. /**
  88690. * Creates a new Sprite
  88691. * @param name defines the name
  88692. * @param manager defines the manager
  88693. */
  88694. constructor(
  88695. /** defines the name */
  88696. name: string, manager: ISpriteManager);
  88697. /**
  88698. * Returns the string "Sprite"
  88699. * @returns "Sprite"
  88700. */
  88701. getClassName(): string;
  88702. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88703. get fromIndex(): number;
  88704. set fromIndex(value: number);
  88705. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88706. get toIndex(): number;
  88707. set toIndex(value: number);
  88708. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88709. get loopAnimation(): boolean;
  88710. set loopAnimation(value: boolean);
  88711. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88712. get delay(): number;
  88713. set delay(value: number);
  88714. /**
  88715. * Starts an animation
  88716. * @param from defines the initial key
  88717. * @param to defines the end key
  88718. * @param loop defines if the animation must loop
  88719. * @param delay defines the start delay (in ms)
  88720. * @param onAnimationEnd defines a callback to call when animation ends
  88721. */
  88722. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88723. /** Stops current animation (if any) */
  88724. stopAnimation(): void;
  88725. /** @hidden */
  88726. _animate(deltaTime: number): void;
  88727. /** Release associated resources */
  88728. dispose(): void;
  88729. /**
  88730. * Serializes the sprite to a JSON object
  88731. * @returns the JSON object
  88732. */
  88733. serialize(): any;
  88734. /**
  88735. * Parses a JSON object to create a new sprite
  88736. * @param parsedSprite The JSON object to parse
  88737. * @param manager defines the hosting manager
  88738. * @returns the new sprite
  88739. */
  88740. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88741. }
  88742. }
  88743. declare module BABYLON {
  88744. /**
  88745. * Information about the result of picking within a scene
  88746. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88747. */
  88748. export class PickingInfo {
  88749. /** @hidden */
  88750. _pickingUnavailable: boolean;
  88751. /**
  88752. * If the pick collided with an object
  88753. */
  88754. hit: boolean;
  88755. /**
  88756. * Distance away where the pick collided
  88757. */
  88758. distance: number;
  88759. /**
  88760. * The location of pick collision
  88761. */
  88762. pickedPoint: Nullable<Vector3>;
  88763. /**
  88764. * The mesh corresponding the the pick collision
  88765. */
  88766. pickedMesh: Nullable<AbstractMesh>;
  88767. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88768. bu: number;
  88769. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88770. bv: number;
  88771. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88772. faceId: number;
  88773. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88774. subMeshFaceId: number;
  88775. /** Id of the the submesh that was picked */
  88776. subMeshId: number;
  88777. /** If a sprite was picked, this will be the sprite the pick collided with */
  88778. pickedSprite: Nullable<Sprite>;
  88779. /**
  88780. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88781. */
  88782. originMesh: Nullable<AbstractMesh>;
  88783. /**
  88784. * The ray that was used to perform the picking.
  88785. */
  88786. ray: Nullable<Ray>;
  88787. /**
  88788. * Gets the normal correspodning to the face the pick collided with
  88789. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88790. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88791. * @returns The normal correspodning to the face the pick collided with
  88792. */
  88793. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88794. /**
  88795. * Gets the texture coordinates of where the pick occured
  88796. * @returns the vector containing the coordnates of the texture
  88797. */
  88798. getTextureCoordinates(): Nullable<Vector2>;
  88799. }
  88800. }
  88801. declare module BABYLON {
  88802. /**
  88803. * Class representing a ray with position and direction
  88804. */
  88805. export class Ray {
  88806. /** origin point */
  88807. origin: Vector3;
  88808. /** direction */
  88809. direction: Vector3;
  88810. /** length of the ray */
  88811. length: number;
  88812. private static readonly TmpVector3;
  88813. private _tmpRay;
  88814. /**
  88815. * Creates a new ray
  88816. * @param origin origin point
  88817. * @param direction direction
  88818. * @param length length of the ray
  88819. */
  88820. constructor(
  88821. /** origin point */
  88822. origin: Vector3,
  88823. /** direction */
  88824. direction: Vector3,
  88825. /** length of the ray */
  88826. length?: number);
  88827. /**
  88828. * Checks if the ray intersects a box
  88829. * This does not account for the ray lenght by design to improve perfs.
  88830. * @param minimum bound of the box
  88831. * @param maximum bound of the box
  88832. * @param intersectionTreshold extra extend to be added to the box in all direction
  88833. * @returns if the box was hit
  88834. */
  88835. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88836. /**
  88837. * Checks if the ray intersects a box
  88838. * This does not account for the ray lenght by design to improve perfs.
  88839. * @param box the bounding box to check
  88840. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88841. * @returns if the box was hit
  88842. */
  88843. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88844. /**
  88845. * If the ray hits a sphere
  88846. * @param sphere the bounding sphere to check
  88847. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88848. * @returns true if it hits the sphere
  88849. */
  88850. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88851. /**
  88852. * If the ray hits a triange
  88853. * @param vertex0 triangle vertex
  88854. * @param vertex1 triangle vertex
  88855. * @param vertex2 triangle vertex
  88856. * @returns intersection information if hit
  88857. */
  88858. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88859. /**
  88860. * Checks if ray intersects a plane
  88861. * @param plane the plane to check
  88862. * @returns the distance away it was hit
  88863. */
  88864. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88865. /**
  88866. * Calculate the intercept of a ray on a given axis
  88867. * @param axis to check 'x' | 'y' | 'z'
  88868. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88869. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88870. */
  88871. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88872. /**
  88873. * Checks if ray intersects a mesh
  88874. * @param mesh the mesh to check
  88875. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88876. * @returns picking info of the intersecton
  88877. */
  88878. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88879. /**
  88880. * Checks if ray intersects a mesh
  88881. * @param meshes the meshes to check
  88882. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88883. * @param results array to store result in
  88884. * @returns Array of picking infos
  88885. */
  88886. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88887. private _comparePickingInfo;
  88888. private static smallnum;
  88889. private static rayl;
  88890. /**
  88891. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88892. * @param sega the first point of the segment to test the intersection against
  88893. * @param segb the second point of the segment to test the intersection against
  88894. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88895. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88896. */
  88897. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88898. /**
  88899. * Update the ray from viewport position
  88900. * @param x position
  88901. * @param y y position
  88902. * @param viewportWidth viewport width
  88903. * @param viewportHeight viewport height
  88904. * @param world world matrix
  88905. * @param view view matrix
  88906. * @param projection projection matrix
  88907. * @returns this ray updated
  88908. */
  88909. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88910. /**
  88911. * Creates a ray with origin and direction of 0,0,0
  88912. * @returns the new ray
  88913. */
  88914. static Zero(): Ray;
  88915. /**
  88916. * Creates a new ray from screen space and viewport
  88917. * @param x position
  88918. * @param y y position
  88919. * @param viewportWidth viewport width
  88920. * @param viewportHeight viewport height
  88921. * @param world world matrix
  88922. * @param view view matrix
  88923. * @param projection projection matrix
  88924. * @returns new ray
  88925. */
  88926. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88927. /**
  88928. * 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
  88929. * transformed to the given world matrix.
  88930. * @param origin The origin point
  88931. * @param end The end point
  88932. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88933. * @returns the new ray
  88934. */
  88935. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88936. /**
  88937. * Transforms a ray by a matrix
  88938. * @param ray ray to transform
  88939. * @param matrix matrix to apply
  88940. * @returns the resulting new ray
  88941. */
  88942. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88943. /**
  88944. * Transforms a ray by a matrix
  88945. * @param ray ray to transform
  88946. * @param matrix matrix to apply
  88947. * @param result ray to store result in
  88948. */
  88949. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88950. /**
  88951. * Unproject a ray from screen space to object space
  88952. * @param sourceX defines the screen space x coordinate to use
  88953. * @param sourceY defines the screen space y coordinate to use
  88954. * @param viewportWidth defines the current width of the viewport
  88955. * @param viewportHeight defines the current height of the viewport
  88956. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88957. * @param view defines the view matrix to use
  88958. * @param projection defines the projection matrix to use
  88959. */
  88960. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88961. }
  88962. /**
  88963. * Type used to define predicate used to select faces when a mesh intersection is detected
  88964. */
  88965. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88966. interface Scene {
  88967. /** @hidden */
  88968. _tempPickingRay: Nullable<Ray>;
  88969. /** @hidden */
  88970. _cachedRayForTransform: Ray;
  88971. /** @hidden */
  88972. _pickWithRayInverseMatrix: Matrix;
  88973. /** @hidden */
  88974. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88975. /** @hidden */
  88976. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88977. }
  88978. }
  88979. declare module BABYLON {
  88980. /**
  88981. * Groups all the scene component constants in one place to ease maintenance.
  88982. * @hidden
  88983. */
  88984. export class SceneComponentConstants {
  88985. static readonly NAME_EFFECTLAYER: string;
  88986. static readonly NAME_LAYER: string;
  88987. static readonly NAME_LENSFLARESYSTEM: string;
  88988. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88989. static readonly NAME_PARTICLESYSTEM: string;
  88990. static readonly NAME_GAMEPAD: string;
  88991. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88992. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88993. static readonly NAME_PREPASSRENDERER: string;
  88994. static readonly NAME_DEPTHRENDERER: string;
  88995. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88996. static readonly NAME_SPRITE: string;
  88997. static readonly NAME_OUTLINERENDERER: string;
  88998. static readonly NAME_PROCEDURALTEXTURE: string;
  88999. static readonly NAME_SHADOWGENERATOR: string;
  89000. static readonly NAME_OCTREE: string;
  89001. static readonly NAME_PHYSICSENGINE: string;
  89002. static readonly NAME_AUDIO: string;
  89003. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89004. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89005. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89006. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89007. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89008. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89009. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89010. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89011. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89012. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89013. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89014. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89015. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89016. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89017. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89018. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89019. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89020. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89021. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89022. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89023. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89024. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89025. static readonly STEP_AFTERRENDER_AUDIO: number;
  89026. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89027. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89028. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89029. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89030. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89031. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89032. static readonly STEP_POINTERMOVE_SPRITE: number;
  89033. static readonly STEP_POINTERDOWN_SPRITE: number;
  89034. static readonly STEP_POINTERUP_SPRITE: number;
  89035. }
  89036. /**
  89037. * This represents a scene component.
  89038. *
  89039. * This is used to decouple the dependency the scene is having on the different workloads like
  89040. * layers, post processes...
  89041. */
  89042. export interface ISceneComponent {
  89043. /**
  89044. * The name of the component. Each component must have a unique name.
  89045. */
  89046. name: string;
  89047. /**
  89048. * The scene the component belongs to.
  89049. */
  89050. scene: Scene;
  89051. /**
  89052. * Register the component to one instance of a scene.
  89053. */
  89054. register(): void;
  89055. /**
  89056. * Rebuilds the elements related to this component in case of
  89057. * context lost for instance.
  89058. */
  89059. rebuild(): void;
  89060. /**
  89061. * Disposes the component and the associated ressources.
  89062. */
  89063. dispose(): void;
  89064. }
  89065. /**
  89066. * This represents a SERIALIZABLE scene component.
  89067. *
  89068. * This extends Scene Component to add Serialization methods on top.
  89069. */
  89070. export interface ISceneSerializableComponent extends ISceneComponent {
  89071. /**
  89072. * Adds all the elements from the container to the scene
  89073. * @param container the container holding the elements
  89074. */
  89075. addFromContainer(container: AbstractScene): void;
  89076. /**
  89077. * Removes all the elements in the container from the scene
  89078. * @param container contains the elements to remove
  89079. * @param dispose if the removed element should be disposed (default: false)
  89080. */
  89081. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89082. /**
  89083. * Serializes the component data to the specified json object
  89084. * @param serializationObject The object to serialize to
  89085. */
  89086. serialize(serializationObject: any): void;
  89087. }
  89088. /**
  89089. * Strong typing of a Mesh related stage step action
  89090. */
  89091. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89092. /**
  89093. * Strong typing of a Evaluate Sub Mesh related stage step action
  89094. */
  89095. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89096. /**
  89097. * Strong typing of a Active Mesh related stage step action
  89098. */
  89099. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89100. /**
  89101. * Strong typing of a Camera related stage step action
  89102. */
  89103. export type CameraStageAction = (camera: Camera) => void;
  89104. /**
  89105. * Strong typing of a Camera Frame buffer related stage step action
  89106. */
  89107. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89108. /**
  89109. * Strong typing of a Render Target related stage step action
  89110. */
  89111. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89112. /**
  89113. * Strong typing of a RenderingGroup related stage step action
  89114. */
  89115. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89116. /**
  89117. * Strong typing of a Mesh Render related stage step action
  89118. */
  89119. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89120. /**
  89121. * Strong typing of a simple stage step action
  89122. */
  89123. export type SimpleStageAction = () => void;
  89124. /**
  89125. * Strong typing of a render target action.
  89126. */
  89127. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89128. /**
  89129. * Strong typing of a pointer move action.
  89130. */
  89131. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89132. /**
  89133. * Strong typing of a pointer up/down action.
  89134. */
  89135. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89136. /**
  89137. * Representation of a stage in the scene (Basically a list of ordered steps)
  89138. * @hidden
  89139. */
  89140. export class Stage<T extends Function> extends Array<{
  89141. index: number;
  89142. component: ISceneComponent;
  89143. action: T;
  89144. }> {
  89145. /**
  89146. * Hide ctor from the rest of the world.
  89147. * @param items The items to add.
  89148. */
  89149. private constructor();
  89150. /**
  89151. * Creates a new Stage.
  89152. * @returns A new instance of a Stage
  89153. */
  89154. static Create<T extends Function>(): Stage<T>;
  89155. /**
  89156. * Registers a step in an ordered way in the targeted stage.
  89157. * @param index Defines the position to register the step in
  89158. * @param component Defines the component attached to the step
  89159. * @param action Defines the action to launch during the step
  89160. */
  89161. registerStep(index: number, component: ISceneComponent, action: T): void;
  89162. /**
  89163. * Clears all the steps from the stage.
  89164. */
  89165. clear(): void;
  89166. }
  89167. }
  89168. declare module BABYLON {
  89169. interface Scene {
  89170. /** @hidden */
  89171. _pointerOverSprite: Nullable<Sprite>;
  89172. /** @hidden */
  89173. _pickedDownSprite: Nullable<Sprite>;
  89174. /** @hidden */
  89175. _tempSpritePickingRay: Nullable<Ray>;
  89176. /**
  89177. * All of the sprite managers added to this scene
  89178. * @see https://doc.babylonjs.com/babylon101/sprites
  89179. */
  89180. spriteManagers: Array<ISpriteManager>;
  89181. /**
  89182. * An event triggered when sprites rendering is about to start
  89183. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89184. */
  89185. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89186. /**
  89187. * An event triggered when sprites rendering is done
  89188. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89189. */
  89190. onAfterSpritesRenderingObservable: Observable<Scene>;
  89191. /** @hidden */
  89192. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89193. /** Launch a ray to try to pick a sprite in the scene
  89194. * @param x position on screen
  89195. * @param y position on screen
  89196. * @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
  89197. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89198. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89199. * @returns a PickingInfo
  89200. */
  89201. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89202. /** Use the given ray to pick a sprite in the scene
  89203. * @param ray The ray (in world space) to use to pick meshes
  89204. * @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
  89205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89206. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89207. * @returns a PickingInfo
  89208. */
  89209. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89210. /** @hidden */
  89211. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89212. /** Launch a ray to try to pick sprites in the scene
  89213. * @param x position on screen
  89214. * @param y position on screen
  89215. * @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
  89216. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89217. * @returns a PickingInfo array
  89218. */
  89219. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89220. /** Use the given ray to pick sprites in the scene
  89221. * @param ray The ray (in world space) to use to pick meshes
  89222. * @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
  89223. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89224. * @returns a PickingInfo array
  89225. */
  89226. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89227. /**
  89228. * Force the sprite under the pointer
  89229. * @param sprite defines the sprite to use
  89230. */
  89231. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89232. /**
  89233. * Gets the sprite under the pointer
  89234. * @returns a Sprite or null if no sprite is under the pointer
  89235. */
  89236. getPointerOverSprite(): Nullable<Sprite>;
  89237. }
  89238. /**
  89239. * Defines the sprite scene component responsible to manage sprites
  89240. * in a given scene.
  89241. */
  89242. export class SpriteSceneComponent implements ISceneComponent {
  89243. /**
  89244. * The component name helpfull to identify the component in the list of scene components.
  89245. */
  89246. readonly name: string;
  89247. /**
  89248. * The scene the component belongs to.
  89249. */
  89250. scene: Scene;
  89251. /** @hidden */
  89252. private _spritePredicate;
  89253. /**
  89254. * Creates a new instance of the component for the given scene
  89255. * @param scene Defines the scene to register the component in
  89256. */
  89257. constructor(scene: Scene);
  89258. /**
  89259. * Registers the component in a given scene
  89260. */
  89261. register(): void;
  89262. /**
  89263. * Rebuilds the elements related to this component in case of
  89264. * context lost for instance.
  89265. */
  89266. rebuild(): void;
  89267. /**
  89268. * Disposes the component and the associated ressources.
  89269. */
  89270. dispose(): void;
  89271. private _pickSpriteButKeepRay;
  89272. private _pointerMove;
  89273. private _pointerDown;
  89274. private _pointerUp;
  89275. }
  89276. }
  89277. declare module BABYLON {
  89278. /** @hidden */
  89279. export var fogFragmentDeclaration: {
  89280. name: string;
  89281. shader: string;
  89282. };
  89283. }
  89284. declare module BABYLON {
  89285. /** @hidden */
  89286. export var fogFragment: {
  89287. name: string;
  89288. shader: string;
  89289. };
  89290. }
  89291. declare module BABYLON {
  89292. /** @hidden */
  89293. export var spritesPixelShader: {
  89294. name: string;
  89295. shader: string;
  89296. };
  89297. }
  89298. declare module BABYLON {
  89299. /** @hidden */
  89300. export var fogVertexDeclaration: {
  89301. name: string;
  89302. shader: string;
  89303. };
  89304. }
  89305. declare module BABYLON {
  89306. /** @hidden */
  89307. export var spritesVertexShader: {
  89308. name: string;
  89309. shader: string;
  89310. };
  89311. }
  89312. declare module BABYLON {
  89313. /**
  89314. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89315. */
  89316. export interface ISpriteManager extends IDisposable {
  89317. /**
  89318. * Gets manager's name
  89319. */
  89320. name: string;
  89321. /**
  89322. * Restricts the camera to viewing objects with the same layerMask.
  89323. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89324. */
  89325. layerMask: number;
  89326. /**
  89327. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89328. */
  89329. isPickable: boolean;
  89330. /**
  89331. * Gets the hosting scene
  89332. */
  89333. scene: Scene;
  89334. /**
  89335. * Specifies the rendering group id for this mesh (0 by default)
  89336. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89337. */
  89338. renderingGroupId: number;
  89339. /**
  89340. * Defines the list of sprites managed by the manager.
  89341. */
  89342. sprites: Array<Sprite>;
  89343. /**
  89344. * Gets or sets the spritesheet texture
  89345. */
  89346. texture: Texture;
  89347. /** Defines the default width of a cell in the spritesheet */
  89348. cellWidth: number;
  89349. /** Defines the default height of a cell in the spritesheet */
  89350. cellHeight: number;
  89351. /**
  89352. * Tests the intersection of a sprite with a specific ray.
  89353. * @param ray The ray we are sending to test the collision
  89354. * @param camera The camera space we are sending rays in
  89355. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89356. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89357. * @returns picking info or null.
  89358. */
  89359. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89360. /**
  89361. * Intersects the sprites with a ray
  89362. * @param ray defines the ray to intersect with
  89363. * @param camera defines the current active camera
  89364. * @param predicate defines a predicate used to select candidate sprites
  89365. * @returns null if no hit or a PickingInfo array
  89366. */
  89367. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89368. /**
  89369. * Renders the list of sprites on screen.
  89370. */
  89371. render(): void;
  89372. }
  89373. /**
  89374. * Class used to manage multiple sprites on the same spritesheet
  89375. * @see https://doc.babylonjs.com/babylon101/sprites
  89376. */
  89377. export class SpriteManager implements ISpriteManager {
  89378. /** defines the manager's name */
  89379. name: string;
  89380. /** Define the Url to load snippets */
  89381. static SnippetUrl: string;
  89382. /** Snippet ID if the manager was created from the snippet server */
  89383. snippetId: string;
  89384. /** Gets the list of sprites */
  89385. sprites: Sprite[];
  89386. /** Gets or sets the rendering group id (0 by default) */
  89387. renderingGroupId: number;
  89388. /** Gets or sets camera layer mask */
  89389. layerMask: number;
  89390. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89391. fogEnabled: boolean;
  89392. /** Gets or sets a boolean indicating if the sprites are pickable */
  89393. isPickable: boolean;
  89394. /** Defines the default width of a cell in the spritesheet */
  89395. cellWidth: number;
  89396. /** Defines the default height of a cell in the spritesheet */
  89397. cellHeight: number;
  89398. /** Associative array from JSON sprite data file */
  89399. private _cellData;
  89400. /** Array of sprite names from JSON sprite data file */
  89401. private _spriteMap;
  89402. /** True when packed cell data from JSON file is ready*/
  89403. private _packedAndReady;
  89404. private _textureContent;
  89405. /**
  89406. * An event triggered when the manager is disposed.
  89407. */
  89408. onDisposeObservable: Observable<SpriteManager>;
  89409. private _onDisposeObserver;
  89410. /**
  89411. * Callback called when the manager is disposed
  89412. */
  89413. set onDispose(callback: () => void);
  89414. private _capacity;
  89415. private _fromPacked;
  89416. private _spriteTexture;
  89417. private _epsilon;
  89418. private _scene;
  89419. private _vertexData;
  89420. private _buffer;
  89421. private _vertexBuffers;
  89422. private _indexBuffer;
  89423. private _effectBase;
  89424. private _effectFog;
  89425. /**
  89426. * Gets or sets the unique id of the sprite
  89427. */
  89428. uniqueId: number;
  89429. /**
  89430. * Gets the array of sprites
  89431. */
  89432. get children(): Sprite[];
  89433. /**
  89434. * Gets the hosting scene
  89435. */
  89436. get scene(): Scene;
  89437. /**
  89438. * Gets the capacity of the manager
  89439. */
  89440. get capacity(): number;
  89441. /**
  89442. * Gets or sets the spritesheet texture
  89443. */
  89444. get texture(): Texture;
  89445. set texture(value: Texture);
  89446. private _blendMode;
  89447. /**
  89448. * Blend mode use to render the particle, it can be any of
  89449. * the static Constants.ALPHA_x properties provided in this class.
  89450. * Default value is Constants.ALPHA_COMBINE
  89451. */
  89452. get blendMode(): number;
  89453. set blendMode(blendMode: number);
  89454. /** Disables writing to the depth buffer when rendering the sprites.
  89455. * It can be handy to disable depth writing when using textures without alpha channel
  89456. * and setting some specific blend modes.
  89457. */
  89458. disableDepthWrite: boolean;
  89459. /**
  89460. * Creates a new sprite manager
  89461. * @param name defines the manager's name
  89462. * @param imgUrl defines the sprite sheet url
  89463. * @param capacity defines the maximum allowed number of sprites
  89464. * @param cellSize defines the size of a sprite cell
  89465. * @param scene defines the hosting scene
  89466. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89467. * @param samplingMode defines the smapling mode to use with spritesheet
  89468. * @param fromPacked set to false; do not alter
  89469. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89470. */
  89471. constructor(
  89472. /** defines the manager's name */
  89473. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89474. /**
  89475. * Returns the string "SpriteManager"
  89476. * @returns "SpriteManager"
  89477. */
  89478. getClassName(): string;
  89479. private _makePacked;
  89480. private _appendSpriteVertex;
  89481. private _checkTextureAlpha;
  89482. /**
  89483. * Intersects the sprites with a ray
  89484. * @param ray defines the ray to intersect with
  89485. * @param camera defines the current active camera
  89486. * @param predicate defines a predicate used to select candidate sprites
  89487. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89488. * @returns null if no hit or a PickingInfo
  89489. */
  89490. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89491. /**
  89492. * Intersects the sprites with a ray
  89493. * @param ray defines the ray to intersect with
  89494. * @param camera defines the current active camera
  89495. * @param predicate defines a predicate used to select candidate sprites
  89496. * @returns null if no hit or a PickingInfo array
  89497. */
  89498. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89499. /**
  89500. * Render all child sprites
  89501. */
  89502. render(): void;
  89503. /**
  89504. * Release associated resources
  89505. */
  89506. dispose(): void;
  89507. /**
  89508. * Serializes the sprite manager to a JSON object
  89509. * @param serializeTexture defines if the texture must be serialized as well
  89510. * @returns the JSON object
  89511. */
  89512. serialize(serializeTexture?: boolean): any;
  89513. /**
  89514. * Parses a JSON object to create a new sprite manager.
  89515. * @param parsedManager The JSON object to parse
  89516. * @param scene The scene to create the sprite managerin
  89517. * @param rootUrl The root url to use to load external dependencies like texture
  89518. * @returns the new sprite manager
  89519. */
  89520. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89521. /**
  89522. * Creates a sprite manager from a snippet saved in a remote file
  89523. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89524. * @param url defines the url to load from
  89525. * @param scene defines the hosting scene
  89526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89527. * @returns a promise that will resolve to the new sprite manager
  89528. */
  89529. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89530. /**
  89531. * Creates a sprite manager from a snippet saved by the sprite editor
  89532. * @param snippetId defines the snippet to load
  89533. * @param scene defines the hosting scene
  89534. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89535. * @returns a promise that will resolve to the new sprite manager
  89536. */
  89537. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89538. }
  89539. }
  89540. declare module BABYLON {
  89541. /** Interface used by value gradients (color, factor, ...) */
  89542. export interface IValueGradient {
  89543. /**
  89544. * Gets or sets the gradient value (between 0 and 1)
  89545. */
  89546. gradient: number;
  89547. }
  89548. /** Class used to store color4 gradient */
  89549. export class ColorGradient implements IValueGradient {
  89550. /**
  89551. * Gets or sets the gradient value (between 0 and 1)
  89552. */
  89553. gradient: number;
  89554. /**
  89555. * Gets or sets first associated color
  89556. */
  89557. color1: Color4;
  89558. /**
  89559. * Gets or sets second associated color
  89560. */
  89561. color2?: Color4 | undefined;
  89562. /**
  89563. * Creates a new color4 gradient
  89564. * @param gradient gets or sets the gradient value (between 0 and 1)
  89565. * @param color1 gets or sets first associated color
  89566. * @param color2 gets or sets first second color
  89567. */
  89568. constructor(
  89569. /**
  89570. * Gets or sets the gradient value (between 0 and 1)
  89571. */
  89572. gradient: number,
  89573. /**
  89574. * Gets or sets first associated color
  89575. */
  89576. color1: Color4,
  89577. /**
  89578. * Gets or sets second associated color
  89579. */
  89580. color2?: Color4 | undefined);
  89581. /**
  89582. * Will get a color picked randomly between color1 and color2.
  89583. * If color2 is undefined then color1 will be used
  89584. * @param result defines the target Color4 to store the result in
  89585. */
  89586. getColorToRef(result: Color4): void;
  89587. }
  89588. /** Class used to store color 3 gradient */
  89589. export class Color3Gradient implements IValueGradient {
  89590. /**
  89591. * Gets or sets the gradient value (between 0 and 1)
  89592. */
  89593. gradient: number;
  89594. /**
  89595. * Gets or sets the associated color
  89596. */
  89597. color: Color3;
  89598. /**
  89599. * Creates a new color3 gradient
  89600. * @param gradient gets or sets the gradient value (between 0 and 1)
  89601. * @param color gets or sets associated color
  89602. */
  89603. constructor(
  89604. /**
  89605. * Gets or sets the gradient value (between 0 and 1)
  89606. */
  89607. gradient: number,
  89608. /**
  89609. * Gets or sets the associated color
  89610. */
  89611. color: Color3);
  89612. }
  89613. /** Class used to store factor gradient */
  89614. export class FactorGradient implements IValueGradient {
  89615. /**
  89616. * Gets or sets the gradient value (between 0 and 1)
  89617. */
  89618. gradient: number;
  89619. /**
  89620. * Gets or sets first associated factor
  89621. */
  89622. factor1: number;
  89623. /**
  89624. * Gets or sets second associated factor
  89625. */
  89626. factor2?: number | undefined;
  89627. /**
  89628. * Creates a new factor gradient
  89629. * @param gradient gets or sets the gradient value (between 0 and 1)
  89630. * @param factor1 gets or sets first associated factor
  89631. * @param factor2 gets or sets second associated factor
  89632. */
  89633. constructor(
  89634. /**
  89635. * Gets or sets the gradient value (between 0 and 1)
  89636. */
  89637. gradient: number,
  89638. /**
  89639. * Gets or sets first associated factor
  89640. */
  89641. factor1: number,
  89642. /**
  89643. * Gets or sets second associated factor
  89644. */
  89645. factor2?: number | undefined);
  89646. /**
  89647. * Will get a number picked randomly between factor1 and factor2.
  89648. * If factor2 is undefined then factor1 will be used
  89649. * @returns the picked number
  89650. */
  89651. getFactor(): number;
  89652. }
  89653. /**
  89654. * Helper used to simplify some generic gradient tasks
  89655. */
  89656. export class GradientHelper {
  89657. /**
  89658. * Gets the current gradient from an array of IValueGradient
  89659. * @param ratio defines the current ratio to get
  89660. * @param gradients defines the array of IValueGradient
  89661. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89662. */
  89663. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89664. }
  89665. }
  89666. declare module BABYLON {
  89667. interface ThinEngine {
  89668. /**
  89669. * Creates a raw texture
  89670. * @param data defines the data to store in the texture
  89671. * @param width defines the width of the texture
  89672. * @param height defines the height of the texture
  89673. * @param format defines the format of the data
  89674. * @param generateMipMaps defines if the engine should generate the mip levels
  89675. * @param invertY defines if data must be stored with Y axis inverted
  89676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89677. * @param compression defines the compression used (null by default)
  89678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89679. * @returns the raw texture inside an InternalTexture
  89680. */
  89681. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89682. /**
  89683. * Update a raw texture
  89684. * @param texture defines the texture to update
  89685. * @param data defines the data to store in the texture
  89686. * @param format defines the format of the data
  89687. * @param invertY defines if data must be stored with Y axis inverted
  89688. */
  89689. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89690. /**
  89691. * Update a raw texture
  89692. * @param texture defines the texture to update
  89693. * @param data defines the data to store in the texture
  89694. * @param format defines the format of the data
  89695. * @param invertY defines if data must be stored with Y axis inverted
  89696. * @param compression defines the compression used (null by default)
  89697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89698. */
  89699. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89700. /**
  89701. * Creates a new raw cube texture
  89702. * @param data defines the array of data to use to create each face
  89703. * @param size defines the size of the textures
  89704. * @param format defines the format of the data
  89705. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89706. * @param generateMipMaps defines if the engine should generate the mip levels
  89707. * @param invertY defines if data must be stored with Y axis inverted
  89708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89709. * @param compression defines the compression used (null by default)
  89710. * @returns the cube texture as an InternalTexture
  89711. */
  89712. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89713. /**
  89714. * Update a raw cube texture
  89715. * @param texture defines the texture to udpdate
  89716. * @param data defines the data to store
  89717. * @param format defines the data format
  89718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89719. * @param invertY defines if data must be stored with Y axis inverted
  89720. */
  89721. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89722. /**
  89723. * Update a raw cube texture
  89724. * @param texture defines the texture to udpdate
  89725. * @param data defines the data to store
  89726. * @param format defines the data format
  89727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89728. * @param invertY defines if data must be stored with Y axis inverted
  89729. * @param compression defines the compression used (null by default)
  89730. */
  89731. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89732. /**
  89733. * Update a raw cube texture
  89734. * @param texture defines the texture to udpdate
  89735. * @param data defines the data to store
  89736. * @param format defines the data format
  89737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89738. * @param invertY defines if data must be stored with Y axis inverted
  89739. * @param compression defines the compression used (null by default)
  89740. * @param level defines which level of the texture to update
  89741. */
  89742. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89743. /**
  89744. * Creates a new raw cube texture from a specified url
  89745. * @param url defines the url where the data is located
  89746. * @param scene defines the current scene
  89747. * @param size defines the size of the textures
  89748. * @param format defines the format of the data
  89749. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89750. * @param noMipmap defines if the engine should avoid generating the mip levels
  89751. * @param callback defines a callback used to extract texture data from loaded data
  89752. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89753. * @param onLoad defines a callback called when texture is loaded
  89754. * @param onError defines a callback called if there is an error
  89755. * @returns the cube texture as an InternalTexture
  89756. */
  89757. 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;
  89758. /**
  89759. * Creates a new raw cube texture from a specified url
  89760. * @param url defines the url where the data is located
  89761. * @param scene defines the current scene
  89762. * @param size defines the size of the textures
  89763. * @param format defines the format of the data
  89764. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89765. * @param noMipmap defines if the engine should avoid generating the mip levels
  89766. * @param callback defines a callback used to extract texture data from loaded data
  89767. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89768. * @param onLoad defines a callback called when texture is loaded
  89769. * @param onError defines a callback called if there is an error
  89770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89771. * @param invertY defines if data must be stored with Y axis inverted
  89772. * @returns the cube texture as an InternalTexture
  89773. */
  89774. 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;
  89775. /**
  89776. * Creates a new raw 3D texture
  89777. * @param data defines the data used to create the texture
  89778. * @param width defines the width of the texture
  89779. * @param height defines the height of the texture
  89780. * @param depth defines the depth of the texture
  89781. * @param format defines the format of the texture
  89782. * @param generateMipMaps defines if the engine must generate mip levels
  89783. * @param invertY defines if data must be stored with Y axis inverted
  89784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89785. * @param compression defines the compressed used (can be null)
  89786. * @param textureType defines the compressed used (can be null)
  89787. * @returns a new raw 3D texture (stored in an InternalTexture)
  89788. */
  89789. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89790. /**
  89791. * Update a raw 3D texture
  89792. * @param texture defines the texture to update
  89793. * @param data defines the data to store
  89794. * @param format defines the data format
  89795. * @param invertY defines if data must be stored with Y axis inverted
  89796. */
  89797. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89798. /**
  89799. * Update a raw 3D texture
  89800. * @param texture defines the texture to update
  89801. * @param data defines the data to store
  89802. * @param format defines the data format
  89803. * @param invertY defines if data must be stored with Y axis inverted
  89804. * @param compression defines the used compression (can be null)
  89805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89806. */
  89807. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89808. /**
  89809. * Creates a new raw 2D array texture
  89810. * @param data defines the data used to create the texture
  89811. * @param width defines the width of the texture
  89812. * @param height defines the height of the texture
  89813. * @param depth defines the number of layers of the texture
  89814. * @param format defines the format of the texture
  89815. * @param generateMipMaps defines if the engine must generate mip levels
  89816. * @param invertY defines if data must be stored with Y axis inverted
  89817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89818. * @param compression defines the compressed used (can be null)
  89819. * @param textureType defines the compressed used (can be null)
  89820. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89821. */
  89822. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89823. /**
  89824. * Update a raw 2D array texture
  89825. * @param texture defines the texture to update
  89826. * @param data defines the data to store
  89827. * @param format defines the data format
  89828. * @param invertY defines if data must be stored with Y axis inverted
  89829. */
  89830. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89831. /**
  89832. * Update a raw 2D array texture
  89833. * @param texture defines the texture to update
  89834. * @param data defines the data to store
  89835. * @param format defines the data format
  89836. * @param invertY defines if data must be stored with Y axis inverted
  89837. * @param compression defines the used compression (can be null)
  89838. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89839. */
  89840. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89841. }
  89842. }
  89843. declare module BABYLON {
  89844. /**
  89845. * Raw texture can help creating a texture directly from an array of data.
  89846. * This can be super useful if you either get the data from an uncompressed source or
  89847. * if you wish to create your texture pixel by pixel.
  89848. */
  89849. export class RawTexture extends Texture {
  89850. /**
  89851. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89852. */
  89853. format: number;
  89854. /**
  89855. * Instantiates a new RawTexture.
  89856. * Raw texture can help creating a texture directly from an array of data.
  89857. * This can be super useful if you either get the data from an uncompressed source or
  89858. * if you wish to create your texture pixel by pixel.
  89859. * @param data define the array of data to use to create the texture
  89860. * @param width define the width of the texture
  89861. * @param height define the height of the texture
  89862. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89863. * @param scene define the scene the texture belongs to
  89864. * @param generateMipMaps define whether mip maps should be generated or not
  89865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89868. */
  89869. constructor(data: ArrayBufferView, width: number, height: number,
  89870. /**
  89871. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89872. */
  89873. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89874. /**
  89875. * Updates the texture underlying data.
  89876. * @param data Define the new data of the texture
  89877. */
  89878. update(data: ArrayBufferView): void;
  89879. /**
  89880. * Creates a luminance texture from some data.
  89881. * @param data Define the texture data
  89882. * @param width Define the width of the texture
  89883. * @param height Define the height of the texture
  89884. * @param scene Define the scene the texture belongs to
  89885. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89886. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89887. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89888. * @returns the luminance texture
  89889. */
  89890. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89891. /**
  89892. * Creates a luminance alpha texture from some data.
  89893. * @param data Define the texture data
  89894. * @param width Define the width of the texture
  89895. * @param height Define the height of the texture
  89896. * @param scene Define the scene the texture belongs to
  89897. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89898. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89899. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89900. * @returns the luminance alpha texture
  89901. */
  89902. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89903. /**
  89904. * Creates an alpha texture from some data.
  89905. * @param data Define the texture data
  89906. * @param width Define the width of the texture
  89907. * @param height Define the height of the texture
  89908. * @param scene Define the scene the texture belongs to
  89909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89912. * @returns the alpha texture
  89913. */
  89914. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89915. /**
  89916. * Creates a RGB texture from some data.
  89917. * @param data Define the texture data
  89918. * @param width Define the width of the texture
  89919. * @param height Define the height of the texture
  89920. * @param scene Define the scene the texture belongs to
  89921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89925. * @returns the RGB alpha texture
  89926. */
  89927. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89928. /**
  89929. * Creates a RGBA texture from some data.
  89930. * @param data Define the texture data
  89931. * @param width Define the width of the texture
  89932. * @param height Define the height of the texture
  89933. * @param scene Define the scene the texture belongs to
  89934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89937. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89938. * @returns the RGBA texture
  89939. */
  89940. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89941. /**
  89942. * Creates a R texture from some data.
  89943. * @param data Define the texture data
  89944. * @param width Define the width of the texture
  89945. * @param height Define the height of the texture
  89946. * @param scene Define the scene the texture belongs to
  89947. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89948. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89949. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89950. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89951. * @returns the R texture
  89952. */
  89953. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89954. }
  89955. }
  89956. declare module BABYLON {
  89957. interface AbstractScene {
  89958. /**
  89959. * The list of procedural textures added to the scene
  89960. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89961. */
  89962. proceduralTextures: Array<ProceduralTexture>;
  89963. }
  89964. /**
  89965. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89966. * in a given scene.
  89967. */
  89968. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89969. /**
  89970. * The component name helpfull to identify the component in the list of scene components.
  89971. */
  89972. readonly name: string;
  89973. /**
  89974. * The scene the component belongs to.
  89975. */
  89976. scene: Scene;
  89977. /**
  89978. * Creates a new instance of the component for the given scene
  89979. * @param scene Defines the scene to register the component in
  89980. */
  89981. constructor(scene: Scene);
  89982. /**
  89983. * Registers the component in a given scene
  89984. */
  89985. register(): void;
  89986. /**
  89987. * Rebuilds the elements related to this component in case of
  89988. * context lost for instance.
  89989. */
  89990. rebuild(): void;
  89991. /**
  89992. * Disposes the component and the associated ressources.
  89993. */
  89994. dispose(): void;
  89995. private _beforeClear;
  89996. }
  89997. }
  89998. declare module BABYLON {
  89999. interface ThinEngine {
  90000. /**
  90001. * Creates a new render target cube texture
  90002. * @param size defines the size of the texture
  90003. * @param options defines the options used to create the texture
  90004. * @returns a new render target cube texture stored in an InternalTexture
  90005. */
  90006. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90007. }
  90008. }
  90009. declare module BABYLON {
  90010. /** @hidden */
  90011. export var proceduralVertexShader: {
  90012. name: string;
  90013. shader: string;
  90014. };
  90015. }
  90016. declare module BABYLON {
  90017. /**
  90018. * 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.
  90019. * This is the base class of any Procedural texture and contains most of the shareable code.
  90020. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90021. */
  90022. export class ProceduralTexture extends Texture {
  90023. isCube: boolean;
  90024. /**
  90025. * Define if the texture is enabled or not (disabled texture will not render)
  90026. */
  90027. isEnabled: boolean;
  90028. /**
  90029. * Define if the texture must be cleared before rendering (default is true)
  90030. */
  90031. autoClear: boolean;
  90032. /**
  90033. * Callback called when the texture is generated
  90034. */
  90035. onGenerated: () => void;
  90036. /**
  90037. * Event raised when the texture is generated
  90038. */
  90039. onGeneratedObservable: Observable<ProceduralTexture>;
  90040. /** @hidden */
  90041. _generateMipMaps: boolean;
  90042. /** @hidden **/
  90043. _effect: Effect;
  90044. /** @hidden */
  90045. _textures: {
  90046. [key: string]: Texture;
  90047. };
  90048. /** @hidden */
  90049. protected _fallbackTexture: Nullable<Texture>;
  90050. private _size;
  90051. private _currentRefreshId;
  90052. private _frameId;
  90053. private _refreshRate;
  90054. private _vertexBuffers;
  90055. private _indexBuffer;
  90056. private _uniforms;
  90057. private _samplers;
  90058. private _fragment;
  90059. private _floats;
  90060. private _ints;
  90061. private _floatsArrays;
  90062. private _colors3;
  90063. private _colors4;
  90064. private _vectors2;
  90065. private _vectors3;
  90066. private _matrices;
  90067. private _fallbackTextureUsed;
  90068. private _fullEngine;
  90069. private _cachedDefines;
  90070. private _contentUpdateId;
  90071. private _contentData;
  90072. /**
  90073. * Instantiates a new procedural texture.
  90074. * 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.
  90075. * This is the base class of any Procedural texture and contains most of the shareable code.
  90076. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90077. * @param name Define the name of the texture
  90078. * @param size Define the size of the texture to create
  90079. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90080. * @param scene Define the scene the texture belongs to
  90081. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90082. * @param generateMipMaps Define if the texture should creates mip maps or not
  90083. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90084. */
  90085. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90086. /**
  90087. * The effect that is created when initializing the post process.
  90088. * @returns The created effect corresponding the the postprocess.
  90089. */
  90090. getEffect(): Effect;
  90091. /**
  90092. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90093. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90094. */
  90095. getContent(): Nullable<ArrayBufferView>;
  90096. private _createIndexBuffer;
  90097. /** @hidden */
  90098. _rebuild(): void;
  90099. /**
  90100. * Resets the texture in order to recreate its associated resources.
  90101. * This can be called in case of context loss
  90102. */
  90103. reset(): void;
  90104. protected _getDefines(): string;
  90105. /**
  90106. * Is the texture ready to be used ? (rendered at least once)
  90107. * @returns true if ready, otherwise, false.
  90108. */
  90109. isReady(): boolean;
  90110. /**
  90111. * Resets the refresh counter of the texture and start bak from scratch.
  90112. * Could be useful to regenerate the texture if it is setup to render only once.
  90113. */
  90114. resetRefreshCounter(): void;
  90115. /**
  90116. * Set the fragment shader to use in order to render the texture.
  90117. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90118. */
  90119. setFragment(fragment: any): void;
  90120. /**
  90121. * Define the refresh rate of the texture or the rendering frequency.
  90122. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90123. */
  90124. get refreshRate(): number;
  90125. set refreshRate(value: number);
  90126. /** @hidden */
  90127. _shouldRender(): boolean;
  90128. /**
  90129. * Get the size the texture is rendering at.
  90130. * @returns the size (texture is always squared)
  90131. */
  90132. getRenderSize(): number;
  90133. /**
  90134. * Resize the texture to new value.
  90135. * @param size Define the new size the texture should have
  90136. * @param generateMipMaps Define whether the new texture should create mip maps
  90137. */
  90138. resize(size: number, generateMipMaps: boolean): void;
  90139. private _checkUniform;
  90140. /**
  90141. * Set a texture in the shader program used to render.
  90142. * @param name Define the name of the uniform samplers as defined in the shader
  90143. * @param texture Define the texture to bind to this sampler
  90144. * @return the texture itself allowing "fluent" like uniform updates
  90145. */
  90146. setTexture(name: string, texture: Texture): ProceduralTexture;
  90147. /**
  90148. * Set a float in the shader.
  90149. * @param name Define the name of the uniform as defined in the shader
  90150. * @param value Define the value to give to the uniform
  90151. * @return the texture itself allowing "fluent" like uniform updates
  90152. */
  90153. setFloat(name: string, value: number): ProceduralTexture;
  90154. /**
  90155. * Set a int in the shader.
  90156. * @param name Define the name of the uniform as defined in the shader
  90157. * @param value Define the value to give to the uniform
  90158. * @return the texture itself allowing "fluent" like uniform updates
  90159. */
  90160. setInt(name: string, value: number): ProceduralTexture;
  90161. /**
  90162. * Set an array of floats in the shader.
  90163. * @param name Define the name of the uniform as defined in the shader
  90164. * @param value Define the value to give to the uniform
  90165. * @return the texture itself allowing "fluent" like uniform updates
  90166. */
  90167. setFloats(name: string, value: number[]): ProceduralTexture;
  90168. /**
  90169. * Set a vec3 in the shader from a Color3.
  90170. * @param name Define the name of the uniform as defined in the shader
  90171. * @param value Define the value to give to the uniform
  90172. * @return the texture itself allowing "fluent" like uniform updates
  90173. */
  90174. setColor3(name: string, value: Color3): ProceduralTexture;
  90175. /**
  90176. * Set a vec4 in the shader from a Color4.
  90177. * @param name Define the name of the uniform as defined in the shader
  90178. * @param value Define the value to give to the uniform
  90179. * @return the texture itself allowing "fluent" like uniform updates
  90180. */
  90181. setColor4(name: string, value: Color4): ProceduralTexture;
  90182. /**
  90183. * Set a vec2 in the shader from a Vector2.
  90184. * @param name Define the name of the uniform as defined in the shader
  90185. * @param value Define the value to give to the uniform
  90186. * @return the texture itself allowing "fluent" like uniform updates
  90187. */
  90188. setVector2(name: string, value: Vector2): ProceduralTexture;
  90189. /**
  90190. * Set a vec3 in the shader from a Vector3.
  90191. * @param name Define the name of the uniform as defined in the shader
  90192. * @param value Define the value to give to the uniform
  90193. * @return the texture itself allowing "fluent" like uniform updates
  90194. */
  90195. setVector3(name: string, value: Vector3): ProceduralTexture;
  90196. /**
  90197. * Set a mat4 in the shader from a MAtrix.
  90198. * @param name Define the name of the uniform as defined in the shader
  90199. * @param value Define the value to give to the uniform
  90200. * @return the texture itself allowing "fluent" like uniform updates
  90201. */
  90202. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90203. /**
  90204. * Render the texture to its associated render target.
  90205. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90206. */
  90207. render(useCameraPostProcess?: boolean): void;
  90208. /**
  90209. * Clone the texture.
  90210. * @returns the cloned texture
  90211. */
  90212. clone(): ProceduralTexture;
  90213. /**
  90214. * Dispose the texture and release its asoociated resources.
  90215. */
  90216. dispose(): void;
  90217. }
  90218. }
  90219. declare module BABYLON {
  90220. /**
  90221. * This represents the base class for particle system in Babylon.
  90222. * 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.
  90223. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90224. * @example https://doc.babylonjs.com/babylon101/particles
  90225. */
  90226. export class BaseParticleSystem {
  90227. /**
  90228. * Source color is added to the destination color without alpha affecting the result
  90229. */
  90230. static BLENDMODE_ONEONE: number;
  90231. /**
  90232. * Blend current color and particle color using particle’s alpha
  90233. */
  90234. static BLENDMODE_STANDARD: number;
  90235. /**
  90236. * Add current color and particle color multiplied by particle’s alpha
  90237. */
  90238. static BLENDMODE_ADD: number;
  90239. /**
  90240. * Multiply current color with particle color
  90241. */
  90242. static BLENDMODE_MULTIPLY: number;
  90243. /**
  90244. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90245. */
  90246. static BLENDMODE_MULTIPLYADD: number;
  90247. /**
  90248. * List of animations used by the particle system.
  90249. */
  90250. animations: Animation[];
  90251. /**
  90252. * Gets or sets the unique id of the particle system
  90253. */
  90254. uniqueId: number;
  90255. /**
  90256. * The id of the Particle system.
  90257. */
  90258. id: string;
  90259. /**
  90260. * The friendly name of the Particle system.
  90261. */
  90262. name: string;
  90263. /**
  90264. * Snippet ID if the particle system was created from the snippet server
  90265. */
  90266. snippetId: string;
  90267. /**
  90268. * The rendering group used by the Particle system to chose when to render.
  90269. */
  90270. renderingGroupId: number;
  90271. /**
  90272. * The emitter represents the Mesh or position we are attaching the particle system to.
  90273. */
  90274. emitter: Nullable<AbstractMesh | Vector3>;
  90275. /**
  90276. * The maximum number of particles to emit per frame
  90277. */
  90278. emitRate: number;
  90279. /**
  90280. * If you want to launch only a few particles at once, that can be done, as well.
  90281. */
  90282. manualEmitCount: number;
  90283. /**
  90284. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90285. */
  90286. updateSpeed: number;
  90287. /**
  90288. * The amount of time the particle system is running (depends of the overall update speed).
  90289. */
  90290. targetStopDuration: number;
  90291. /**
  90292. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90293. */
  90294. disposeOnStop: boolean;
  90295. /**
  90296. * Minimum power of emitting particles.
  90297. */
  90298. minEmitPower: number;
  90299. /**
  90300. * Maximum power of emitting particles.
  90301. */
  90302. maxEmitPower: number;
  90303. /**
  90304. * Minimum life time of emitting particles.
  90305. */
  90306. minLifeTime: number;
  90307. /**
  90308. * Maximum life time of emitting particles.
  90309. */
  90310. maxLifeTime: number;
  90311. /**
  90312. * Minimum Size of emitting particles.
  90313. */
  90314. minSize: number;
  90315. /**
  90316. * Maximum Size of emitting particles.
  90317. */
  90318. maxSize: number;
  90319. /**
  90320. * Minimum scale of emitting particles on X axis.
  90321. */
  90322. minScaleX: number;
  90323. /**
  90324. * Maximum scale of emitting particles on X axis.
  90325. */
  90326. maxScaleX: number;
  90327. /**
  90328. * Minimum scale of emitting particles on Y axis.
  90329. */
  90330. minScaleY: number;
  90331. /**
  90332. * Maximum scale of emitting particles on Y axis.
  90333. */
  90334. maxScaleY: number;
  90335. /**
  90336. * Gets or sets the minimal initial rotation in radians.
  90337. */
  90338. minInitialRotation: number;
  90339. /**
  90340. * Gets or sets the maximal initial rotation in radians.
  90341. */
  90342. maxInitialRotation: number;
  90343. /**
  90344. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90345. */
  90346. minAngularSpeed: number;
  90347. /**
  90348. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90349. */
  90350. maxAngularSpeed: number;
  90351. /**
  90352. * The texture used to render each particle. (this can be a spritesheet)
  90353. */
  90354. particleTexture: Nullable<Texture>;
  90355. /**
  90356. * The layer mask we are rendering the particles through.
  90357. */
  90358. layerMask: number;
  90359. /**
  90360. * This can help using your own shader to render the particle system.
  90361. * The according effect will be created
  90362. */
  90363. customShader: any;
  90364. /**
  90365. * By default particle system starts as soon as they are created. This prevents the
  90366. * automatic start to happen and let you decide when to start emitting particles.
  90367. */
  90368. preventAutoStart: boolean;
  90369. private _noiseTexture;
  90370. /**
  90371. * Gets or sets a texture used to add random noise to particle positions
  90372. */
  90373. get noiseTexture(): Nullable<ProceduralTexture>;
  90374. set noiseTexture(value: Nullable<ProceduralTexture>);
  90375. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90376. noiseStrength: Vector3;
  90377. /**
  90378. * Callback triggered when the particle animation is ending.
  90379. */
  90380. onAnimationEnd: Nullable<() => void>;
  90381. /**
  90382. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90383. */
  90384. blendMode: number;
  90385. /**
  90386. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90387. * to override the particles.
  90388. */
  90389. forceDepthWrite: boolean;
  90390. /** 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 */
  90391. preWarmCycles: number;
  90392. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90393. preWarmStepOffset: number;
  90394. /**
  90395. * 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)
  90396. */
  90397. spriteCellChangeSpeed: number;
  90398. /**
  90399. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90400. */
  90401. startSpriteCellID: number;
  90402. /**
  90403. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90404. */
  90405. endSpriteCellID: number;
  90406. /**
  90407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90408. */
  90409. spriteCellWidth: number;
  90410. /**
  90411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90412. */
  90413. spriteCellHeight: number;
  90414. /**
  90415. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90416. */
  90417. spriteRandomStartCell: boolean;
  90418. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90419. translationPivot: Vector2;
  90420. /** @hidden */
  90421. protected _isAnimationSheetEnabled: boolean;
  90422. /**
  90423. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90424. */
  90425. beginAnimationOnStart: boolean;
  90426. /**
  90427. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90428. */
  90429. beginAnimationFrom: number;
  90430. /**
  90431. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90432. */
  90433. beginAnimationTo: number;
  90434. /**
  90435. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90436. */
  90437. beginAnimationLoop: boolean;
  90438. /**
  90439. * Gets or sets a world offset applied to all particles
  90440. */
  90441. worldOffset: Vector3;
  90442. /**
  90443. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90444. */
  90445. get isAnimationSheetEnabled(): boolean;
  90446. set isAnimationSheetEnabled(value: boolean);
  90447. /**
  90448. * Get hosting scene
  90449. * @returns the scene
  90450. */
  90451. getScene(): Scene;
  90452. /**
  90453. * You can use gravity if you want to give an orientation to your particles.
  90454. */
  90455. gravity: Vector3;
  90456. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90457. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90458. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90459. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90460. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90461. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90462. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90463. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90464. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90465. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90466. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90467. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90468. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90469. /**
  90470. * Defines the delay in milliseconds before starting the system (0 by default)
  90471. */
  90472. startDelay: number;
  90473. /**
  90474. * Gets the current list of drag gradients.
  90475. * You must use addDragGradient and removeDragGradient to udpate this list
  90476. * @returns the list of drag gradients
  90477. */
  90478. getDragGradients(): Nullable<Array<FactorGradient>>;
  90479. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90480. limitVelocityDamping: number;
  90481. /**
  90482. * Gets the current list of limit velocity gradients.
  90483. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90484. * @returns the list of limit velocity gradients
  90485. */
  90486. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90487. /**
  90488. * Gets the current list of color gradients.
  90489. * You must use addColorGradient and removeColorGradient to udpate this list
  90490. * @returns the list of color gradients
  90491. */
  90492. getColorGradients(): Nullable<Array<ColorGradient>>;
  90493. /**
  90494. * Gets the current list of size gradients.
  90495. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90496. * @returns the list of size gradients
  90497. */
  90498. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90499. /**
  90500. * Gets the current list of color remap gradients.
  90501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90502. * @returns the list of color remap gradients
  90503. */
  90504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90505. /**
  90506. * Gets the current list of alpha remap gradients.
  90507. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90508. * @returns the list of alpha remap gradients
  90509. */
  90510. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90511. /**
  90512. * Gets the current list of life time gradients.
  90513. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90514. * @returns the list of life time gradients
  90515. */
  90516. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90517. /**
  90518. * Gets the current list of angular speed gradients.
  90519. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90520. * @returns the list of angular speed gradients
  90521. */
  90522. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90523. /**
  90524. * Gets the current list of velocity gradients.
  90525. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90526. * @returns the list of velocity gradients
  90527. */
  90528. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90529. /**
  90530. * Gets the current list of start size gradients.
  90531. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90532. * @returns the list of start size gradients
  90533. */
  90534. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90535. /**
  90536. * Gets the current list of emit rate gradients.
  90537. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90538. * @returns the list of emit rate gradients
  90539. */
  90540. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90541. /**
  90542. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90543. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90544. */
  90545. get direction1(): Vector3;
  90546. set direction1(value: Vector3);
  90547. /**
  90548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90550. */
  90551. get direction2(): Vector3;
  90552. set direction2(value: Vector3);
  90553. /**
  90554. * 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.
  90555. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90556. */
  90557. get minEmitBox(): Vector3;
  90558. set minEmitBox(value: Vector3);
  90559. /**
  90560. * 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.
  90561. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90562. */
  90563. get maxEmitBox(): Vector3;
  90564. set maxEmitBox(value: Vector3);
  90565. /**
  90566. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90567. */
  90568. color1: Color4;
  90569. /**
  90570. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90571. */
  90572. color2: Color4;
  90573. /**
  90574. * Color the particle will have at the end of its lifetime
  90575. */
  90576. colorDead: Color4;
  90577. /**
  90578. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90579. */
  90580. textureMask: Color4;
  90581. /**
  90582. * The particle emitter type defines the emitter used by the particle system.
  90583. * It can be for example box, sphere, or cone...
  90584. */
  90585. particleEmitterType: IParticleEmitterType;
  90586. /** @hidden */
  90587. _isSubEmitter: boolean;
  90588. /**
  90589. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90590. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90591. */
  90592. billboardMode: number;
  90593. protected _isBillboardBased: boolean;
  90594. /**
  90595. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90596. */
  90597. get isBillboardBased(): boolean;
  90598. set isBillboardBased(value: boolean);
  90599. /**
  90600. * The scene the particle system belongs to.
  90601. */
  90602. protected _scene: Scene;
  90603. /**
  90604. * Local cache of defines for image processing.
  90605. */
  90606. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90607. /**
  90608. * Default configuration related to image processing available in the standard Material.
  90609. */
  90610. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90611. /**
  90612. * Gets the image processing configuration used either in this material.
  90613. */
  90614. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90615. /**
  90616. * Sets the Default image processing configuration used either in the this material.
  90617. *
  90618. * If sets to null, the scene one is in use.
  90619. */
  90620. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90621. /**
  90622. * Attaches a new image processing configuration to the Standard Material.
  90623. * @param configuration
  90624. */
  90625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90626. /** @hidden */
  90627. protected _reset(): void;
  90628. /** @hidden */
  90629. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90630. /**
  90631. * Instantiates a particle system.
  90632. * 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.
  90633. * @param name The name of the particle system
  90634. */
  90635. constructor(name: string);
  90636. /**
  90637. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90640. * @returns the emitter
  90641. */
  90642. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90643. /**
  90644. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90645. * @param radius The radius of the hemisphere to emit from
  90646. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90647. * @returns the emitter
  90648. */
  90649. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90650. /**
  90651. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90652. * @param radius The radius of the sphere to emit from
  90653. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90654. * @returns the emitter
  90655. */
  90656. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90657. /**
  90658. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90659. * @param radius The radius of the sphere to emit from
  90660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90662. * @returns the emitter
  90663. */
  90664. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90665. /**
  90666. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90667. * @param radius The radius of the emission cylinder
  90668. * @param height The height of the emission cylinder
  90669. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90670. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90671. * @returns the emitter
  90672. */
  90673. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90674. /**
  90675. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90676. * @param radius The radius of the cylinder to emit from
  90677. * @param height The height of the emission cylinder
  90678. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90681. * @returns the emitter
  90682. */
  90683. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90684. /**
  90685. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90686. * @param radius The radius of the cone to emit from
  90687. * @param angle The base angle of the cone
  90688. * @returns the emitter
  90689. */
  90690. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90691. /**
  90692. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90695. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90696. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90697. * @returns the emitter
  90698. */
  90699. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90700. }
  90701. }
  90702. declare module BABYLON {
  90703. /**
  90704. * Type of sub emitter
  90705. */
  90706. export enum SubEmitterType {
  90707. /**
  90708. * Attached to the particle over it's lifetime
  90709. */
  90710. ATTACHED = 0,
  90711. /**
  90712. * Created when the particle dies
  90713. */
  90714. END = 1
  90715. }
  90716. /**
  90717. * Sub emitter class used to emit particles from an existing particle
  90718. */
  90719. export class SubEmitter {
  90720. /**
  90721. * the particle system to be used by the sub emitter
  90722. */
  90723. particleSystem: ParticleSystem;
  90724. /**
  90725. * Type of the submitter (Default: END)
  90726. */
  90727. type: SubEmitterType;
  90728. /**
  90729. * 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)
  90730. * Note: This only is supported when using an emitter of type Mesh
  90731. */
  90732. inheritDirection: boolean;
  90733. /**
  90734. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90735. */
  90736. inheritedVelocityAmount: number;
  90737. /**
  90738. * Creates a sub emitter
  90739. * @param particleSystem the particle system to be used by the sub emitter
  90740. */
  90741. constructor(
  90742. /**
  90743. * the particle system to be used by the sub emitter
  90744. */
  90745. particleSystem: ParticleSystem);
  90746. /**
  90747. * Clones the sub emitter
  90748. * @returns the cloned sub emitter
  90749. */
  90750. clone(): SubEmitter;
  90751. /**
  90752. * Serialize current object to a JSON object
  90753. * @returns the serialized object
  90754. */
  90755. serialize(): any;
  90756. /** @hidden */
  90757. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90758. /**
  90759. * Creates a new SubEmitter from a serialized JSON version
  90760. * @param serializationObject defines the JSON object to read from
  90761. * @param scene defines the hosting scene
  90762. * @param rootUrl defines the rootUrl for data loading
  90763. * @returns a new SubEmitter
  90764. */
  90765. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90766. /** Release associated resources */
  90767. dispose(): void;
  90768. }
  90769. }
  90770. declare module BABYLON {
  90771. /** @hidden */
  90772. export var imageProcessingDeclaration: {
  90773. name: string;
  90774. shader: string;
  90775. };
  90776. }
  90777. declare module BABYLON {
  90778. /** @hidden */
  90779. export var imageProcessingFunctions: {
  90780. name: string;
  90781. shader: string;
  90782. };
  90783. }
  90784. declare module BABYLON {
  90785. /** @hidden */
  90786. export var particlesPixelShader: {
  90787. name: string;
  90788. shader: string;
  90789. };
  90790. }
  90791. declare module BABYLON {
  90792. /** @hidden */
  90793. export var particlesVertexShader: {
  90794. name: string;
  90795. shader: string;
  90796. };
  90797. }
  90798. declare module BABYLON {
  90799. /**
  90800. * This represents a particle system in Babylon.
  90801. * 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.
  90802. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90803. * @example https://doc.babylonjs.com/babylon101/particles
  90804. */
  90805. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90806. /**
  90807. * Billboard mode will only apply to Y axis
  90808. */
  90809. static readonly BILLBOARDMODE_Y: number;
  90810. /**
  90811. * Billboard mode will apply to all axes
  90812. */
  90813. static readonly BILLBOARDMODE_ALL: number;
  90814. /**
  90815. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90816. */
  90817. static readonly BILLBOARDMODE_STRETCHED: number;
  90818. /**
  90819. * This function can be defined to provide custom update for active particles.
  90820. * This function will be called instead of regular update (age, position, color, etc.).
  90821. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90822. */
  90823. updateFunction: (particles: Particle[]) => void;
  90824. private _emitterWorldMatrix;
  90825. /**
  90826. * This function can be defined to specify initial direction for every new particle.
  90827. * It by default use the emitterType defined function
  90828. */
  90829. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90830. /**
  90831. * This function can be defined to specify initial position for every new particle.
  90832. * It by default use the emitterType defined function
  90833. */
  90834. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90835. /**
  90836. * @hidden
  90837. */
  90838. _inheritedVelocityOffset: Vector3;
  90839. /**
  90840. * An event triggered when the system is disposed
  90841. */
  90842. onDisposeObservable: Observable<IParticleSystem>;
  90843. private _onDisposeObserver;
  90844. /**
  90845. * Sets a callback that will be triggered when the system is disposed
  90846. */
  90847. set onDispose(callback: () => void);
  90848. private _particles;
  90849. private _epsilon;
  90850. private _capacity;
  90851. private _stockParticles;
  90852. private _newPartsExcess;
  90853. private _vertexData;
  90854. private _vertexBuffer;
  90855. private _vertexBuffers;
  90856. private _spriteBuffer;
  90857. private _indexBuffer;
  90858. private _effect;
  90859. private _customEffect;
  90860. private _cachedDefines;
  90861. private _scaledColorStep;
  90862. private _colorDiff;
  90863. private _scaledDirection;
  90864. private _scaledGravity;
  90865. private _currentRenderId;
  90866. private _alive;
  90867. private _useInstancing;
  90868. private _started;
  90869. private _stopped;
  90870. private _actualFrame;
  90871. private _scaledUpdateSpeed;
  90872. private _vertexBufferSize;
  90873. /** @hidden */
  90874. _currentEmitRateGradient: Nullable<FactorGradient>;
  90875. /** @hidden */
  90876. _currentEmitRate1: number;
  90877. /** @hidden */
  90878. _currentEmitRate2: number;
  90879. /** @hidden */
  90880. _currentStartSizeGradient: Nullable<FactorGradient>;
  90881. /** @hidden */
  90882. _currentStartSize1: number;
  90883. /** @hidden */
  90884. _currentStartSize2: number;
  90885. private readonly _rawTextureWidth;
  90886. private _rampGradientsTexture;
  90887. private _useRampGradients;
  90888. /** Gets or sets a boolean indicating that ramp gradients must be used
  90889. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90890. */
  90891. get useRampGradients(): boolean;
  90892. set useRampGradients(value: boolean);
  90893. /**
  90894. * 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.
  90895. * 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: [])
  90896. */
  90897. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90898. private _subEmitters;
  90899. /**
  90900. * @hidden
  90901. * If the particle systems emitter should be disposed when the particle system is disposed
  90902. */
  90903. _disposeEmitterOnDispose: boolean;
  90904. /**
  90905. * The current active Sub-systems, this property is used by the root particle system only.
  90906. */
  90907. activeSubSystems: Array<ParticleSystem>;
  90908. /**
  90909. * Specifies if the particles are updated in emitter local space or world space
  90910. */
  90911. isLocal: boolean;
  90912. private _rootParticleSystem;
  90913. /**
  90914. * Gets the current list of active particles
  90915. */
  90916. get particles(): Particle[];
  90917. /**
  90918. * Gets the number of particles active at the same time.
  90919. * @returns The number of active particles.
  90920. */
  90921. getActiveCount(): number;
  90922. /**
  90923. * Returns the string "ParticleSystem"
  90924. * @returns a string containing the class name
  90925. */
  90926. getClassName(): string;
  90927. /**
  90928. * Gets a boolean indicating that the system is stopping
  90929. * @returns true if the system is currently stopping
  90930. */
  90931. isStopping(): boolean;
  90932. /**
  90933. * Gets the custom effect used to render the particles
  90934. * @param blendMode Blend mode for which the effect should be retrieved
  90935. * @returns The effect
  90936. */
  90937. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90938. /**
  90939. * Sets the custom effect used to render the particles
  90940. * @param effect The effect to set
  90941. * @param blendMode Blend mode for which the effect should be set
  90942. */
  90943. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90944. /** @hidden */
  90945. private _onBeforeDrawParticlesObservable;
  90946. /**
  90947. * Observable that will be called just before the particles are drawn
  90948. */
  90949. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90950. /**
  90951. * Gets the name of the particle vertex shader
  90952. */
  90953. get vertexShaderName(): string;
  90954. /**
  90955. * Instantiates a particle system.
  90956. * 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.
  90957. * @param name The name of the particle system
  90958. * @param capacity The max number of particles alive at the same time
  90959. * @param scene The scene the particle system belongs to
  90960. * @param customEffect a custom effect used to change the way particles are rendered by default
  90961. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90962. * @param epsilon Offset used to render the particles
  90963. */
  90964. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90965. private _addFactorGradient;
  90966. private _removeFactorGradient;
  90967. /**
  90968. * Adds a new life time gradient
  90969. * @param gradient defines the gradient to use (between 0 and 1)
  90970. * @param factor defines the life time factor to affect to the specified gradient
  90971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90972. * @returns the current particle system
  90973. */
  90974. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90975. /**
  90976. * Remove a specific life time gradient
  90977. * @param gradient defines the gradient to remove
  90978. * @returns the current particle system
  90979. */
  90980. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90981. /**
  90982. * Adds a new size gradient
  90983. * @param gradient defines the gradient to use (between 0 and 1)
  90984. * @param factor defines the size factor to affect to the specified gradient
  90985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90986. * @returns the current particle system
  90987. */
  90988. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90989. /**
  90990. * Remove a specific size gradient
  90991. * @param gradient defines the gradient to remove
  90992. * @returns the current particle system
  90993. */
  90994. removeSizeGradient(gradient: number): IParticleSystem;
  90995. /**
  90996. * Adds a new color remap gradient
  90997. * @param gradient defines the gradient to use (between 0 and 1)
  90998. * @param min defines the color remap minimal range
  90999. * @param max defines the color remap maximal range
  91000. * @returns the current particle system
  91001. */
  91002. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91003. /**
  91004. * Remove a specific color remap gradient
  91005. * @param gradient defines the gradient to remove
  91006. * @returns the current particle system
  91007. */
  91008. removeColorRemapGradient(gradient: number): IParticleSystem;
  91009. /**
  91010. * Adds a new alpha remap gradient
  91011. * @param gradient defines the gradient to use (between 0 and 1)
  91012. * @param min defines the alpha remap minimal range
  91013. * @param max defines the alpha remap maximal range
  91014. * @returns the current particle system
  91015. */
  91016. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91017. /**
  91018. * Remove a specific alpha remap gradient
  91019. * @param gradient defines the gradient to remove
  91020. * @returns the current particle system
  91021. */
  91022. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91023. /**
  91024. * Adds a new angular speed gradient
  91025. * @param gradient defines the gradient to use (between 0 and 1)
  91026. * @param factor defines the angular speed to affect to the specified gradient
  91027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91028. * @returns the current particle system
  91029. */
  91030. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91031. /**
  91032. * Remove a specific angular speed gradient
  91033. * @param gradient defines the gradient to remove
  91034. * @returns the current particle system
  91035. */
  91036. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91037. /**
  91038. * Adds a new velocity gradient
  91039. * @param gradient defines the gradient to use (between 0 and 1)
  91040. * @param factor defines the velocity to affect to the specified gradient
  91041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91042. * @returns the current particle system
  91043. */
  91044. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91045. /**
  91046. * Remove a specific velocity gradient
  91047. * @param gradient defines the gradient to remove
  91048. * @returns the current particle system
  91049. */
  91050. removeVelocityGradient(gradient: number): IParticleSystem;
  91051. /**
  91052. * Adds a new limit velocity gradient
  91053. * @param gradient defines the gradient to use (between 0 and 1)
  91054. * @param factor defines the limit velocity value to affect to the specified gradient
  91055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91056. * @returns the current particle system
  91057. */
  91058. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91059. /**
  91060. * Remove a specific limit velocity gradient
  91061. * @param gradient defines the gradient to remove
  91062. * @returns the current particle system
  91063. */
  91064. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91065. /**
  91066. * Adds a new drag gradient
  91067. * @param gradient defines the gradient to use (between 0 and 1)
  91068. * @param factor defines the drag value to affect to the specified gradient
  91069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91070. * @returns the current particle system
  91071. */
  91072. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91073. /**
  91074. * Remove a specific drag gradient
  91075. * @param gradient defines the gradient to remove
  91076. * @returns the current particle system
  91077. */
  91078. removeDragGradient(gradient: number): IParticleSystem;
  91079. /**
  91080. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91081. * @param gradient defines the gradient to use (between 0 and 1)
  91082. * @param factor defines the emit rate value to affect to the specified gradient
  91083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91084. * @returns the current particle system
  91085. */
  91086. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91087. /**
  91088. * Remove a specific emit rate gradient
  91089. * @param gradient defines the gradient to remove
  91090. * @returns the current particle system
  91091. */
  91092. removeEmitRateGradient(gradient: number): IParticleSystem;
  91093. /**
  91094. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91095. * @param gradient defines the gradient to use (between 0 and 1)
  91096. * @param factor defines the start size value to affect to the specified gradient
  91097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91098. * @returns the current particle system
  91099. */
  91100. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91101. /**
  91102. * Remove a specific start size gradient
  91103. * @param gradient defines the gradient to remove
  91104. * @returns the current particle system
  91105. */
  91106. removeStartSizeGradient(gradient: number): IParticleSystem;
  91107. private _createRampGradientTexture;
  91108. /**
  91109. * Gets the current list of ramp gradients.
  91110. * You must use addRampGradient and removeRampGradient to udpate this list
  91111. * @returns the list of ramp gradients
  91112. */
  91113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91114. /** Force the system to rebuild all gradients that need to be resync */
  91115. forceRefreshGradients(): void;
  91116. private _syncRampGradientTexture;
  91117. /**
  91118. * Adds a new ramp gradient used to remap particle colors
  91119. * @param gradient defines the gradient to use (between 0 and 1)
  91120. * @param color defines the color to affect to the specified gradient
  91121. * @returns the current particle system
  91122. */
  91123. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91124. /**
  91125. * Remove a specific ramp gradient
  91126. * @param gradient defines the gradient to remove
  91127. * @returns the current particle system
  91128. */
  91129. removeRampGradient(gradient: number): ParticleSystem;
  91130. /**
  91131. * Adds a new color gradient
  91132. * @param gradient defines the gradient to use (between 0 and 1)
  91133. * @param color1 defines the color to affect to the specified gradient
  91134. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91135. * @returns this particle system
  91136. */
  91137. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91138. /**
  91139. * Remove a specific color gradient
  91140. * @param gradient defines the gradient to remove
  91141. * @returns this particle system
  91142. */
  91143. removeColorGradient(gradient: number): IParticleSystem;
  91144. private _fetchR;
  91145. protected _reset(): void;
  91146. private _resetEffect;
  91147. private _createVertexBuffers;
  91148. private _createIndexBuffer;
  91149. /**
  91150. * Gets the maximum number of particles active at the same time.
  91151. * @returns The max number of active particles.
  91152. */
  91153. getCapacity(): number;
  91154. /**
  91155. * Gets whether there are still active particles in the system.
  91156. * @returns True if it is alive, otherwise false.
  91157. */
  91158. isAlive(): boolean;
  91159. /**
  91160. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91161. * @returns True if it has been started, otherwise false.
  91162. */
  91163. isStarted(): boolean;
  91164. private _prepareSubEmitterInternalArray;
  91165. /**
  91166. * Starts the particle system and begins to emit
  91167. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91168. */
  91169. start(delay?: number): void;
  91170. /**
  91171. * Stops the particle system.
  91172. * @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.
  91173. */
  91174. stop(stopSubEmitters?: boolean): void;
  91175. /**
  91176. * Remove all active particles
  91177. */
  91178. reset(): void;
  91179. /**
  91180. * @hidden (for internal use only)
  91181. */
  91182. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91183. /**
  91184. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91185. * Its lifetime will start back at 0.
  91186. */
  91187. recycleParticle: (particle: Particle) => void;
  91188. private _stopSubEmitters;
  91189. private _createParticle;
  91190. private _removeFromRoot;
  91191. private _emitFromParticle;
  91192. private _update;
  91193. /** @hidden */
  91194. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91195. /** @hidden */
  91196. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91197. /**
  91198. * Fill the defines array according to the current settings of the particle system
  91199. * @param defines Array to be updated
  91200. * @param blendMode blend mode to take into account when updating the array
  91201. */
  91202. fillDefines(defines: Array<string>, blendMode: number): void;
  91203. /**
  91204. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91205. * @param uniforms Uniforms array to fill
  91206. * @param attributes Attributes array to fill
  91207. * @param samplers Samplers array to fill
  91208. */
  91209. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91210. /** @hidden */
  91211. private _getEffect;
  91212. /**
  91213. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91214. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91215. */
  91216. animate(preWarmOnly?: boolean): void;
  91217. private _appendParticleVertices;
  91218. /**
  91219. * Rebuilds the particle system.
  91220. */
  91221. rebuild(): void;
  91222. /**
  91223. * Is this system ready to be used/rendered
  91224. * @return true if the system is ready
  91225. */
  91226. isReady(): boolean;
  91227. private _render;
  91228. /**
  91229. * Renders the particle system in its current state.
  91230. * @returns the current number of particles
  91231. */
  91232. render(): number;
  91233. /**
  91234. * Disposes the particle system and free the associated resources
  91235. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91236. */
  91237. dispose(disposeTexture?: boolean): void;
  91238. /**
  91239. * Clones the particle system.
  91240. * @param name The name of the cloned object
  91241. * @param newEmitter The new emitter to use
  91242. * @returns the cloned particle system
  91243. */
  91244. clone(name: string, newEmitter: any): ParticleSystem;
  91245. /**
  91246. * Serializes the particle system to a JSON object
  91247. * @param serializeTexture defines if the texture must be serialized as well
  91248. * @returns the JSON object
  91249. */
  91250. serialize(serializeTexture?: boolean): any;
  91251. /** @hidden */
  91252. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91253. /** @hidden */
  91254. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91255. /**
  91256. * Parses a JSON object to create a particle system.
  91257. * @param parsedParticleSystem The JSON object to parse
  91258. * @param scene The scene to create the particle system in
  91259. * @param rootUrl The root url to use to load external dependencies like texture
  91260. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91261. * @returns the Parsed particle system
  91262. */
  91263. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91264. }
  91265. }
  91266. declare module BABYLON {
  91267. /**
  91268. * A particle represents one of the element emitted by a particle system.
  91269. * This is mainly define by its coordinates, direction, velocity and age.
  91270. */
  91271. export class Particle {
  91272. /**
  91273. * The particle system the particle belongs to.
  91274. */
  91275. particleSystem: ParticleSystem;
  91276. private static _Count;
  91277. /**
  91278. * Unique ID of the particle
  91279. */
  91280. id: number;
  91281. /**
  91282. * The world position of the particle in the scene.
  91283. */
  91284. position: Vector3;
  91285. /**
  91286. * The world direction of the particle in the scene.
  91287. */
  91288. direction: Vector3;
  91289. /**
  91290. * The color of the particle.
  91291. */
  91292. color: Color4;
  91293. /**
  91294. * The color change of the particle per step.
  91295. */
  91296. colorStep: Color4;
  91297. /**
  91298. * Defines how long will the life of the particle be.
  91299. */
  91300. lifeTime: number;
  91301. /**
  91302. * The current age of the particle.
  91303. */
  91304. age: number;
  91305. /**
  91306. * The current size of the particle.
  91307. */
  91308. size: number;
  91309. /**
  91310. * The current scale of the particle.
  91311. */
  91312. scale: Vector2;
  91313. /**
  91314. * The current angle of the particle.
  91315. */
  91316. angle: number;
  91317. /**
  91318. * Defines how fast is the angle changing.
  91319. */
  91320. angularSpeed: number;
  91321. /**
  91322. * Defines the cell index used by the particle to be rendered from a sprite.
  91323. */
  91324. cellIndex: number;
  91325. /**
  91326. * The information required to support color remapping
  91327. */
  91328. remapData: Vector4;
  91329. /** @hidden */
  91330. _randomCellOffset?: number;
  91331. /** @hidden */
  91332. _initialDirection: Nullable<Vector3>;
  91333. /** @hidden */
  91334. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91335. /** @hidden */
  91336. _initialStartSpriteCellID: number;
  91337. /** @hidden */
  91338. _initialEndSpriteCellID: number;
  91339. /** @hidden */
  91340. _currentColorGradient: Nullable<ColorGradient>;
  91341. /** @hidden */
  91342. _currentColor1: Color4;
  91343. /** @hidden */
  91344. _currentColor2: Color4;
  91345. /** @hidden */
  91346. _currentSizeGradient: Nullable<FactorGradient>;
  91347. /** @hidden */
  91348. _currentSize1: number;
  91349. /** @hidden */
  91350. _currentSize2: number;
  91351. /** @hidden */
  91352. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91353. /** @hidden */
  91354. _currentAngularSpeed1: number;
  91355. /** @hidden */
  91356. _currentAngularSpeed2: number;
  91357. /** @hidden */
  91358. _currentVelocityGradient: Nullable<FactorGradient>;
  91359. /** @hidden */
  91360. _currentVelocity1: number;
  91361. /** @hidden */
  91362. _currentVelocity2: number;
  91363. /** @hidden */
  91364. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91365. /** @hidden */
  91366. _currentLimitVelocity1: number;
  91367. /** @hidden */
  91368. _currentLimitVelocity2: number;
  91369. /** @hidden */
  91370. _currentDragGradient: Nullable<FactorGradient>;
  91371. /** @hidden */
  91372. _currentDrag1: number;
  91373. /** @hidden */
  91374. _currentDrag2: number;
  91375. /** @hidden */
  91376. _randomNoiseCoordinates1: Vector3;
  91377. /** @hidden */
  91378. _randomNoiseCoordinates2: Vector3;
  91379. /** @hidden */
  91380. _localPosition?: Vector3;
  91381. /**
  91382. * Creates a new instance Particle
  91383. * @param particleSystem the particle system the particle belongs to
  91384. */
  91385. constructor(
  91386. /**
  91387. * The particle system the particle belongs to.
  91388. */
  91389. particleSystem: ParticleSystem);
  91390. private updateCellInfoFromSystem;
  91391. /**
  91392. * Defines how the sprite cell index is updated for the particle
  91393. */
  91394. updateCellIndex(): void;
  91395. /** @hidden */
  91396. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91397. /** @hidden */
  91398. _inheritParticleInfoToSubEmitters(): void;
  91399. /** @hidden */
  91400. _reset(): void;
  91401. /**
  91402. * Copy the properties of particle to another one.
  91403. * @param other the particle to copy the information to.
  91404. */
  91405. copyTo(other: Particle): void;
  91406. }
  91407. }
  91408. declare module BABYLON {
  91409. /**
  91410. * Particle emitter represents a volume emitting particles.
  91411. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91412. */
  91413. export interface IParticleEmitterType {
  91414. /**
  91415. * Called by the particle System when the direction is computed for the created particle.
  91416. * @param worldMatrix is the world matrix of the particle system
  91417. * @param directionToUpdate is the direction vector to update with the result
  91418. * @param particle is the particle we are computed the direction for
  91419. * @param isLocal defines if the direction should be set in local space
  91420. */
  91421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91422. /**
  91423. * Called by the particle System when the position is computed for the created particle.
  91424. * @param worldMatrix is the world matrix of the particle system
  91425. * @param positionToUpdate is the position vector to update with the result
  91426. * @param particle is the particle we are computed the position for
  91427. * @param isLocal defines if the position should be set in local space
  91428. */
  91429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91430. /**
  91431. * Clones the current emitter and returns a copy of it
  91432. * @returns the new emitter
  91433. */
  91434. clone(): IParticleEmitterType;
  91435. /**
  91436. * Called by the GPUParticleSystem to setup the update shader
  91437. * @param effect defines the update shader
  91438. */
  91439. applyToShader(effect: Effect): void;
  91440. /**
  91441. * Returns a string to use to update the GPU particles update shader
  91442. * @returns the effect defines string
  91443. */
  91444. getEffectDefines(): string;
  91445. /**
  91446. * Returns a string representing the class name
  91447. * @returns a string containing the class name
  91448. */
  91449. getClassName(): string;
  91450. /**
  91451. * Serializes the particle system to a JSON object.
  91452. * @returns the JSON object
  91453. */
  91454. serialize(): any;
  91455. /**
  91456. * Parse properties from a JSON object
  91457. * @param serializationObject defines the JSON object
  91458. * @param scene defines the hosting scene
  91459. */
  91460. parse(serializationObject: any, scene: Scene): void;
  91461. }
  91462. }
  91463. declare module BABYLON {
  91464. /**
  91465. * Particle emitter emitting particles from the inside of a box.
  91466. * It emits the particles randomly between 2 given directions.
  91467. */
  91468. export class BoxParticleEmitter implements IParticleEmitterType {
  91469. /**
  91470. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91471. */
  91472. direction1: Vector3;
  91473. /**
  91474. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91475. */
  91476. direction2: Vector3;
  91477. /**
  91478. * 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.
  91479. */
  91480. minEmitBox: Vector3;
  91481. /**
  91482. * 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.
  91483. */
  91484. maxEmitBox: Vector3;
  91485. /**
  91486. * Creates a new instance BoxParticleEmitter
  91487. */
  91488. constructor();
  91489. /**
  91490. * Called by the particle System when the direction is computed for the created particle.
  91491. * @param worldMatrix is the world matrix of the particle system
  91492. * @param directionToUpdate is the direction vector to update with the result
  91493. * @param particle is the particle we are computed the direction for
  91494. * @param isLocal defines if the direction should be set in local space
  91495. */
  91496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91497. /**
  91498. * Called by the particle System when the position is computed for the created particle.
  91499. * @param worldMatrix is the world matrix of the particle system
  91500. * @param positionToUpdate is the position vector to update with the result
  91501. * @param particle is the particle we are computed the position for
  91502. * @param isLocal defines if the position should be set in local space
  91503. */
  91504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91505. /**
  91506. * Clones the current emitter and returns a copy of it
  91507. * @returns the new emitter
  91508. */
  91509. clone(): BoxParticleEmitter;
  91510. /**
  91511. * Called by the GPUParticleSystem to setup the update shader
  91512. * @param effect defines the update shader
  91513. */
  91514. applyToShader(effect: Effect): void;
  91515. /**
  91516. * Returns a string to use to update the GPU particles update shader
  91517. * @returns a string containng the defines string
  91518. */
  91519. getEffectDefines(): string;
  91520. /**
  91521. * Returns the string "BoxParticleEmitter"
  91522. * @returns a string containing the class name
  91523. */
  91524. getClassName(): string;
  91525. /**
  91526. * Serializes the particle system to a JSON object.
  91527. * @returns the JSON object
  91528. */
  91529. serialize(): any;
  91530. /**
  91531. * Parse properties from a JSON object
  91532. * @param serializationObject defines the JSON object
  91533. */
  91534. parse(serializationObject: any): void;
  91535. }
  91536. }
  91537. declare module BABYLON {
  91538. /**
  91539. * Particle emitter emitting particles from the inside of a cone.
  91540. * It emits the particles alongside the cone volume from the base to the particle.
  91541. * The emission direction might be randomized.
  91542. */
  91543. export class ConeParticleEmitter implements IParticleEmitterType {
  91544. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91545. directionRandomizer: number;
  91546. private _radius;
  91547. private _angle;
  91548. private _height;
  91549. /**
  91550. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91551. */
  91552. radiusRange: number;
  91553. /**
  91554. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91555. */
  91556. heightRange: number;
  91557. /**
  91558. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91559. */
  91560. emitFromSpawnPointOnly: boolean;
  91561. /**
  91562. * Gets or sets the radius of the emission cone
  91563. */
  91564. get radius(): number;
  91565. set radius(value: number);
  91566. /**
  91567. * Gets or sets the angle of the emission cone
  91568. */
  91569. get angle(): number;
  91570. set angle(value: number);
  91571. private _buildHeight;
  91572. /**
  91573. * Creates a new instance ConeParticleEmitter
  91574. * @param radius the radius of the emission cone (1 by default)
  91575. * @param angle the cone base angle (PI by default)
  91576. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91577. */
  91578. constructor(radius?: number, angle?: number,
  91579. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91580. directionRandomizer?: number);
  91581. /**
  91582. * Called by the particle System when the direction is computed for the created particle.
  91583. * @param worldMatrix is the world matrix of the particle system
  91584. * @param directionToUpdate is the direction vector to update with the result
  91585. * @param particle is the particle we are computed the direction for
  91586. * @param isLocal defines if the direction should be set in local space
  91587. */
  91588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91589. /**
  91590. * Called by the particle System when the position is computed for the created particle.
  91591. * @param worldMatrix is the world matrix of the particle system
  91592. * @param positionToUpdate is the position vector to update with the result
  91593. * @param particle is the particle we are computed the position for
  91594. * @param isLocal defines if the position should be set in local space
  91595. */
  91596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91597. /**
  91598. * Clones the current emitter and returns a copy of it
  91599. * @returns the new emitter
  91600. */
  91601. clone(): ConeParticleEmitter;
  91602. /**
  91603. * Called by the GPUParticleSystem to setup the update shader
  91604. * @param effect defines the update shader
  91605. */
  91606. applyToShader(effect: Effect): void;
  91607. /**
  91608. * Returns a string to use to update the GPU particles update shader
  91609. * @returns a string containng the defines string
  91610. */
  91611. getEffectDefines(): string;
  91612. /**
  91613. * Returns the string "ConeParticleEmitter"
  91614. * @returns a string containing the class name
  91615. */
  91616. getClassName(): string;
  91617. /**
  91618. * Serializes the particle system to a JSON object.
  91619. * @returns the JSON object
  91620. */
  91621. serialize(): any;
  91622. /**
  91623. * Parse properties from a JSON object
  91624. * @param serializationObject defines the JSON object
  91625. */
  91626. parse(serializationObject: any): void;
  91627. }
  91628. }
  91629. declare module BABYLON {
  91630. /**
  91631. * Particle emitter emitting particles from the inside of a cylinder.
  91632. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91633. */
  91634. export class CylinderParticleEmitter implements IParticleEmitterType {
  91635. /**
  91636. * The radius of the emission cylinder.
  91637. */
  91638. radius: number;
  91639. /**
  91640. * The height of the emission cylinder.
  91641. */
  91642. height: number;
  91643. /**
  91644. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91645. */
  91646. radiusRange: number;
  91647. /**
  91648. * How much to randomize the particle direction [0-1].
  91649. */
  91650. directionRandomizer: number;
  91651. /**
  91652. * Creates a new instance CylinderParticleEmitter
  91653. * @param radius the radius of the emission cylinder (1 by default)
  91654. * @param height the height of the emission cylinder (1 by default)
  91655. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91656. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91657. */
  91658. constructor(
  91659. /**
  91660. * The radius of the emission cylinder.
  91661. */
  91662. radius?: number,
  91663. /**
  91664. * The height of the emission cylinder.
  91665. */
  91666. height?: number,
  91667. /**
  91668. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91669. */
  91670. radiusRange?: number,
  91671. /**
  91672. * How much to randomize the particle direction [0-1].
  91673. */
  91674. directionRandomizer?: number);
  91675. /**
  91676. * Called by the particle System when the direction is computed for the created particle.
  91677. * @param worldMatrix is the world matrix of the particle system
  91678. * @param directionToUpdate is the direction vector to update with the result
  91679. * @param particle is the particle we are computed the direction for
  91680. * @param isLocal defines if the direction should be set in local space
  91681. */
  91682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91683. /**
  91684. * Called by the particle System when the position is computed for the created particle.
  91685. * @param worldMatrix is the world matrix of the particle system
  91686. * @param positionToUpdate is the position vector to update with the result
  91687. * @param particle is the particle we are computed the position for
  91688. * @param isLocal defines if the position should be set in local space
  91689. */
  91690. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91691. /**
  91692. * Clones the current emitter and returns a copy of it
  91693. * @returns the new emitter
  91694. */
  91695. clone(): CylinderParticleEmitter;
  91696. /**
  91697. * Called by the GPUParticleSystem to setup the update shader
  91698. * @param effect defines the update shader
  91699. */
  91700. applyToShader(effect: Effect): void;
  91701. /**
  91702. * Returns a string to use to update the GPU particles update shader
  91703. * @returns a string containng the defines string
  91704. */
  91705. getEffectDefines(): string;
  91706. /**
  91707. * Returns the string "CylinderParticleEmitter"
  91708. * @returns a string containing the class name
  91709. */
  91710. getClassName(): string;
  91711. /**
  91712. * Serializes the particle system to a JSON object.
  91713. * @returns the JSON object
  91714. */
  91715. serialize(): any;
  91716. /**
  91717. * Parse properties from a JSON object
  91718. * @param serializationObject defines the JSON object
  91719. */
  91720. parse(serializationObject: any): void;
  91721. }
  91722. /**
  91723. * Particle emitter emitting particles from the inside of a cylinder.
  91724. * It emits the particles randomly between two vectors.
  91725. */
  91726. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91727. /**
  91728. * The min limit of the emission direction.
  91729. */
  91730. direction1: Vector3;
  91731. /**
  91732. * The max limit of the emission direction.
  91733. */
  91734. direction2: Vector3;
  91735. /**
  91736. * Creates a new instance CylinderDirectedParticleEmitter
  91737. * @param radius the radius of the emission cylinder (1 by default)
  91738. * @param height the height of the emission cylinder (1 by default)
  91739. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91740. * @param direction1 the min limit of the emission direction (up vector by default)
  91741. * @param direction2 the max limit of the emission direction (up vector by default)
  91742. */
  91743. constructor(radius?: number, height?: number, radiusRange?: number,
  91744. /**
  91745. * The min limit of the emission direction.
  91746. */
  91747. direction1?: Vector3,
  91748. /**
  91749. * The max limit of the emission direction.
  91750. */
  91751. direction2?: Vector3);
  91752. /**
  91753. * Called by the particle System when the direction is computed for the created particle.
  91754. * @param worldMatrix is the world matrix of the particle system
  91755. * @param directionToUpdate is the direction vector to update with the result
  91756. * @param particle is the particle we are computed the direction for
  91757. */
  91758. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91759. /**
  91760. * Clones the current emitter and returns a copy of it
  91761. * @returns the new emitter
  91762. */
  91763. clone(): CylinderDirectedParticleEmitter;
  91764. /**
  91765. * Called by the GPUParticleSystem to setup the update shader
  91766. * @param effect defines the update shader
  91767. */
  91768. applyToShader(effect: Effect): void;
  91769. /**
  91770. * Returns a string to use to update the GPU particles update shader
  91771. * @returns a string containng the defines string
  91772. */
  91773. getEffectDefines(): string;
  91774. /**
  91775. * Returns the string "CylinderDirectedParticleEmitter"
  91776. * @returns a string containing the class name
  91777. */
  91778. getClassName(): string;
  91779. /**
  91780. * Serializes the particle system to a JSON object.
  91781. * @returns the JSON object
  91782. */
  91783. serialize(): any;
  91784. /**
  91785. * Parse properties from a JSON object
  91786. * @param serializationObject defines the JSON object
  91787. */
  91788. parse(serializationObject: any): void;
  91789. }
  91790. }
  91791. declare module BABYLON {
  91792. /**
  91793. * Particle emitter emitting particles from the inside of a hemisphere.
  91794. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91795. */
  91796. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91797. /**
  91798. * The radius of the emission hemisphere.
  91799. */
  91800. radius: number;
  91801. /**
  91802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91803. */
  91804. radiusRange: number;
  91805. /**
  91806. * How much to randomize the particle direction [0-1].
  91807. */
  91808. directionRandomizer: number;
  91809. /**
  91810. * Creates a new instance HemisphericParticleEmitter
  91811. * @param radius the radius of the emission hemisphere (1 by default)
  91812. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91813. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91814. */
  91815. constructor(
  91816. /**
  91817. * The radius of the emission hemisphere.
  91818. */
  91819. radius?: number,
  91820. /**
  91821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91822. */
  91823. radiusRange?: number,
  91824. /**
  91825. * How much to randomize the particle direction [0-1].
  91826. */
  91827. directionRandomizer?: number);
  91828. /**
  91829. * Called by the particle System when the direction is computed for the created particle.
  91830. * @param worldMatrix is the world matrix of the particle system
  91831. * @param directionToUpdate is the direction vector to update with the result
  91832. * @param particle is the particle we are computed the direction for
  91833. * @param isLocal defines if the direction should be set in local space
  91834. */
  91835. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91836. /**
  91837. * Called by the particle System when the position is computed for the created particle.
  91838. * @param worldMatrix is the world matrix of the particle system
  91839. * @param positionToUpdate is the position vector to update with the result
  91840. * @param particle is the particle we are computed the position for
  91841. * @param isLocal defines if the position should be set in local space
  91842. */
  91843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91844. /**
  91845. * Clones the current emitter and returns a copy of it
  91846. * @returns the new emitter
  91847. */
  91848. clone(): HemisphericParticleEmitter;
  91849. /**
  91850. * Called by the GPUParticleSystem to setup the update shader
  91851. * @param effect defines the update shader
  91852. */
  91853. applyToShader(effect: Effect): void;
  91854. /**
  91855. * Returns a string to use to update the GPU particles update shader
  91856. * @returns a string containng the defines string
  91857. */
  91858. getEffectDefines(): string;
  91859. /**
  91860. * Returns the string "HemisphericParticleEmitter"
  91861. * @returns a string containing the class name
  91862. */
  91863. getClassName(): string;
  91864. /**
  91865. * Serializes the particle system to a JSON object.
  91866. * @returns the JSON object
  91867. */
  91868. serialize(): any;
  91869. /**
  91870. * Parse properties from a JSON object
  91871. * @param serializationObject defines the JSON object
  91872. */
  91873. parse(serializationObject: any): void;
  91874. }
  91875. }
  91876. declare module BABYLON {
  91877. /**
  91878. * Particle emitter emitting particles from a point.
  91879. * It emits the particles randomly between 2 given directions.
  91880. */
  91881. export class PointParticleEmitter implements IParticleEmitterType {
  91882. /**
  91883. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91884. */
  91885. direction1: Vector3;
  91886. /**
  91887. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91888. */
  91889. direction2: Vector3;
  91890. /**
  91891. * Creates a new instance PointParticleEmitter
  91892. */
  91893. constructor();
  91894. /**
  91895. * Called by the particle System when the direction is computed for the created particle.
  91896. * @param worldMatrix is the world matrix of the particle system
  91897. * @param directionToUpdate is the direction vector to update with the result
  91898. * @param particle is the particle we are computed the direction for
  91899. * @param isLocal defines if the direction should be set in local space
  91900. */
  91901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91902. /**
  91903. * Called by the particle System when the position is computed for the created particle.
  91904. * @param worldMatrix is the world matrix of the particle system
  91905. * @param positionToUpdate is the position vector to update with the result
  91906. * @param particle is the particle we are computed the position for
  91907. * @param isLocal defines if the position should be set in local space
  91908. */
  91909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91910. /**
  91911. * Clones the current emitter and returns a copy of it
  91912. * @returns the new emitter
  91913. */
  91914. clone(): PointParticleEmitter;
  91915. /**
  91916. * Called by the GPUParticleSystem to setup the update shader
  91917. * @param effect defines the update shader
  91918. */
  91919. applyToShader(effect: Effect): void;
  91920. /**
  91921. * Returns a string to use to update the GPU particles update shader
  91922. * @returns a string containng the defines string
  91923. */
  91924. getEffectDefines(): string;
  91925. /**
  91926. * Returns the string "PointParticleEmitter"
  91927. * @returns a string containing the class name
  91928. */
  91929. getClassName(): string;
  91930. /**
  91931. * Serializes the particle system to a JSON object.
  91932. * @returns the JSON object
  91933. */
  91934. serialize(): any;
  91935. /**
  91936. * Parse properties from a JSON object
  91937. * @param serializationObject defines the JSON object
  91938. */
  91939. parse(serializationObject: any): void;
  91940. }
  91941. }
  91942. declare module BABYLON {
  91943. /**
  91944. * Particle emitter emitting particles from the inside of a sphere.
  91945. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91946. */
  91947. export class SphereParticleEmitter implements IParticleEmitterType {
  91948. /**
  91949. * The radius of the emission sphere.
  91950. */
  91951. radius: number;
  91952. /**
  91953. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91954. */
  91955. radiusRange: number;
  91956. /**
  91957. * How much to randomize the particle direction [0-1].
  91958. */
  91959. directionRandomizer: number;
  91960. /**
  91961. * Creates a new instance SphereParticleEmitter
  91962. * @param radius the radius of the emission sphere (1 by default)
  91963. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91964. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91965. */
  91966. constructor(
  91967. /**
  91968. * The radius of the emission sphere.
  91969. */
  91970. radius?: number,
  91971. /**
  91972. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91973. */
  91974. radiusRange?: number,
  91975. /**
  91976. * How much to randomize the particle direction [0-1].
  91977. */
  91978. directionRandomizer?: number);
  91979. /**
  91980. * Called by the particle System when the direction is computed for the created particle.
  91981. * @param worldMatrix is the world matrix of the particle system
  91982. * @param directionToUpdate is the direction vector to update with the result
  91983. * @param particle is the particle we are computed the direction for
  91984. * @param isLocal defines if the direction should be set in local space
  91985. */
  91986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91987. /**
  91988. * Called by the particle System when the position is computed for the created particle.
  91989. * @param worldMatrix is the world matrix of the particle system
  91990. * @param positionToUpdate is the position vector to update with the result
  91991. * @param particle is the particle we are computed the position for
  91992. * @param isLocal defines if the position should be set in local space
  91993. */
  91994. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91995. /**
  91996. * Clones the current emitter and returns a copy of it
  91997. * @returns the new emitter
  91998. */
  91999. clone(): SphereParticleEmitter;
  92000. /**
  92001. * Called by the GPUParticleSystem to setup the update shader
  92002. * @param effect defines the update shader
  92003. */
  92004. applyToShader(effect: Effect): void;
  92005. /**
  92006. * Returns a string to use to update the GPU particles update shader
  92007. * @returns a string containng the defines string
  92008. */
  92009. getEffectDefines(): string;
  92010. /**
  92011. * Returns the string "SphereParticleEmitter"
  92012. * @returns a string containing the class name
  92013. */
  92014. getClassName(): string;
  92015. /**
  92016. * Serializes the particle system to a JSON object.
  92017. * @returns the JSON object
  92018. */
  92019. serialize(): any;
  92020. /**
  92021. * Parse properties from a JSON object
  92022. * @param serializationObject defines the JSON object
  92023. */
  92024. parse(serializationObject: any): void;
  92025. }
  92026. /**
  92027. * Particle emitter emitting particles from the inside of a sphere.
  92028. * It emits the particles randomly between two vectors.
  92029. */
  92030. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92031. /**
  92032. * The min limit of the emission direction.
  92033. */
  92034. direction1: Vector3;
  92035. /**
  92036. * The max limit of the emission direction.
  92037. */
  92038. direction2: Vector3;
  92039. /**
  92040. * Creates a new instance SphereDirectedParticleEmitter
  92041. * @param radius the radius of the emission sphere (1 by default)
  92042. * @param direction1 the min limit of the emission direction (up vector by default)
  92043. * @param direction2 the max limit of the emission direction (up vector by default)
  92044. */
  92045. constructor(radius?: number,
  92046. /**
  92047. * The min limit of the emission direction.
  92048. */
  92049. direction1?: Vector3,
  92050. /**
  92051. * The max limit of the emission direction.
  92052. */
  92053. direction2?: Vector3);
  92054. /**
  92055. * Called by the particle System when the direction is computed for the created particle.
  92056. * @param worldMatrix is the world matrix of the particle system
  92057. * @param directionToUpdate is the direction vector to update with the result
  92058. * @param particle is the particle we are computed the direction for
  92059. */
  92060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92061. /**
  92062. * Clones the current emitter and returns a copy of it
  92063. * @returns the new emitter
  92064. */
  92065. clone(): SphereDirectedParticleEmitter;
  92066. /**
  92067. * Called by the GPUParticleSystem to setup the update shader
  92068. * @param effect defines the update shader
  92069. */
  92070. applyToShader(effect: Effect): void;
  92071. /**
  92072. * Returns a string to use to update the GPU particles update shader
  92073. * @returns a string containng the defines string
  92074. */
  92075. getEffectDefines(): string;
  92076. /**
  92077. * Returns the string "SphereDirectedParticleEmitter"
  92078. * @returns a string containing the class name
  92079. */
  92080. getClassName(): string;
  92081. /**
  92082. * Serializes the particle system to a JSON object.
  92083. * @returns the JSON object
  92084. */
  92085. serialize(): any;
  92086. /**
  92087. * Parse properties from a JSON object
  92088. * @param serializationObject defines the JSON object
  92089. */
  92090. parse(serializationObject: any): void;
  92091. }
  92092. }
  92093. declare module BABYLON {
  92094. /**
  92095. * Particle emitter emitting particles from a custom list of positions.
  92096. */
  92097. export class CustomParticleEmitter implements IParticleEmitterType {
  92098. /**
  92099. * Gets or sets the position generator that will create the inital position of each particle.
  92100. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92101. */
  92102. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92103. /**
  92104. * Gets or sets the destination generator that will create the final destination of each particle.
  92105. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92106. */
  92107. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92108. /**
  92109. * Creates a new instance CustomParticleEmitter
  92110. */
  92111. constructor();
  92112. /**
  92113. * Called by the particle System when the direction is computed for the created particle.
  92114. * @param worldMatrix is the world matrix of the particle system
  92115. * @param directionToUpdate is the direction vector to update with the result
  92116. * @param particle is the particle we are computed the direction for
  92117. * @param isLocal defines if the direction should be set in local space
  92118. */
  92119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92120. /**
  92121. * Called by the particle System when the position is computed for the created particle.
  92122. * @param worldMatrix is the world matrix of the particle system
  92123. * @param positionToUpdate is the position vector to update with the result
  92124. * @param particle is the particle we are computed the position for
  92125. * @param isLocal defines if the position should be set in local space
  92126. */
  92127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92128. /**
  92129. * Clones the current emitter and returns a copy of it
  92130. * @returns the new emitter
  92131. */
  92132. clone(): CustomParticleEmitter;
  92133. /**
  92134. * Called by the GPUParticleSystem to setup the update shader
  92135. * @param effect defines the update shader
  92136. */
  92137. applyToShader(effect: Effect): void;
  92138. /**
  92139. * Returns a string to use to update the GPU particles update shader
  92140. * @returns a string containng the defines string
  92141. */
  92142. getEffectDefines(): string;
  92143. /**
  92144. * Returns the string "PointParticleEmitter"
  92145. * @returns a string containing the class name
  92146. */
  92147. getClassName(): string;
  92148. /**
  92149. * Serializes the particle system to a JSON object.
  92150. * @returns the JSON object
  92151. */
  92152. serialize(): any;
  92153. /**
  92154. * Parse properties from a JSON object
  92155. * @param serializationObject defines the JSON object
  92156. */
  92157. parse(serializationObject: any): void;
  92158. }
  92159. }
  92160. declare module BABYLON {
  92161. /**
  92162. * Particle emitter emitting particles from the inside of a box.
  92163. * It emits the particles randomly between 2 given directions.
  92164. */
  92165. export class MeshParticleEmitter implements IParticleEmitterType {
  92166. private _indices;
  92167. private _positions;
  92168. private _normals;
  92169. private _storedNormal;
  92170. private _mesh;
  92171. /**
  92172. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92173. */
  92174. direction1: Vector3;
  92175. /**
  92176. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92177. */
  92178. direction2: Vector3;
  92179. /**
  92180. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92181. */
  92182. useMeshNormalsForDirection: boolean;
  92183. /** Defines the mesh to use as source */
  92184. get mesh(): Nullable<AbstractMesh>;
  92185. set mesh(value: Nullable<AbstractMesh>);
  92186. /**
  92187. * Creates a new instance MeshParticleEmitter
  92188. * @param mesh defines the mesh to use as source
  92189. */
  92190. constructor(mesh?: Nullable<AbstractMesh>);
  92191. /**
  92192. * Called by the particle System when the direction is computed for the created particle.
  92193. * @param worldMatrix is the world matrix of the particle system
  92194. * @param directionToUpdate is the direction vector to update with the result
  92195. * @param particle is the particle we are computed the direction for
  92196. * @param isLocal defines if the direction should be set in local space
  92197. */
  92198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92199. /**
  92200. * Called by the particle System when the position is computed for the created particle.
  92201. * @param worldMatrix is the world matrix of the particle system
  92202. * @param positionToUpdate is the position vector to update with the result
  92203. * @param particle is the particle we are computed the position for
  92204. * @param isLocal defines if the position should be set in local space
  92205. */
  92206. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92207. /**
  92208. * Clones the current emitter and returns a copy of it
  92209. * @returns the new emitter
  92210. */
  92211. clone(): MeshParticleEmitter;
  92212. /**
  92213. * Called by the GPUParticleSystem to setup the update shader
  92214. * @param effect defines the update shader
  92215. */
  92216. applyToShader(effect: Effect): void;
  92217. /**
  92218. * Returns a string to use to update the GPU particles update shader
  92219. * @returns a string containng the defines string
  92220. */
  92221. getEffectDefines(): string;
  92222. /**
  92223. * Returns the string "BoxParticleEmitter"
  92224. * @returns a string containing the class name
  92225. */
  92226. getClassName(): string;
  92227. /**
  92228. * Serializes the particle system to a JSON object.
  92229. * @returns the JSON object
  92230. */
  92231. serialize(): any;
  92232. /**
  92233. * Parse properties from a JSON object
  92234. * @param serializationObject defines the JSON object
  92235. * @param scene defines the hosting scene
  92236. */
  92237. parse(serializationObject: any, scene: Scene): void;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * Interface representing a particle system in Babylon.js.
  92243. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92244. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92245. */
  92246. export interface IParticleSystem {
  92247. /**
  92248. * List of animations used by the particle system.
  92249. */
  92250. animations: Animation[];
  92251. /**
  92252. * The id of the Particle system.
  92253. */
  92254. id: string;
  92255. /**
  92256. * The name of the Particle system.
  92257. */
  92258. name: string;
  92259. /**
  92260. * The emitter represents the Mesh or position we are attaching the particle system to.
  92261. */
  92262. emitter: Nullable<AbstractMesh | Vector3>;
  92263. /**
  92264. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92265. */
  92266. isBillboardBased: boolean;
  92267. /**
  92268. * The rendering group used by the Particle system to chose when to render.
  92269. */
  92270. renderingGroupId: number;
  92271. /**
  92272. * The layer mask we are rendering the particles through.
  92273. */
  92274. layerMask: number;
  92275. /**
  92276. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92277. */
  92278. updateSpeed: number;
  92279. /**
  92280. * The amount of time the particle system is running (depends of the overall update speed).
  92281. */
  92282. targetStopDuration: number;
  92283. /**
  92284. * The texture used to render each particle. (this can be a spritesheet)
  92285. */
  92286. particleTexture: Nullable<Texture>;
  92287. /**
  92288. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92289. */
  92290. blendMode: number;
  92291. /**
  92292. * Minimum life time of emitting particles.
  92293. */
  92294. minLifeTime: number;
  92295. /**
  92296. * Maximum life time of emitting particles.
  92297. */
  92298. maxLifeTime: number;
  92299. /**
  92300. * Minimum Size of emitting particles.
  92301. */
  92302. minSize: number;
  92303. /**
  92304. * Maximum Size of emitting particles.
  92305. */
  92306. maxSize: number;
  92307. /**
  92308. * Minimum scale of emitting particles on X axis.
  92309. */
  92310. minScaleX: number;
  92311. /**
  92312. * Maximum scale of emitting particles on X axis.
  92313. */
  92314. maxScaleX: number;
  92315. /**
  92316. * Minimum scale of emitting particles on Y axis.
  92317. */
  92318. minScaleY: number;
  92319. /**
  92320. * Maximum scale of emitting particles on Y axis.
  92321. */
  92322. maxScaleY: number;
  92323. /**
  92324. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92325. */
  92326. color1: Color4;
  92327. /**
  92328. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92329. */
  92330. color2: Color4;
  92331. /**
  92332. * Color the particle will have at the end of its lifetime.
  92333. */
  92334. colorDead: Color4;
  92335. /**
  92336. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92337. */
  92338. emitRate: number;
  92339. /**
  92340. * You can use gravity if you want to give an orientation to your particles.
  92341. */
  92342. gravity: Vector3;
  92343. /**
  92344. * Minimum power of emitting particles.
  92345. */
  92346. minEmitPower: number;
  92347. /**
  92348. * Maximum power of emitting particles.
  92349. */
  92350. maxEmitPower: number;
  92351. /**
  92352. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92353. */
  92354. minAngularSpeed: number;
  92355. /**
  92356. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92357. */
  92358. maxAngularSpeed: number;
  92359. /**
  92360. * Gets or sets the minimal initial rotation in radians.
  92361. */
  92362. minInitialRotation: number;
  92363. /**
  92364. * Gets or sets the maximal initial rotation in radians.
  92365. */
  92366. maxInitialRotation: number;
  92367. /**
  92368. * The particle emitter type defines the emitter used by the particle system.
  92369. * It can be for example box, sphere, or cone...
  92370. */
  92371. particleEmitterType: Nullable<IParticleEmitterType>;
  92372. /**
  92373. * Defines the delay in milliseconds before starting the system (0 by default)
  92374. */
  92375. startDelay: number;
  92376. /**
  92377. * 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
  92378. */
  92379. preWarmCycles: number;
  92380. /**
  92381. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92382. */
  92383. preWarmStepOffset: number;
  92384. /**
  92385. * 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)
  92386. */
  92387. spriteCellChangeSpeed: number;
  92388. /**
  92389. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92390. */
  92391. startSpriteCellID: number;
  92392. /**
  92393. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92394. */
  92395. endSpriteCellID: number;
  92396. /**
  92397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92398. */
  92399. spriteCellWidth: number;
  92400. /**
  92401. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92402. */
  92403. spriteCellHeight: number;
  92404. /**
  92405. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92406. */
  92407. spriteRandomStartCell: boolean;
  92408. /**
  92409. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92410. */
  92411. isAnimationSheetEnabled: boolean;
  92412. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92413. translationPivot: Vector2;
  92414. /**
  92415. * Gets or sets a texture used to add random noise to particle positions
  92416. */
  92417. noiseTexture: Nullable<BaseTexture>;
  92418. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92419. noiseStrength: Vector3;
  92420. /**
  92421. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92422. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92423. */
  92424. billboardMode: number;
  92425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92426. limitVelocityDamping: number;
  92427. /**
  92428. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92429. */
  92430. beginAnimationOnStart: boolean;
  92431. /**
  92432. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92433. */
  92434. beginAnimationFrom: number;
  92435. /**
  92436. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92437. */
  92438. beginAnimationTo: number;
  92439. /**
  92440. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92441. */
  92442. beginAnimationLoop: boolean;
  92443. /**
  92444. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92445. */
  92446. disposeOnStop: boolean;
  92447. /**
  92448. * Specifies if the particles are updated in emitter local space or world space
  92449. */
  92450. isLocal: boolean;
  92451. /** Snippet ID if the particle system was created from the snippet server */
  92452. snippetId: string;
  92453. /**
  92454. * Gets the maximum number of particles active at the same time.
  92455. * @returns The max number of active particles.
  92456. */
  92457. getCapacity(): number;
  92458. /**
  92459. * Gets the number of particles active at the same time.
  92460. * @returns The number of active particles.
  92461. */
  92462. getActiveCount(): number;
  92463. /**
  92464. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92465. * @returns True if it has been started, otherwise false.
  92466. */
  92467. isStarted(): boolean;
  92468. /**
  92469. * Animates the particle system for this frame.
  92470. */
  92471. animate(): void;
  92472. /**
  92473. * Renders the particle system in its current state.
  92474. * @returns the current number of particles
  92475. */
  92476. render(): number;
  92477. /**
  92478. * Dispose the particle system and frees its associated resources.
  92479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92480. */
  92481. dispose(disposeTexture?: boolean): void;
  92482. /**
  92483. * An event triggered when the system is disposed
  92484. */
  92485. onDisposeObservable: Observable<IParticleSystem>;
  92486. /**
  92487. * Clones the particle system.
  92488. * @param name The name of the cloned object
  92489. * @param newEmitter The new emitter to use
  92490. * @returns the cloned particle system
  92491. */
  92492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92493. /**
  92494. * Serializes the particle system to a JSON object
  92495. * @param serializeTexture defines if the texture must be serialized as well
  92496. * @returns the JSON object
  92497. */
  92498. serialize(serializeTexture: boolean): any;
  92499. /**
  92500. * Rebuild the particle system
  92501. */
  92502. rebuild(): void;
  92503. /** Force the system to rebuild all gradients that need to be resync */
  92504. forceRefreshGradients(): void;
  92505. /**
  92506. * Starts the particle system and begins to emit
  92507. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92508. */
  92509. start(delay?: number): void;
  92510. /**
  92511. * Stops the particle system.
  92512. */
  92513. stop(): void;
  92514. /**
  92515. * Remove all active particles
  92516. */
  92517. reset(): void;
  92518. /**
  92519. * Gets a boolean indicating that the system is stopping
  92520. * @returns true if the system is currently stopping
  92521. */
  92522. isStopping(): boolean;
  92523. /**
  92524. * Is this system ready to be used/rendered
  92525. * @return true if the system is ready
  92526. */
  92527. isReady(): boolean;
  92528. /**
  92529. * Returns the string "ParticleSystem"
  92530. * @returns a string containing the class name
  92531. */
  92532. getClassName(): string;
  92533. /**
  92534. * Gets the custom effect used to render the particles
  92535. * @param blendMode Blend mode for which the effect should be retrieved
  92536. * @returns The effect
  92537. */
  92538. getCustomEffect(blendMode: number): Nullable<Effect>;
  92539. /**
  92540. * Sets the custom effect used to render the particles
  92541. * @param effect The effect to set
  92542. * @param blendMode Blend mode for which the effect should be set
  92543. */
  92544. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92545. /**
  92546. * Fill the defines array according to the current settings of the particle system
  92547. * @param defines Array to be updated
  92548. * @param blendMode blend mode to take into account when updating the array
  92549. */
  92550. fillDefines(defines: Array<string>, blendMode: number): void;
  92551. /**
  92552. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92553. * @param uniforms Uniforms array to fill
  92554. * @param attributes Attributes array to fill
  92555. * @param samplers Samplers array to fill
  92556. */
  92557. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92558. /**
  92559. * Observable that will be called just before the particles are drawn
  92560. */
  92561. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92562. /**
  92563. * Gets the name of the particle vertex shader
  92564. */
  92565. vertexShaderName: string;
  92566. /**
  92567. * Adds a new color gradient
  92568. * @param gradient defines the gradient to use (between 0 and 1)
  92569. * @param color1 defines the color to affect to the specified gradient
  92570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92571. * @returns the current particle system
  92572. */
  92573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92574. /**
  92575. * Remove a specific color gradient
  92576. * @param gradient defines the gradient to remove
  92577. * @returns the current particle system
  92578. */
  92579. removeColorGradient(gradient: number): IParticleSystem;
  92580. /**
  92581. * Adds a new size gradient
  92582. * @param gradient defines the gradient to use (between 0 and 1)
  92583. * @param factor defines the size factor to affect to the specified gradient
  92584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92585. * @returns the current particle system
  92586. */
  92587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92588. /**
  92589. * Remove a specific size gradient
  92590. * @param gradient defines the gradient to remove
  92591. * @returns the current particle system
  92592. */
  92593. removeSizeGradient(gradient: number): IParticleSystem;
  92594. /**
  92595. * Gets the current list of color gradients.
  92596. * You must use addColorGradient and removeColorGradient to udpate this list
  92597. * @returns the list of color gradients
  92598. */
  92599. getColorGradients(): Nullable<Array<ColorGradient>>;
  92600. /**
  92601. * Gets the current list of size gradients.
  92602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92603. * @returns the list of size gradients
  92604. */
  92605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92606. /**
  92607. * Gets the current list of angular speed gradients.
  92608. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92609. * @returns the list of angular speed gradients
  92610. */
  92611. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92612. /**
  92613. * Adds a new angular speed gradient
  92614. * @param gradient defines the gradient to use (between 0 and 1)
  92615. * @param factor defines the angular speed to affect to the specified gradient
  92616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92617. * @returns the current particle system
  92618. */
  92619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92620. /**
  92621. * Remove a specific angular speed gradient
  92622. * @param gradient defines the gradient to remove
  92623. * @returns the current particle system
  92624. */
  92625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92626. /**
  92627. * Gets the current list of velocity gradients.
  92628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92629. * @returns the list of velocity gradients
  92630. */
  92631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92632. /**
  92633. * Adds a new velocity gradient
  92634. * @param gradient defines the gradient to use (between 0 and 1)
  92635. * @param factor defines the velocity to affect to the specified gradient
  92636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92637. * @returns the current particle system
  92638. */
  92639. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92640. /**
  92641. * Remove a specific velocity gradient
  92642. * @param gradient defines the gradient to remove
  92643. * @returns the current particle system
  92644. */
  92645. removeVelocityGradient(gradient: number): IParticleSystem;
  92646. /**
  92647. * Gets the current list of limit velocity gradients.
  92648. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92649. * @returns the list of limit velocity gradients
  92650. */
  92651. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92652. /**
  92653. * Adds a new limit velocity gradient
  92654. * @param gradient defines the gradient to use (between 0 and 1)
  92655. * @param factor defines the limit velocity to affect to the specified gradient
  92656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92657. * @returns the current particle system
  92658. */
  92659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92660. /**
  92661. * Remove a specific limit velocity gradient
  92662. * @param gradient defines the gradient to remove
  92663. * @returns the current particle system
  92664. */
  92665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92666. /**
  92667. * Adds a new drag gradient
  92668. * @param gradient defines the gradient to use (between 0 and 1)
  92669. * @param factor defines the drag to affect to the specified gradient
  92670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92671. * @returns the current particle system
  92672. */
  92673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92674. /**
  92675. * Remove a specific drag gradient
  92676. * @param gradient defines the gradient to remove
  92677. * @returns the current particle system
  92678. */
  92679. removeDragGradient(gradient: number): IParticleSystem;
  92680. /**
  92681. * Gets the current list of drag gradients.
  92682. * You must use addDragGradient and removeDragGradient to udpate this list
  92683. * @returns the list of drag gradients
  92684. */
  92685. getDragGradients(): Nullable<Array<FactorGradient>>;
  92686. /**
  92687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92688. * @param gradient defines the gradient to use (between 0 and 1)
  92689. * @param factor defines the emit rate to affect to the specified gradient
  92690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92691. * @returns the current particle system
  92692. */
  92693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92694. /**
  92695. * Remove a specific emit rate gradient
  92696. * @param gradient defines the gradient to remove
  92697. * @returns the current particle system
  92698. */
  92699. removeEmitRateGradient(gradient: number): IParticleSystem;
  92700. /**
  92701. * Gets the current list of emit rate gradients.
  92702. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92703. * @returns the list of emit rate gradients
  92704. */
  92705. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92706. /**
  92707. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92708. * @param gradient defines the gradient to use (between 0 and 1)
  92709. * @param factor defines the start size to affect to the specified gradient
  92710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92711. * @returns the current particle system
  92712. */
  92713. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92714. /**
  92715. * Remove a specific start size gradient
  92716. * @param gradient defines the gradient to remove
  92717. * @returns the current particle system
  92718. */
  92719. removeStartSizeGradient(gradient: number): IParticleSystem;
  92720. /**
  92721. * Gets the current list of start size gradients.
  92722. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92723. * @returns the list of start size gradients
  92724. */
  92725. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92726. /**
  92727. * Adds a new life time gradient
  92728. * @param gradient defines the gradient to use (between 0 and 1)
  92729. * @param factor defines the life time factor to affect to the specified gradient
  92730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92731. * @returns the current particle system
  92732. */
  92733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92734. /**
  92735. * Remove a specific life time gradient
  92736. * @param gradient defines the gradient to remove
  92737. * @returns the current particle system
  92738. */
  92739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92740. /**
  92741. * Gets the current list of life time gradients.
  92742. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92743. * @returns the list of life time gradients
  92744. */
  92745. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92746. /**
  92747. * Gets the current list of color gradients.
  92748. * You must use addColorGradient and removeColorGradient to udpate this list
  92749. * @returns the list of color gradients
  92750. */
  92751. getColorGradients(): Nullable<Array<ColorGradient>>;
  92752. /**
  92753. * Adds a new ramp gradient used to remap particle colors
  92754. * @param gradient defines the gradient to use (between 0 and 1)
  92755. * @param color defines the color to affect to the specified gradient
  92756. * @returns the current particle system
  92757. */
  92758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92759. /**
  92760. * Gets the current list of ramp gradients.
  92761. * You must use addRampGradient and removeRampGradient to udpate this list
  92762. * @returns the list of ramp gradients
  92763. */
  92764. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92765. /** Gets or sets a boolean indicating that ramp gradients must be used
  92766. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92767. */
  92768. useRampGradients: boolean;
  92769. /**
  92770. * Adds a new color remap gradient
  92771. * @param gradient defines the gradient to use (between 0 and 1)
  92772. * @param min defines the color remap minimal range
  92773. * @param max defines the color remap maximal range
  92774. * @returns the current particle system
  92775. */
  92776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92777. /**
  92778. * Gets the current list of color remap gradients.
  92779. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92780. * @returns the list of color remap gradients
  92781. */
  92782. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92783. /**
  92784. * Adds a new alpha remap gradient
  92785. * @param gradient defines the gradient to use (between 0 and 1)
  92786. * @param min defines the alpha remap minimal range
  92787. * @param max defines the alpha remap maximal range
  92788. * @returns the current particle system
  92789. */
  92790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92791. /**
  92792. * Gets the current list of alpha remap gradients.
  92793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92794. * @returns the list of alpha remap gradients
  92795. */
  92796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92797. /**
  92798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92801. * @returns the emitter
  92802. */
  92803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92804. /**
  92805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92806. * @param radius The radius of the hemisphere to emit from
  92807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92808. * @returns the emitter
  92809. */
  92810. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92811. /**
  92812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92813. * @param radius The radius of the sphere to emit from
  92814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92815. * @returns the emitter
  92816. */
  92817. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92818. /**
  92819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92820. * @param radius The radius of the sphere to emit from
  92821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92823. * @returns the emitter
  92824. */
  92825. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92826. /**
  92827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92828. * @param radius The radius of the emission cylinder
  92829. * @param height The height of the emission cylinder
  92830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92832. * @returns the emitter
  92833. */
  92834. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92835. /**
  92836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92837. * @param radius The radius of the cylinder to emit from
  92838. * @param height The height of the emission cylinder
  92839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92842. * @returns the emitter
  92843. */
  92844. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92845. /**
  92846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92847. * @param radius The radius of the cone to emit from
  92848. * @param angle The base angle of the cone
  92849. * @returns the emitter
  92850. */
  92851. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92852. /**
  92853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92858. * @returns the emitter
  92859. */
  92860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92861. /**
  92862. * Get hosting scene
  92863. * @returns the scene
  92864. */
  92865. getScene(): Scene;
  92866. }
  92867. }
  92868. declare module BABYLON {
  92869. /**
  92870. * 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.
  92871. * @see https://doc.babylonjs.com/how_to/transformnode
  92872. */
  92873. export class TransformNode extends Node {
  92874. /**
  92875. * Object will not rotate to face the camera
  92876. */
  92877. static BILLBOARDMODE_NONE: number;
  92878. /**
  92879. * Object will rotate to face the camera but only on the x axis
  92880. */
  92881. static BILLBOARDMODE_X: number;
  92882. /**
  92883. * Object will rotate to face the camera but only on the y axis
  92884. */
  92885. static BILLBOARDMODE_Y: number;
  92886. /**
  92887. * Object will rotate to face the camera but only on the z axis
  92888. */
  92889. static BILLBOARDMODE_Z: number;
  92890. /**
  92891. * Object will rotate to face the camera
  92892. */
  92893. static BILLBOARDMODE_ALL: number;
  92894. /**
  92895. * Object will rotate to face the camera's position instead of orientation
  92896. */
  92897. static BILLBOARDMODE_USE_POSITION: number;
  92898. private static _TmpRotation;
  92899. private static _TmpScaling;
  92900. private static _TmpTranslation;
  92901. private _forward;
  92902. private _forwardInverted;
  92903. private _up;
  92904. private _right;
  92905. private _rightInverted;
  92906. private _position;
  92907. private _rotation;
  92908. private _rotationQuaternion;
  92909. protected _scaling: Vector3;
  92910. protected _isDirty: boolean;
  92911. private _transformToBoneReferal;
  92912. private _isAbsoluteSynced;
  92913. private _billboardMode;
  92914. /**
  92915. * Gets or sets the billboard mode. Default is 0.
  92916. *
  92917. * | Value | Type | Description |
  92918. * | --- | --- | --- |
  92919. * | 0 | BILLBOARDMODE_NONE | |
  92920. * | 1 | BILLBOARDMODE_X | |
  92921. * | 2 | BILLBOARDMODE_Y | |
  92922. * | 4 | BILLBOARDMODE_Z | |
  92923. * | 7 | BILLBOARDMODE_ALL | |
  92924. *
  92925. */
  92926. get billboardMode(): number;
  92927. set billboardMode(value: number);
  92928. private _preserveParentRotationForBillboard;
  92929. /**
  92930. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92931. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92932. */
  92933. get preserveParentRotationForBillboard(): boolean;
  92934. set preserveParentRotationForBillboard(value: boolean);
  92935. /**
  92936. * 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
  92937. */
  92938. scalingDeterminant: number;
  92939. private _infiniteDistance;
  92940. /**
  92941. * Gets or sets the distance of the object to max, often used by skybox
  92942. */
  92943. get infiniteDistance(): boolean;
  92944. set infiniteDistance(value: boolean);
  92945. /**
  92946. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92947. * By default the system will update normals to compensate
  92948. */
  92949. ignoreNonUniformScaling: boolean;
  92950. /**
  92951. * 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
  92952. */
  92953. reIntegrateRotationIntoRotationQuaternion: boolean;
  92954. /** @hidden */
  92955. _poseMatrix: Nullable<Matrix>;
  92956. /** @hidden */
  92957. _localMatrix: Matrix;
  92958. private _usePivotMatrix;
  92959. private _absolutePosition;
  92960. private _absoluteScaling;
  92961. private _absoluteRotationQuaternion;
  92962. private _pivotMatrix;
  92963. private _pivotMatrixInverse;
  92964. protected _postMultiplyPivotMatrix: boolean;
  92965. protected _isWorldMatrixFrozen: boolean;
  92966. /** @hidden */
  92967. _indexInSceneTransformNodesArray: number;
  92968. /**
  92969. * An event triggered after the world matrix is updated
  92970. */
  92971. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92972. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92973. /**
  92974. * Gets a string identifying the name of the class
  92975. * @returns "TransformNode" string
  92976. */
  92977. getClassName(): string;
  92978. /**
  92979. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92980. */
  92981. get position(): Vector3;
  92982. set position(newPosition: Vector3);
  92983. /**
  92984. * 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)).
  92985. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92986. */
  92987. get rotation(): Vector3;
  92988. set rotation(newRotation: Vector3);
  92989. /**
  92990. * 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)).
  92991. */
  92992. get scaling(): Vector3;
  92993. set scaling(newScaling: Vector3);
  92994. /**
  92995. * 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).
  92996. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92997. */
  92998. get rotationQuaternion(): Nullable<Quaternion>;
  92999. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93000. /**
  93001. * The forward direction of that transform in world space.
  93002. */
  93003. get forward(): Vector3;
  93004. /**
  93005. * The up direction of that transform in world space.
  93006. */
  93007. get up(): Vector3;
  93008. /**
  93009. * The right direction of that transform in world space.
  93010. */
  93011. get right(): Vector3;
  93012. /**
  93013. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93014. * @param matrix the matrix to copy the pose from
  93015. * @returns this TransformNode.
  93016. */
  93017. updatePoseMatrix(matrix: Matrix): TransformNode;
  93018. /**
  93019. * Returns the mesh Pose matrix.
  93020. * @returns the pose matrix
  93021. */
  93022. getPoseMatrix(): Matrix;
  93023. /** @hidden */
  93024. _isSynchronized(): boolean;
  93025. /** @hidden */
  93026. _initCache(): void;
  93027. /**
  93028. * Flag the transform node as dirty (Forcing it to update everything)
  93029. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93030. * @returns this transform node
  93031. */
  93032. markAsDirty(property: string): TransformNode;
  93033. /**
  93034. * Returns the current mesh absolute position.
  93035. * Returns a Vector3.
  93036. */
  93037. get absolutePosition(): Vector3;
  93038. /**
  93039. * Returns the current mesh absolute scaling.
  93040. * Returns a Vector3.
  93041. */
  93042. get absoluteScaling(): Vector3;
  93043. /**
  93044. * Returns the current mesh absolute rotation.
  93045. * Returns a Quaternion.
  93046. */
  93047. get absoluteRotationQuaternion(): Quaternion;
  93048. /**
  93049. * Sets a new matrix to apply before all other transformation
  93050. * @param matrix defines the transform matrix
  93051. * @returns the current TransformNode
  93052. */
  93053. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93054. /**
  93055. * Sets a new pivot matrix to the current node
  93056. * @param matrix defines the new pivot matrix to use
  93057. * @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
  93058. * @returns the current TransformNode
  93059. */
  93060. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93061. /**
  93062. * Returns the mesh pivot matrix.
  93063. * Default : Identity.
  93064. * @returns the matrix
  93065. */
  93066. getPivotMatrix(): Matrix;
  93067. /**
  93068. * Instantiate (when possible) or clone that node with its hierarchy
  93069. * @param newParent defines the new parent to use for the instance (or clone)
  93070. * @param options defines options to configure how copy is done
  93071. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93072. * @returns an instance (or a clone) of the current node with its hiearchy
  93073. */
  93074. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93075. doNotInstantiate: boolean;
  93076. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93077. /**
  93078. * Prevents the World matrix to be computed any longer
  93079. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93080. * @returns the TransformNode.
  93081. */
  93082. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93083. /**
  93084. * Allows back the World matrix computation.
  93085. * @returns the TransformNode.
  93086. */
  93087. unfreezeWorldMatrix(): this;
  93088. /**
  93089. * True if the World matrix has been frozen.
  93090. */
  93091. get isWorldMatrixFrozen(): boolean;
  93092. /**
  93093. * Retuns the mesh absolute position in the World.
  93094. * @returns a Vector3.
  93095. */
  93096. getAbsolutePosition(): Vector3;
  93097. /**
  93098. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93099. * @param absolutePosition the absolute position to set
  93100. * @returns the TransformNode.
  93101. */
  93102. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93103. /**
  93104. * Sets the mesh position in its local space.
  93105. * @param vector3 the position to set in localspace
  93106. * @returns the TransformNode.
  93107. */
  93108. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93109. /**
  93110. * Returns the mesh position in the local space from the current World matrix values.
  93111. * @returns a new Vector3.
  93112. */
  93113. getPositionExpressedInLocalSpace(): Vector3;
  93114. /**
  93115. * Translates the mesh along the passed Vector3 in its local space.
  93116. * @param vector3 the distance to translate in localspace
  93117. * @returns the TransformNode.
  93118. */
  93119. locallyTranslate(vector3: Vector3): TransformNode;
  93120. private static _lookAtVectorCache;
  93121. /**
  93122. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93123. * @param targetPoint the position (must be in same space as current mesh) to look at
  93124. * @param yawCor optional yaw (y-axis) correction in radians
  93125. * @param pitchCor optional pitch (x-axis) correction in radians
  93126. * @param rollCor optional roll (z-axis) correction in radians
  93127. * @param space the choosen space of the target
  93128. * @returns the TransformNode.
  93129. */
  93130. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93131. /**
  93132. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93133. * This Vector3 is expressed in the World space.
  93134. * @param localAxis axis to rotate
  93135. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93136. */
  93137. getDirection(localAxis: Vector3): Vector3;
  93138. /**
  93139. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93140. * localAxis is expressed in the mesh local space.
  93141. * result is computed in the Wordl space from the mesh World matrix.
  93142. * @param localAxis axis to rotate
  93143. * @param result the resulting transformnode
  93144. * @returns this TransformNode.
  93145. */
  93146. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93147. /**
  93148. * Sets this transform node rotation to the given local axis.
  93149. * @param localAxis the axis in local space
  93150. * @param yawCor optional yaw (y-axis) correction in radians
  93151. * @param pitchCor optional pitch (x-axis) correction in radians
  93152. * @param rollCor optional roll (z-axis) correction in radians
  93153. * @returns this TransformNode
  93154. */
  93155. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93156. /**
  93157. * Sets a new pivot point to the current node
  93158. * @param point defines the new pivot point to use
  93159. * @param space defines if the point is in world or local space (local by default)
  93160. * @returns the current TransformNode
  93161. */
  93162. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93163. /**
  93164. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93165. * @returns the pivot point
  93166. */
  93167. getPivotPoint(): Vector3;
  93168. /**
  93169. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93170. * @param result the vector3 to store the result
  93171. * @returns this TransformNode.
  93172. */
  93173. getPivotPointToRef(result: Vector3): TransformNode;
  93174. /**
  93175. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93176. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93177. */
  93178. getAbsolutePivotPoint(): Vector3;
  93179. /**
  93180. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93181. * @param result vector3 to store the result
  93182. * @returns this TransformNode.
  93183. */
  93184. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93185. /**
  93186. * Defines the passed node as the parent of the current node.
  93187. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93188. * @see https://doc.babylonjs.com/how_to/parenting
  93189. * @param node the node ot set as the parent
  93190. * @returns this TransformNode.
  93191. */
  93192. setParent(node: Nullable<Node>): TransformNode;
  93193. private _nonUniformScaling;
  93194. /**
  93195. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93196. */
  93197. get nonUniformScaling(): boolean;
  93198. /** @hidden */
  93199. _updateNonUniformScalingState(value: boolean): boolean;
  93200. /**
  93201. * Attach the current TransformNode to another TransformNode associated with a bone
  93202. * @param bone Bone affecting the TransformNode
  93203. * @param affectedTransformNode TransformNode associated with the bone
  93204. * @returns this object
  93205. */
  93206. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93207. /**
  93208. * Detach the transform node if its associated with a bone
  93209. * @returns this object
  93210. */
  93211. detachFromBone(): TransformNode;
  93212. private static _rotationAxisCache;
  93213. /**
  93214. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93215. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93216. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93217. * The passed axis is also normalized.
  93218. * @param axis the axis to rotate around
  93219. * @param amount the amount to rotate in radians
  93220. * @param space Space to rotate in (Default: local)
  93221. * @returns the TransformNode.
  93222. */
  93223. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93224. /**
  93225. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93226. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93227. * The passed axis is also normalized. .
  93228. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93229. * @param point the point to rotate around
  93230. * @param axis the axis to rotate around
  93231. * @param amount the amount to rotate in radians
  93232. * @returns the TransformNode
  93233. */
  93234. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93235. /**
  93236. * Translates the mesh along the axis vector for the passed distance in the given space.
  93237. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93238. * @param axis the axis to translate in
  93239. * @param distance the distance to translate
  93240. * @param space Space to rotate in (Default: local)
  93241. * @returns the TransformNode.
  93242. */
  93243. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93244. /**
  93245. * Adds a rotation step to the mesh current rotation.
  93246. * x, y, z are Euler angles expressed in radians.
  93247. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93248. * This means this rotation is made in the mesh local space only.
  93249. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93250. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93251. * ```javascript
  93252. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93253. * ```
  93254. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93255. * 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.
  93256. * @param x Rotation to add
  93257. * @param y Rotation to add
  93258. * @param z Rotation to add
  93259. * @returns the TransformNode.
  93260. */
  93261. addRotation(x: number, y: number, z: number): TransformNode;
  93262. /**
  93263. * @hidden
  93264. */
  93265. protected _getEffectiveParent(): Nullable<Node>;
  93266. /**
  93267. * Computes the world matrix of the node
  93268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93269. * @returns the world matrix
  93270. */
  93271. computeWorldMatrix(force?: boolean): Matrix;
  93272. /**
  93273. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93274. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93275. */
  93276. resetLocalMatrix(independentOfChildren?: boolean): void;
  93277. protected _afterComputeWorldMatrix(): void;
  93278. /**
  93279. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93280. * @param func callback function to add
  93281. *
  93282. * @returns the TransformNode.
  93283. */
  93284. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93285. /**
  93286. * Removes a registered callback function.
  93287. * @param func callback function to remove
  93288. * @returns the TransformNode.
  93289. */
  93290. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93291. /**
  93292. * Gets the position of the current mesh in camera space
  93293. * @param camera defines the camera to use
  93294. * @returns a position
  93295. */
  93296. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93297. /**
  93298. * Returns the distance from the mesh to the active camera
  93299. * @param camera defines the camera to use
  93300. * @returns the distance
  93301. */
  93302. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93303. /**
  93304. * Clone the current transform node
  93305. * @param name Name of the new clone
  93306. * @param newParent New parent for the clone
  93307. * @param doNotCloneChildren Do not clone children hierarchy
  93308. * @returns the new transform node
  93309. */
  93310. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93311. /**
  93312. * Serializes the objects information.
  93313. * @param currentSerializationObject defines the object to serialize in
  93314. * @returns the serialized object
  93315. */
  93316. serialize(currentSerializationObject?: any): any;
  93317. /**
  93318. * Returns a new TransformNode object parsed from the source provided.
  93319. * @param parsedTransformNode is the source.
  93320. * @param scene the scne the object belongs to
  93321. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93322. * @returns a new TransformNode object parsed from the source provided.
  93323. */
  93324. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93325. /**
  93326. * Get all child-transformNodes of this node
  93327. * @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
  93328. * @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
  93329. * @returns an array of TransformNode
  93330. */
  93331. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93332. /**
  93333. * Releases resources associated with this transform node.
  93334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93336. */
  93337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93338. /**
  93339. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93340. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93341. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93342. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93343. * @returns the current mesh
  93344. */
  93345. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93346. private _syncAbsoluteScalingAndRotation;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /**
  93351. * Class used to override all child animations of a given target
  93352. */
  93353. export class AnimationPropertiesOverride {
  93354. /**
  93355. * Gets or sets a value indicating if animation blending must be used
  93356. */
  93357. enableBlending: boolean;
  93358. /**
  93359. * Gets or sets the blending speed to use when enableBlending is true
  93360. */
  93361. blendingSpeed: number;
  93362. /**
  93363. * Gets or sets the default loop mode to use
  93364. */
  93365. loopMode: number;
  93366. }
  93367. }
  93368. declare module BABYLON {
  93369. /**
  93370. * Class used to store bone information
  93371. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93372. */
  93373. export class Bone extends Node {
  93374. /**
  93375. * defines the bone name
  93376. */
  93377. name: string;
  93378. private static _tmpVecs;
  93379. private static _tmpQuat;
  93380. private static _tmpMats;
  93381. /**
  93382. * Gets the list of child bones
  93383. */
  93384. children: Bone[];
  93385. /** Gets the animations associated with this bone */
  93386. animations: Animation[];
  93387. /**
  93388. * Gets or sets bone length
  93389. */
  93390. length: number;
  93391. /**
  93392. * @hidden Internal only
  93393. * Set this value to map this bone to a different index in the transform matrices
  93394. * Set this value to -1 to exclude the bone from the transform matrices
  93395. */
  93396. _index: Nullable<number>;
  93397. private _skeleton;
  93398. private _localMatrix;
  93399. private _restPose;
  93400. private _baseMatrix;
  93401. private _absoluteTransform;
  93402. private _invertedAbsoluteTransform;
  93403. private _parent;
  93404. private _scalingDeterminant;
  93405. private _worldTransform;
  93406. private _localScaling;
  93407. private _localRotation;
  93408. private _localPosition;
  93409. private _needToDecompose;
  93410. private _needToCompose;
  93411. /** @hidden */
  93412. _linkedTransformNode: Nullable<TransformNode>;
  93413. /** @hidden */
  93414. _waitingTransformNodeId: Nullable<string>;
  93415. /** @hidden */
  93416. get _matrix(): Matrix;
  93417. /** @hidden */
  93418. set _matrix(value: Matrix);
  93419. /**
  93420. * Create a new bone
  93421. * @param name defines the bone name
  93422. * @param skeleton defines the parent skeleton
  93423. * @param parentBone defines the parent (can be null if the bone is the root)
  93424. * @param localMatrix defines the local matrix
  93425. * @param restPose defines the rest pose matrix
  93426. * @param baseMatrix defines the base matrix
  93427. * @param index defines index of the bone in the hiearchy
  93428. */
  93429. constructor(
  93430. /**
  93431. * defines the bone name
  93432. */
  93433. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93434. /**
  93435. * Gets the current object class name.
  93436. * @return the class name
  93437. */
  93438. getClassName(): string;
  93439. /**
  93440. * Gets the parent skeleton
  93441. * @returns a skeleton
  93442. */
  93443. getSkeleton(): Skeleton;
  93444. /**
  93445. * Gets parent bone
  93446. * @returns a bone or null if the bone is the root of the bone hierarchy
  93447. */
  93448. getParent(): Nullable<Bone>;
  93449. /**
  93450. * Returns an array containing the root bones
  93451. * @returns an array containing the root bones
  93452. */
  93453. getChildren(): Array<Bone>;
  93454. /**
  93455. * Gets the node index in matrix array generated for rendering
  93456. * @returns the node index
  93457. */
  93458. getIndex(): number;
  93459. /**
  93460. * Sets the parent bone
  93461. * @param parent defines the parent (can be null if the bone is the root)
  93462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93463. */
  93464. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93465. /**
  93466. * Gets the local matrix
  93467. * @returns a matrix
  93468. */
  93469. getLocalMatrix(): Matrix;
  93470. /**
  93471. * Gets the base matrix (initial matrix which remains unchanged)
  93472. * @returns a matrix
  93473. */
  93474. getBaseMatrix(): Matrix;
  93475. /**
  93476. * Gets the rest pose matrix
  93477. * @returns a matrix
  93478. */
  93479. getRestPose(): Matrix;
  93480. /**
  93481. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93482. */
  93483. getWorldMatrix(): Matrix;
  93484. /**
  93485. * Sets the local matrix to rest pose matrix
  93486. */
  93487. returnToRest(): void;
  93488. /**
  93489. * Gets the inverse of the absolute transform matrix.
  93490. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93491. * @returns a matrix
  93492. */
  93493. getInvertedAbsoluteTransform(): Matrix;
  93494. /**
  93495. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93496. * @returns a matrix
  93497. */
  93498. getAbsoluteTransform(): Matrix;
  93499. /**
  93500. * Links with the given transform node.
  93501. * The local matrix of this bone is copied from the transform node every frame.
  93502. * @param transformNode defines the transform node to link to
  93503. */
  93504. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93505. /**
  93506. * Gets the node used to drive the bone's transformation
  93507. * @returns a transform node or null
  93508. */
  93509. getTransformNode(): Nullable<TransformNode>;
  93510. /** Gets or sets current position (in local space) */
  93511. get position(): Vector3;
  93512. set position(newPosition: Vector3);
  93513. /** Gets or sets current rotation (in local space) */
  93514. get rotation(): Vector3;
  93515. set rotation(newRotation: Vector3);
  93516. /** Gets or sets current rotation quaternion (in local space) */
  93517. get rotationQuaternion(): Quaternion;
  93518. set rotationQuaternion(newRotation: Quaternion);
  93519. /** Gets or sets current scaling (in local space) */
  93520. get scaling(): Vector3;
  93521. set scaling(newScaling: Vector3);
  93522. /**
  93523. * Gets the animation properties override
  93524. */
  93525. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93526. private _decompose;
  93527. private _compose;
  93528. /**
  93529. * Update the base and local matrices
  93530. * @param matrix defines the new base or local matrix
  93531. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93532. * @param updateLocalMatrix defines if the local matrix should be updated
  93533. */
  93534. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93535. /** @hidden */
  93536. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93537. /**
  93538. * Flag the bone as dirty (Forcing it to update everything)
  93539. */
  93540. markAsDirty(): void;
  93541. /** @hidden */
  93542. _markAsDirtyAndCompose(): void;
  93543. private _markAsDirtyAndDecompose;
  93544. /**
  93545. * Translate the bone in local or world space
  93546. * @param vec The amount to translate the bone
  93547. * @param space The space that the translation is in
  93548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93549. */
  93550. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93551. /**
  93552. * Set the postion of the bone in local or world space
  93553. * @param position The position to set the bone
  93554. * @param space The space that the position is in
  93555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93556. */
  93557. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93558. /**
  93559. * Set the absolute position of the bone (world space)
  93560. * @param position The position to set the bone
  93561. * @param mesh The mesh that this bone is attached to
  93562. */
  93563. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93564. /**
  93565. * Scale the bone on the x, y and z axes (in local space)
  93566. * @param x The amount to scale the bone on the x axis
  93567. * @param y The amount to scale the bone on the y axis
  93568. * @param z The amount to scale the bone on the z axis
  93569. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93570. */
  93571. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93572. /**
  93573. * Set the bone scaling in local space
  93574. * @param scale defines the scaling vector
  93575. */
  93576. setScale(scale: Vector3): void;
  93577. /**
  93578. * Gets the current scaling in local space
  93579. * @returns the current scaling vector
  93580. */
  93581. getScale(): Vector3;
  93582. /**
  93583. * Gets the current scaling in local space and stores it in a target vector
  93584. * @param result defines the target vector
  93585. */
  93586. getScaleToRef(result: Vector3): void;
  93587. /**
  93588. * Set the yaw, pitch, and roll of the bone in local or world space
  93589. * @param yaw The rotation of the bone on the y axis
  93590. * @param pitch The rotation of the bone on the x axis
  93591. * @param roll The rotation of the bone on the z axis
  93592. * @param space The space that the axes of rotation are in
  93593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93594. */
  93595. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93596. /**
  93597. * Add a rotation to the bone on an axis in local or world space
  93598. * @param axis The axis to rotate the bone on
  93599. * @param amount The amount to rotate the bone
  93600. * @param space The space that the axis is in
  93601. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93602. */
  93603. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93604. /**
  93605. * Set the rotation of the bone to a particular axis angle in local or world space
  93606. * @param axis The axis to rotate the bone on
  93607. * @param angle The angle that the bone should be rotated to
  93608. * @param space The space that the axis is in
  93609. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93610. */
  93611. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93612. /**
  93613. * Set the euler rotation of the bone in local of world space
  93614. * @param rotation The euler rotation that the bone should be set to
  93615. * @param space The space that the rotation is in
  93616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93617. */
  93618. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93619. /**
  93620. * Set the quaternion rotation of the bone in local of world space
  93621. * @param quat The quaternion rotation that the bone should be set to
  93622. * @param space The space that the rotation is in
  93623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93624. */
  93625. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93626. /**
  93627. * Set the rotation matrix of the bone in local of world space
  93628. * @param rotMat The rotation matrix that the bone should be set to
  93629. * @param space The space that the rotation is in
  93630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93631. */
  93632. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93633. private _rotateWithMatrix;
  93634. private _getNegativeRotationToRef;
  93635. /**
  93636. * Get the position of the bone in local or world space
  93637. * @param space The space that the returned position is in
  93638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93639. * @returns The position of the bone
  93640. */
  93641. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93642. /**
  93643. * Copy the position of the bone to a vector3 in local or world space
  93644. * @param space The space that the returned position is in
  93645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93646. * @param result The vector3 to copy the position to
  93647. */
  93648. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93649. /**
  93650. * Get the absolute position of the bone (world space)
  93651. * @param mesh The mesh that this bone is attached to
  93652. * @returns The absolute position of the bone
  93653. */
  93654. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93655. /**
  93656. * Copy the absolute position of the bone (world space) to the result param
  93657. * @param mesh The mesh that this bone is attached to
  93658. * @param result The vector3 to copy the absolute position to
  93659. */
  93660. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93661. /**
  93662. * Compute the absolute transforms of this bone and its children
  93663. */
  93664. computeAbsoluteTransforms(): void;
  93665. /**
  93666. * Get the world direction from an axis that is in the local space of the bone
  93667. * @param localAxis The local direction that is used to compute the world direction
  93668. * @param mesh The mesh that this bone is attached to
  93669. * @returns The world direction
  93670. */
  93671. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93672. /**
  93673. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93674. * @param localAxis The local direction that is used to compute the world direction
  93675. * @param mesh The mesh that this bone is attached to
  93676. * @param result The vector3 that the world direction will be copied to
  93677. */
  93678. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93679. /**
  93680. * Get the euler rotation of the bone in local or world space
  93681. * @param space The space that the rotation should be in
  93682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93683. * @returns The euler rotation
  93684. */
  93685. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93686. /**
  93687. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93688. * @param space The space that the rotation should be in
  93689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93690. * @param result The vector3 that the rotation should be copied to
  93691. */
  93692. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93693. /**
  93694. * Get the quaternion rotation of the bone in either local or world space
  93695. * @param space The space that the rotation should be in
  93696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93697. * @returns The quaternion rotation
  93698. */
  93699. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93700. /**
  93701. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93702. * @param space The space that the rotation should be in
  93703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93704. * @param result The quaternion that the rotation should be copied to
  93705. */
  93706. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93707. /**
  93708. * Get the rotation matrix of the bone in local or world space
  93709. * @param space The space that the rotation should be in
  93710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93711. * @returns The rotation matrix
  93712. */
  93713. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93714. /**
  93715. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93716. * @param space The space that the rotation should be in
  93717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93718. * @param result The quaternion that the rotation should be copied to
  93719. */
  93720. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93721. /**
  93722. * Get the world position of a point that is in the local space of the bone
  93723. * @param position The local position
  93724. * @param mesh The mesh that this bone is attached to
  93725. * @returns The world position
  93726. */
  93727. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93728. /**
  93729. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93730. * @param position The local position
  93731. * @param mesh The mesh that this bone is attached to
  93732. * @param result The vector3 that the world position should be copied to
  93733. */
  93734. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93735. /**
  93736. * Get the local position of a point that is in world space
  93737. * @param position The world position
  93738. * @param mesh The mesh that this bone is attached to
  93739. * @returns The local position
  93740. */
  93741. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93742. /**
  93743. * Get the local position of a point that is in world space and copy it to the result param
  93744. * @param position The world position
  93745. * @param mesh The mesh that this bone is attached to
  93746. * @param result The vector3 that the local position should be copied to
  93747. */
  93748. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93749. }
  93750. }
  93751. declare module BABYLON {
  93752. /**
  93753. * Defines a runtime animation
  93754. */
  93755. export class RuntimeAnimation {
  93756. private _events;
  93757. /**
  93758. * The current frame of the runtime animation
  93759. */
  93760. private _currentFrame;
  93761. /**
  93762. * The animation used by the runtime animation
  93763. */
  93764. private _animation;
  93765. /**
  93766. * The target of the runtime animation
  93767. */
  93768. private _target;
  93769. /**
  93770. * The initiating animatable
  93771. */
  93772. private _host;
  93773. /**
  93774. * The original value of the runtime animation
  93775. */
  93776. private _originalValue;
  93777. /**
  93778. * The original blend value of the runtime animation
  93779. */
  93780. private _originalBlendValue;
  93781. /**
  93782. * The offsets cache of the runtime animation
  93783. */
  93784. private _offsetsCache;
  93785. /**
  93786. * The high limits cache of the runtime animation
  93787. */
  93788. private _highLimitsCache;
  93789. /**
  93790. * Specifies if the runtime animation has been stopped
  93791. */
  93792. private _stopped;
  93793. /**
  93794. * The blending factor of the runtime animation
  93795. */
  93796. private _blendingFactor;
  93797. /**
  93798. * The BabylonJS scene
  93799. */
  93800. private _scene;
  93801. /**
  93802. * The current value of the runtime animation
  93803. */
  93804. private _currentValue;
  93805. /** @hidden */
  93806. _animationState: _IAnimationState;
  93807. /**
  93808. * The active target of the runtime animation
  93809. */
  93810. private _activeTargets;
  93811. private _currentActiveTarget;
  93812. private _directTarget;
  93813. /**
  93814. * The target path of the runtime animation
  93815. */
  93816. private _targetPath;
  93817. /**
  93818. * The weight of the runtime animation
  93819. */
  93820. private _weight;
  93821. /**
  93822. * The ratio offset of the runtime animation
  93823. */
  93824. private _ratioOffset;
  93825. /**
  93826. * The previous delay of the runtime animation
  93827. */
  93828. private _previousDelay;
  93829. /**
  93830. * The previous ratio of the runtime animation
  93831. */
  93832. private _previousRatio;
  93833. private _enableBlending;
  93834. private _keys;
  93835. private _minFrame;
  93836. private _maxFrame;
  93837. private _minValue;
  93838. private _maxValue;
  93839. private _targetIsArray;
  93840. /**
  93841. * Gets the current frame of the runtime animation
  93842. */
  93843. get currentFrame(): number;
  93844. /**
  93845. * Gets the weight of the runtime animation
  93846. */
  93847. get weight(): number;
  93848. /**
  93849. * Gets the current value of the runtime animation
  93850. */
  93851. get currentValue(): any;
  93852. /**
  93853. * Gets the target path of the runtime animation
  93854. */
  93855. get targetPath(): string;
  93856. /**
  93857. * Gets the actual target of the runtime animation
  93858. */
  93859. get target(): any;
  93860. /**
  93861. * Gets the additive state of the runtime animation
  93862. */
  93863. get isAdditive(): boolean;
  93864. /** @hidden */
  93865. _onLoop: () => void;
  93866. /**
  93867. * Create a new RuntimeAnimation object
  93868. * @param target defines the target of the animation
  93869. * @param animation defines the source animation object
  93870. * @param scene defines the hosting scene
  93871. * @param host defines the initiating Animatable
  93872. */
  93873. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93874. private _preparePath;
  93875. /**
  93876. * Gets the animation from the runtime animation
  93877. */
  93878. get animation(): Animation;
  93879. /**
  93880. * Resets the runtime animation to the beginning
  93881. * @param restoreOriginal defines whether to restore the target property to the original value
  93882. */
  93883. reset(restoreOriginal?: boolean): void;
  93884. /**
  93885. * Specifies if the runtime animation is stopped
  93886. * @returns Boolean specifying if the runtime animation is stopped
  93887. */
  93888. isStopped(): boolean;
  93889. /**
  93890. * Disposes of the runtime animation
  93891. */
  93892. dispose(): void;
  93893. /**
  93894. * Apply the interpolated value to the target
  93895. * @param currentValue defines the value computed by the animation
  93896. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93897. */
  93898. setValue(currentValue: any, weight: number): void;
  93899. private _getOriginalValues;
  93900. private _setValue;
  93901. /**
  93902. * Gets the loop pmode of the runtime animation
  93903. * @returns Loop Mode
  93904. */
  93905. private _getCorrectLoopMode;
  93906. /**
  93907. * Move the current animation to a given frame
  93908. * @param frame defines the frame to move to
  93909. */
  93910. goToFrame(frame: number): void;
  93911. /**
  93912. * @hidden Internal use only
  93913. */
  93914. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93915. /**
  93916. * Execute the current animation
  93917. * @param delay defines the delay to add to the current frame
  93918. * @param from defines the lower bound of the animation range
  93919. * @param to defines the upper bound of the animation range
  93920. * @param loop defines if the current animation must loop
  93921. * @param speedRatio defines the current speed ratio
  93922. * @param weight defines the weight of the animation (default is -1 so no weight)
  93923. * @param onLoop optional callback called when animation loops
  93924. * @returns a boolean indicating if the animation is running
  93925. */
  93926. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93927. }
  93928. }
  93929. declare module BABYLON {
  93930. /**
  93931. * Class used to store an actual running animation
  93932. */
  93933. export class Animatable {
  93934. /** defines the target object */
  93935. target: any;
  93936. /** defines the starting frame number (default is 0) */
  93937. fromFrame: number;
  93938. /** defines the ending frame number (default is 100) */
  93939. toFrame: number;
  93940. /** defines if the animation must loop (default is false) */
  93941. loopAnimation: boolean;
  93942. /** defines a callback to call when animation ends if it is not looping */
  93943. onAnimationEnd?: (() => void) | null | undefined;
  93944. /** defines a callback to call when animation loops */
  93945. onAnimationLoop?: (() => void) | null | undefined;
  93946. /** defines whether the animation should be evaluated additively */
  93947. isAdditive: boolean;
  93948. private _localDelayOffset;
  93949. private _pausedDelay;
  93950. private _runtimeAnimations;
  93951. private _paused;
  93952. private _scene;
  93953. private _speedRatio;
  93954. private _weight;
  93955. private _syncRoot;
  93956. /**
  93957. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93958. * This will only apply for non looping animation (default is true)
  93959. */
  93960. disposeOnEnd: boolean;
  93961. /**
  93962. * Gets a boolean indicating if the animation has started
  93963. */
  93964. animationStarted: boolean;
  93965. /**
  93966. * Observer raised when the animation ends
  93967. */
  93968. onAnimationEndObservable: Observable<Animatable>;
  93969. /**
  93970. * Observer raised when the animation loops
  93971. */
  93972. onAnimationLoopObservable: Observable<Animatable>;
  93973. /**
  93974. * Gets the root Animatable used to synchronize and normalize animations
  93975. */
  93976. get syncRoot(): Nullable<Animatable>;
  93977. /**
  93978. * Gets the current frame of the first RuntimeAnimation
  93979. * Used to synchronize Animatables
  93980. */
  93981. get masterFrame(): number;
  93982. /**
  93983. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93984. */
  93985. get weight(): number;
  93986. set weight(value: number);
  93987. /**
  93988. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93989. */
  93990. get speedRatio(): number;
  93991. set speedRatio(value: number);
  93992. /**
  93993. * Creates a new Animatable
  93994. * @param scene defines the hosting scene
  93995. * @param target defines the target object
  93996. * @param fromFrame defines the starting frame number (default is 0)
  93997. * @param toFrame defines the ending frame number (default is 100)
  93998. * @param loopAnimation defines if the animation must loop (default is false)
  93999. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94000. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94001. * @param animations defines a group of animation to add to the new Animatable
  94002. * @param onAnimationLoop defines a callback to call when animation loops
  94003. * @param isAdditive defines whether the animation should be evaluated additively
  94004. */
  94005. constructor(scene: Scene,
  94006. /** defines the target object */
  94007. target: any,
  94008. /** defines the starting frame number (default is 0) */
  94009. fromFrame?: number,
  94010. /** defines the ending frame number (default is 100) */
  94011. toFrame?: number,
  94012. /** defines if the animation must loop (default is false) */
  94013. loopAnimation?: boolean, speedRatio?: number,
  94014. /** defines a callback to call when animation ends if it is not looping */
  94015. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94016. /** defines a callback to call when animation loops */
  94017. onAnimationLoop?: (() => void) | null | undefined,
  94018. /** defines whether the animation should be evaluated additively */
  94019. isAdditive?: boolean);
  94020. /**
  94021. * Synchronize and normalize current Animatable with a source Animatable
  94022. * This is useful when using animation weights and when animations are not of the same length
  94023. * @param root defines the root Animatable to synchronize with
  94024. * @returns the current Animatable
  94025. */
  94026. syncWith(root: Animatable): Animatable;
  94027. /**
  94028. * Gets the list of runtime animations
  94029. * @returns an array of RuntimeAnimation
  94030. */
  94031. getAnimations(): RuntimeAnimation[];
  94032. /**
  94033. * Adds more animations to the current animatable
  94034. * @param target defines the target of the animations
  94035. * @param animations defines the new animations to add
  94036. */
  94037. appendAnimations(target: any, animations: Animation[]): void;
  94038. /**
  94039. * Gets the source animation for a specific property
  94040. * @param property defines the propertyu to look for
  94041. * @returns null or the source animation for the given property
  94042. */
  94043. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94044. /**
  94045. * Gets the runtime animation for a specific property
  94046. * @param property defines the propertyu to look for
  94047. * @returns null or the runtime animation for the given property
  94048. */
  94049. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94050. /**
  94051. * Resets the animatable to its original state
  94052. */
  94053. reset(): void;
  94054. /**
  94055. * Allows the animatable to blend with current running animations
  94056. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94057. * @param blendingSpeed defines the blending speed to use
  94058. */
  94059. enableBlending(blendingSpeed: number): void;
  94060. /**
  94061. * Disable animation blending
  94062. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94063. */
  94064. disableBlending(): void;
  94065. /**
  94066. * Jump directly to a given frame
  94067. * @param frame defines the frame to jump to
  94068. */
  94069. goToFrame(frame: number): void;
  94070. /**
  94071. * Pause the animation
  94072. */
  94073. pause(): void;
  94074. /**
  94075. * Restart the animation
  94076. */
  94077. restart(): void;
  94078. private _raiseOnAnimationEnd;
  94079. /**
  94080. * Stop and delete the current animation
  94081. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94082. * @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)
  94083. */
  94084. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94085. /**
  94086. * Wait asynchronously for the animation to end
  94087. * @returns a promise which will be fullfilled when the animation ends
  94088. */
  94089. waitAsync(): Promise<Animatable>;
  94090. /** @hidden */
  94091. _animate(delay: number): boolean;
  94092. }
  94093. interface Scene {
  94094. /** @hidden */
  94095. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94096. /** @hidden */
  94097. _processLateAnimationBindingsForMatrices(holder: {
  94098. totalWeight: number;
  94099. totalAdditiveWeight: number;
  94100. animations: RuntimeAnimation[];
  94101. additiveAnimations: RuntimeAnimation[];
  94102. originalValue: Matrix;
  94103. }): any;
  94104. /** @hidden */
  94105. _processLateAnimationBindingsForQuaternions(holder: {
  94106. totalWeight: number;
  94107. totalAdditiveWeight: number;
  94108. animations: RuntimeAnimation[];
  94109. additiveAnimations: RuntimeAnimation[];
  94110. originalValue: Quaternion;
  94111. }, refQuaternion: Quaternion): Quaternion;
  94112. /** @hidden */
  94113. _processLateAnimationBindings(): void;
  94114. /**
  94115. * Will start the animation sequence of a given target
  94116. * @param target defines the target
  94117. * @param from defines from which frame should animation start
  94118. * @param to defines until which frame should animation run.
  94119. * @param weight defines the weight to apply to the animation (1.0 by default)
  94120. * @param loop defines if the animation loops
  94121. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94122. * @param onAnimationEnd defines the function to be executed when the animation ends
  94123. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94124. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94125. * @param onAnimationLoop defines the callback to call when an animation loops
  94126. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94127. * @returns the animatable object created for this animation
  94128. */
  94129. 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;
  94130. /**
  94131. * Will start the animation sequence of a given target
  94132. * @param target defines the target
  94133. * @param from defines from which frame should animation start
  94134. * @param to defines until which frame should animation run.
  94135. * @param loop defines if the animation loops
  94136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94137. * @param onAnimationEnd defines the function to be executed when the animation ends
  94138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94139. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94140. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94141. * @param onAnimationLoop defines the callback to call when an animation loops
  94142. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94143. * @returns the animatable object created for this animation
  94144. */
  94145. 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;
  94146. /**
  94147. * Will start the animation sequence of a given target and its hierarchy
  94148. * @param target defines the target
  94149. * @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.
  94150. * @param from defines from which frame should animation start
  94151. * @param to defines until which frame should animation run.
  94152. * @param loop defines if the animation loops
  94153. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94154. * @param onAnimationEnd defines the function to be executed when the animation ends
  94155. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94156. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94157. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94158. * @param onAnimationLoop defines the callback to call when an animation loops
  94159. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94160. * @returns the list of created animatables
  94161. */
  94162. 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[];
  94163. /**
  94164. * Begin a new animation on a given node
  94165. * @param target defines the target where the animation will take place
  94166. * @param animations defines the list of animations to start
  94167. * @param from defines the initial value
  94168. * @param to defines the final value
  94169. * @param loop defines if you want animation to loop (off by default)
  94170. * @param speedRatio defines the speed ratio to apply to all animations
  94171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94172. * @param onAnimationLoop defines the callback to call when an animation loops
  94173. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94174. * @returns the list of created animatables
  94175. */
  94176. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94177. /**
  94178. * Begin a new animation on a given node and its hierarchy
  94179. * @param target defines the root node where the animation will take place
  94180. * @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.
  94181. * @param animations defines the list of animations to start
  94182. * @param from defines the initial value
  94183. * @param to defines the final value
  94184. * @param loop defines if you want animation to loop (off by default)
  94185. * @param speedRatio defines the speed ratio to apply to all animations
  94186. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94187. * @param onAnimationLoop defines the callback to call when an animation loops
  94188. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94189. * @returns the list of animatables created for all nodes
  94190. */
  94191. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94192. /**
  94193. * Gets the animatable associated with a specific target
  94194. * @param target defines the target of the animatable
  94195. * @returns the required animatable if found
  94196. */
  94197. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94198. /**
  94199. * Gets all animatables associated with a given target
  94200. * @param target defines the target to look animatables for
  94201. * @returns an array of Animatables
  94202. */
  94203. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94204. /**
  94205. * Stops and removes all animations that have been applied to the scene
  94206. */
  94207. stopAllAnimations(): void;
  94208. /**
  94209. * Gets the current delta time used by animation engine
  94210. */
  94211. deltaTime: number;
  94212. }
  94213. interface Bone {
  94214. /**
  94215. * Copy an animation range from another bone
  94216. * @param source defines the source bone
  94217. * @param rangeName defines the range name to copy
  94218. * @param frameOffset defines the frame offset
  94219. * @param rescaleAsRequired defines if rescaling must be applied if required
  94220. * @param skelDimensionsRatio defines the scaling ratio
  94221. * @returns true if operation was successful
  94222. */
  94223. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94224. }
  94225. }
  94226. declare module BABYLON {
  94227. /**
  94228. * Class used to handle skinning animations
  94229. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94230. */
  94231. export class Skeleton implements IAnimatable {
  94232. /** defines the skeleton name */
  94233. name: string;
  94234. /** defines the skeleton Id */
  94235. id: string;
  94236. /**
  94237. * Defines the list of child bones
  94238. */
  94239. bones: Bone[];
  94240. /**
  94241. * Defines an estimate of the dimension of the skeleton at rest
  94242. */
  94243. dimensionsAtRest: Vector3;
  94244. /**
  94245. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94246. */
  94247. needInitialSkinMatrix: boolean;
  94248. /**
  94249. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94250. */
  94251. overrideMesh: Nullable<AbstractMesh>;
  94252. /**
  94253. * Gets the list of animations attached to this skeleton
  94254. */
  94255. animations: Array<Animation>;
  94256. private _scene;
  94257. private _isDirty;
  94258. private _transformMatrices;
  94259. private _transformMatrixTexture;
  94260. private _meshesWithPoseMatrix;
  94261. private _animatables;
  94262. private _identity;
  94263. private _synchronizedWithMesh;
  94264. private _ranges;
  94265. private _lastAbsoluteTransformsUpdateId;
  94266. private _canUseTextureForBones;
  94267. private _uniqueId;
  94268. /** @hidden */
  94269. _numBonesWithLinkedTransformNode: number;
  94270. /** @hidden */
  94271. _hasWaitingData: Nullable<boolean>;
  94272. /**
  94273. * Specifies if the skeleton should be serialized
  94274. */
  94275. doNotSerialize: boolean;
  94276. private _useTextureToStoreBoneMatrices;
  94277. /**
  94278. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94279. * Please note that this option is not available if the hardware does not support it
  94280. */
  94281. get useTextureToStoreBoneMatrices(): boolean;
  94282. set useTextureToStoreBoneMatrices(value: boolean);
  94283. private _animationPropertiesOverride;
  94284. /**
  94285. * Gets or sets the animation properties override
  94286. */
  94287. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94288. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94289. /**
  94290. * List of inspectable custom properties (used by the Inspector)
  94291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94292. */
  94293. inspectableCustomProperties: IInspectable[];
  94294. /**
  94295. * An observable triggered before computing the skeleton's matrices
  94296. */
  94297. onBeforeComputeObservable: Observable<Skeleton>;
  94298. /**
  94299. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94300. */
  94301. get isUsingTextureForMatrices(): boolean;
  94302. /**
  94303. * Gets the unique ID of this skeleton
  94304. */
  94305. get uniqueId(): number;
  94306. /**
  94307. * Creates a new skeleton
  94308. * @param name defines the skeleton name
  94309. * @param id defines the skeleton Id
  94310. * @param scene defines the hosting scene
  94311. */
  94312. constructor(
  94313. /** defines the skeleton name */
  94314. name: string,
  94315. /** defines the skeleton Id */
  94316. id: string, scene: Scene);
  94317. /**
  94318. * Gets the current object class name.
  94319. * @return the class name
  94320. */
  94321. getClassName(): string;
  94322. /**
  94323. * Returns an array containing the root bones
  94324. * @returns an array containing the root bones
  94325. */
  94326. getChildren(): Array<Bone>;
  94327. /**
  94328. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94329. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94330. * @returns a Float32Array containing matrices data
  94331. */
  94332. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94333. /**
  94334. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94335. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94336. * @returns a raw texture containing the data
  94337. */
  94338. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94339. /**
  94340. * Gets the current hosting scene
  94341. * @returns a scene object
  94342. */
  94343. getScene(): Scene;
  94344. /**
  94345. * Gets a string representing the current skeleton data
  94346. * @param fullDetails defines a boolean indicating if we want a verbose version
  94347. * @returns a string representing the current skeleton data
  94348. */
  94349. toString(fullDetails?: boolean): string;
  94350. /**
  94351. * Get bone's index searching by name
  94352. * @param name defines bone's name to search for
  94353. * @return the indice of the bone. Returns -1 if not found
  94354. */
  94355. getBoneIndexByName(name: string): number;
  94356. /**
  94357. * Creater a new animation range
  94358. * @param name defines the name of the range
  94359. * @param from defines the start key
  94360. * @param to defines the end key
  94361. */
  94362. createAnimationRange(name: string, from: number, to: number): void;
  94363. /**
  94364. * Delete a specific animation range
  94365. * @param name defines the name of the range
  94366. * @param deleteFrames defines if frames must be removed as well
  94367. */
  94368. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94369. /**
  94370. * Gets a specific animation range
  94371. * @param name defines the name of the range to look for
  94372. * @returns the requested animation range or null if not found
  94373. */
  94374. getAnimationRange(name: string): Nullable<AnimationRange>;
  94375. /**
  94376. * Gets the list of all animation ranges defined on this skeleton
  94377. * @returns an array
  94378. */
  94379. getAnimationRanges(): Nullable<AnimationRange>[];
  94380. /**
  94381. * Copy animation range from a source skeleton.
  94382. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94383. * @param source defines the source skeleton
  94384. * @param name defines the name of the range to copy
  94385. * @param rescaleAsRequired defines if rescaling must be applied if required
  94386. * @returns true if operation was successful
  94387. */
  94388. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94389. /**
  94390. * Forces the skeleton to go to rest pose
  94391. */
  94392. returnToRest(): void;
  94393. private _getHighestAnimationFrame;
  94394. /**
  94395. * Begin a specific animation range
  94396. * @param name defines the name of the range to start
  94397. * @param loop defines if looping must be turned on (false by default)
  94398. * @param speedRatio defines the speed ratio to apply (1 by default)
  94399. * @param onAnimationEnd defines a callback which will be called when animation will end
  94400. * @returns a new animatable
  94401. */
  94402. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94403. /**
  94404. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94405. * @param skeleton defines the Skeleton containing the animation range to convert
  94406. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94407. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94408. * @returns the original skeleton
  94409. */
  94410. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94411. /** @hidden */
  94412. _markAsDirty(): void;
  94413. /** @hidden */
  94414. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94415. /** @hidden */
  94416. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94417. private _computeTransformMatrices;
  94418. /**
  94419. * Build all resources required to render a skeleton
  94420. */
  94421. prepare(): void;
  94422. /**
  94423. * Gets the list of animatables currently running for this skeleton
  94424. * @returns an array of animatables
  94425. */
  94426. getAnimatables(): IAnimatable[];
  94427. /**
  94428. * Clone the current skeleton
  94429. * @param name defines the name of the new skeleton
  94430. * @param id defines the id of the new skeleton
  94431. * @returns the new skeleton
  94432. */
  94433. clone(name: string, id?: string): Skeleton;
  94434. /**
  94435. * Enable animation blending for this skeleton
  94436. * @param blendingSpeed defines the blending speed to apply
  94437. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94438. */
  94439. enableBlending(blendingSpeed?: number): void;
  94440. /**
  94441. * Releases all resources associated with the current skeleton
  94442. */
  94443. dispose(): void;
  94444. /**
  94445. * Serialize the skeleton in a JSON object
  94446. * @returns a JSON object
  94447. */
  94448. serialize(): any;
  94449. /**
  94450. * Creates a new skeleton from serialized data
  94451. * @param parsedSkeleton defines the serialized data
  94452. * @param scene defines the hosting scene
  94453. * @returns a new skeleton
  94454. */
  94455. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94456. /**
  94457. * Compute all node absolute transforms
  94458. * @param forceUpdate defines if computation must be done even if cache is up to date
  94459. */
  94460. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94461. /**
  94462. * Gets the root pose matrix
  94463. * @returns a matrix
  94464. */
  94465. getPoseMatrix(): Nullable<Matrix>;
  94466. /**
  94467. * Sorts bones per internal index
  94468. */
  94469. sortBones(): void;
  94470. private _sortBones;
  94471. }
  94472. }
  94473. declare module BABYLON {
  94474. /**
  94475. * Creates an instance based on a source mesh.
  94476. */
  94477. export class InstancedMesh extends AbstractMesh {
  94478. private _sourceMesh;
  94479. private _currentLOD;
  94480. /** @hidden */
  94481. _indexInSourceMeshInstanceArray: number;
  94482. constructor(name: string, source: Mesh);
  94483. /**
  94484. * Returns the string "InstancedMesh".
  94485. */
  94486. getClassName(): string;
  94487. /** Gets the list of lights affecting that mesh */
  94488. get lightSources(): Light[];
  94489. _resyncLightSources(): void;
  94490. _resyncLightSource(light: Light): void;
  94491. _removeLightSource(light: Light, dispose: boolean): void;
  94492. /**
  94493. * If the source mesh receives shadows
  94494. */
  94495. get receiveShadows(): boolean;
  94496. /**
  94497. * The material of the source mesh
  94498. */
  94499. get material(): Nullable<Material>;
  94500. /**
  94501. * Visibility of the source mesh
  94502. */
  94503. get visibility(): number;
  94504. /**
  94505. * Skeleton of the source mesh
  94506. */
  94507. get skeleton(): Nullable<Skeleton>;
  94508. /**
  94509. * Rendering ground id of the source mesh
  94510. */
  94511. get renderingGroupId(): number;
  94512. set renderingGroupId(value: number);
  94513. /**
  94514. * Returns the total number of vertices (integer).
  94515. */
  94516. getTotalVertices(): number;
  94517. /**
  94518. * Returns a positive integer : the total number of indices in this mesh geometry.
  94519. * @returns the numner of indices or zero if the mesh has no geometry.
  94520. */
  94521. getTotalIndices(): number;
  94522. /**
  94523. * The source mesh of the instance
  94524. */
  94525. get sourceMesh(): Mesh;
  94526. /**
  94527. * Creates a new InstancedMesh object from the mesh model.
  94528. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94529. * @param name defines the name of the new instance
  94530. * @returns a new InstancedMesh
  94531. */
  94532. createInstance(name: string): InstancedMesh;
  94533. /**
  94534. * Is this node ready to be used/rendered
  94535. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94536. * @return {boolean} is it ready
  94537. */
  94538. isReady(completeCheck?: boolean): boolean;
  94539. /**
  94540. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94541. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94542. * @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.
  94543. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94544. */
  94545. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94546. /**
  94547. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94548. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94549. * The `data` are either a numeric array either a Float32Array.
  94550. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94551. * 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).
  94552. * Note that a new underlying VertexBuffer object is created each call.
  94553. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94554. *
  94555. * Possible `kind` values :
  94556. * - VertexBuffer.PositionKind
  94557. * - VertexBuffer.UVKind
  94558. * - VertexBuffer.UV2Kind
  94559. * - VertexBuffer.UV3Kind
  94560. * - VertexBuffer.UV4Kind
  94561. * - VertexBuffer.UV5Kind
  94562. * - VertexBuffer.UV6Kind
  94563. * - VertexBuffer.ColorKind
  94564. * - VertexBuffer.MatricesIndicesKind
  94565. * - VertexBuffer.MatricesIndicesExtraKind
  94566. * - VertexBuffer.MatricesWeightsKind
  94567. * - VertexBuffer.MatricesWeightsExtraKind
  94568. *
  94569. * Returns the Mesh.
  94570. */
  94571. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94572. /**
  94573. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94574. * If the mesh has no geometry, it is simply returned as it is.
  94575. * The `data` are either a numeric array either a Float32Array.
  94576. * No new underlying VertexBuffer object is created.
  94577. * 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.
  94578. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94579. *
  94580. * Possible `kind` values :
  94581. * - VertexBuffer.PositionKind
  94582. * - VertexBuffer.UVKind
  94583. * - VertexBuffer.UV2Kind
  94584. * - VertexBuffer.UV3Kind
  94585. * - VertexBuffer.UV4Kind
  94586. * - VertexBuffer.UV5Kind
  94587. * - VertexBuffer.UV6Kind
  94588. * - VertexBuffer.ColorKind
  94589. * - VertexBuffer.MatricesIndicesKind
  94590. * - VertexBuffer.MatricesIndicesExtraKind
  94591. * - VertexBuffer.MatricesWeightsKind
  94592. * - VertexBuffer.MatricesWeightsExtraKind
  94593. *
  94594. * Returns the Mesh.
  94595. */
  94596. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94597. /**
  94598. * Sets the mesh indices.
  94599. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94600. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94601. * This method creates a new index buffer each call.
  94602. * Returns the Mesh.
  94603. */
  94604. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94605. /**
  94606. * Boolean : True if the mesh owns the requested kind of data.
  94607. */
  94608. isVerticesDataPresent(kind: string): boolean;
  94609. /**
  94610. * Returns an array of indices (IndicesArray).
  94611. */
  94612. getIndices(): Nullable<IndicesArray>;
  94613. get _positions(): Nullable<Vector3[]>;
  94614. /**
  94615. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94616. * This means the mesh underlying bounding box and sphere are recomputed.
  94617. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94618. * @returns the current mesh
  94619. */
  94620. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94621. /** @hidden */
  94622. _preActivate(): InstancedMesh;
  94623. /** @hidden */
  94624. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94625. /** @hidden */
  94626. _postActivate(): void;
  94627. getWorldMatrix(): Matrix;
  94628. get isAnInstance(): boolean;
  94629. /**
  94630. * Returns the current associated LOD AbstractMesh.
  94631. */
  94632. getLOD(camera: Camera): AbstractMesh;
  94633. /** @hidden */
  94634. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94635. /** @hidden */
  94636. _syncSubMeshes(): InstancedMesh;
  94637. /** @hidden */
  94638. _generatePointsArray(): boolean;
  94639. /**
  94640. * Creates a new InstancedMesh from the current mesh.
  94641. * - name (string) : the cloned mesh name
  94642. * - newParent (optional Node) : the optional Node to parent the clone to.
  94643. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94644. *
  94645. * Returns the clone.
  94646. */
  94647. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94648. /**
  94649. * Disposes the InstancedMesh.
  94650. * Returns nothing.
  94651. */
  94652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94653. }
  94654. interface Mesh {
  94655. /**
  94656. * Register a custom buffer that will be instanced
  94657. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94658. * @param kind defines the buffer kind
  94659. * @param stride defines the stride in floats
  94660. */
  94661. registerInstancedBuffer(kind: string, stride: number): void;
  94662. /**
  94663. * true to use the edge renderer for all instances of this mesh
  94664. */
  94665. edgesShareWithInstances: boolean;
  94666. /** @hidden */
  94667. _userInstancedBuffersStorage: {
  94668. data: {
  94669. [key: string]: Float32Array;
  94670. };
  94671. sizes: {
  94672. [key: string]: number;
  94673. };
  94674. vertexBuffers: {
  94675. [key: string]: Nullable<VertexBuffer>;
  94676. };
  94677. strides: {
  94678. [key: string]: number;
  94679. };
  94680. };
  94681. }
  94682. interface AbstractMesh {
  94683. /**
  94684. * Object used to store instanced buffers defined by user
  94685. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94686. */
  94687. instancedBuffers: {
  94688. [key: string]: any;
  94689. };
  94690. }
  94691. }
  94692. declare module BABYLON {
  94693. /**
  94694. * Defines the options associated with the creation of a shader material.
  94695. */
  94696. export interface IShaderMaterialOptions {
  94697. /**
  94698. * Does the material work in alpha blend mode
  94699. */
  94700. needAlphaBlending: boolean;
  94701. /**
  94702. * Does the material work in alpha test mode
  94703. */
  94704. needAlphaTesting: boolean;
  94705. /**
  94706. * The list of attribute names used in the shader
  94707. */
  94708. attributes: string[];
  94709. /**
  94710. * The list of unifrom names used in the shader
  94711. */
  94712. uniforms: string[];
  94713. /**
  94714. * The list of UBO names used in the shader
  94715. */
  94716. uniformBuffers: string[];
  94717. /**
  94718. * The list of sampler names used in the shader
  94719. */
  94720. samplers: string[];
  94721. /**
  94722. * The list of defines used in the shader
  94723. */
  94724. defines: string[];
  94725. }
  94726. /**
  94727. * 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.
  94728. *
  94729. * This returned material effects how the mesh will look based on the code in the shaders.
  94730. *
  94731. * @see https://doc.babylonjs.com/how_to/shader_material
  94732. */
  94733. export class ShaderMaterial extends Material {
  94734. private _shaderPath;
  94735. private _options;
  94736. private _textures;
  94737. private _textureArrays;
  94738. private _floats;
  94739. private _ints;
  94740. private _floatsArrays;
  94741. private _colors3;
  94742. private _colors3Arrays;
  94743. private _colors4;
  94744. private _colors4Arrays;
  94745. private _vectors2;
  94746. private _vectors3;
  94747. private _vectors4;
  94748. private _matrices;
  94749. private _matrixArrays;
  94750. private _matrices3x3;
  94751. private _matrices2x2;
  94752. private _vectors2Arrays;
  94753. private _vectors3Arrays;
  94754. private _vectors4Arrays;
  94755. private _cachedWorldViewMatrix;
  94756. private _cachedWorldViewProjectionMatrix;
  94757. private _renderId;
  94758. private _multiview;
  94759. private _cachedDefines;
  94760. /** Define the Url to load snippets */
  94761. static SnippetUrl: string;
  94762. /** Snippet ID if the material was created from the snippet server */
  94763. snippetId: string;
  94764. /**
  94765. * Instantiate a new shader material.
  94766. * 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.
  94767. * This returned material effects how the mesh will look based on the code in the shaders.
  94768. * @see https://doc.babylonjs.com/how_to/shader_material
  94769. * @param name Define the name of the material in the scene
  94770. * @param scene Define the scene the material belongs to
  94771. * @param shaderPath Defines the route to the shader code in one of three ways:
  94772. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94773. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94774. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94775. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94776. * @param options Define the options used to create the shader
  94777. */
  94778. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94779. /**
  94780. * Gets the shader path used to define the shader code
  94781. * It can be modified to trigger a new compilation
  94782. */
  94783. get shaderPath(): any;
  94784. /**
  94785. * Sets the shader path used to define the shader code
  94786. * It can be modified to trigger a new compilation
  94787. */
  94788. set shaderPath(shaderPath: any);
  94789. /**
  94790. * Gets the options used to compile the shader.
  94791. * They can be modified to trigger a new compilation
  94792. */
  94793. get options(): IShaderMaterialOptions;
  94794. /**
  94795. * Gets the current class name of the material e.g. "ShaderMaterial"
  94796. * Mainly use in serialization.
  94797. * @returns the class name
  94798. */
  94799. getClassName(): string;
  94800. /**
  94801. * Specifies if the material will require alpha blending
  94802. * @returns a boolean specifying if alpha blending is needed
  94803. */
  94804. needAlphaBlending(): boolean;
  94805. /**
  94806. * Specifies if this material should be rendered in alpha test mode
  94807. * @returns a boolean specifying if an alpha test is needed.
  94808. */
  94809. needAlphaTesting(): boolean;
  94810. private _checkUniform;
  94811. /**
  94812. * Set a texture in the shader.
  94813. * @param name Define the name of the uniform samplers as defined in the shader
  94814. * @param texture Define the texture to bind to this sampler
  94815. * @return the material itself allowing "fluent" like uniform updates
  94816. */
  94817. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94818. /**
  94819. * Set a texture array in the shader.
  94820. * @param name Define the name of the uniform sampler array as defined in the shader
  94821. * @param textures Define the list of textures to bind to this sampler
  94822. * @return the material itself allowing "fluent" like uniform updates
  94823. */
  94824. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94825. /**
  94826. * Set a float in the shader.
  94827. * @param name Define the name of the uniform as defined in the shader
  94828. * @param value Define the value to give to the uniform
  94829. * @return the material itself allowing "fluent" like uniform updates
  94830. */
  94831. setFloat(name: string, value: number): ShaderMaterial;
  94832. /**
  94833. * Set a int in the shader.
  94834. * @param name Define the name of the uniform as defined in the shader
  94835. * @param value Define the value to give to the uniform
  94836. * @return the material itself allowing "fluent" like uniform updates
  94837. */
  94838. setInt(name: string, value: number): ShaderMaterial;
  94839. /**
  94840. * Set an array of floats in the shader.
  94841. * @param name Define the name of the uniform as defined in the shader
  94842. * @param value Define the value to give to the uniform
  94843. * @return the material itself allowing "fluent" like uniform updates
  94844. */
  94845. setFloats(name: string, value: number[]): ShaderMaterial;
  94846. /**
  94847. * Set a vec3 in the shader from a Color3.
  94848. * @param name Define the name of the uniform as defined in the shader
  94849. * @param value Define the value to give to the uniform
  94850. * @return the material itself allowing "fluent" like uniform updates
  94851. */
  94852. setColor3(name: string, value: Color3): ShaderMaterial;
  94853. /**
  94854. * Set a vec3 array in the shader from a Color3 array.
  94855. * @param name Define the name of the uniform as defined in the shader
  94856. * @param value Define the value to give to the uniform
  94857. * @return the material itself allowing "fluent" like uniform updates
  94858. */
  94859. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94860. /**
  94861. * Set a vec4 in the shader from a Color4.
  94862. * @param name Define the name of the uniform as defined in the shader
  94863. * @param value Define the value to give to the uniform
  94864. * @return the material itself allowing "fluent" like uniform updates
  94865. */
  94866. setColor4(name: string, value: Color4): ShaderMaterial;
  94867. /**
  94868. * Set a vec4 array in the shader from a Color4 array.
  94869. * @param name Define the name of the uniform as defined in the shader
  94870. * @param value Define the value to give to the uniform
  94871. * @return the material itself allowing "fluent" like uniform updates
  94872. */
  94873. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94874. /**
  94875. * Set a vec2 in the shader from a Vector2.
  94876. * @param name Define the name of the uniform as defined in the shader
  94877. * @param value Define the value to give to the uniform
  94878. * @return the material itself allowing "fluent" like uniform updates
  94879. */
  94880. setVector2(name: string, value: Vector2): ShaderMaterial;
  94881. /**
  94882. * Set a vec3 in the shader from a Vector3.
  94883. * @param name Define the name of the uniform as defined in the shader
  94884. * @param value Define the value to give to the uniform
  94885. * @return the material itself allowing "fluent" like uniform updates
  94886. */
  94887. setVector3(name: string, value: Vector3): ShaderMaterial;
  94888. /**
  94889. * Set a vec4 in the shader from a Vector4.
  94890. * @param name Define the name of the uniform as defined in the shader
  94891. * @param value Define the value to give to the uniform
  94892. * @return the material itself allowing "fluent" like uniform updates
  94893. */
  94894. setVector4(name: string, value: Vector4): ShaderMaterial;
  94895. /**
  94896. * Set a mat4 in the shader from a Matrix.
  94897. * @param name Define the name of the uniform as defined in the shader
  94898. * @param value Define the value to give to the uniform
  94899. * @return the material itself allowing "fluent" like uniform updates
  94900. */
  94901. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94902. /**
  94903. * Set a float32Array in the shader from a matrix array.
  94904. * @param name Define the name of the uniform as defined in the shader
  94905. * @param value Define the value to give to the uniform
  94906. * @return the material itself allowing "fluent" like uniform updates
  94907. */
  94908. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94909. /**
  94910. * Set a mat3 in the shader from a Float32Array.
  94911. * @param name Define the name of the uniform as defined in the shader
  94912. * @param value Define the value to give to the uniform
  94913. * @return the material itself allowing "fluent" like uniform updates
  94914. */
  94915. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  94916. /**
  94917. * Set a mat2 in the shader from a Float32Array.
  94918. * @param name Define the name of the uniform as defined in the shader
  94919. * @param value Define the value to give to the uniform
  94920. * @return the material itself allowing "fluent" like uniform updates
  94921. */
  94922. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  94923. /**
  94924. * Set a vec2 array in the shader from a number array.
  94925. * @param name Define the name of the uniform as defined in the shader
  94926. * @param value Define the value to give to the uniform
  94927. * @return the material itself allowing "fluent" like uniform updates
  94928. */
  94929. setArray2(name: string, value: number[]): ShaderMaterial;
  94930. /**
  94931. * Set a vec3 array in the shader from a number array.
  94932. * @param name Define the name of the uniform as defined in the shader
  94933. * @param value Define the value to give to the uniform
  94934. * @return the material itself allowing "fluent" like uniform updates
  94935. */
  94936. setArray3(name: string, value: number[]): ShaderMaterial;
  94937. /**
  94938. * Set a vec4 array in the shader from a number array.
  94939. * @param name Define the name of the uniform as defined in the shader
  94940. * @param value Define the value to give to the uniform
  94941. * @return the material itself allowing "fluent" like uniform updates
  94942. */
  94943. setArray4(name: string, value: number[]): ShaderMaterial;
  94944. private _checkCache;
  94945. /**
  94946. * Specifies that the submesh is ready to be used
  94947. * @param mesh defines the mesh to check
  94948. * @param subMesh defines which submesh to check
  94949. * @param useInstances specifies that instances should be used
  94950. * @returns a boolean indicating that the submesh is ready or not
  94951. */
  94952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94953. /**
  94954. * Checks if the material is ready to render the requested mesh
  94955. * @param mesh Define the mesh to render
  94956. * @param useInstances Define whether or not the material is used with instances
  94957. * @returns true if ready, otherwise false
  94958. */
  94959. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94960. /**
  94961. * Binds the world matrix to the material
  94962. * @param world defines the world transformation matrix
  94963. * @param effectOverride - If provided, use this effect instead of internal effect
  94964. */
  94965. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94966. /**
  94967. * Binds the submesh to this material by preparing the effect and shader to draw
  94968. * @param world defines the world transformation matrix
  94969. * @param mesh defines the mesh containing the submesh
  94970. * @param subMesh defines the submesh to bind the material to
  94971. */
  94972. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94973. /**
  94974. * Binds the material to the mesh
  94975. * @param world defines the world transformation matrix
  94976. * @param mesh defines the mesh to bind the material to
  94977. * @param effectOverride - If provided, use this effect instead of internal effect
  94978. */
  94979. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94980. protected _afterBind(mesh?: Mesh): void;
  94981. /**
  94982. * Gets the active textures from the material
  94983. * @returns an array of textures
  94984. */
  94985. getActiveTextures(): BaseTexture[];
  94986. /**
  94987. * Specifies if the material uses a texture
  94988. * @param texture defines the texture to check against the material
  94989. * @returns a boolean specifying if the material uses the texture
  94990. */
  94991. hasTexture(texture: BaseTexture): boolean;
  94992. /**
  94993. * Makes a duplicate of the material, and gives it a new name
  94994. * @param name defines the new name for the duplicated material
  94995. * @returns the cloned material
  94996. */
  94997. clone(name: string): ShaderMaterial;
  94998. /**
  94999. * Disposes the material
  95000. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95001. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95002. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95003. */
  95004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95005. /**
  95006. * Serializes this material in a JSON representation
  95007. * @returns the serialized material object
  95008. */
  95009. serialize(): any;
  95010. /**
  95011. * Creates a shader material from parsed shader material data
  95012. * @param source defines the JSON represnetation of the material
  95013. * @param scene defines the hosting scene
  95014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95015. * @returns a new material
  95016. */
  95017. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95018. /**
  95019. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95020. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95021. * @param url defines the url to load from
  95022. * @param scene defines the hosting scene
  95023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95024. * @returns a promise that will resolve to the new ShaderMaterial
  95025. */
  95026. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95027. /**
  95028. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95029. * @param snippetId defines the snippet to load
  95030. * @param scene defines the hosting scene
  95031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95032. * @returns a promise that will resolve to the new ShaderMaterial
  95033. */
  95034. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95035. }
  95036. }
  95037. declare module BABYLON {
  95038. /** @hidden */
  95039. export var colorPixelShader: {
  95040. name: string;
  95041. shader: string;
  95042. };
  95043. }
  95044. declare module BABYLON {
  95045. /** @hidden */
  95046. export var colorVertexShader: {
  95047. name: string;
  95048. shader: string;
  95049. };
  95050. }
  95051. declare module BABYLON {
  95052. /**
  95053. * Line mesh
  95054. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95055. */
  95056. export class LinesMesh extends Mesh {
  95057. /**
  95058. * If vertex color should be applied to the mesh
  95059. */
  95060. readonly useVertexColor?: boolean | undefined;
  95061. /**
  95062. * If vertex alpha should be applied to the mesh
  95063. */
  95064. readonly useVertexAlpha?: boolean | undefined;
  95065. /**
  95066. * Color of the line (Default: White)
  95067. */
  95068. color: Color3;
  95069. /**
  95070. * Alpha of the line (Default: 1)
  95071. */
  95072. alpha: number;
  95073. /**
  95074. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95075. * This margin is expressed in world space coordinates, so its value may vary.
  95076. * Default value is 0.1
  95077. */
  95078. intersectionThreshold: number;
  95079. private _colorShader;
  95080. private color4;
  95081. /**
  95082. * Creates a new LinesMesh
  95083. * @param name defines the name
  95084. * @param scene defines the hosting scene
  95085. * @param parent defines the parent mesh if any
  95086. * @param source defines the optional source LinesMesh used to clone data from
  95087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95088. * When false, achieved by calling a clone(), also passing False.
  95089. * This will make creation of children, recursive.
  95090. * @param useVertexColor defines if this LinesMesh supports vertex color
  95091. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95092. */
  95093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95094. /**
  95095. * If vertex color should be applied to the mesh
  95096. */
  95097. useVertexColor?: boolean | undefined,
  95098. /**
  95099. * If vertex alpha should be applied to the mesh
  95100. */
  95101. useVertexAlpha?: boolean | undefined);
  95102. private _addClipPlaneDefine;
  95103. private _removeClipPlaneDefine;
  95104. isReady(): boolean;
  95105. /**
  95106. * Returns the string "LineMesh"
  95107. */
  95108. getClassName(): string;
  95109. /**
  95110. * @hidden
  95111. */
  95112. get material(): Material;
  95113. /**
  95114. * @hidden
  95115. */
  95116. set material(value: Material);
  95117. /**
  95118. * @hidden
  95119. */
  95120. get checkCollisions(): boolean;
  95121. /** @hidden */
  95122. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95123. /** @hidden */
  95124. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95125. /**
  95126. * Disposes of the line mesh
  95127. * @param doNotRecurse If children should be disposed
  95128. */
  95129. dispose(doNotRecurse?: boolean): void;
  95130. /**
  95131. * Returns a new LineMesh object cloned from the current one.
  95132. */
  95133. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95134. /**
  95135. * Creates a new InstancedLinesMesh object from the mesh model.
  95136. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95137. * @param name defines the name of the new instance
  95138. * @returns a new InstancedLinesMesh
  95139. */
  95140. createInstance(name: string): InstancedLinesMesh;
  95141. }
  95142. /**
  95143. * Creates an instance based on a source LinesMesh
  95144. */
  95145. export class InstancedLinesMesh extends InstancedMesh {
  95146. /**
  95147. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95148. * This margin is expressed in world space coordinates, so its value may vary.
  95149. * Initilized with the intersectionThreshold value of the source LinesMesh
  95150. */
  95151. intersectionThreshold: number;
  95152. constructor(name: string, source: LinesMesh);
  95153. /**
  95154. * Returns the string "InstancedLinesMesh".
  95155. */
  95156. getClassName(): string;
  95157. }
  95158. }
  95159. declare module BABYLON {
  95160. /** @hidden */
  95161. export var linePixelShader: {
  95162. name: string;
  95163. shader: string;
  95164. };
  95165. }
  95166. declare module BABYLON {
  95167. /** @hidden */
  95168. export var lineVertexShader: {
  95169. name: string;
  95170. shader: string;
  95171. };
  95172. }
  95173. declare module BABYLON {
  95174. interface Scene {
  95175. /** @hidden */
  95176. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95177. }
  95178. interface AbstractMesh {
  95179. /**
  95180. * Gets the edgesRenderer associated with the mesh
  95181. */
  95182. edgesRenderer: Nullable<EdgesRenderer>;
  95183. }
  95184. interface LinesMesh {
  95185. /**
  95186. * Enables the edge rendering mode on the mesh.
  95187. * This mode makes the mesh edges visible
  95188. * @param epsilon defines the maximal distance between two angles to detect a face
  95189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95190. * @returns the currentAbstractMesh
  95191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95192. */
  95193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95194. }
  95195. interface InstancedLinesMesh {
  95196. /**
  95197. * Enables the edge rendering mode on the mesh.
  95198. * This mode makes the mesh edges visible
  95199. * @param epsilon defines the maximal distance between two angles to detect a face
  95200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95201. * @returns the current InstancedLinesMesh
  95202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95203. */
  95204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95205. }
  95206. /**
  95207. * Defines the minimum contract an Edges renderer should follow.
  95208. */
  95209. export interface IEdgesRenderer extends IDisposable {
  95210. /**
  95211. * Gets or sets a boolean indicating if the edgesRenderer is active
  95212. */
  95213. isEnabled: boolean;
  95214. /**
  95215. * Renders the edges of the attached mesh,
  95216. */
  95217. render(): void;
  95218. /**
  95219. * Checks wether or not the edges renderer is ready to render.
  95220. * @return true if ready, otherwise false.
  95221. */
  95222. isReady(): boolean;
  95223. /**
  95224. * List of instances to render in case the source mesh has instances
  95225. */
  95226. customInstances: SmartArray<Matrix>;
  95227. }
  95228. /**
  95229. * Defines the additional options of the edges renderer
  95230. */
  95231. export interface IEdgesRendererOptions {
  95232. /**
  95233. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95234. * If not defined, the default value is true
  95235. */
  95236. useAlternateEdgeFinder?: boolean;
  95237. /**
  95238. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95239. * If not defined, the default value is true.
  95240. * 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)
  95241. * This option is used only if useAlternateEdgeFinder = true
  95242. */
  95243. useFastVertexMerger?: boolean;
  95244. /**
  95245. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95246. * The default value is 1e-6
  95247. * This option is used only if useAlternateEdgeFinder = true
  95248. */
  95249. epsilonVertexMerge?: number;
  95250. /**
  95251. * 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
  95252. * 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.
  95253. * This option is used only if useAlternateEdgeFinder = true
  95254. */
  95255. applyTessellation?: boolean;
  95256. /**
  95257. * 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
  95258. * The default value is 1e-6
  95259. * This option is used only if useAlternateEdgeFinder = true
  95260. */
  95261. epsilonVertexAligned?: number;
  95262. }
  95263. /**
  95264. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95265. */
  95266. export class EdgesRenderer implements IEdgesRenderer {
  95267. /**
  95268. * Define the size of the edges with an orthographic camera
  95269. */
  95270. edgesWidthScalerForOrthographic: number;
  95271. /**
  95272. * Define the size of the edges with a perspective camera
  95273. */
  95274. edgesWidthScalerForPerspective: number;
  95275. protected _source: AbstractMesh;
  95276. protected _linesPositions: number[];
  95277. protected _linesNormals: number[];
  95278. protected _linesIndices: number[];
  95279. protected _epsilon: number;
  95280. protected _indicesCount: number;
  95281. protected _lineShader: ShaderMaterial;
  95282. protected _ib: DataBuffer;
  95283. protected _buffers: {
  95284. [key: string]: Nullable<VertexBuffer>;
  95285. };
  95286. protected _buffersForInstances: {
  95287. [key: string]: Nullable<VertexBuffer>;
  95288. };
  95289. protected _checkVerticesInsteadOfIndices: boolean;
  95290. protected _options: Nullable<IEdgesRendererOptions>;
  95291. private _meshRebuildObserver;
  95292. private _meshDisposeObserver;
  95293. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95294. isEnabled: boolean;
  95295. /**
  95296. * List of instances to render in case the source mesh has instances
  95297. */
  95298. customInstances: SmartArray<Matrix>;
  95299. private static GetShader;
  95300. /**
  95301. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95302. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95303. * @param source Mesh used to create edges
  95304. * @param epsilon sum of angles in adjacency to check for edge
  95305. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95306. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95307. * @param options The options to apply when generating the edges
  95308. */
  95309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95310. protected _prepareRessources(): void;
  95311. /** @hidden */
  95312. _rebuild(): void;
  95313. /**
  95314. * Releases the required resources for the edges renderer
  95315. */
  95316. dispose(): void;
  95317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95319. /**
  95320. * Checks if the pair of p0 and p1 is en edge
  95321. * @param faceIndex
  95322. * @param edge
  95323. * @param faceNormals
  95324. * @param p0
  95325. * @param p1
  95326. * @private
  95327. */
  95328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95329. /**
  95330. * push line into the position, normal and index buffer
  95331. * @protected
  95332. */
  95333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95334. /**
  95335. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95336. */
  95337. private _tessellateTriangle;
  95338. private _generateEdgesLinesAlternate;
  95339. /**
  95340. * Generates lines edges from adjacencjes
  95341. * @private
  95342. */
  95343. _generateEdgesLines(): void;
  95344. /**
  95345. * Checks wether or not the edges renderer is ready to render.
  95346. * @return true if ready, otherwise false.
  95347. */
  95348. isReady(): boolean;
  95349. /**
  95350. * Renders the edges of the attached mesh,
  95351. */
  95352. render(): void;
  95353. }
  95354. /**
  95355. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95356. */
  95357. export class LineEdgesRenderer extends EdgesRenderer {
  95358. /**
  95359. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95360. * @param source LineMesh used to generate edges
  95361. * @param epsilon not important (specified angle for edge detection)
  95362. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95363. */
  95364. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95365. /**
  95366. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95367. */
  95368. _generateEdgesLines(): void;
  95369. }
  95370. }
  95371. declare module BABYLON {
  95372. /**
  95373. * This represents the object necessary to create a rendering group.
  95374. * This is exclusively used and created by the rendering manager.
  95375. * To modify the behavior, you use the available helpers in your scene or meshes.
  95376. * @hidden
  95377. */
  95378. export class RenderingGroup {
  95379. index: number;
  95380. private static _zeroVector;
  95381. private _scene;
  95382. private _opaqueSubMeshes;
  95383. private _transparentSubMeshes;
  95384. private _alphaTestSubMeshes;
  95385. private _depthOnlySubMeshes;
  95386. private _particleSystems;
  95387. private _spriteManagers;
  95388. private _opaqueSortCompareFn;
  95389. private _alphaTestSortCompareFn;
  95390. private _transparentSortCompareFn;
  95391. private _renderOpaque;
  95392. private _renderAlphaTest;
  95393. private _renderTransparent;
  95394. /** @hidden */
  95395. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95396. onBeforeTransparentRendering: () => void;
  95397. /**
  95398. * Set the opaque sort comparison function.
  95399. * If null the sub meshes will be render in the order they were created
  95400. */
  95401. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95402. /**
  95403. * Set the alpha test sort comparison function.
  95404. * If null the sub meshes will be render in the order they were created
  95405. */
  95406. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95407. /**
  95408. * Set the transparent sort comparison function.
  95409. * If null the sub meshes will be render in the order they were created
  95410. */
  95411. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95412. /**
  95413. * Creates a new rendering group.
  95414. * @param index The rendering group index
  95415. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95416. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95417. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95418. */
  95419. 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>);
  95420. /**
  95421. * Render all the sub meshes contained in the group.
  95422. * @param customRenderFunction Used to override the default render behaviour of the group.
  95423. * @returns true if rendered some submeshes.
  95424. */
  95425. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95426. /**
  95427. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95428. * @param subMeshes The submeshes to render
  95429. */
  95430. private renderOpaqueSorted;
  95431. /**
  95432. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95433. * @param subMeshes The submeshes to render
  95434. */
  95435. private renderAlphaTestSorted;
  95436. /**
  95437. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95438. * @param subMeshes The submeshes to render
  95439. */
  95440. private renderTransparentSorted;
  95441. /**
  95442. * Renders the submeshes in a specified order.
  95443. * @param subMeshes The submeshes to sort before render
  95444. * @param sortCompareFn The comparison function use to sort
  95445. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95446. * @param transparent Specifies to activate blending if true
  95447. */
  95448. private static renderSorted;
  95449. /**
  95450. * Renders the submeshes in the order they were dispatched (no sort applied).
  95451. * @param subMeshes The submeshes to render
  95452. */
  95453. private static renderUnsorted;
  95454. /**
  95455. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95456. * are rendered back to front if in the same alpha index.
  95457. *
  95458. * @param a The first submesh
  95459. * @param b The second submesh
  95460. * @returns The result of the comparison
  95461. */
  95462. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95463. /**
  95464. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95465. * are rendered back to front.
  95466. *
  95467. * @param a The first submesh
  95468. * @param b The second submesh
  95469. * @returns The result of the comparison
  95470. */
  95471. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95472. /**
  95473. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95474. * are rendered front to back (prevent overdraw).
  95475. *
  95476. * @param a The first submesh
  95477. * @param b The second submesh
  95478. * @returns The result of the comparison
  95479. */
  95480. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95481. /**
  95482. * Resets the different lists of submeshes to prepare a new frame.
  95483. */
  95484. prepare(): void;
  95485. dispose(): void;
  95486. /**
  95487. * Inserts the submesh in its correct queue depending on its material.
  95488. * @param subMesh The submesh to dispatch
  95489. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95490. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95491. */
  95492. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95493. dispatchSprites(spriteManager: ISpriteManager): void;
  95494. dispatchParticles(particleSystem: IParticleSystem): void;
  95495. private _renderParticles;
  95496. private _renderSprites;
  95497. }
  95498. }
  95499. declare module BABYLON {
  95500. /**
  95501. * Interface describing the different options available in the rendering manager
  95502. * regarding Auto Clear between groups.
  95503. */
  95504. export interface IRenderingManagerAutoClearSetup {
  95505. /**
  95506. * Defines whether or not autoclear is enable.
  95507. */
  95508. autoClear: boolean;
  95509. /**
  95510. * Defines whether or not to autoclear the depth buffer.
  95511. */
  95512. depth: boolean;
  95513. /**
  95514. * Defines whether or not to autoclear the stencil buffer.
  95515. */
  95516. stencil: boolean;
  95517. }
  95518. /**
  95519. * This class is used by the onRenderingGroupObservable
  95520. */
  95521. export class RenderingGroupInfo {
  95522. /**
  95523. * The Scene that being rendered
  95524. */
  95525. scene: Scene;
  95526. /**
  95527. * The camera currently used for the rendering pass
  95528. */
  95529. camera: Nullable<Camera>;
  95530. /**
  95531. * The ID of the renderingGroup being processed
  95532. */
  95533. renderingGroupId: number;
  95534. }
  95535. /**
  95536. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95537. * It is enable to manage the different groups as well as the different necessary sort functions.
  95538. * This should not be used directly aside of the few static configurations
  95539. */
  95540. export class RenderingManager {
  95541. /**
  95542. * The max id used for rendering groups (not included)
  95543. */
  95544. static MAX_RENDERINGGROUPS: number;
  95545. /**
  95546. * The min id used for rendering groups (included)
  95547. */
  95548. static MIN_RENDERINGGROUPS: number;
  95549. /**
  95550. * Used to globally prevent autoclearing scenes.
  95551. */
  95552. static AUTOCLEAR: boolean;
  95553. /**
  95554. * @hidden
  95555. */
  95556. _useSceneAutoClearSetup: boolean;
  95557. private _scene;
  95558. private _renderingGroups;
  95559. private _depthStencilBufferAlreadyCleaned;
  95560. private _autoClearDepthStencil;
  95561. private _customOpaqueSortCompareFn;
  95562. private _customAlphaTestSortCompareFn;
  95563. private _customTransparentSortCompareFn;
  95564. private _renderingGroupInfo;
  95565. /**
  95566. * Instantiates a new rendering group for a particular scene
  95567. * @param scene Defines the scene the groups belongs to
  95568. */
  95569. constructor(scene: Scene);
  95570. private _clearDepthStencilBuffer;
  95571. /**
  95572. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95573. * @hidden
  95574. */
  95575. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95576. /**
  95577. * Resets the different information of the group to prepare a new frame
  95578. * @hidden
  95579. */
  95580. reset(): void;
  95581. /**
  95582. * Dispose and release the group and its associated resources.
  95583. * @hidden
  95584. */
  95585. dispose(): void;
  95586. /**
  95587. * Clear the info related to rendering groups preventing retention points during dispose.
  95588. */
  95589. freeRenderingGroups(): void;
  95590. private _prepareRenderingGroup;
  95591. /**
  95592. * Add a sprite manager to the rendering manager in order to render it this frame.
  95593. * @param spriteManager Define the sprite manager to render
  95594. */
  95595. dispatchSprites(spriteManager: ISpriteManager): void;
  95596. /**
  95597. * Add a particle system to the rendering manager in order to render it this frame.
  95598. * @param particleSystem Define the particle system to render
  95599. */
  95600. dispatchParticles(particleSystem: IParticleSystem): void;
  95601. /**
  95602. * Add a submesh to the manager in order to render it this frame
  95603. * @param subMesh The submesh to dispatch
  95604. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95605. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95606. */
  95607. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95608. /**
  95609. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95610. * This allowed control for front to back rendering or reversly depending of the special needs.
  95611. *
  95612. * @param renderingGroupId The rendering group id corresponding to its index
  95613. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95614. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95615. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95616. */
  95617. 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;
  95618. /**
  95619. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95620. *
  95621. * @param renderingGroupId The rendering group id corresponding to its index
  95622. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95623. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95624. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95625. */
  95626. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95627. /**
  95628. * Gets the current auto clear configuration for one rendering group of the rendering
  95629. * manager.
  95630. * @param index the rendering group index to get the information for
  95631. * @returns The auto clear setup for the requested rendering group
  95632. */
  95633. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95634. }
  95635. }
  95636. declare module BABYLON {
  95637. /**
  95638. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95639. */
  95640. export interface ICustomShaderOptions {
  95641. /**
  95642. * Gets or sets the custom shader name to use
  95643. */
  95644. shaderName: string;
  95645. /**
  95646. * The list of attribute names used in the shader
  95647. */
  95648. attributes?: string[];
  95649. /**
  95650. * The list of unifrom names used in the shader
  95651. */
  95652. uniforms?: string[];
  95653. /**
  95654. * The list of sampler names used in the shader
  95655. */
  95656. samplers?: string[];
  95657. /**
  95658. * The list of defines used in the shader
  95659. */
  95660. defines?: string[];
  95661. }
  95662. /**
  95663. * Interface to implement to create a shadow generator compatible with BJS.
  95664. */
  95665. export interface IShadowGenerator {
  95666. /**
  95667. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95668. * @returns The render target texture if present otherwise, null
  95669. */
  95670. getShadowMap(): Nullable<RenderTargetTexture>;
  95671. /**
  95672. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95673. * @param subMesh The submesh we want to render in the shadow map
  95674. * @param useInstances Defines wether will draw in the map using instances
  95675. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95676. * @returns true if ready otherwise, false
  95677. */
  95678. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95679. /**
  95680. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95681. * @param defines Defines of the material we want to update
  95682. * @param lightIndex Index of the light in the enabled light list of the material
  95683. */
  95684. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95685. /**
  95686. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95687. * defined in the generator but impacting the effect).
  95688. * It implies the unifroms available on the materials are the standard BJS ones.
  95689. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95690. * @param effect The effect we are binfing the information for
  95691. */
  95692. bindShadowLight(lightIndex: string, effect: Effect): void;
  95693. /**
  95694. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95695. * (eq to shadow prjection matrix * light transform matrix)
  95696. * @returns The transform matrix used to create the shadow map
  95697. */
  95698. getTransformMatrix(): Matrix;
  95699. /**
  95700. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95701. * Cube and 2D textures for instance.
  95702. */
  95703. recreateShadowMap(): void;
  95704. /**
  95705. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95706. * @param onCompiled Callback triggered at the and of the effects compilation
  95707. * @param options Sets of optional options forcing the compilation with different modes
  95708. */
  95709. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95710. useInstances: boolean;
  95711. }>): void;
  95712. /**
  95713. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95714. * @param options Sets of optional options forcing the compilation with different modes
  95715. * @returns A promise that resolves when the compilation completes
  95716. */
  95717. forceCompilationAsync(options?: Partial<{
  95718. useInstances: boolean;
  95719. }>): Promise<void>;
  95720. /**
  95721. * Serializes the shadow generator setup to a json object.
  95722. * @returns The serialized JSON object
  95723. */
  95724. serialize(): any;
  95725. /**
  95726. * Disposes the Shadow map and related Textures and effects.
  95727. */
  95728. dispose(): void;
  95729. }
  95730. /**
  95731. * Default implementation IShadowGenerator.
  95732. * This is the main object responsible of generating shadows in the framework.
  95733. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95734. */
  95735. export class ShadowGenerator implements IShadowGenerator {
  95736. /**
  95737. * Name of the shadow generator class
  95738. */
  95739. static CLASSNAME: string;
  95740. /**
  95741. * Shadow generator mode None: no filtering applied.
  95742. */
  95743. static readonly FILTER_NONE: number;
  95744. /**
  95745. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95746. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95747. */
  95748. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95749. /**
  95750. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95751. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95752. */
  95753. static readonly FILTER_POISSONSAMPLING: number;
  95754. /**
  95755. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95756. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95757. */
  95758. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95759. /**
  95760. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95761. * edge artifacts on steep falloff.
  95762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95763. */
  95764. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95765. /**
  95766. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95767. * edge artifacts on steep falloff.
  95768. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95769. */
  95770. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95771. /**
  95772. * Shadow generator mode PCF: Percentage Closer Filtering
  95773. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95774. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95775. */
  95776. static readonly FILTER_PCF: number;
  95777. /**
  95778. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95779. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95780. * Contact Hardening
  95781. */
  95782. static readonly FILTER_PCSS: number;
  95783. /**
  95784. * Reserved for PCF and PCSS
  95785. * Highest Quality.
  95786. *
  95787. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95788. *
  95789. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95790. */
  95791. static readonly QUALITY_HIGH: number;
  95792. /**
  95793. * Reserved for PCF and PCSS
  95794. * Good tradeoff for quality/perf cross devices
  95795. *
  95796. * Execute PCF on a 3*3 kernel.
  95797. *
  95798. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95799. */
  95800. static readonly QUALITY_MEDIUM: number;
  95801. /**
  95802. * Reserved for PCF and PCSS
  95803. * The lowest quality but the fastest.
  95804. *
  95805. * Execute PCF on a 1*1 kernel.
  95806. *
  95807. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95808. */
  95809. static readonly QUALITY_LOW: number;
  95810. /** Gets or sets the custom shader name to use */
  95811. customShaderOptions: ICustomShaderOptions;
  95812. /**
  95813. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95814. */
  95815. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95816. /**
  95817. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95818. */
  95819. onAfterShadowMapRenderObservable: Observable<Effect>;
  95820. /**
  95821. * Observable triggered before a mesh is rendered in the shadow map.
  95822. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95823. */
  95824. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95825. /**
  95826. * Observable triggered after a mesh is rendered in the shadow map.
  95827. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95828. */
  95829. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95830. protected _bias: number;
  95831. /**
  95832. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95833. */
  95834. get bias(): number;
  95835. /**
  95836. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95837. */
  95838. set bias(bias: number);
  95839. protected _normalBias: number;
  95840. /**
  95841. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95842. */
  95843. get normalBias(): number;
  95844. /**
  95845. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95846. */
  95847. set normalBias(normalBias: number);
  95848. protected _blurBoxOffset: number;
  95849. /**
  95850. * Gets the blur box offset: offset applied during the blur pass.
  95851. * Only useful if useKernelBlur = false
  95852. */
  95853. get blurBoxOffset(): number;
  95854. /**
  95855. * Sets the blur box offset: offset applied during the blur pass.
  95856. * Only useful if useKernelBlur = false
  95857. */
  95858. set blurBoxOffset(value: number);
  95859. protected _blurScale: number;
  95860. /**
  95861. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95862. * 2 means half of the size.
  95863. */
  95864. get blurScale(): number;
  95865. /**
  95866. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95867. * 2 means half of the size.
  95868. */
  95869. set blurScale(value: number);
  95870. protected _blurKernel: number;
  95871. /**
  95872. * Gets the blur kernel: kernel size of the blur pass.
  95873. * Only useful if useKernelBlur = true
  95874. */
  95875. get blurKernel(): number;
  95876. /**
  95877. * Sets the blur kernel: kernel size of the blur pass.
  95878. * Only useful if useKernelBlur = true
  95879. */
  95880. set blurKernel(value: number);
  95881. protected _useKernelBlur: boolean;
  95882. /**
  95883. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95884. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95885. */
  95886. get useKernelBlur(): boolean;
  95887. /**
  95888. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95889. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95890. */
  95891. set useKernelBlur(value: boolean);
  95892. protected _depthScale: number;
  95893. /**
  95894. * Gets the depth scale used in ESM mode.
  95895. */
  95896. get depthScale(): number;
  95897. /**
  95898. * Sets the depth scale used in ESM mode.
  95899. * This can override the scale stored on the light.
  95900. */
  95901. set depthScale(value: number);
  95902. protected _validateFilter(filter: number): number;
  95903. protected _filter: number;
  95904. /**
  95905. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95906. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95907. */
  95908. get filter(): number;
  95909. /**
  95910. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95911. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95912. */
  95913. set filter(value: number);
  95914. /**
  95915. * Gets if the current filter is set to Poisson Sampling.
  95916. */
  95917. get usePoissonSampling(): boolean;
  95918. /**
  95919. * Sets the current filter to Poisson Sampling.
  95920. */
  95921. set usePoissonSampling(value: boolean);
  95922. /**
  95923. * Gets if the current filter is set to ESM.
  95924. */
  95925. get useExponentialShadowMap(): boolean;
  95926. /**
  95927. * Sets the current filter is to ESM.
  95928. */
  95929. set useExponentialShadowMap(value: boolean);
  95930. /**
  95931. * Gets if the current filter is set to filtered ESM.
  95932. */
  95933. get useBlurExponentialShadowMap(): boolean;
  95934. /**
  95935. * Gets if the current filter is set to filtered ESM.
  95936. */
  95937. set useBlurExponentialShadowMap(value: boolean);
  95938. /**
  95939. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95940. * exponential to prevent steep falloff artifacts).
  95941. */
  95942. get useCloseExponentialShadowMap(): boolean;
  95943. /**
  95944. * Sets the current filter to "close ESM" (using the inverse of the
  95945. * exponential to prevent steep falloff artifacts).
  95946. */
  95947. set useCloseExponentialShadowMap(value: boolean);
  95948. /**
  95949. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95950. * exponential to prevent steep falloff artifacts).
  95951. */
  95952. get useBlurCloseExponentialShadowMap(): boolean;
  95953. /**
  95954. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95955. * exponential to prevent steep falloff artifacts).
  95956. */
  95957. set useBlurCloseExponentialShadowMap(value: boolean);
  95958. /**
  95959. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95960. */
  95961. get usePercentageCloserFiltering(): boolean;
  95962. /**
  95963. * Sets the current filter to "PCF" (percentage closer filtering).
  95964. */
  95965. set usePercentageCloserFiltering(value: boolean);
  95966. protected _filteringQuality: number;
  95967. /**
  95968. * Gets the PCF or PCSS Quality.
  95969. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95970. */
  95971. get filteringQuality(): number;
  95972. /**
  95973. * Sets the PCF or PCSS Quality.
  95974. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95975. */
  95976. set filteringQuality(filteringQuality: number);
  95977. /**
  95978. * Gets if the current filter is set to "PCSS" (contact hardening).
  95979. */
  95980. get useContactHardeningShadow(): boolean;
  95981. /**
  95982. * Sets the current filter to "PCSS" (contact hardening).
  95983. */
  95984. set useContactHardeningShadow(value: boolean);
  95985. protected _contactHardeningLightSizeUVRatio: number;
  95986. /**
  95987. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95988. * Using a ratio helps keeping shape stability independently of the map size.
  95989. *
  95990. * It does not account for the light projection as it was having too much
  95991. * instability during the light setup or during light position changes.
  95992. *
  95993. * Only valid if useContactHardeningShadow is true.
  95994. */
  95995. get contactHardeningLightSizeUVRatio(): number;
  95996. /**
  95997. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95998. * Using a ratio helps keeping shape stability independently of the map size.
  95999. *
  96000. * It does not account for the light projection as it was having too much
  96001. * instability during the light setup or during light position changes.
  96002. *
  96003. * Only valid if useContactHardeningShadow is true.
  96004. */
  96005. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96006. protected _darkness: number;
  96007. /** Gets or sets the actual darkness of a shadow */
  96008. get darkness(): number;
  96009. set darkness(value: number);
  96010. /**
  96011. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96012. * 0 means strongest and 1 would means no shadow.
  96013. * @returns the darkness.
  96014. */
  96015. getDarkness(): number;
  96016. /**
  96017. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96018. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96019. * @returns the shadow generator allowing fluent coding.
  96020. */
  96021. setDarkness(darkness: number): ShadowGenerator;
  96022. protected _transparencyShadow: boolean;
  96023. /** Gets or sets the ability to have transparent shadow */
  96024. get transparencyShadow(): boolean;
  96025. set transparencyShadow(value: boolean);
  96026. /**
  96027. * Sets the ability to have transparent shadow (boolean).
  96028. * @param transparent True if transparent else False
  96029. * @returns the shadow generator allowing fluent coding
  96030. */
  96031. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96032. /**
  96033. * Enables or disables shadows with varying strength based on the transparency
  96034. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96035. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96036. * mesh.visibility * alphaTexture.a
  96037. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96038. */
  96039. enableSoftTransparentShadow: boolean;
  96040. protected _shadowMap: Nullable<RenderTargetTexture>;
  96041. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96042. /**
  96043. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96044. * @returns The render target texture if present otherwise, null
  96045. */
  96046. getShadowMap(): Nullable<RenderTargetTexture>;
  96047. /**
  96048. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96049. * @returns The render target texture if the shadow map is present otherwise, null
  96050. */
  96051. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96052. /**
  96053. * Gets the class name of that object
  96054. * @returns "ShadowGenerator"
  96055. */
  96056. getClassName(): string;
  96057. /**
  96058. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96059. * @param mesh Mesh to add
  96060. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96061. * @returns the Shadow Generator itself
  96062. */
  96063. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96064. /**
  96065. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96066. * @param mesh Mesh to remove
  96067. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96068. * @returns the Shadow Generator itself
  96069. */
  96070. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96071. /**
  96072. * Controls the extent to which the shadows fade out at the edge of the frustum
  96073. */
  96074. frustumEdgeFalloff: number;
  96075. protected _light: IShadowLight;
  96076. /**
  96077. * Returns the associated light object.
  96078. * @returns the light generating the shadow
  96079. */
  96080. getLight(): IShadowLight;
  96081. /**
  96082. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96083. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96084. * It might on the other hand introduce peter panning.
  96085. */
  96086. forceBackFacesOnly: boolean;
  96087. protected _scene: Scene;
  96088. protected _lightDirection: Vector3;
  96089. protected _effect: Effect;
  96090. protected _viewMatrix: Matrix;
  96091. protected _projectionMatrix: Matrix;
  96092. protected _transformMatrix: Matrix;
  96093. protected _cachedPosition: Vector3;
  96094. protected _cachedDirection: Vector3;
  96095. protected _cachedDefines: string;
  96096. protected _currentRenderID: number;
  96097. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96098. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96099. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96100. protected _blurPostProcesses: PostProcess[];
  96101. protected _mapSize: number;
  96102. protected _currentFaceIndex: number;
  96103. protected _currentFaceIndexCache: number;
  96104. protected _textureType: number;
  96105. protected _defaultTextureMatrix: Matrix;
  96106. protected _storedUniqueId: Nullable<number>;
  96107. /** @hidden */
  96108. static _SceneComponentInitialization: (scene: Scene) => void;
  96109. /**
  96110. * Creates a ShadowGenerator object.
  96111. * A ShadowGenerator is the required tool to use the shadows.
  96112. * Each light casting shadows needs to use its own ShadowGenerator.
  96113. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96114. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96115. * @param light The light object generating the shadows.
  96116. * @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.
  96117. */
  96118. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96119. protected _initializeGenerator(): void;
  96120. protected _createTargetRenderTexture(): void;
  96121. protected _initializeShadowMap(): void;
  96122. protected _initializeBlurRTTAndPostProcesses(): void;
  96123. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96124. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96125. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96126. protected _applyFilterValues(): void;
  96127. /**
  96128. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96129. * @param onCompiled Callback triggered at the and of the effects compilation
  96130. * @param options Sets of optional options forcing the compilation with different modes
  96131. */
  96132. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96133. useInstances: boolean;
  96134. }>): void;
  96135. /**
  96136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96137. * @param options Sets of optional options forcing the compilation with different modes
  96138. * @returns A promise that resolves when the compilation completes
  96139. */
  96140. forceCompilationAsync(options?: Partial<{
  96141. useInstances: boolean;
  96142. }>): Promise<void>;
  96143. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96144. private _prepareShadowDefines;
  96145. /**
  96146. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96147. * @param subMesh The submesh we want to render in the shadow map
  96148. * @param useInstances Defines wether will draw in the map using instances
  96149. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96150. * @returns true if ready otherwise, false
  96151. */
  96152. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96153. /**
  96154. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96155. * @param defines Defines of the material we want to update
  96156. * @param lightIndex Index of the light in the enabled light list of the material
  96157. */
  96158. prepareDefines(defines: any, lightIndex: number): void;
  96159. /**
  96160. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96161. * defined in the generator but impacting the effect).
  96162. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96163. * @param effect The effect we are binfing the information for
  96164. */
  96165. bindShadowLight(lightIndex: string, effect: Effect): void;
  96166. /**
  96167. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96168. * (eq to shadow prjection matrix * light transform matrix)
  96169. * @returns The transform matrix used to create the shadow map
  96170. */
  96171. getTransformMatrix(): Matrix;
  96172. /**
  96173. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96174. * Cube and 2D textures for instance.
  96175. */
  96176. recreateShadowMap(): void;
  96177. protected _disposeBlurPostProcesses(): void;
  96178. protected _disposeRTTandPostProcesses(): void;
  96179. /**
  96180. * Disposes the ShadowGenerator.
  96181. * Returns nothing.
  96182. */
  96183. dispose(): void;
  96184. /**
  96185. * Serializes the shadow generator setup to a json object.
  96186. * @returns The serialized JSON object
  96187. */
  96188. serialize(): any;
  96189. /**
  96190. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96191. * @param parsedShadowGenerator The JSON object to parse
  96192. * @param scene The scene to create the shadow map for
  96193. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96194. * @returns The parsed shadow generator
  96195. */
  96196. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96197. }
  96198. }
  96199. declare module BABYLON {
  96200. /**
  96201. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96202. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96203. * 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.
  96204. */
  96205. export abstract class Light extends Node {
  96206. /**
  96207. * Falloff Default: light is falling off following the material specification:
  96208. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96209. */
  96210. static readonly FALLOFF_DEFAULT: number;
  96211. /**
  96212. * Falloff Physical: light is falling off following the inverse squared distance law.
  96213. */
  96214. static readonly FALLOFF_PHYSICAL: number;
  96215. /**
  96216. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96217. * to enhance interoperability with other engines.
  96218. */
  96219. static readonly FALLOFF_GLTF: number;
  96220. /**
  96221. * Falloff Standard: light is falling off like in the standard material
  96222. * to enhance interoperability with other materials.
  96223. */
  96224. static readonly FALLOFF_STANDARD: number;
  96225. /**
  96226. * If every light affecting the material is in this lightmapMode,
  96227. * material.lightmapTexture adds or multiplies
  96228. * (depends on material.useLightmapAsShadowmap)
  96229. * after every other light calculations.
  96230. */
  96231. static readonly LIGHTMAP_DEFAULT: number;
  96232. /**
  96233. * material.lightmapTexture as only diffuse lighting from this light
  96234. * adds only specular lighting from this light
  96235. * adds dynamic shadows
  96236. */
  96237. static readonly LIGHTMAP_SPECULAR: number;
  96238. /**
  96239. * material.lightmapTexture as only lighting
  96240. * no light calculation from this light
  96241. * only adds dynamic shadows from this light
  96242. */
  96243. static readonly LIGHTMAP_SHADOWSONLY: number;
  96244. /**
  96245. * Each light type uses the default quantity according to its type:
  96246. * point/spot lights use luminous intensity
  96247. * directional lights use illuminance
  96248. */
  96249. static readonly INTENSITYMODE_AUTOMATIC: number;
  96250. /**
  96251. * lumen (lm)
  96252. */
  96253. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96254. /**
  96255. * candela (lm/sr)
  96256. */
  96257. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96258. /**
  96259. * lux (lm/m^2)
  96260. */
  96261. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96262. /**
  96263. * nit (cd/m^2)
  96264. */
  96265. static readonly INTENSITYMODE_LUMINANCE: number;
  96266. /**
  96267. * Light type const id of the point light.
  96268. */
  96269. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96270. /**
  96271. * Light type const id of the directional light.
  96272. */
  96273. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96274. /**
  96275. * Light type const id of the spot light.
  96276. */
  96277. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96278. /**
  96279. * Light type const id of the hemispheric light.
  96280. */
  96281. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96282. /**
  96283. * Diffuse gives the basic color to an object.
  96284. */
  96285. diffuse: Color3;
  96286. /**
  96287. * Specular produces a highlight color on an object.
  96288. * Note: This is note affecting PBR materials.
  96289. */
  96290. specular: Color3;
  96291. /**
  96292. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96293. * falling off base on range or angle.
  96294. * This can be set to any values in Light.FALLOFF_x.
  96295. *
  96296. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96297. * other types of materials.
  96298. */
  96299. falloffType: number;
  96300. /**
  96301. * Strength of the light.
  96302. * Note: By default it is define in the framework own unit.
  96303. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96304. */
  96305. intensity: number;
  96306. private _range;
  96307. protected _inverseSquaredRange: number;
  96308. /**
  96309. * Defines how far from the source the light is impacting in scene units.
  96310. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96311. */
  96312. get range(): number;
  96313. /**
  96314. * Defines how far from the source the light is impacting in scene units.
  96315. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96316. */
  96317. set range(value: number);
  96318. /**
  96319. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96320. * of light.
  96321. */
  96322. private _photometricScale;
  96323. private _intensityMode;
  96324. /**
  96325. * Gets the photometric scale used to interpret the intensity.
  96326. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96327. */
  96328. get intensityMode(): number;
  96329. /**
  96330. * Sets the photometric scale used to interpret the intensity.
  96331. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96332. */
  96333. set intensityMode(value: number);
  96334. private _radius;
  96335. /**
  96336. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96337. */
  96338. get radius(): number;
  96339. /**
  96340. * sets the light radius used by PBR Materials to simulate soft area lights.
  96341. */
  96342. set radius(value: number);
  96343. private _renderPriority;
  96344. /**
  96345. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96346. * exceeding the number allowed of the materials.
  96347. */
  96348. renderPriority: number;
  96349. private _shadowEnabled;
  96350. /**
  96351. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96352. * the current shadow generator.
  96353. */
  96354. get shadowEnabled(): boolean;
  96355. /**
  96356. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96357. * the current shadow generator.
  96358. */
  96359. set shadowEnabled(value: boolean);
  96360. private _includedOnlyMeshes;
  96361. /**
  96362. * Gets the only meshes impacted by this light.
  96363. */
  96364. get includedOnlyMeshes(): AbstractMesh[];
  96365. /**
  96366. * Sets the only meshes impacted by this light.
  96367. */
  96368. set includedOnlyMeshes(value: AbstractMesh[]);
  96369. private _excludedMeshes;
  96370. /**
  96371. * Gets the meshes not impacted by this light.
  96372. */
  96373. get excludedMeshes(): AbstractMesh[];
  96374. /**
  96375. * Sets the meshes not impacted by this light.
  96376. */
  96377. set excludedMeshes(value: AbstractMesh[]);
  96378. private _excludeWithLayerMask;
  96379. /**
  96380. * Gets the layer id use to find what meshes are not impacted by the light.
  96381. * Inactive if 0
  96382. */
  96383. get excludeWithLayerMask(): number;
  96384. /**
  96385. * Sets the layer id use to find what meshes are not impacted by the light.
  96386. * Inactive if 0
  96387. */
  96388. set excludeWithLayerMask(value: number);
  96389. private _includeOnlyWithLayerMask;
  96390. /**
  96391. * Gets the layer id use to find what meshes are impacted by the light.
  96392. * Inactive if 0
  96393. */
  96394. get includeOnlyWithLayerMask(): number;
  96395. /**
  96396. * Sets the layer id use to find what meshes are impacted by the light.
  96397. * Inactive if 0
  96398. */
  96399. set includeOnlyWithLayerMask(value: number);
  96400. private _lightmapMode;
  96401. /**
  96402. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96403. */
  96404. get lightmapMode(): number;
  96405. /**
  96406. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96407. */
  96408. set lightmapMode(value: number);
  96409. /**
  96410. * Shadow generator associted to the light.
  96411. * @hidden Internal use only.
  96412. */
  96413. _shadowGenerator: Nullable<IShadowGenerator>;
  96414. /**
  96415. * @hidden Internal use only.
  96416. */
  96417. _excludedMeshesIds: string[];
  96418. /**
  96419. * @hidden Internal use only.
  96420. */
  96421. _includedOnlyMeshesIds: string[];
  96422. /**
  96423. * The current light unifom buffer.
  96424. * @hidden Internal use only.
  96425. */
  96426. _uniformBuffer: UniformBuffer;
  96427. /** @hidden */
  96428. _renderId: number;
  96429. /**
  96430. * Creates a Light object in the scene.
  96431. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96432. * @param name The firendly name of the light
  96433. * @param scene The scene the light belongs too
  96434. */
  96435. constructor(name: string, scene: Scene);
  96436. protected abstract _buildUniformLayout(): void;
  96437. /**
  96438. * Sets the passed Effect "effect" with the Light information.
  96439. * @param effect The effect to update
  96440. * @param lightIndex The index of the light in the effect to update
  96441. * @returns The light
  96442. */
  96443. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96444. /**
  96445. * Sets the passed Effect "effect" with the Light textures.
  96446. * @param effect The effect to update
  96447. * @param lightIndex The index of the light in the effect to update
  96448. * @returns The light
  96449. */
  96450. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96451. /**
  96452. * Binds the lights information from the scene to the effect for the given mesh.
  96453. * @param lightIndex Light index
  96454. * @param scene The scene where the light belongs to
  96455. * @param effect The effect we are binding the data to
  96456. * @param useSpecular Defines if specular is supported
  96457. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96458. */
  96459. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96460. /**
  96461. * Sets the passed Effect "effect" with the Light information.
  96462. * @param effect The effect to update
  96463. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96464. * @returns The light
  96465. */
  96466. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96467. /**
  96468. * Returns the string "Light".
  96469. * @returns the class name
  96470. */
  96471. getClassName(): string;
  96472. /** @hidden */
  96473. readonly _isLight: boolean;
  96474. /**
  96475. * Converts the light information to a readable string for debug purpose.
  96476. * @param fullDetails Supports for multiple levels of logging within scene loading
  96477. * @returns the human readable light info
  96478. */
  96479. toString(fullDetails?: boolean): string;
  96480. /** @hidden */
  96481. protected _syncParentEnabledState(): void;
  96482. /**
  96483. * Set the enabled state of this node.
  96484. * @param value - the new enabled state
  96485. */
  96486. setEnabled(value: boolean): void;
  96487. /**
  96488. * Returns the Light associated shadow generator if any.
  96489. * @return the associated shadow generator.
  96490. */
  96491. getShadowGenerator(): Nullable<IShadowGenerator>;
  96492. /**
  96493. * Returns a Vector3, the absolute light position in the World.
  96494. * @returns the world space position of the light
  96495. */
  96496. getAbsolutePosition(): Vector3;
  96497. /**
  96498. * Specifies if the light will affect the passed mesh.
  96499. * @param mesh The mesh to test against the light
  96500. * @return true the mesh is affected otherwise, false.
  96501. */
  96502. canAffectMesh(mesh: AbstractMesh): boolean;
  96503. /**
  96504. * Sort function to order lights for rendering.
  96505. * @param a First Light object to compare to second.
  96506. * @param b Second Light object to compare first.
  96507. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96508. */
  96509. static CompareLightsPriority(a: Light, b: Light): number;
  96510. /**
  96511. * Releases resources associated with this node.
  96512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96514. */
  96515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96516. /**
  96517. * Returns the light type ID (integer).
  96518. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96519. */
  96520. getTypeID(): number;
  96521. /**
  96522. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96523. * @returns the scaled intensity in intensity mode unit
  96524. */
  96525. getScaledIntensity(): number;
  96526. /**
  96527. * Returns a new Light object, named "name", from the current one.
  96528. * @param name The name of the cloned light
  96529. * @param newParent The parent of this light, if it has one
  96530. * @returns the new created light
  96531. */
  96532. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96533. /**
  96534. * Serializes the current light into a Serialization object.
  96535. * @returns the serialized object.
  96536. */
  96537. serialize(): any;
  96538. /**
  96539. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96540. * This new light is named "name" and added to the passed scene.
  96541. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96542. * @param name The friendly name of the light
  96543. * @param scene The scene the new light will belong to
  96544. * @returns the constructor function
  96545. */
  96546. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96547. /**
  96548. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96549. * @param parsedLight The JSON representation of the light
  96550. * @param scene The scene to create the parsed light in
  96551. * @returns the created light after parsing
  96552. */
  96553. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96554. private _hookArrayForExcluded;
  96555. private _hookArrayForIncludedOnly;
  96556. private _resyncMeshes;
  96557. /**
  96558. * Forces the meshes to update their light related information in their rendering used effects
  96559. * @hidden Internal Use Only
  96560. */
  96561. _markMeshesAsLightDirty(): void;
  96562. /**
  96563. * Recomputes the cached photometric scale if needed.
  96564. */
  96565. private _computePhotometricScale;
  96566. /**
  96567. * Returns the Photometric Scale according to the light type and intensity mode.
  96568. */
  96569. private _getPhotometricScale;
  96570. /**
  96571. * Reorder the light in the scene according to their defined priority.
  96572. * @hidden Internal Use Only
  96573. */
  96574. _reorderLightsInScene(): void;
  96575. /**
  96576. * Prepares the list of defines specific to the light type.
  96577. * @param defines the list of defines
  96578. * @param lightIndex defines the index of the light for the effect
  96579. */
  96580. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96581. }
  96582. }
  96583. declare module BABYLON {
  96584. /**
  96585. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96586. * This is the base of the follow, arc rotate cameras and Free camera
  96587. * @see https://doc.babylonjs.com/features/cameras
  96588. */
  96589. export class TargetCamera extends Camera {
  96590. private static _RigCamTransformMatrix;
  96591. private static _TargetTransformMatrix;
  96592. private static _TargetFocalPoint;
  96593. private _tmpUpVector;
  96594. private _tmpTargetVector;
  96595. /**
  96596. * Define the current direction the camera is moving to
  96597. */
  96598. cameraDirection: Vector3;
  96599. /**
  96600. * Define the current rotation the camera is rotating to
  96601. */
  96602. cameraRotation: Vector2;
  96603. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96604. ignoreParentScaling: boolean;
  96605. /**
  96606. * When set, the up vector of the camera will be updated by the rotation of the camera
  96607. */
  96608. updateUpVectorFromRotation: boolean;
  96609. private _tmpQuaternion;
  96610. /**
  96611. * Define the current rotation of the camera
  96612. */
  96613. rotation: Vector3;
  96614. /**
  96615. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96616. */
  96617. rotationQuaternion: Quaternion;
  96618. /**
  96619. * Define the current speed of the camera
  96620. */
  96621. speed: number;
  96622. /**
  96623. * Add constraint to the camera to prevent it to move freely in all directions and
  96624. * around all axis.
  96625. */
  96626. noRotationConstraint: boolean;
  96627. /**
  96628. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96629. * panning
  96630. */
  96631. invertRotation: boolean;
  96632. /**
  96633. * Speed multiplier for inverse camera panning
  96634. */
  96635. inverseRotationSpeed: number;
  96636. /**
  96637. * Define the current target of the camera as an object or a position.
  96638. */
  96639. lockedTarget: any;
  96640. /** @hidden */
  96641. _currentTarget: Vector3;
  96642. /** @hidden */
  96643. _initialFocalDistance: number;
  96644. /** @hidden */
  96645. _viewMatrix: Matrix;
  96646. /** @hidden */
  96647. _camMatrix: Matrix;
  96648. /** @hidden */
  96649. _cameraTransformMatrix: Matrix;
  96650. /** @hidden */
  96651. _cameraRotationMatrix: Matrix;
  96652. /** @hidden */
  96653. _referencePoint: Vector3;
  96654. /** @hidden */
  96655. _transformedReferencePoint: Vector3;
  96656. /** @hidden */
  96657. _reset: () => void;
  96658. private _defaultUp;
  96659. /**
  96660. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96661. * This is the base of the follow, arc rotate cameras and Free camera
  96662. * @see https://doc.babylonjs.com/features/cameras
  96663. * @param name Defines the name of the camera in the scene
  96664. * @param position Defines the start position of the camera in the scene
  96665. * @param scene Defines the scene the camera belongs to
  96666. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96667. */
  96668. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96669. /**
  96670. * Gets the position in front of the camera at a given distance.
  96671. * @param distance The distance from the camera we want the position to be
  96672. * @returns the position
  96673. */
  96674. getFrontPosition(distance: number): Vector3;
  96675. /** @hidden */
  96676. _getLockedTargetPosition(): Nullable<Vector3>;
  96677. private _storedPosition;
  96678. private _storedRotation;
  96679. private _storedRotationQuaternion;
  96680. /**
  96681. * Store current camera state of the camera (fov, position, rotation, etc..)
  96682. * @returns the camera
  96683. */
  96684. storeState(): Camera;
  96685. /**
  96686. * Restored camera state. You must call storeState() first
  96687. * @returns whether it was successful or not
  96688. * @hidden
  96689. */
  96690. _restoreStateValues(): boolean;
  96691. /** @hidden */
  96692. _initCache(): void;
  96693. /** @hidden */
  96694. _updateCache(ignoreParentClass?: boolean): void;
  96695. /** @hidden */
  96696. _isSynchronizedViewMatrix(): boolean;
  96697. /** @hidden */
  96698. _computeLocalCameraSpeed(): number;
  96699. /**
  96700. * Defines the target the camera should look at.
  96701. * @param target Defines the new target as a Vector or a mesh
  96702. */
  96703. setTarget(target: Vector3): void;
  96704. /**
  96705. * Return the current target position of the camera. This value is expressed in local space.
  96706. * @returns the target position
  96707. */
  96708. getTarget(): Vector3;
  96709. /** @hidden */
  96710. _decideIfNeedsToMove(): boolean;
  96711. /** @hidden */
  96712. _updatePosition(): void;
  96713. /** @hidden */
  96714. _checkInputs(): void;
  96715. protected _updateCameraRotationMatrix(): void;
  96716. /**
  96717. * 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)
  96718. * @returns the current camera
  96719. */
  96720. private _rotateUpVectorWithCameraRotationMatrix;
  96721. private _cachedRotationZ;
  96722. private _cachedQuaternionRotationZ;
  96723. /** @hidden */
  96724. _getViewMatrix(): Matrix;
  96725. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96726. /**
  96727. * @hidden
  96728. */
  96729. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96730. /**
  96731. * @hidden
  96732. */
  96733. _updateRigCameras(): void;
  96734. private _getRigCamPositionAndTarget;
  96735. /**
  96736. * Gets the current object class name.
  96737. * @return the class name
  96738. */
  96739. getClassName(): string;
  96740. }
  96741. }
  96742. declare module BABYLON {
  96743. /**
  96744. * Gather the list of keyboard event types as constants.
  96745. */
  96746. export class KeyboardEventTypes {
  96747. /**
  96748. * The keydown event is fired when a key becomes active (pressed).
  96749. */
  96750. static readonly KEYDOWN: number;
  96751. /**
  96752. * The keyup event is fired when a key has been released.
  96753. */
  96754. static readonly KEYUP: number;
  96755. }
  96756. /**
  96757. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96758. */
  96759. export class KeyboardInfo {
  96760. /**
  96761. * Defines the type of event (KeyboardEventTypes)
  96762. */
  96763. type: number;
  96764. /**
  96765. * Defines the related dom event
  96766. */
  96767. event: KeyboardEvent;
  96768. /**
  96769. * Instantiates a new keyboard info.
  96770. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96771. * @param type Defines the type of event (KeyboardEventTypes)
  96772. * @param event Defines the related dom event
  96773. */
  96774. constructor(
  96775. /**
  96776. * Defines the type of event (KeyboardEventTypes)
  96777. */
  96778. type: number,
  96779. /**
  96780. * Defines the related dom event
  96781. */
  96782. event: KeyboardEvent);
  96783. }
  96784. /**
  96785. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96786. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96787. */
  96788. export class KeyboardInfoPre extends KeyboardInfo {
  96789. /**
  96790. * Defines the type of event (KeyboardEventTypes)
  96791. */
  96792. type: number;
  96793. /**
  96794. * Defines the related dom event
  96795. */
  96796. event: KeyboardEvent;
  96797. /**
  96798. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96799. */
  96800. skipOnPointerObservable: boolean;
  96801. /**
  96802. * Instantiates a new keyboard pre info.
  96803. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96804. * @param type Defines the type of event (KeyboardEventTypes)
  96805. * @param event Defines the related dom event
  96806. */
  96807. constructor(
  96808. /**
  96809. * Defines the type of event (KeyboardEventTypes)
  96810. */
  96811. type: number,
  96812. /**
  96813. * Defines the related dom event
  96814. */
  96815. event: KeyboardEvent);
  96816. }
  96817. }
  96818. declare module BABYLON {
  96819. /**
  96820. * Manage the keyboard inputs to control the movement of a free camera.
  96821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96822. */
  96823. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96824. /**
  96825. * Defines the camera the input is attached to.
  96826. */
  96827. camera: FreeCamera;
  96828. /**
  96829. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96830. */
  96831. keysUp: number[];
  96832. /**
  96833. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96834. */
  96835. keysUpward: number[];
  96836. /**
  96837. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96838. */
  96839. keysDown: number[];
  96840. /**
  96841. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96842. */
  96843. keysDownward: number[];
  96844. /**
  96845. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96846. */
  96847. keysLeft: number[];
  96848. /**
  96849. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96850. */
  96851. keysRight: number[];
  96852. private _keys;
  96853. private _onCanvasBlurObserver;
  96854. private _onKeyboardObserver;
  96855. private _engine;
  96856. private _scene;
  96857. /**
  96858. * Attach the input controls to a specific dom element to get the input from.
  96859. * @param element Defines the element the controls should be listened from
  96860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96861. */
  96862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96863. /**
  96864. * Detach the current controls from the specified dom element.
  96865. * @param element Defines the element to stop listening the inputs from
  96866. */
  96867. detachControl(element: Nullable<HTMLElement>): void;
  96868. /**
  96869. * Update the current camera state depending on the inputs that have been used this frame.
  96870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96871. */
  96872. checkInputs(): void;
  96873. /**
  96874. * Gets the class name of the current intput.
  96875. * @returns the class name
  96876. */
  96877. getClassName(): string;
  96878. /** @hidden */
  96879. _onLostFocus(): void;
  96880. /**
  96881. * Get the friendly name associated with the input class.
  96882. * @returns the input friendly name
  96883. */
  96884. getSimpleName(): string;
  96885. }
  96886. }
  96887. declare module BABYLON {
  96888. /**
  96889. * Gather the list of pointer event types as constants.
  96890. */
  96891. export class PointerEventTypes {
  96892. /**
  96893. * 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.
  96894. */
  96895. static readonly POINTERDOWN: number;
  96896. /**
  96897. * The pointerup event is fired when a pointer is no longer active.
  96898. */
  96899. static readonly POINTERUP: number;
  96900. /**
  96901. * The pointermove event is fired when a pointer changes coordinates.
  96902. */
  96903. static readonly POINTERMOVE: number;
  96904. /**
  96905. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96906. */
  96907. static readonly POINTERWHEEL: number;
  96908. /**
  96909. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96910. */
  96911. static readonly POINTERPICK: number;
  96912. /**
  96913. * The pointertap event is fired when a the object has been touched and released without drag.
  96914. */
  96915. static readonly POINTERTAP: number;
  96916. /**
  96917. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96918. */
  96919. static readonly POINTERDOUBLETAP: number;
  96920. }
  96921. /**
  96922. * Base class of pointer info types.
  96923. */
  96924. export class PointerInfoBase {
  96925. /**
  96926. * Defines the type of event (PointerEventTypes)
  96927. */
  96928. type: number;
  96929. /**
  96930. * Defines the related dom event
  96931. */
  96932. event: PointerEvent | MouseWheelEvent;
  96933. /**
  96934. * Instantiates the base class of pointers info.
  96935. * @param type Defines the type of event (PointerEventTypes)
  96936. * @param event Defines the related dom event
  96937. */
  96938. constructor(
  96939. /**
  96940. * Defines the type of event (PointerEventTypes)
  96941. */
  96942. type: number,
  96943. /**
  96944. * Defines the related dom event
  96945. */
  96946. event: PointerEvent | MouseWheelEvent);
  96947. }
  96948. /**
  96949. * This class is used to store pointer related info for the onPrePointerObservable event.
  96950. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96951. */
  96952. export class PointerInfoPre extends PointerInfoBase {
  96953. /**
  96954. * Ray from a pointer if availible (eg. 6dof controller)
  96955. */
  96956. ray: Nullable<Ray>;
  96957. /**
  96958. * Defines the local position of the pointer on the canvas.
  96959. */
  96960. localPosition: Vector2;
  96961. /**
  96962. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96963. */
  96964. skipOnPointerObservable: boolean;
  96965. /**
  96966. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96967. * @param type Defines the type of event (PointerEventTypes)
  96968. * @param event Defines the related dom event
  96969. * @param localX Defines the local x coordinates of the pointer when the event occured
  96970. * @param localY Defines the local y coordinates of the pointer when the event occured
  96971. */
  96972. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96973. }
  96974. /**
  96975. * This type contains all the data related to a pointer event in Babylon.js.
  96976. * 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.
  96977. */
  96978. export class PointerInfo extends PointerInfoBase {
  96979. /**
  96980. * Defines the picking info associated to the info (if any)\
  96981. */
  96982. pickInfo: Nullable<PickingInfo>;
  96983. /**
  96984. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96985. * @param type Defines the type of event (PointerEventTypes)
  96986. * @param event Defines the related dom event
  96987. * @param pickInfo Defines the picking info associated to the info (if any)\
  96988. */
  96989. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96990. /**
  96991. * Defines the picking info associated to the info (if any)\
  96992. */
  96993. pickInfo: Nullable<PickingInfo>);
  96994. }
  96995. /**
  96996. * Data relating to a touch event on the screen.
  96997. */
  96998. export interface PointerTouch {
  96999. /**
  97000. * X coordinate of touch.
  97001. */
  97002. x: number;
  97003. /**
  97004. * Y coordinate of touch.
  97005. */
  97006. y: number;
  97007. /**
  97008. * Id of touch. Unique for each finger.
  97009. */
  97010. pointerId: number;
  97011. /**
  97012. * Event type passed from DOM.
  97013. */
  97014. type: any;
  97015. }
  97016. }
  97017. declare module BABYLON {
  97018. /**
  97019. * Manage the mouse inputs to control the movement of a free camera.
  97020. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97021. */
  97022. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97023. /**
  97024. * Define if touch is enabled in the mouse input
  97025. */
  97026. touchEnabled: boolean;
  97027. /**
  97028. * Defines the camera the input is attached to.
  97029. */
  97030. camera: FreeCamera;
  97031. /**
  97032. * Defines the buttons associated with the input to handle camera move.
  97033. */
  97034. buttons: number[];
  97035. /**
  97036. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97037. */
  97038. angularSensibility: number;
  97039. private _pointerInput;
  97040. private _onMouseMove;
  97041. private _observer;
  97042. private previousPosition;
  97043. /**
  97044. * Observable for when a pointer move event occurs containing the move offset
  97045. */
  97046. onPointerMovedObservable: Observable<{
  97047. offsetX: number;
  97048. offsetY: number;
  97049. }>;
  97050. /**
  97051. * @hidden
  97052. * If the camera should be rotated automatically based on pointer movement
  97053. */
  97054. _allowCameraRotation: boolean;
  97055. /**
  97056. * Manage the mouse inputs to control the movement of a free camera.
  97057. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97058. * @param touchEnabled Defines if touch is enabled or not
  97059. */
  97060. constructor(
  97061. /**
  97062. * Define if touch is enabled in the mouse input
  97063. */
  97064. touchEnabled?: boolean);
  97065. /**
  97066. * Attach the input controls to a specific dom element to get the input from.
  97067. * @param element Defines the element the controls should be listened from
  97068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97069. */
  97070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97071. /**
  97072. * Called on JS contextmenu event.
  97073. * Override this method to provide functionality.
  97074. */
  97075. protected onContextMenu(evt: PointerEvent): void;
  97076. /**
  97077. * Detach the current controls from the specified dom element.
  97078. * @param element Defines the element to stop listening the inputs from
  97079. */
  97080. detachControl(element: Nullable<HTMLElement>): void;
  97081. /**
  97082. * Gets the class name of the current intput.
  97083. * @returns the class name
  97084. */
  97085. getClassName(): string;
  97086. /**
  97087. * Get the friendly name associated with the input class.
  97088. * @returns the input friendly name
  97089. */
  97090. getSimpleName(): string;
  97091. }
  97092. }
  97093. declare module BABYLON {
  97094. /**
  97095. * Manage the touch inputs to control the movement of a free camera.
  97096. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97097. */
  97098. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97099. /**
  97100. * Defines the camera the input is attached to.
  97101. */
  97102. camera: FreeCamera;
  97103. /**
  97104. * Defines the touch sensibility for rotation.
  97105. * The higher the faster.
  97106. */
  97107. touchAngularSensibility: number;
  97108. /**
  97109. * Defines the touch sensibility for move.
  97110. * The higher the faster.
  97111. */
  97112. touchMoveSensibility: number;
  97113. private _offsetX;
  97114. private _offsetY;
  97115. private _pointerPressed;
  97116. private _pointerInput;
  97117. private _observer;
  97118. private _onLostFocus;
  97119. /**
  97120. * Attach the input controls to a specific dom element to get the input from.
  97121. * @param element Defines the element the controls should be listened from
  97122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97123. */
  97124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97125. /**
  97126. * Detach the current controls from the specified dom element.
  97127. * @param element Defines the element to stop listening the inputs from
  97128. */
  97129. detachControl(element: Nullable<HTMLElement>): void;
  97130. /**
  97131. * Update the current camera state depending on the inputs that have been used this frame.
  97132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97133. */
  97134. checkInputs(): void;
  97135. /**
  97136. * Gets the class name of the current intput.
  97137. * @returns the class name
  97138. */
  97139. getClassName(): string;
  97140. /**
  97141. * Get the friendly name associated with the input class.
  97142. * @returns the input friendly name
  97143. */
  97144. getSimpleName(): string;
  97145. }
  97146. }
  97147. declare module BABYLON {
  97148. /**
  97149. * Default Inputs manager for the FreeCamera.
  97150. * It groups all the default supported inputs for ease of use.
  97151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97152. */
  97153. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97154. /**
  97155. * @hidden
  97156. */
  97157. _mouseInput: Nullable<FreeCameraMouseInput>;
  97158. /**
  97159. * Instantiates a new FreeCameraInputsManager.
  97160. * @param camera Defines the camera the inputs belong to
  97161. */
  97162. constructor(camera: FreeCamera);
  97163. /**
  97164. * Add keyboard input support to the input manager.
  97165. * @returns the current input manager
  97166. */
  97167. addKeyboard(): FreeCameraInputsManager;
  97168. /**
  97169. * Add mouse input support to the input manager.
  97170. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97171. * @returns the current input manager
  97172. */
  97173. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97174. /**
  97175. * Removes the mouse input support from the manager
  97176. * @returns the current input manager
  97177. */
  97178. removeMouse(): FreeCameraInputsManager;
  97179. /**
  97180. * Add touch input support to the input manager.
  97181. * @returns the current input manager
  97182. */
  97183. addTouch(): FreeCameraInputsManager;
  97184. /**
  97185. * Remove all attached input methods from a camera
  97186. */
  97187. clear(): void;
  97188. }
  97189. }
  97190. declare module BABYLON {
  97191. /**
  97192. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97193. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97194. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97195. */
  97196. export class FreeCamera extends TargetCamera {
  97197. /**
  97198. * Define the collision ellipsoid of the camera.
  97199. * This is helpful to simulate a camera body like the player body around the camera
  97200. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97201. */
  97202. ellipsoid: Vector3;
  97203. /**
  97204. * Define an offset for the position of the ellipsoid around the camera.
  97205. * This can be helpful to determine the center of the body near the gravity center of the body
  97206. * instead of its head.
  97207. */
  97208. ellipsoidOffset: Vector3;
  97209. /**
  97210. * Enable or disable collisions of the camera with the rest of the scene objects.
  97211. */
  97212. checkCollisions: boolean;
  97213. /**
  97214. * Enable or disable gravity on the camera.
  97215. */
  97216. applyGravity: boolean;
  97217. /**
  97218. * Define the input manager associated to the camera.
  97219. */
  97220. inputs: FreeCameraInputsManager;
  97221. /**
  97222. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97223. * Higher values reduce sensitivity.
  97224. */
  97225. get angularSensibility(): number;
  97226. /**
  97227. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97228. * Higher values reduce sensitivity.
  97229. */
  97230. set angularSensibility(value: number);
  97231. /**
  97232. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97233. */
  97234. get keysUp(): number[];
  97235. set keysUp(value: number[]);
  97236. /**
  97237. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97238. */
  97239. get keysUpward(): number[];
  97240. set keysUpward(value: number[]);
  97241. /**
  97242. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97243. */
  97244. get keysDown(): number[];
  97245. set keysDown(value: number[]);
  97246. /**
  97247. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97248. */
  97249. get keysDownward(): number[];
  97250. set keysDownward(value: number[]);
  97251. /**
  97252. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97253. */
  97254. get keysLeft(): number[];
  97255. set keysLeft(value: number[]);
  97256. /**
  97257. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97258. */
  97259. get keysRight(): number[];
  97260. set keysRight(value: number[]);
  97261. /**
  97262. * Event raised when the camera collide with a mesh in the scene.
  97263. */
  97264. onCollide: (collidedMesh: AbstractMesh) => void;
  97265. private _collider;
  97266. private _needMoveForGravity;
  97267. private _oldPosition;
  97268. private _diffPosition;
  97269. private _newPosition;
  97270. /** @hidden */
  97271. _localDirection: Vector3;
  97272. /** @hidden */
  97273. _transformedDirection: Vector3;
  97274. /**
  97275. * Instantiates a Free Camera.
  97276. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97277. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97278. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97279. * @param name Define the name of the camera in the scene
  97280. * @param position Define the start position of the camera in the scene
  97281. * @param scene Define the scene the camera belongs to
  97282. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97283. */
  97284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97285. /**
  97286. * Attached controls to the current camera.
  97287. * @param element Defines the element the controls should be listened from
  97288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97289. */
  97290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97291. /**
  97292. * Detach the current controls from the camera.
  97293. * The camera will stop reacting to inputs.
  97294. * @param element Defines the element to stop listening the inputs from
  97295. */
  97296. detachControl(element: HTMLElement): void;
  97297. private _collisionMask;
  97298. /**
  97299. * Define a collision mask to limit the list of object the camera can collide with
  97300. */
  97301. get collisionMask(): number;
  97302. set collisionMask(mask: number);
  97303. /** @hidden */
  97304. _collideWithWorld(displacement: Vector3): void;
  97305. private _onCollisionPositionChange;
  97306. /** @hidden */
  97307. _checkInputs(): void;
  97308. /** @hidden */
  97309. _decideIfNeedsToMove(): boolean;
  97310. /** @hidden */
  97311. _updatePosition(): void;
  97312. /**
  97313. * Destroy the camera and release the current resources hold by it.
  97314. */
  97315. dispose(): void;
  97316. /**
  97317. * Gets the current object class name.
  97318. * @return the class name
  97319. */
  97320. getClassName(): string;
  97321. }
  97322. }
  97323. declare module BABYLON {
  97324. /**
  97325. * Represents a gamepad control stick position
  97326. */
  97327. export class StickValues {
  97328. /**
  97329. * The x component of the control stick
  97330. */
  97331. x: number;
  97332. /**
  97333. * The y component of the control stick
  97334. */
  97335. y: number;
  97336. /**
  97337. * Initializes the gamepad x and y control stick values
  97338. * @param x The x component of the gamepad control stick value
  97339. * @param y The y component of the gamepad control stick value
  97340. */
  97341. constructor(
  97342. /**
  97343. * The x component of the control stick
  97344. */
  97345. x: number,
  97346. /**
  97347. * The y component of the control stick
  97348. */
  97349. y: number);
  97350. }
  97351. /**
  97352. * An interface which manages callbacks for gamepad button changes
  97353. */
  97354. export interface GamepadButtonChanges {
  97355. /**
  97356. * Called when a gamepad has been changed
  97357. */
  97358. changed: boolean;
  97359. /**
  97360. * Called when a gamepad press event has been triggered
  97361. */
  97362. pressChanged: boolean;
  97363. /**
  97364. * Called when a touch event has been triggered
  97365. */
  97366. touchChanged: boolean;
  97367. /**
  97368. * Called when a value has changed
  97369. */
  97370. valueChanged: boolean;
  97371. }
  97372. /**
  97373. * Represents a gamepad
  97374. */
  97375. export class Gamepad {
  97376. /**
  97377. * The id of the gamepad
  97378. */
  97379. id: string;
  97380. /**
  97381. * The index of the gamepad
  97382. */
  97383. index: number;
  97384. /**
  97385. * The browser gamepad
  97386. */
  97387. browserGamepad: any;
  97388. /**
  97389. * Specifies what type of gamepad this represents
  97390. */
  97391. type: number;
  97392. private _leftStick;
  97393. private _rightStick;
  97394. /** @hidden */
  97395. _isConnected: boolean;
  97396. private _leftStickAxisX;
  97397. private _leftStickAxisY;
  97398. private _rightStickAxisX;
  97399. private _rightStickAxisY;
  97400. /**
  97401. * Triggered when the left control stick has been changed
  97402. */
  97403. private _onleftstickchanged;
  97404. /**
  97405. * Triggered when the right control stick has been changed
  97406. */
  97407. private _onrightstickchanged;
  97408. /**
  97409. * Represents a gamepad controller
  97410. */
  97411. static GAMEPAD: number;
  97412. /**
  97413. * Represents a generic controller
  97414. */
  97415. static GENERIC: number;
  97416. /**
  97417. * Represents an XBox controller
  97418. */
  97419. static XBOX: number;
  97420. /**
  97421. * Represents a pose-enabled controller
  97422. */
  97423. static POSE_ENABLED: number;
  97424. /**
  97425. * Represents an Dual Shock controller
  97426. */
  97427. static DUALSHOCK: number;
  97428. /**
  97429. * Specifies whether the left control stick should be Y-inverted
  97430. */
  97431. protected _invertLeftStickY: boolean;
  97432. /**
  97433. * Specifies if the gamepad has been connected
  97434. */
  97435. get isConnected(): boolean;
  97436. /**
  97437. * Initializes the gamepad
  97438. * @param id The id of the gamepad
  97439. * @param index The index of the gamepad
  97440. * @param browserGamepad The browser gamepad
  97441. * @param leftStickX The x component of the left joystick
  97442. * @param leftStickY The y component of the left joystick
  97443. * @param rightStickX The x component of the right joystick
  97444. * @param rightStickY The y component of the right joystick
  97445. */
  97446. constructor(
  97447. /**
  97448. * The id of the gamepad
  97449. */
  97450. id: string,
  97451. /**
  97452. * The index of the gamepad
  97453. */
  97454. index: number,
  97455. /**
  97456. * The browser gamepad
  97457. */
  97458. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97459. /**
  97460. * Callback triggered when the left joystick has changed
  97461. * @param callback
  97462. */
  97463. onleftstickchanged(callback: (values: StickValues) => void): void;
  97464. /**
  97465. * Callback triggered when the right joystick has changed
  97466. * @param callback
  97467. */
  97468. onrightstickchanged(callback: (values: StickValues) => void): void;
  97469. /**
  97470. * Gets the left joystick
  97471. */
  97472. get leftStick(): StickValues;
  97473. /**
  97474. * Sets the left joystick values
  97475. */
  97476. set leftStick(newValues: StickValues);
  97477. /**
  97478. * Gets the right joystick
  97479. */
  97480. get rightStick(): StickValues;
  97481. /**
  97482. * Sets the right joystick value
  97483. */
  97484. set rightStick(newValues: StickValues);
  97485. /**
  97486. * Updates the gamepad joystick positions
  97487. */
  97488. update(): void;
  97489. /**
  97490. * Disposes the gamepad
  97491. */
  97492. dispose(): void;
  97493. }
  97494. /**
  97495. * Represents a generic gamepad
  97496. */
  97497. export class GenericPad extends Gamepad {
  97498. private _buttons;
  97499. private _onbuttondown;
  97500. private _onbuttonup;
  97501. /**
  97502. * Observable triggered when a button has been pressed
  97503. */
  97504. onButtonDownObservable: Observable<number>;
  97505. /**
  97506. * Observable triggered when a button has been released
  97507. */
  97508. onButtonUpObservable: Observable<number>;
  97509. /**
  97510. * Callback triggered when a button has been pressed
  97511. * @param callback Called when a button has been pressed
  97512. */
  97513. onbuttondown(callback: (buttonPressed: number) => void): void;
  97514. /**
  97515. * Callback triggered when a button has been released
  97516. * @param callback Called when a button has been released
  97517. */
  97518. onbuttonup(callback: (buttonReleased: number) => void): void;
  97519. /**
  97520. * Initializes the generic gamepad
  97521. * @param id The id of the generic gamepad
  97522. * @param index The index of the generic gamepad
  97523. * @param browserGamepad The browser gamepad
  97524. */
  97525. constructor(id: string, index: number, browserGamepad: any);
  97526. private _setButtonValue;
  97527. /**
  97528. * Updates the generic gamepad
  97529. */
  97530. update(): void;
  97531. /**
  97532. * Disposes the generic gamepad
  97533. */
  97534. dispose(): void;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * Defines the types of pose enabled controllers that are supported
  97540. */
  97541. export enum PoseEnabledControllerType {
  97542. /**
  97543. * HTC Vive
  97544. */
  97545. VIVE = 0,
  97546. /**
  97547. * Oculus Rift
  97548. */
  97549. OCULUS = 1,
  97550. /**
  97551. * Windows mixed reality
  97552. */
  97553. WINDOWS = 2,
  97554. /**
  97555. * Samsung gear VR
  97556. */
  97557. GEAR_VR = 3,
  97558. /**
  97559. * Google Daydream
  97560. */
  97561. DAYDREAM = 4,
  97562. /**
  97563. * Generic
  97564. */
  97565. GENERIC = 5
  97566. }
  97567. /**
  97568. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97569. */
  97570. export interface MutableGamepadButton {
  97571. /**
  97572. * Value of the button/trigger
  97573. */
  97574. value: number;
  97575. /**
  97576. * If the button/trigger is currently touched
  97577. */
  97578. touched: boolean;
  97579. /**
  97580. * If the button/trigger is currently pressed
  97581. */
  97582. pressed: boolean;
  97583. }
  97584. /**
  97585. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97586. * @hidden
  97587. */
  97588. export interface ExtendedGamepadButton extends GamepadButton {
  97589. /**
  97590. * If the button/trigger is currently pressed
  97591. */
  97592. readonly pressed: boolean;
  97593. /**
  97594. * If the button/trigger is currently touched
  97595. */
  97596. readonly touched: boolean;
  97597. /**
  97598. * Value of the button/trigger
  97599. */
  97600. readonly value: number;
  97601. }
  97602. /** @hidden */
  97603. export interface _GamePadFactory {
  97604. /**
  97605. * Returns whether or not the current gamepad can be created for this type of controller.
  97606. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97607. * @returns true if it can be created, otherwise false
  97608. */
  97609. canCreate(gamepadInfo: any): boolean;
  97610. /**
  97611. * Creates a new instance of the Gamepad.
  97612. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97613. * @returns the new gamepad instance
  97614. */
  97615. create(gamepadInfo: any): Gamepad;
  97616. }
  97617. /**
  97618. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97619. */
  97620. export class PoseEnabledControllerHelper {
  97621. /** @hidden */
  97622. static _ControllerFactories: _GamePadFactory[];
  97623. /** @hidden */
  97624. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97625. /**
  97626. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97627. * @param vrGamepad the gamepad to initialized
  97628. * @returns a vr controller of the type the gamepad identified as
  97629. */
  97630. static InitiateController(vrGamepad: any): Gamepad;
  97631. }
  97632. /**
  97633. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97634. */
  97635. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97636. /**
  97637. * If the controller is used in a webXR session
  97638. */
  97639. isXR: boolean;
  97640. private _deviceRoomPosition;
  97641. private _deviceRoomRotationQuaternion;
  97642. /**
  97643. * The device position in babylon space
  97644. */
  97645. devicePosition: Vector3;
  97646. /**
  97647. * The device rotation in babylon space
  97648. */
  97649. deviceRotationQuaternion: Quaternion;
  97650. /**
  97651. * The scale factor of the device in babylon space
  97652. */
  97653. deviceScaleFactor: number;
  97654. /**
  97655. * (Likely devicePosition should be used instead) The device position in its room space
  97656. */
  97657. position: Vector3;
  97658. /**
  97659. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97660. */
  97661. rotationQuaternion: Quaternion;
  97662. /**
  97663. * The type of controller (Eg. Windows mixed reality)
  97664. */
  97665. controllerType: PoseEnabledControllerType;
  97666. protected _calculatedPosition: Vector3;
  97667. private _calculatedRotation;
  97668. /**
  97669. * The raw pose from the device
  97670. */
  97671. rawPose: DevicePose;
  97672. private _trackPosition;
  97673. private _maxRotationDistFromHeadset;
  97674. private _draggedRoomRotation;
  97675. /**
  97676. * @hidden
  97677. */
  97678. _disableTrackPosition(fixedPosition: Vector3): void;
  97679. /**
  97680. * Internal, the mesh attached to the controller
  97681. * @hidden
  97682. */
  97683. _mesh: Nullable<AbstractMesh>;
  97684. private _poseControlledCamera;
  97685. private _leftHandSystemQuaternion;
  97686. /**
  97687. * Internal, matrix used to convert room space to babylon space
  97688. * @hidden
  97689. */
  97690. _deviceToWorld: Matrix;
  97691. /**
  97692. * Node to be used when casting a ray from the controller
  97693. * @hidden
  97694. */
  97695. _pointingPoseNode: Nullable<TransformNode>;
  97696. /**
  97697. * Name of the child mesh that can be used to cast a ray from the controller
  97698. */
  97699. static readonly POINTING_POSE: string;
  97700. /**
  97701. * Creates a new PoseEnabledController from a gamepad
  97702. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97703. */
  97704. constructor(browserGamepad: any);
  97705. private _workingMatrix;
  97706. /**
  97707. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97708. */
  97709. update(): void;
  97710. /**
  97711. * Updates only the pose device and mesh without doing any button event checking
  97712. */
  97713. protected _updatePoseAndMesh(): void;
  97714. /**
  97715. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97716. * @param poseData raw pose fromthe device
  97717. */
  97718. updateFromDevice(poseData: DevicePose): void;
  97719. /**
  97720. * @hidden
  97721. */
  97722. _meshAttachedObservable: Observable<AbstractMesh>;
  97723. /**
  97724. * Attaches a mesh to the controller
  97725. * @param mesh the mesh to be attached
  97726. */
  97727. attachToMesh(mesh: AbstractMesh): void;
  97728. /**
  97729. * Attaches the controllers mesh to a camera
  97730. * @param camera the camera the mesh should be attached to
  97731. */
  97732. attachToPoseControlledCamera(camera: TargetCamera): void;
  97733. /**
  97734. * Disposes of the controller
  97735. */
  97736. dispose(): void;
  97737. /**
  97738. * The mesh that is attached to the controller
  97739. */
  97740. get mesh(): Nullable<AbstractMesh>;
  97741. /**
  97742. * Gets the ray of the controller in the direction the controller is pointing
  97743. * @param length the length the resulting ray should be
  97744. * @returns a ray in the direction the controller is pointing
  97745. */
  97746. getForwardRay(length?: number): Ray;
  97747. }
  97748. }
  97749. declare module BABYLON {
  97750. /**
  97751. * Defines the WebVRController object that represents controllers tracked in 3D space
  97752. */
  97753. export abstract class WebVRController extends PoseEnabledController {
  97754. /**
  97755. * Internal, the default controller model for the controller
  97756. */
  97757. protected _defaultModel: Nullable<AbstractMesh>;
  97758. /**
  97759. * Fired when the trigger state has changed
  97760. */
  97761. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97762. /**
  97763. * Fired when the main button state has changed
  97764. */
  97765. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97766. /**
  97767. * Fired when the secondary button state has changed
  97768. */
  97769. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97770. /**
  97771. * Fired when the pad state has changed
  97772. */
  97773. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97774. /**
  97775. * Fired when controllers stick values have changed
  97776. */
  97777. onPadValuesChangedObservable: Observable<StickValues>;
  97778. /**
  97779. * Array of button availible on the controller
  97780. */
  97781. protected _buttons: Array<MutableGamepadButton>;
  97782. private _onButtonStateChange;
  97783. /**
  97784. * Fired when a controller button's state has changed
  97785. * @param callback the callback containing the button that was modified
  97786. */
  97787. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97788. /**
  97789. * X and Y axis corresponding to the controllers joystick
  97790. */
  97791. pad: StickValues;
  97792. /**
  97793. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97794. */
  97795. hand: string;
  97796. /**
  97797. * The default controller model for the controller
  97798. */
  97799. get defaultModel(): Nullable<AbstractMesh>;
  97800. /**
  97801. * Creates a new WebVRController from a gamepad
  97802. * @param vrGamepad the gamepad that the WebVRController should be created from
  97803. */
  97804. constructor(vrGamepad: any);
  97805. /**
  97806. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97807. */
  97808. update(): void;
  97809. /**
  97810. * Function to be called when a button is modified
  97811. */
  97812. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97813. /**
  97814. * Loads a mesh and attaches it to the controller
  97815. * @param scene the scene the mesh should be added to
  97816. * @param meshLoaded callback for when the mesh has been loaded
  97817. */
  97818. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97819. private _setButtonValue;
  97820. private _changes;
  97821. private _checkChanges;
  97822. /**
  97823. * Disposes of th webVRCOntroller
  97824. */
  97825. dispose(): void;
  97826. }
  97827. }
  97828. declare module BABYLON {
  97829. /**
  97830. * The HemisphericLight simulates the ambient environment light,
  97831. * so the passed direction is the light reflection direction, not the incoming direction.
  97832. */
  97833. export class HemisphericLight extends Light {
  97834. /**
  97835. * The groundColor is the light in the opposite direction to the one specified during creation.
  97836. * 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.
  97837. */
  97838. groundColor: Color3;
  97839. /**
  97840. * The light reflection direction, not the incoming direction.
  97841. */
  97842. direction: Vector3;
  97843. /**
  97844. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97845. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97846. * The HemisphericLight can't cast shadows.
  97847. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97848. * @param name The friendly name of the light
  97849. * @param direction The direction of the light reflection
  97850. * @param scene The scene the light belongs to
  97851. */
  97852. constructor(name: string, direction: Vector3, scene: Scene);
  97853. protected _buildUniformLayout(): void;
  97854. /**
  97855. * Returns the string "HemisphericLight".
  97856. * @return The class name
  97857. */
  97858. getClassName(): string;
  97859. /**
  97860. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97861. * Returns the updated direction.
  97862. * @param target The target the direction should point to
  97863. * @return The computed direction
  97864. */
  97865. setDirectionToTarget(target: Vector3): Vector3;
  97866. /**
  97867. * Returns the shadow generator associated to the light.
  97868. * @returns Always null for hemispheric lights because it does not support shadows.
  97869. */
  97870. getShadowGenerator(): Nullable<IShadowGenerator>;
  97871. /**
  97872. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97873. * @param effect The effect to update
  97874. * @param lightIndex The index of the light in the effect to update
  97875. * @returns The hemispheric light
  97876. */
  97877. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97878. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97879. /**
  97880. * Computes the world matrix of the node
  97881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97882. * @param useWasUpdatedFlag defines a reserved property
  97883. * @returns the world matrix
  97884. */
  97885. computeWorldMatrix(): Matrix;
  97886. /**
  97887. * Returns the integer 3.
  97888. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97889. */
  97890. getTypeID(): number;
  97891. /**
  97892. * Prepares the list of defines specific to the light type.
  97893. * @param defines the list of defines
  97894. * @param lightIndex defines the index of the light for the effect
  97895. */
  97896. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97897. }
  97898. }
  97899. declare module BABYLON {
  97900. /** @hidden */
  97901. export var vrMultiviewToSingleviewPixelShader: {
  97902. name: string;
  97903. shader: string;
  97904. };
  97905. }
  97906. declare module BABYLON {
  97907. /**
  97908. * Renders to multiple views with a single draw call
  97909. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97910. */
  97911. export class MultiviewRenderTarget extends RenderTargetTexture {
  97912. /**
  97913. * Creates a multiview render target
  97914. * @param scene scene used with the render target
  97915. * @param size the size of the render target (used for each view)
  97916. */
  97917. constructor(scene: Scene, size?: number | {
  97918. width: number;
  97919. height: number;
  97920. } | {
  97921. ratio: number;
  97922. });
  97923. /**
  97924. * @hidden
  97925. * @param faceIndex the face index, if its a cube texture
  97926. */
  97927. _bindFrameBuffer(faceIndex?: number): void;
  97928. /**
  97929. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97930. * @returns the view count
  97931. */
  97932. getViewCount(): number;
  97933. }
  97934. }
  97935. declare module BABYLON {
  97936. interface Engine {
  97937. /**
  97938. * Creates a new multiview render target
  97939. * @param width defines the width of the texture
  97940. * @param height defines the height of the texture
  97941. * @returns the created multiview texture
  97942. */
  97943. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97944. /**
  97945. * Binds a multiview framebuffer to be drawn to
  97946. * @param multiviewTexture texture to bind
  97947. */
  97948. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97949. }
  97950. interface Camera {
  97951. /**
  97952. * @hidden
  97953. * 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)
  97954. */
  97955. _useMultiviewToSingleView: boolean;
  97956. /**
  97957. * @hidden
  97958. * 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)
  97959. */
  97960. _multiviewTexture: Nullable<RenderTargetTexture>;
  97961. /**
  97962. * @hidden
  97963. * ensures the multiview texture of the camera exists and has the specified width/height
  97964. * @param width height to set on the multiview texture
  97965. * @param height width to set on the multiview texture
  97966. */
  97967. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97968. }
  97969. interface Scene {
  97970. /** @hidden */
  97971. _transformMatrixR: Matrix;
  97972. /** @hidden */
  97973. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97974. /** @hidden */
  97975. _createMultiviewUbo(): void;
  97976. /** @hidden */
  97977. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97978. /** @hidden */
  97979. _renderMultiviewToSingleView(camera: Camera): void;
  97980. }
  97981. }
  97982. declare module BABYLON {
  97983. /**
  97984. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97985. * This will not be used for webXR as it supports displaying texture arrays directly
  97986. */
  97987. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97988. /**
  97989. * Initializes a VRMultiviewToSingleview
  97990. * @param name name of the post process
  97991. * @param camera camera to be applied to
  97992. * @param scaleFactor scaling factor to the size of the output texture
  97993. */
  97994. constructor(name: string, camera: Camera, scaleFactor: number);
  97995. }
  97996. }
  97997. declare module BABYLON {
  97998. /**
  97999. * Interface used to define additional presentation attributes
  98000. */
  98001. export interface IVRPresentationAttributes {
  98002. /**
  98003. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98004. */
  98005. highRefreshRate: boolean;
  98006. /**
  98007. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98008. */
  98009. foveationLevel: number;
  98010. }
  98011. interface Engine {
  98012. /** @hidden */
  98013. _vrDisplay: any;
  98014. /** @hidden */
  98015. _vrSupported: boolean;
  98016. /** @hidden */
  98017. _oldSize: Size;
  98018. /** @hidden */
  98019. _oldHardwareScaleFactor: number;
  98020. /** @hidden */
  98021. _vrExclusivePointerMode: boolean;
  98022. /** @hidden */
  98023. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98024. /** @hidden */
  98025. _onVRDisplayPointerRestricted: () => void;
  98026. /** @hidden */
  98027. _onVRDisplayPointerUnrestricted: () => void;
  98028. /** @hidden */
  98029. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98030. /** @hidden */
  98031. _onVrDisplayDisconnect: Nullable<() => void>;
  98032. /** @hidden */
  98033. _onVrDisplayPresentChange: Nullable<() => void>;
  98034. /**
  98035. * Observable signaled when VR display mode changes
  98036. */
  98037. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98038. /**
  98039. * Observable signaled when VR request present is complete
  98040. */
  98041. onVRRequestPresentComplete: Observable<boolean>;
  98042. /**
  98043. * Observable signaled when VR request present starts
  98044. */
  98045. onVRRequestPresentStart: Observable<Engine>;
  98046. /**
  98047. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98048. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98049. */
  98050. isInVRExclusivePointerMode: boolean;
  98051. /**
  98052. * Gets a boolean indicating if a webVR device was detected
  98053. * @returns true if a webVR device was detected
  98054. */
  98055. isVRDevicePresent(): boolean;
  98056. /**
  98057. * Gets the current webVR device
  98058. * @returns the current webVR device (or null)
  98059. */
  98060. getVRDevice(): any;
  98061. /**
  98062. * Initializes a webVR display and starts listening to display change events
  98063. * The onVRDisplayChangedObservable will be notified upon these changes
  98064. * @returns A promise containing a VRDisplay and if vr is supported
  98065. */
  98066. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98067. /** @hidden */
  98068. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98069. /**
  98070. * Gets or sets the presentation attributes used to configure VR rendering
  98071. */
  98072. vrPresentationAttributes?: IVRPresentationAttributes;
  98073. /**
  98074. * Call this function to switch to webVR mode
  98075. * Will do nothing if webVR is not supported or if there is no webVR device
  98076. * @param options the webvr options provided to the camera. mainly used for multiview
  98077. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98078. */
  98079. enableVR(options: WebVROptions): void;
  98080. /** @hidden */
  98081. _onVRFullScreenTriggered(): void;
  98082. }
  98083. }
  98084. declare module BABYLON {
  98085. /**
  98086. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98087. * IMPORTANT!! The data is right-hand data.
  98088. * @export
  98089. * @interface DevicePose
  98090. */
  98091. export interface DevicePose {
  98092. /**
  98093. * The position of the device, values in array are [x,y,z].
  98094. */
  98095. readonly position: Nullable<Float32Array>;
  98096. /**
  98097. * The linearVelocity of the device, values in array are [x,y,z].
  98098. */
  98099. readonly linearVelocity: Nullable<Float32Array>;
  98100. /**
  98101. * The linearAcceleration of the device, values in array are [x,y,z].
  98102. */
  98103. readonly linearAcceleration: Nullable<Float32Array>;
  98104. /**
  98105. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98106. */
  98107. readonly orientation: Nullable<Float32Array>;
  98108. /**
  98109. * The angularVelocity of the device, values in array are [x,y,z].
  98110. */
  98111. readonly angularVelocity: Nullable<Float32Array>;
  98112. /**
  98113. * The angularAcceleration of the device, values in array are [x,y,z].
  98114. */
  98115. readonly angularAcceleration: Nullable<Float32Array>;
  98116. }
  98117. /**
  98118. * Interface representing a pose controlled object in Babylon.
  98119. * A pose controlled object has both regular pose values as well as pose values
  98120. * from an external device such as a VR head mounted display
  98121. */
  98122. export interface PoseControlled {
  98123. /**
  98124. * The position of the object in babylon space.
  98125. */
  98126. position: Vector3;
  98127. /**
  98128. * The rotation quaternion of the object in babylon space.
  98129. */
  98130. rotationQuaternion: Quaternion;
  98131. /**
  98132. * The position of the device in babylon space.
  98133. */
  98134. devicePosition?: Vector3;
  98135. /**
  98136. * The rotation quaternion of the device in babylon space.
  98137. */
  98138. deviceRotationQuaternion: Quaternion;
  98139. /**
  98140. * The raw pose coming from the device.
  98141. */
  98142. rawPose: Nullable<DevicePose>;
  98143. /**
  98144. * The scale of the device to be used when translating from device space to babylon space.
  98145. */
  98146. deviceScaleFactor: number;
  98147. /**
  98148. * Updates the poseControlled values based on the input device pose.
  98149. * @param poseData the pose data to update the object with
  98150. */
  98151. updateFromDevice(poseData: DevicePose): void;
  98152. }
  98153. /**
  98154. * Set of options to customize the webVRCamera
  98155. */
  98156. export interface WebVROptions {
  98157. /**
  98158. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98159. */
  98160. trackPosition?: boolean;
  98161. /**
  98162. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98163. */
  98164. positionScale?: number;
  98165. /**
  98166. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98167. */
  98168. displayName?: string;
  98169. /**
  98170. * Should the native controller meshes be initialized. (default: true)
  98171. */
  98172. controllerMeshes?: boolean;
  98173. /**
  98174. * Creating a default HemiLight only on controllers. (default: true)
  98175. */
  98176. defaultLightingOnControllers?: boolean;
  98177. /**
  98178. * If you don't want to use the default VR button of the helper. (default: false)
  98179. */
  98180. useCustomVRButton?: boolean;
  98181. /**
  98182. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98183. */
  98184. customVRButton?: HTMLButtonElement;
  98185. /**
  98186. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98187. */
  98188. rayLength?: number;
  98189. /**
  98190. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98191. */
  98192. defaultHeight?: number;
  98193. /**
  98194. * If multiview should be used if availible (default: false)
  98195. */
  98196. useMultiview?: boolean;
  98197. }
  98198. /**
  98199. * This represents a WebVR camera.
  98200. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98201. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98202. */
  98203. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98204. private webVROptions;
  98205. /**
  98206. * @hidden
  98207. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98208. */
  98209. _vrDevice: any;
  98210. /**
  98211. * The rawPose of the vrDevice.
  98212. */
  98213. rawPose: Nullable<DevicePose>;
  98214. private _onVREnabled;
  98215. private _specsVersion;
  98216. private _attached;
  98217. private _frameData;
  98218. protected _descendants: Array<Node>;
  98219. private _deviceRoomPosition;
  98220. /** @hidden */
  98221. _deviceRoomRotationQuaternion: Quaternion;
  98222. private _standingMatrix;
  98223. /**
  98224. * Represents device position in babylon space.
  98225. */
  98226. devicePosition: Vector3;
  98227. /**
  98228. * Represents device rotation in babylon space.
  98229. */
  98230. deviceRotationQuaternion: Quaternion;
  98231. /**
  98232. * The scale of the device to be used when translating from device space to babylon space.
  98233. */
  98234. deviceScaleFactor: number;
  98235. private _deviceToWorld;
  98236. private _worldToDevice;
  98237. /**
  98238. * References to the webVR controllers for the vrDevice.
  98239. */
  98240. controllers: Array<WebVRController>;
  98241. /**
  98242. * Emits an event when a controller is attached.
  98243. */
  98244. onControllersAttachedObservable: Observable<WebVRController[]>;
  98245. /**
  98246. * Emits an event when a controller's mesh has been loaded;
  98247. */
  98248. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98249. /**
  98250. * Emits an event when the HMD's pose has been updated.
  98251. */
  98252. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98253. private _poseSet;
  98254. /**
  98255. * If the rig cameras be used as parent instead of this camera.
  98256. */
  98257. rigParenting: boolean;
  98258. private _lightOnControllers;
  98259. private _defaultHeight?;
  98260. /**
  98261. * Instantiates a WebVRFreeCamera.
  98262. * @param name The name of the WebVRFreeCamera
  98263. * @param position The starting anchor position for the camera
  98264. * @param scene The scene the camera belongs to
  98265. * @param webVROptions a set of customizable options for the webVRCamera
  98266. */
  98267. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98268. /**
  98269. * Gets the device distance from the ground in meters.
  98270. * @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.
  98271. */
  98272. deviceDistanceToRoomGround(): number;
  98273. /**
  98274. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98275. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98276. */
  98277. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98278. /**
  98279. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98280. * @returns A promise with a boolean set to if the standing matrix is supported.
  98281. */
  98282. useStandingMatrixAsync(): Promise<boolean>;
  98283. /**
  98284. * Disposes the camera
  98285. */
  98286. dispose(): void;
  98287. /**
  98288. * Gets a vrController by name.
  98289. * @param name The name of the controller to retreive
  98290. * @returns the controller matching the name specified or null if not found
  98291. */
  98292. getControllerByName(name: string): Nullable<WebVRController>;
  98293. private _leftController;
  98294. /**
  98295. * The controller corresponding to the users left hand.
  98296. */
  98297. get leftController(): Nullable<WebVRController>;
  98298. private _rightController;
  98299. /**
  98300. * The controller corresponding to the users right hand.
  98301. */
  98302. get rightController(): Nullable<WebVRController>;
  98303. /**
  98304. * Casts a ray forward from the vrCamera's gaze.
  98305. * @param length Length of the ray (default: 100)
  98306. * @returns the ray corresponding to the gaze
  98307. */
  98308. getForwardRay(length?: number): Ray;
  98309. /**
  98310. * @hidden
  98311. * Updates the camera based on device's frame data
  98312. */
  98313. _checkInputs(): void;
  98314. /**
  98315. * Updates the poseControlled values based on the input device pose.
  98316. * @param poseData Pose coming from the device
  98317. */
  98318. updateFromDevice(poseData: DevicePose): void;
  98319. private _htmlElementAttached;
  98320. private _detachIfAttached;
  98321. /**
  98322. * WebVR's attach control will start broadcasting frames to the device.
  98323. * Note that in certain browsers (chrome for example) this function must be called
  98324. * within a user-interaction callback. Example:
  98325. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98326. *
  98327. * @param element html element to attach the vrDevice to
  98328. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98329. */
  98330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98331. /**
  98332. * Detaches the camera from the html element and disables VR
  98333. *
  98334. * @param element html element to detach from
  98335. */
  98336. detachControl(element: HTMLElement): void;
  98337. /**
  98338. * @returns the name of this class
  98339. */
  98340. getClassName(): string;
  98341. /**
  98342. * Calls resetPose on the vrDisplay
  98343. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98344. */
  98345. resetToCurrentRotation(): void;
  98346. /**
  98347. * @hidden
  98348. * Updates the rig cameras (left and right eye)
  98349. */
  98350. _updateRigCameras(): void;
  98351. private _workingVector;
  98352. private _oneVector;
  98353. private _workingMatrix;
  98354. private updateCacheCalled;
  98355. private _correctPositionIfNotTrackPosition;
  98356. /**
  98357. * @hidden
  98358. * Updates the cached values of the camera
  98359. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98360. */
  98361. _updateCache(ignoreParentClass?: boolean): void;
  98362. /**
  98363. * @hidden
  98364. * Get current device position in babylon world
  98365. */
  98366. _computeDevicePosition(): void;
  98367. /**
  98368. * Updates the current device position and rotation in the babylon world
  98369. */
  98370. update(): void;
  98371. /**
  98372. * @hidden
  98373. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98374. * @returns an identity matrix
  98375. */
  98376. _getViewMatrix(): Matrix;
  98377. private _tmpMatrix;
  98378. /**
  98379. * This function is called by the two RIG cameras.
  98380. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98381. * @hidden
  98382. */
  98383. _getWebVRViewMatrix(): Matrix;
  98384. /** @hidden */
  98385. _getWebVRProjectionMatrix(): Matrix;
  98386. private _onGamepadConnectedObserver;
  98387. private _onGamepadDisconnectedObserver;
  98388. private _updateCacheWhenTrackingDisabledObserver;
  98389. /**
  98390. * Initializes the controllers and their meshes
  98391. */
  98392. initControllers(): void;
  98393. }
  98394. }
  98395. declare module BABYLON {
  98396. /**
  98397. * "Static Class" containing the most commonly used helper while dealing with material for
  98398. * rendering purpose.
  98399. *
  98400. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98401. *
  98402. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98403. */
  98404. export class MaterialHelper {
  98405. /**
  98406. * Bind the current view position to an effect.
  98407. * @param effect The effect to be bound
  98408. * @param scene The scene the eyes position is used from
  98409. * @param variableName name of the shader variable that will hold the eye position
  98410. */
  98411. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98412. /**
  98413. * Helps preparing the defines values about the UVs in used in the effect.
  98414. * UVs are shared as much as we can accross channels in the shaders.
  98415. * @param texture The texture we are preparing the UVs for
  98416. * @param defines The defines to update
  98417. * @param key The channel key "diffuse", "specular"... used in the shader
  98418. */
  98419. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98420. /**
  98421. * Binds a texture matrix value to its corrsponding uniform
  98422. * @param texture The texture to bind the matrix for
  98423. * @param uniformBuffer The uniform buffer receivin the data
  98424. * @param key The channel key "diffuse", "specular"... used in the shader
  98425. */
  98426. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98427. /**
  98428. * Gets the current status of the fog (should it be enabled?)
  98429. * @param mesh defines the mesh to evaluate for fog support
  98430. * @param scene defines the hosting scene
  98431. * @returns true if fog must be enabled
  98432. */
  98433. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98434. /**
  98435. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98436. * @param mesh defines the current mesh
  98437. * @param scene defines the current scene
  98438. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98439. * @param pointsCloud defines if point cloud rendering has to be turned on
  98440. * @param fogEnabled defines if fog has to be turned on
  98441. * @param alphaTest defines if alpha testing has to be turned on
  98442. * @param defines defines the current list of defines
  98443. */
  98444. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98445. /**
  98446. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98447. * @param scene defines the current scene
  98448. * @param engine defines the current engine
  98449. * @param defines specifies the list of active defines
  98450. * @param useInstances defines if instances have to be turned on
  98451. * @param useClipPlane defines if clip plane have to be turned on
  98452. * @param useInstances defines if instances have to be turned on
  98453. * @param useThinInstances defines if thin instances have to be turned on
  98454. */
  98455. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98456. /**
  98457. * Prepares the defines for bones
  98458. * @param mesh The mesh containing the geometry data we will draw
  98459. * @param defines The defines to update
  98460. */
  98461. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98462. /**
  98463. * Prepares the defines for morph targets
  98464. * @param mesh The mesh containing the geometry data we will draw
  98465. * @param defines The defines to update
  98466. */
  98467. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98468. /**
  98469. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98470. * @param mesh The mesh containing the geometry data we will draw
  98471. * @param defines The defines to update
  98472. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98473. * @param useBones Precise whether bones should be used or not (override mesh info)
  98474. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98475. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98476. * @returns false if defines are considered not dirty and have not been checked
  98477. */
  98478. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98479. /**
  98480. * Prepares the defines related to multiview
  98481. * @param scene The scene we are intending to draw
  98482. * @param defines The defines to update
  98483. */
  98484. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98485. /**
  98486. * Prepares the defines related to the prepass
  98487. * @param scene The scene we are intending to draw
  98488. * @param defines The defines to update
  98489. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98490. */
  98491. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98492. /**
  98493. * Prepares the defines related to the light information passed in parameter
  98494. * @param scene The scene we are intending to draw
  98495. * @param mesh The mesh the effect is compiling for
  98496. * @param light The light the effect is compiling for
  98497. * @param lightIndex The index of the light
  98498. * @param defines The defines to update
  98499. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98500. * @param state Defines the current state regarding what is needed (normals, etc...)
  98501. */
  98502. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98503. needNormals: boolean;
  98504. needRebuild: boolean;
  98505. shadowEnabled: boolean;
  98506. specularEnabled: boolean;
  98507. lightmapMode: boolean;
  98508. }): void;
  98509. /**
  98510. * Prepares the defines related to the light information passed in parameter
  98511. * @param scene The scene we are intending to draw
  98512. * @param mesh The mesh the effect is compiling for
  98513. * @param defines The defines to update
  98514. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98515. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98516. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98517. * @returns true if normals will be required for the rest of the effect
  98518. */
  98519. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98520. /**
  98521. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98522. * @param lightIndex defines the light index
  98523. * @param uniformsList The uniform list
  98524. * @param samplersList The sampler list
  98525. * @param projectedLightTexture defines if projected texture must be used
  98526. * @param uniformBuffersList defines an optional list of uniform buffers
  98527. */
  98528. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98529. /**
  98530. * Prepares the uniforms and samplers list to be used in the effect
  98531. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98532. * @param samplersList The sampler list
  98533. * @param defines The defines helping in the list generation
  98534. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98535. */
  98536. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98537. /**
  98538. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98539. * @param defines The defines to update while falling back
  98540. * @param fallbacks The authorized effect fallbacks
  98541. * @param maxSimultaneousLights The maximum number of lights allowed
  98542. * @param rank the current rank of the Effect
  98543. * @returns The newly affected rank
  98544. */
  98545. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98546. private static _TmpMorphInfluencers;
  98547. /**
  98548. * Prepares the list of attributes required for morph targets according to the effect defines.
  98549. * @param attribs The current list of supported attribs
  98550. * @param mesh The mesh to prepare the morph targets attributes for
  98551. * @param influencers The number of influencers
  98552. */
  98553. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98554. /**
  98555. * Prepares the list of attributes required for morph targets according to the effect defines.
  98556. * @param attribs The current list of supported attribs
  98557. * @param mesh The mesh to prepare the morph targets attributes for
  98558. * @param defines The current Defines of the effect
  98559. */
  98560. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98561. /**
  98562. * Prepares the list of attributes required for bones according to the effect defines.
  98563. * @param attribs The current list of supported attribs
  98564. * @param mesh The mesh to prepare the bones attributes for
  98565. * @param defines The current Defines of the effect
  98566. * @param fallbacks The current efffect fallback strategy
  98567. */
  98568. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98569. /**
  98570. * Check and prepare the list of attributes required for instances according to the effect defines.
  98571. * @param attribs The current list of supported attribs
  98572. * @param defines The current MaterialDefines of the effect
  98573. */
  98574. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98575. /**
  98576. * Add the list of attributes required for instances to the attribs array.
  98577. * @param attribs The current list of supported attribs
  98578. */
  98579. static PushAttributesForInstances(attribs: string[]): void;
  98580. /**
  98581. * Binds the light information to the effect.
  98582. * @param light The light containing the generator
  98583. * @param effect The effect we are binding the data to
  98584. * @param lightIndex The light index in the effect used to render
  98585. */
  98586. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98587. /**
  98588. * Binds the lights information from the scene to the effect for the given mesh.
  98589. * @param light Light to bind
  98590. * @param lightIndex Light index
  98591. * @param scene The scene where the light belongs to
  98592. * @param effect The effect we are binding the data to
  98593. * @param useSpecular Defines if specular is supported
  98594. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98595. */
  98596. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98597. /**
  98598. * Binds the lights information from the scene to the effect for the given mesh.
  98599. * @param scene The scene the lights belongs to
  98600. * @param mesh The mesh we are binding the information to render
  98601. * @param effect The effect we are binding the data to
  98602. * @param defines The generated defines for the effect
  98603. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98604. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98605. */
  98606. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98607. private static _tempFogColor;
  98608. /**
  98609. * Binds the fog information from the scene to the effect for the given mesh.
  98610. * @param scene The scene the lights belongs to
  98611. * @param mesh The mesh we are binding the information to render
  98612. * @param effect The effect we are binding the data to
  98613. * @param linearSpace Defines if the fog effect is applied in linear space
  98614. */
  98615. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98616. /**
  98617. * Binds the bones information from the mesh to the effect.
  98618. * @param mesh The mesh we are binding the information to render
  98619. * @param effect The effect we are binding the data to
  98620. */
  98621. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98622. /**
  98623. * Binds the morph targets information from the mesh to the effect.
  98624. * @param abstractMesh The mesh we are binding the information to render
  98625. * @param effect The effect we are binding the data to
  98626. */
  98627. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98628. /**
  98629. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98630. * @param defines The generated defines used in the effect
  98631. * @param effect The effect we are binding the data to
  98632. * @param scene The scene we are willing to render with logarithmic scale for
  98633. */
  98634. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98635. /**
  98636. * Binds the clip plane information from the scene to the effect.
  98637. * @param scene The scene the clip plane information are extracted from
  98638. * @param effect The effect we are binding the data to
  98639. */
  98640. static BindClipPlane(effect: Effect, scene: Scene): void;
  98641. }
  98642. }
  98643. declare module BABYLON {
  98644. /**
  98645. * Block used to expose an input value
  98646. */
  98647. export class InputBlock extends NodeMaterialBlock {
  98648. private _mode;
  98649. private _associatedVariableName;
  98650. private _storedValue;
  98651. private _valueCallback;
  98652. private _type;
  98653. private _animationType;
  98654. /** Gets or set a value used to limit the range of float values */
  98655. min: number;
  98656. /** Gets or set a value used to limit the range of float values */
  98657. max: number;
  98658. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98659. isBoolean: boolean;
  98660. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98661. matrixMode: number;
  98662. /** @hidden */
  98663. _systemValue: Nullable<NodeMaterialSystemValues>;
  98664. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98665. visibleInInspector: boolean;
  98666. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98667. isConstant: boolean;
  98668. /** Gets or sets the group to use to display this block in the Inspector */
  98669. groupInInspector: string;
  98670. /** Gets an observable raised when the value is changed */
  98671. onValueChangedObservable: Observable<InputBlock>;
  98672. /**
  98673. * Gets or sets the connection point type (default is float)
  98674. */
  98675. get type(): NodeMaterialBlockConnectionPointTypes;
  98676. /**
  98677. * Creates a new InputBlock
  98678. * @param name defines the block name
  98679. * @param target defines the target of that block (Vertex by default)
  98680. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98681. */
  98682. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98683. /**
  98684. * Validates if a name is a reserve word.
  98685. * @param newName the new name to be given to the node.
  98686. * @returns false if the name is a reserve word, else true.
  98687. */
  98688. validateBlockName(newName: string): boolean;
  98689. /**
  98690. * Gets the output component
  98691. */
  98692. get output(): NodeMaterialConnectionPoint;
  98693. /**
  98694. * Set the source of this connection point to a vertex attribute
  98695. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98696. * @returns the current connection point
  98697. */
  98698. setAsAttribute(attributeName?: string): InputBlock;
  98699. /**
  98700. * Set the source of this connection point to a system value
  98701. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98702. * @returns the current connection point
  98703. */
  98704. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98705. /**
  98706. * Gets or sets the value of that point.
  98707. * Please note that this value will be ignored if valueCallback is defined
  98708. */
  98709. get value(): any;
  98710. set value(value: any);
  98711. /**
  98712. * Gets or sets a callback used to get the value of that point.
  98713. * Please note that setting this value will force the connection point to ignore the value property
  98714. */
  98715. get valueCallback(): () => any;
  98716. set valueCallback(value: () => any);
  98717. /**
  98718. * Gets or sets the associated variable name in the shader
  98719. */
  98720. get associatedVariableName(): string;
  98721. set associatedVariableName(value: string);
  98722. /** Gets or sets the type of animation applied to the input */
  98723. get animationType(): AnimatedInputBlockTypes;
  98724. set animationType(value: AnimatedInputBlockTypes);
  98725. /**
  98726. * Gets a boolean indicating that this connection point not defined yet
  98727. */
  98728. get isUndefined(): boolean;
  98729. /**
  98730. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98731. * In this case the connection point name must be the name of the uniform to use.
  98732. * Can only be set on inputs
  98733. */
  98734. get isUniform(): boolean;
  98735. set isUniform(value: boolean);
  98736. /**
  98737. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98738. * In this case the connection point name must be the name of the attribute to use
  98739. * Can only be set on inputs
  98740. */
  98741. get isAttribute(): boolean;
  98742. set isAttribute(value: boolean);
  98743. /**
  98744. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98745. * Can only be set on exit points
  98746. */
  98747. get isVarying(): boolean;
  98748. set isVarying(value: boolean);
  98749. /**
  98750. * Gets a boolean indicating that the current connection point is a system value
  98751. */
  98752. get isSystemValue(): boolean;
  98753. /**
  98754. * Gets or sets the current well known value or null if not defined as a system value
  98755. */
  98756. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98757. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98758. /**
  98759. * Gets the current class name
  98760. * @returns the class name
  98761. */
  98762. getClassName(): string;
  98763. /**
  98764. * Animate the input if animationType !== None
  98765. * @param scene defines the rendering scene
  98766. */
  98767. animate(scene: Scene): void;
  98768. private _emitDefine;
  98769. initialize(state: NodeMaterialBuildState): void;
  98770. /**
  98771. * Set the input block to its default value (based on its type)
  98772. */
  98773. setDefaultValue(): void;
  98774. private _emitConstant;
  98775. /** @hidden */
  98776. get _noContextSwitch(): boolean;
  98777. private _emit;
  98778. /** @hidden */
  98779. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98780. /** @hidden */
  98781. _transmit(effect: Effect, scene: Scene): void;
  98782. protected _buildBlock(state: NodeMaterialBuildState): void;
  98783. protected _dumpPropertiesCode(): string;
  98784. dispose(): void;
  98785. serialize(): any;
  98786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98787. }
  98788. }
  98789. declare module BABYLON {
  98790. /**
  98791. * Enum used to define the compatibility state between two connection points
  98792. */
  98793. export enum NodeMaterialConnectionPointCompatibilityStates {
  98794. /** Points are compatibles */
  98795. Compatible = 0,
  98796. /** Points are incompatible because of their types */
  98797. TypeIncompatible = 1,
  98798. /** Points are incompatible because of their targets (vertex vs fragment) */
  98799. TargetIncompatible = 2
  98800. }
  98801. /**
  98802. * Defines the direction of a connection point
  98803. */
  98804. export enum NodeMaterialConnectionPointDirection {
  98805. /** Input */
  98806. Input = 0,
  98807. /** Output */
  98808. Output = 1
  98809. }
  98810. /**
  98811. * Defines a connection point for a block
  98812. */
  98813. export class NodeMaterialConnectionPoint {
  98814. /** @hidden */
  98815. _ownerBlock: NodeMaterialBlock;
  98816. /** @hidden */
  98817. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98818. private _endpoints;
  98819. private _associatedVariableName;
  98820. private _direction;
  98821. /** @hidden */
  98822. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98823. /** @hidden */
  98824. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98825. private _type;
  98826. /** @hidden */
  98827. _enforceAssociatedVariableName: boolean;
  98828. /** Gets the direction of the point */
  98829. get direction(): NodeMaterialConnectionPointDirection;
  98830. /** Indicates that this connection point needs dual validation before being connected to another point */
  98831. needDualDirectionValidation: boolean;
  98832. /**
  98833. * Gets or sets the additional types supported by this connection point
  98834. */
  98835. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98836. /**
  98837. * Gets or sets the additional types excluded by this connection point
  98838. */
  98839. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98840. /**
  98841. * Observable triggered when this point is connected
  98842. */
  98843. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98844. /**
  98845. * Gets or sets the associated variable name in the shader
  98846. */
  98847. get associatedVariableName(): string;
  98848. set associatedVariableName(value: string);
  98849. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98850. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98851. /**
  98852. * Gets or sets the connection point type (default is float)
  98853. */
  98854. get type(): NodeMaterialBlockConnectionPointTypes;
  98855. set type(value: NodeMaterialBlockConnectionPointTypes);
  98856. /**
  98857. * Gets or sets the connection point name
  98858. */
  98859. name: string;
  98860. /**
  98861. * Gets or sets the connection point name
  98862. */
  98863. displayName: string;
  98864. /**
  98865. * Gets or sets a boolean indicating that this connection point can be omitted
  98866. */
  98867. isOptional: boolean;
  98868. /**
  98869. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98870. */
  98871. isExposedOnFrame: boolean;
  98872. /**
  98873. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98874. */
  98875. define: string;
  98876. /** @hidden */
  98877. _prioritizeVertex: boolean;
  98878. private _target;
  98879. /** Gets or sets the target of that connection point */
  98880. get target(): NodeMaterialBlockTargets;
  98881. set target(value: NodeMaterialBlockTargets);
  98882. /**
  98883. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98884. */
  98885. get isConnected(): boolean;
  98886. /**
  98887. * Gets a boolean indicating that the current point is connected to an input block
  98888. */
  98889. get isConnectedToInputBlock(): boolean;
  98890. /**
  98891. * Gets a the connected input block (if any)
  98892. */
  98893. get connectInputBlock(): Nullable<InputBlock>;
  98894. /** Get the other side of the connection (if any) */
  98895. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98896. /** Get the block that owns this connection point */
  98897. get ownerBlock(): NodeMaterialBlock;
  98898. /** Get the block connected on the other side of this connection (if any) */
  98899. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98900. /** Get the block connected on the endpoints of this connection (if any) */
  98901. get connectedBlocks(): Array<NodeMaterialBlock>;
  98902. /** Gets the list of connected endpoints */
  98903. get endpoints(): NodeMaterialConnectionPoint[];
  98904. /** Gets a boolean indicating if that output point is connected to at least one input */
  98905. get hasEndpoints(): boolean;
  98906. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98907. get isConnectedInVertexShader(): boolean;
  98908. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98909. get isConnectedInFragmentShader(): boolean;
  98910. /**
  98911. * Creates a block suitable to be used as an input for this input point.
  98912. * If null is returned, a block based on the point type will be created.
  98913. * @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
  98914. */
  98915. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98916. /**
  98917. * Creates a new connection point
  98918. * @param name defines the connection point name
  98919. * @param ownerBlock defines the block hosting this connection point
  98920. * @param direction defines the direction of the connection point
  98921. */
  98922. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98923. /**
  98924. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98925. * @returns the class name
  98926. */
  98927. getClassName(): string;
  98928. /**
  98929. * Gets a boolean indicating if the current point can be connected to another point
  98930. * @param connectionPoint defines the other connection point
  98931. * @returns a boolean
  98932. */
  98933. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98934. /**
  98935. * Gets a number indicating if the current point can be connected to another point
  98936. * @param connectionPoint defines the other connection point
  98937. * @returns a number defining the compatibility state
  98938. */
  98939. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98940. /**
  98941. * Connect this point to another connection point
  98942. * @param connectionPoint defines the other connection point
  98943. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98944. * @returns the current connection point
  98945. */
  98946. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98947. /**
  98948. * Disconnect this point from one of his endpoint
  98949. * @param endpoint defines the other connection point
  98950. * @returns the current connection point
  98951. */
  98952. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98953. /**
  98954. * Serializes this point in a JSON representation
  98955. * @param isInput defines if the connection point is an input (default is true)
  98956. * @returns the serialized point object
  98957. */
  98958. serialize(isInput?: boolean): any;
  98959. /**
  98960. * Release resources
  98961. */
  98962. dispose(): void;
  98963. }
  98964. }
  98965. declare module BABYLON {
  98966. /**
  98967. * Enum used to define the material modes
  98968. */
  98969. export enum NodeMaterialModes {
  98970. /** Regular material */
  98971. Material = 0,
  98972. /** For post process */
  98973. PostProcess = 1,
  98974. /** For particle system */
  98975. Particle = 2
  98976. }
  98977. }
  98978. declare module BABYLON {
  98979. /**
  98980. * Block used to read a texture from a sampler
  98981. */
  98982. export class TextureBlock extends NodeMaterialBlock {
  98983. private _defineName;
  98984. private _linearDefineName;
  98985. private _gammaDefineName;
  98986. private _tempTextureRead;
  98987. private _samplerName;
  98988. private _transformedUVName;
  98989. private _textureTransformName;
  98990. private _textureInfoName;
  98991. private _mainUVName;
  98992. private _mainUVDefineName;
  98993. private _fragmentOnly;
  98994. /**
  98995. * Gets or sets the texture associated with the node
  98996. */
  98997. texture: Nullable<Texture>;
  98998. /**
  98999. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99000. */
  99001. convertToGammaSpace: boolean;
  99002. /**
  99003. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99004. */
  99005. convertToLinearSpace: boolean;
  99006. /**
  99007. * Create a new TextureBlock
  99008. * @param name defines the block name
  99009. */
  99010. constructor(name: string, fragmentOnly?: boolean);
  99011. /**
  99012. * Gets the current class name
  99013. * @returns the class name
  99014. */
  99015. getClassName(): string;
  99016. /**
  99017. * Gets the uv input component
  99018. */
  99019. get uv(): NodeMaterialConnectionPoint;
  99020. /**
  99021. * Gets the rgba output component
  99022. */
  99023. get rgba(): NodeMaterialConnectionPoint;
  99024. /**
  99025. * Gets the rgb output component
  99026. */
  99027. get rgb(): NodeMaterialConnectionPoint;
  99028. /**
  99029. * Gets the r output component
  99030. */
  99031. get r(): NodeMaterialConnectionPoint;
  99032. /**
  99033. * Gets the g output component
  99034. */
  99035. get g(): NodeMaterialConnectionPoint;
  99036. /**
  99037. * Gets the b output component
  99038. */
  99039. get b(): NodeMaterialConnectionPoint;
  99040. /**
  99041. * Gets the a output component
  99042. */
  99043. get a(): NodeMaterialConnectionPoint;
  99044. get target(): NodeMaterialBlockTargets;
  99045. autoConfigure(material: NodeMaterial): void;
  99046. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99048. isReady(): boolean;
  99049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99050. private get _isMixed();
  99051. private _injectVertexCode;
  99052. private _writeTextureRead;
  99053. private _writeOutput;
  99054. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99055. protected _dumpPropertiesCode(): string;
  99056. serialize(): any;
  99057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99058. }
  99059. }
  99060. declare module BABYLON {
  99061. /** @hidden */
  99062. export var reflectionFunction: {
  99063. name: string;
  99064. shader: string;
  99065. };
  99066. }
  99067. declare module BABYLON {
  99068. /**
  99069. * Base block used to read a reflection texture from a sampler
  99070. */
  99071. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99072. /** @hidden */
  99073. _define3DName: string;
  99074. /** @hidden */
  99075. _defineCubicName: string;
  99076. /** @hidden */
  99077. _defineExplicitName: string;
  99078. /** @hidden */
  99079. _defineProjectionName: string;
  99080. /** @hidden */
  99081. _defineLocalCubicName: string;
  99082. /** @hidden */
  99083. _defineSphericalName: string;
  99084. /** @hidden */
  99085. _definePlanarName: string;
  99086. /** @hidden */
  99087. _defineEquirectangularName: string;
  99088. /** @hidden */
  99089. _defineMirroredEquirectangularFixedName: string;
  99090. /** @hidden */
  99091. _defineEquirectangularFixedName: string;
  99092. /** @hidden */
  99093. _defineSkyboxName: string;
  99094. /** @hidden */
  99095. _defineOppositeZ: string;
  99096. /** @hidden */
  99097. _cubeSamplerName: string;
  99098. /** @hidden */
  99099. _2DSamplerName: string;
  99100. protected _positionUVWName: string;
  99101. protected _directionWName: string;
  99102. protected _reflectionVectorName: string;
  99103. /** @hidden */
  99104. _reflectionCoordsName: string;
  99105. /** @hidden */
  99106. _reflectionMatrixName: string;
  99107. protected _reflectionColorName: string;
  99108. /**
  99109. * Gets or sets the texture associated with the node
  99110. */
  99111. texture: Nullable<BaseTexture>;
  99112. /**
  99113. * Create a new ReflectionTextureBaseBlock
  99114. * @param name defines the block name
  99115. */
  99116. constructor(name: string);
  99117. /**
  99118. * Gets the current class name
  99119. * @returns the class name
  99120. */
  99121. getClassName(): string;
  99122. /**
  99123. * Gets the world position input component
  99124. */
  99125. abstract get position(): NodeMaterialConnectionPoint;
  99126. /**
  99127. * Gets the world position input component
  99128. */
  99129. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99130. /**
  99131. * Gets the world normal input component
  99132. */
  99133. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99134. /**
  99135. * Gets the world input component
  99136. */
  99137. abstract get world(): NodeMaterialConnectionPoint;
  99138. /**
  99139. * Gets the camera (or eye) position component
  99140. */
  99141. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99142. /**
  99143. * Gets the view input component
  99144. */
  99145. abstract get view(): NodeMaterialConnectionPoint;
  99146. protected _getTexture(): Nullable<BaseTexture>;
  99147. autoConfigure(material: NodeMaterial): void;
  99148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99149. isReady(): boolean;
  99150. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99151. /**
  99152. * Gets the code to inject in the vertex shader
  99153. * @param state current state of the node material building
  99154. * @returns the shader code
  99155. */
  99156. handleVertexSide(state: NodeMaterialBuildState): string;
  99157. /**
  99158. * Handles the inits for the fragment code path
  99159. * @param state node material build state
  99160. */
  99161. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99162. /**
  99163. * Generates the reflection coords code for the fragment code path
  99164. * @param worldNormalVarName name of the world normal variable
  99165. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99166. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99167. * @returns the shader code
  99168. */
  99169. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99170. /**
  99171. * Generates the reflection color code for the fragment code path
  99172. * @param lodVarName name of the lod variable
  99173. * @param swizzleLookupTexture swizzle to use for the final color variable
  99174. * @returns the shader code
  99175. */
  99176. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99177. /**
  99178. * Generates the code corresponding to the connected output points
  99179. * @param state node material build state
  99180. * @param varName name of the variable to output
  99181. * @returns the shader code
  99182. */
  99183. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99184. protected _buildBlock(state: NodeMaterialBuildState): this;
  99185. protected _dumpPropertiesCode(): string;
  99186. serialize(): any;
  99187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99188. }
  99189. }
  99190. declare module BABYLON {
  99191. /**
  99192. * Defines a connection point to be used for points with a custom object type
  99193. */
  99194. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99195. private _blockType;
  99196. private _blockName;
  99197. private _nameForCheking?;
  99198. /**
  99199. * Creates a new connection point
  99200. * @param name defines the connection point name
  99201. * @param ownerBlock defines the block hosting this connection point
  99202. * @param direction defines the direction of the connection point
  99203. */
  99204. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99205. /**
  99206. * Gets a number indicating if the current point can be connected to another point
  99207. * @param connectionPoint defines the other connection point
  99208. * @returns a number defining the compatibility state
  99209. */
  99210. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99211. /**
  99212. * Creates a block suitable to be used as an input for this input point.
  99213. * If null is returned, a block based on the point type will be created.
  99214. * @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
  99215. */
  99216. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99217. }
  99218. }
  99219. declare module BABYLON {
  99220. /**
  99221. * Enum defining the type of properties that can be edited in the property pages in the NME
  99222. */
  99223. export enum PropertyTypeForEdition {
  99224. /** property is a boolean */
  99225. Boolean = 0,
  99226. /** property is a float */
  99227. Float = 1,
  99228. /** property is a Vector2 */
  99229. Vector2 = 2,
  99230. /** property is a list of values */
  99231. List = 3
  99232. }
  99233. /**
  99234. * Interface that defines an option in a variable of type list
  99235. */
  99236. export interface IEditablePropertyListOption {
  99237. /** label of the option */
  99238. "label": string;
  99239. /** value of the option */
  99240. "value": number;
  99241. }
  99242. /**
  99243. * Interface that defines the options available for an editable property
  99244. */
  99245. export interface IEditablePropertyOption {
  99246. /** min value */
  99247. "min"?: number;
  99248. /** max value */
  99249. "max"?: number;
  99250. /** notifiers: indicates which actions to take when the property is changed */
  99251. "notifiers"?: {
  99252. /** the material should be rebuilt */
  99253. "rebuild"?: boolean;
  99254. /** the preview should be updated */
  99255. "update"?: boolean;
  99256. };
  99257. /** list of the options for a variable of type list */
  99258. "options"?: IEditablePropertyListOption[];
  99259. }
  99260. /**
  99261. * Interface that describes an editable property
  99262. */
  99263. export interface IPropertyDescriptionForEdition {
  99264. /** name of the property */
  99265. "propertyName": string;
  99266. /** display name of the property */
  99267. "displayName": string;
  99268. /** type of the property */
  99269. "type": PropertyTypeForEdition;
  99270. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99271. "groupName": string;
  99272. /** options for the property */
  99273. "options": IEditablePropertyOption;
  99274. }
  99275. /**
  99276. * Decorator that flags a property in a node material block as being editable
  99277. */
  99278. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * Block used to implement the refraction part of the sub surface module of the PBR material
  99283. */
  99284. export class RefractionBlock extends NodeMaterialBlock {
  99285. /** @hidden */
  99286. _define3DName: string;
  99287. /** @hidden */
  99288. _refractionMatrixName: string;
  99289. /** @hidden */
  99290. _defineLODRefractionAlpha: string;
  99291. /** @hidden */
  99292. _defineLinearSpecularRefraction: string;
  99293. /** @hidden */
  99294. _defineOppositeZ: string;
  99295. /** @hidden */
  99296. _cubeSamplerName: string;
  99297. /** @hidden */
  99298. _2DSamplerName: string;
  99299. /** @hidden */
  99300. _vRefractionMicrosurfaceInfosName: string;
  99301. /** @hidden */
  99302. _vRefractionInfosName: string;
  99303. private _scene;
  99304. /**
  99305. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99306. * Materials half opaque for instance using refraction could benefit from this control.
  99307. */
  99308. linkRefractionWithTransparency: boolean;
  99309. /**
  99310. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99311. */
  99312. invertRefractionY: boolean;
  99313. /**
  99314. * Gets or sets the texture associated with the node
  99315. */
  99316. texture: Nullable<BaseTexture>;
  99317. /**
  99318. * Create a new RefractionBlock
  99319. * @param name defines the block name
  99320. */
  99321. constructor(name: string);
  99322. /**
  99323. * Gets the current class name
  99324. * @returns the class name
  99325. */
  99326. getClassName(): string;
  99327. /**
  99328. * Gets the intensity input component
  99329. */
  99330. get intensity(): NodeMaterialConnectionPoint;
  99331. /**
  99332. * Gets the index of refraction input component
  99333. */
  99334. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99335. /**
  99336. * Gets the tint at distance input component
  99337. */
  99338. get tintAtDistance(): NodeMaterialConnectionPoint;
  99339. /**
  99340. * Gets the view input component
  99341. */
  99342. get view(): NodeMaterialConnectionPoint;
  99343. /**
  99344. * Gets the refraction object output component
  99345. */
  99346. get refraction(): NodeMaterialConnectionPoint;
  99347. /**
  99348. * Returns true if the block has a texture
  99349. */
  99350. get hasTexture(): boolean;
  99351. protected _getTexture(): Nullable<BaseTexture>;
  99352. autoConfigure(material: NodeMaterial): void;
  99353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99354. isReady(): boolean;
  99355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99356. /**
  99357. * Gets the main code of the block (fragment side)
  99358. * @param state current state of the node material building
  99359. * @returns the shader code
  99360. */
  99361. getCode(state: NodeMaterialBuildState): string;
  99362. protected _buildBlock(state: NodeMaterialBuildState): this;
  99363. protected _dumpPropertiesCode(): string;
  99364. serialize(): any;
  99365. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99366. }
  99367. }
  99368. declare module BABYLON {
  99369. /**
  99370. * Base block used as input for post process
  99371. */
  99372. export class CurrentScreenBlock extends NodeMaterialBlock {
  99373. private _samplerName;
  99374. private _linearDefineName;
  99375. private _gammaDefineName;
  99376. private _mainUVName;
  99377. private _tempTextureRead;
  99378. /**
  99379. * Gets or sets the texture associated with the node
  99380. */
  99381. texture: Nullable<BaseTexture>;
  99382. /**
  99383. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99384. */
  99385. convertToGammaSpace: boolean;
  99386. /**
  99387. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99388. */
  99389. convertToLinearSpace: boolean;
  99390. /**
  99391. * Create a new CurrentScreenBlock
  99392. * @param name defines the block name
  99393. */
  99394. constructor(name: string);
  99395. /**
  99396. * Gets the current class name
  99397. * @returns the class name
  99398. */
  99399. getClassName(): string;
  99400. /**
  99401. * Gets the uv input component
  99402. */
  99403. get uv(): NodeMaterialConnectionPoint;
  99404. /**
  99405. * Gets the rgba output component
  99406. */
  99407. get rgba(): NodeMaterialConnectionPoint;
  99408. /**
  99409. * Gets the rgb output component
  99410. */
  99411. get rgb(): NodeMaterialConnectionPoint;
  99412. /**
  99413. * Gets the r output component
  99414. */
  99415. get r(): NodeMaterialConnectionPoint;
  99416. /**
  99417. * Gets the g output component
  99418. */
  99419. get g(): NodeMaterialConnectionPoint;
  99420. /**
  99421. * Gets the b output component
  99422. */
  99423. get b(): NodeMaterialConnectionPoint;
  99424. /**
  99425. * Gets the a output component
  99426. */
  99427. get a(): NodeMaterialConnectionPoint;
  99428. /**
  99429. * Initialize the block and prepare the context for build
  99430. * @param state defines the state that will be used for the build
  99431. */
  99432. initialize(state: NodeMaterialBuildState): void;
  99433. get target(): NodeMaterialBlockTargets;
  99434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99435. isReady(): boolean;
  99436. private _injectVertexCode;
  99437. private _writeTextureRead;
  99438. private _writeOutput;
  99439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99440. serialize(): any;
  99441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99442. }
  99443. }
  99444. declare module BABYLON {
  99445. /**
  99446. * Base block used for the particle texture
  99447. */
  99448. export class ParticleTextureBlock extends NodeMaterialBlock {
  99449. private _samplerName;
  99450. private _linearDefineName;
  99451. private _gammaDefineName;
  99452. private _tempTextureRead;
  99453. /**
  99454. * Gets or sets the texture associated with the node
  99455. */
  99456. texture: Nullable<BaseTexture>;
  99457. /**
  99458. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99459. */
  99460. convertToGammaSpace: boolean;
  99461. /**
  99462. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99463. */
  99464. convertToLinearSpace: boolean;
  99465. /**
  99466. * Create a new ParticleTextureBlock
  99467. * @param name defines the block name
  99468. */
  99469. constructor(name: string);
  99470. /**
  99471. * Gets the current class name
  99472. * @returns the class name
  99473. */
  99474. getClassName(): string;
  99475. /**
  99476. * Gets the uv input component
  99477. */
  99478. get uv(): NodeMaterialConnectionPoint;
  99479. /**
  99480. * Gets the rgba output component
  99481. */
  99482. get rgba(): NodeMaterialConnectionPoint;
  99483. /**
  99484. * Gets the rgb output component
  99485. */
  99486. get rgb(): NodeMaterialConnectionPoint;
  99487. /**
  99488. * Gets the r output component
  99489. */
  99490. get r(): NodeMaterialConnectionPoint;
  99491. /**
  99492. * Gets the g output component
  99493. */
  99494. get g(): NodeMaterialConnectionPoint;
  99495. /**
  99496. * Gets the b output component
  99497. */
  99498. get b(): NodeMaterialConnectionPoint;
  99499. /**
  99500. * Gets the a output component
  99501. */
  99502. get a(): NodeMaterialConnectionPoint;
  99503. /**
  99504. * Initialize the block and prepare the context for build
  99505. * @param state defines the state that will be used for the build
  99506. */
  99507. initialize(state: NodeMaterialBuildState): void;
  99508. autoConfigure(material: NodeMaterial): void;
  99509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99510. isReady(): boolean;
  99511. private _writeOutput;
  99512. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99513. serialize(): any;
  99514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99515. }
  99516. }
  99517. declare module BABYLON {
  99518. /**
  99519. * Class used to store shared data between 2 NodeMaterialBuildState
  99520. */
  99521. export class NodeMaterialBuildStateSharedData {
  99522. /**
  99523. * Gets the list of emitted varyings
  99524. */
  99525. temps: string[];
  99526. /**
  99527. * Gets the list of emitted varyings
  99528. */
  99529. varyings: string[];
  99530. /**
  99531. * Gets the varying declaration string
  99532. */
  99533. varyingDeclaration: string;
  99534. /**
  99535. * Input blocks
  99536. */
  99537. inputBlocks: InputBlock[];
  99538. /**
  99539. * Input blocks
  99540. */
  99541. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99542. /**
  99543. * Bindable blocks (Blocks that need to set data to the effect)
  99544. */
  99545. bindableBlocks: NodeMaterialBlock[];
  99546. /**
  99547. * List of blocks that can provide a compilation fallback
  99548. */
  99549. blocksWithFallbacks: NodeMaterialBlock[];
  99550. /**
  99551. * List of blocks that can provide a define update
  99552. */
  99553. blocksWithDefines: NodeMaterialBlock[];
  99554. /**
  99555. * List of blocks that can provide a repeatable content
  99556. */
  99557. repeatableContentBlocks: NodeMaterialBlock[];
  99558. /**
  99559. * List of blocks that can provide a dynamic list of uniforms
  99560. */
  99561. dynamicUniformBlocks: NodeMaterialBlock[];
  99562. /**
  99563. * List of blocks that can block the isReady function for the material
  99564. */
  99565. blockingBlocks: NodeMaterialBlock[];
  99566. /**
  99567. * Gets the list of animated inputs
  99568. */
  99569. animatedInputs: InputBlock[];
  99570. /**
  99571. * Build Id used to avoid multiple recompilations
  99572. */
  99573. buildId: number;
  99574. /** List of emitted variables */
  99575. variableNames: {
  99576. [key: string]: number;
  99577. };
  99578. /** List of emitted defines */
  99579. defineNames: {
  99580. [key: string]: number;
  99581. };
  99582. /** Should emit comments? */
  99583. emitComments: boolean;
  99584. /** Emit build activity */
  99585. verbose: boolean;
  99586. /** Gets or sets the hosting scene */
  99587. scene: Scene;
  99588. /**
  99589. * Gets the compilation hints emitted at compilation time
  99590. */
  99591. hints: {
  99592. needWorldViewMatrix: boolean;
  99593. needWorldViewProjectionMatrix: boolean;
  99594. needAlphaBlending: boolean;
  99595. needAlphaTesting: boolean;
  99596. };
  99597. /**
  99598. * List of compilation checks
  99599. */
  99600. checks: {
  99601. emitVertex: boolean;
  99602. emitFragment: boolean;
  99603. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99604. };
  99605. /**
  99606. * Is vertex program allowed to be empty?
  99607. */
  99608. allowEmptyVertexProgram: boolean;
  99609. /** Creates a new shared data */
  99610. constructor();
  99611. /**
  99612. * Emits console errors and exceptions if there is a failing check
  99613. */
  99614. emitErrors(): void;
  99615. }
  99616. }
  99617. declare module BABYLON {
  99618. /**
  99619. * Class used to store node based material build state
  99620. */
  99621. export class NodeMaterialBuildState {
  99622. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99623. supportUniformBuffers: boolean;
  99624. /**
  99625. * Gets the list of emitted attributes
  99626. */
  99627. attributes: string[];
  99628. /**
  99629. * Gets the list of emitted uniforms
  99630. */
  99631. uniforms: string[];
  99632. /**
  99633. * Gets the list of emitted constants
  99634. */
  99635. constants: string[];
  99636. /**
  99637. * Gets the list of emitted samplers
  99638. */
  99639. samplers: string[];
  99640. /**
  99641. * Gets the list of emitted functions
  99642. */
  99643. functions: {
  99644. [key: string]: string;
  99645. };
  99646. /**
  99647. * Gets the list of emitted extensions
  99648. */
  99649. extensions: {
  99650. [key: string]: string;
  99651. };
  99652. /**
  99653. * Gets the target of the compilation state
  99654. */
  99655. target: NodeMaterialBlockTargets;
  99656. /**
  99657. * Gets the list of emitted counters
  99658. */
  99659. counters: {
  99660. [key: string]: number;
  99661. };
  99662. /**
  99663. * Shared data between multiple NodeMaterialBuildState instances
  99664. */
  99665. sharedData: NodeMaterialBuildStateSharedData;
  99666. /** @hidden */
  99667. _vertexState: NodeMaterialBuildState;
  99668. /** @hidden */
  99669. _attributeDeclaration: string;
  99670. /** @hidden */
  99671. _uniformDeclaration: string;
  99672. /** @hidden */
  99673. _constantDeclaration: string;
  99674. /** @hidden */
  99675. _samplerDeclaration: string;
  99676. /** @hidden */
  99677. _varyingTransfer: string;
  99678. /** @hidden */
  99679. _injectAtEnd: string;
  99680. private _repeatableContentAnchorIndex;
  99681. /** @hidden */
  99682. _builtCompilationString: string;
  99683. /**
  99684. * Gets the emitted compilation strings
  99685. */
  99686. compilationString: string;
  99687. /**
  99688. * Finalize the compilation strings
  99689. * @param state defines the current compilation state
  99690. */
  99691. finalize(state: NodeMaterialBuildState): void;
  99692. /** @hidden */
  99693. get _repeatableContentAnchor(): string;
  99694. /** @hidden */
  99695. _getFreeVariableName(prefix: string): string;
  99696. /** @hidden */
  99697. _getFreeDefineName(prefix: string): string;
  99698. /** @hidden */
  99699. _excludeVariableName(name: string): void;
  99700. /** @hidden */
  99701. _emit2DSampler(name: string): void;
  99702. /** @hidden */
  99703. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99704. /** @hidden */
  99705. _emitExtension(name: string, extension: string, define?: string): void;
  99706. /** @hidden */
  99707. _emitFunction(name: string, code: string, comments: string): void;
  99708. /** @hidden */
  99709. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99710. replaceStrings?: {
  99711. search: RegExp;
  99712. replace: string;
  99713. }[];
  99714. repeatKey?: string;
  99715. }): string;
  99716. /** @hidden */
  99717. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99718. repeatKey?: string;
  99719. removeAttributes?: boolean;
  99720. removeUniforms?: boolean;
  99721. removeVaryings?: boolean;
  99722. removeIfDef?: boolean;
  99723. replaceStrings?: {
  99724. search: RegExp;
  99725. replace: string;
  99726. }[];
  99727. }, storeKey?: string): void;
  99728. /** @hidden */
  99729. _registerTempVariable(name: string): boolean;
  99730. /** @hidden */
  99731. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99732. /** @hidden */
  99733. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99734. /** @hidden */
  99735. _emitFloat(value: number): string;
  99736. }
  99737. }
  99738. declare module BABYLON {
  99739. /**
  99740. * Helper class used to generate session unique ID
  99741. */
  99742. export class UniqueIdGenerator {
  99743. private static _UniqueIdCounter;
  99744. /**
  99745. * Gets an unique (relatively to the current scene) Id
  99746. */
  99747. static get UniqueId(): number;
  99748. }
  99749. }
  99750. declare module BABYLON {
  99751. /**
  99752. * Defines a block that can be used inside a node based material
  99753. */
  99754. export class NodeMaterialBlock {
  99755. private _buildId;
  99756. private _buildTarget;
  99757. private _target;
  99758. private _isFinalMerger;
  99759. private _isInput;
  99760. private _name;
  99761. protected _isUnique: boolean;
  99762. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99763. inputsAreExclusive: boolean;
  99764. /** @hidden */
  99765. _codeVariableName: string;
  99766. /** @hidden */
  99767. _inputs: NodeMaterialConnectionPoint[];
  99768. /** @hidden */
  99769. _outputs: NodeMaterialConnectionPoint[];
  99770. /** @hidden */
  99771. _preparationId: number;
  99772. /**
  99773. * Gets the name of the block
  99774. */
  99775. get name(): string;
  99776. /**
  99777. * Sets the name of the block. Will check if the name is valid.
  99778. */
  99779. set name(newName: string);
  99780. /**
  99781. * Gets or sets the unique id of the node
  99782. */
  99783. uniqueId: number;
  99784. /**
  99785. * Gets or sets the comments associated with this block
  99786. */
  99787. comments: string;
  99788. /**
  99789. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99790. */
  99791. get isUnique(): boolean;
  99792. /**
  99793. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99794. */
  99795. get isFinalMerger(): boolean;
  99796. /**
  99797. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99798. */
  99799. get isInput(): boolean;
  99800. /**
  99801. * Gets or sets the build Id
  99802. */
  99803. get buildId(): number;
  99804. set buildId(value: number);
  99805. /**
  99806. * Gets or sets the target of the block
  99807. */
  99808. get target(): NodeMaterialBlockTargets;
  99809. set target(value: NodeMaterialBlockTargets);
  99810. /**
  99811. * Gets the list of input points
  99812. */
  99813. get inputs(): NodeMaterialConnectionPoint[];
  99814. /** Gets the list of output points */
  99815. get outputs(): NodeMaterialConnectionPoint[];
  99816. /**
  99817. * Find an input by its name
  99818. * @param name defines the name of the input to look for
  99819. * @returns the input or null if not found
  99820. */
  99821. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99822. /**
  99823. * Find an output by its name
  99824. * @param name defines the name of the outputto look for
  99825. * @returns the output or null if not found
  99826. */
  99827. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99828. /**
  99829. * Creates a new NodeMaterialBlock
  99830. * @param name defines the block name
  99831. * @param target defines the target of that block (Vertex by default)
  99832. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99833. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99834. */
  99835. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99836. /**
  99837. * Initialize the block and prepare the context for build
  99838. * @param state defines the state that will be used for the build
  99839. */
  99840. initialize(state: NodeMaterialBuildState): void;
  99841. /**
  99842. * Bind data to effect. Will only be called for blocks with isBindable === true
  99843. * @param effect defines the effect to bind data to
  99844. * @param nodeMaterial defines the hosting NodeMaterial
  99845. * @param mesh defines the mesh that will be rendered
  99846. * @param subMesh defines the submesh that will be rendered
  99847. */
  99848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99849. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99850. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99851. protected _writeFloat(value: number): string;
  99852. /**
  99853. * Gets the current class name e.g. "NodeMaterialBlock"
  99854. * @returns the class name
  99855. */
  99856. getClassName(): string;
  99857. /**
  99858. * Register a new input. Must be called inside a block constructor
  99859. * @param name defines the connection point name
  99860. * @param type defines the connection point type
  99861. * @param isOptional defines a boolean indicating that this input can be omitted
  99862. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99863. * @param point an already created connection point. If not provided, create a new one
  99864. * @returns the current block
  99865. */
  99866. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99867. /**
  99868. * Register a new output. Must be called inside a block constructor
  99869. * @param name defines the connection point name
  99870. * @param type defines the connection point type
  99871. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99872. * @param point an already created connection point. If not provided, create a new one
  99873. * @returns the current block
  99874. */
  99875. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99876. /**
  99877. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99878. * @param forOutput defines an optional connection point to check compatibility with
  99879. * @returns the first available input or null
  99880. */
  99881. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99882. /**
  99883. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99884. * @param forBlock defines an optional block to check compatibility with
  99885. * @returns the first available input or null
  99886. */
  99887. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99888. /**
  99889. * Gets the sibling of the given output
  99890. * @param current defines the current output
  99891. * @returns the next output in the list or null
  99892. */
  99893. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99894. /**
  99895. * Connect current block with another block
  99896. * @param other defines the block to connect with
  99897. * @param options define the various options to help pick the right connections
  99898. * @returns the current block
  99899. */
  99900. connectTo(other: NodeMaterialBlock, options?: {
  99901. input?: string;
  99902. output?: string;
  99903. outputSwizzle?: string;
  99904. }): this | undefined;
  99905. protected _buildBlock(state: NodeMaterialBuildState): void;
  99906. /**
  99907. * Add uniforms, samplers and uniform buffers at compilation time
  99908. * @param state defines the state to update
  99909. * @param nodeMaterial defines the node material requesting the update
  99910. * @param defines defines the material defines to update
  99911. * @param uniformBuffers defines the list of uniform buffer names
  99912. */
  99913. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99914. /**
  99915. * Add potential fallbacks if shader compilation fails
  99916. * @param mesh defines the mesh to be rendered
  99917. * @param fallbacks defines the current prioritized list of fallbacks
  99918. */
  99919. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99920. /**
  99921. * Initialize defines for shader compilation
  99922. * @param mesh defines the mesh to be rendered
  99923. * @param nodeMaterial defines the node material requesting the update
  99924. * @param defines defines the material defines to update
  99925. * @param useInstances specifies that instances should be used
  99926. */
  99927. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99928. /**
  99929. * Update defines for shader compilation
  99930. * @param mesh defines the mesh to be rendered
  99931. * @param nodeMaterial defines the node material requesting the update
  99932. * @param defines defines the material defines to update
  99933. * @param useInstances specifies that instances should be used
  99934. * @param subMesh defines which submesh to render
  99935. */
  99936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99937. /**
  99938. * Lets the block try to connect some inputs automatically
  99939. * @param material defines the hosting NodeMaterial
  99940. */
  99941. autoConfigure(material: NodeMaterial): void;
  99942. /**
  99943. * Function called when a block is declared as repeatable content generator
  99944. * @param vertexShaderState defines the current compilation state for the vertex shader
  99945. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99946. * @param mesh defines the mesh to be rendered
  99947. * @param defines defines the material defines to update
  99948. */
  99949. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99950. /**
  99951. * Checks if the block is ready
  99952. * @param mesh defines the mesh to be rendered
  99953. * @param nodeMaterial defines the node material requesting the update
  99954. * @param defines defines the material defines to update
  99955. * @param useInstances specifies that instances should be used
  99956. * @returns true if the block is ready
  99957. */
  99958. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99959. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99960. private _processBuild;
  99961. /**
  99962. * Validates the new name for the block node.
  99963. * @param newName the new name to be given to the node.
  99964. * @returns false if the name is a reserve word, else true.
  99965. */
  99966. validateBlockName(newName: string): boolean;
  99967. /**
  99968. * Compile the current node and generate the shader code
  99969. * @param state defines the current compilation state (uniforms, samplers, current string)
  99970. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99971. * @returns true if already built
  99972. */
  99973. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99974. protected _inputRename(name: string): string;
  99975. protected _outputRename(name: string): string;
  99976. protected _dumpPropertiesCode(): string;
  99977. /** @hidden */
  99978. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99979. /** @hidden */
  99980. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99981. /**
  99982. * Clone the current block to a new identical block
  99983. * @param scene defines the hosting scene
  99984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99985. * @returns a copy of the current block
  99986. */
  99987. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99988. /**
  99989. * Serializes this block in a JSON representation
  99990. * @returns the serialized block object
  99991. */
  99992. serialize(): any;
  99993. /** @hidden */
  99994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99995. private _deserializePortDisplayNamesAndExposedOnFrame;
  99996. /**
  99997. * Release resources
  99998. */
  99999. dispose(): void;
  100000. }
  100001. }
  100002. declare module BABYLON {
  100003. /**
  100004. * Base class of materials working in push mode in babylon JS
  100005. * @hidden
  100006. */
  100007. export class PushMaterial extends Material {
  100008. protected _activeEffect: Effect;
  100009. protected _normalMatrix: Matrix;
  100010. constructor(name: string, scene: Scene);
  100011. getEffect(): Effect;
  100012. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100013. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100014. /**
  100015. * Binds the given world matrix to the active effect
  100016. *
  100017. * @param world the matrix to bind
  100018. */
  100019. bindOnlyWorldMatrix(world: Matrix): void;
  100020. /**
  100021. * Binds the given normal matrix to the active effect
  100022. *
  100023. * @param normalMatrix the matrix to bind
  100024. */
  100025. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100026. bind(world: Matrix, mesh?: Mesh): void;
  100027. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100028. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100029. }
  100030. }
  100031. declare module BABYLON {
  100032. /**
  100033. * Root class for all node material optimizers
  100034. */
  100035. export class NodeMaterialOptimizer {
  100036. /**
  100037. * Function used to optimize a NodeMaterial graph
  100038. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100039. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100040. */
  100041. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100042. }
  100043. }
  100044. declare module BABYLON {
  100045. /**
  100046. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100047. */
  100048. export class TransformBlock extends NodeMaterialBlock {
  100049. /**
  100050. * Defines the value to use to complement W value to transform it to a Vector4
  100051. */
  100052. complementW: number;
  100053. /**
  100054. * Defines the value to use to complement z value to transform it to a Vector4
  100055. */
  100056. complementZ: number;
  100057. /**
  100058. * Creates a new TransformBlock
  100059. * @param name defines the block name
  100060. */
  100061. constructor(name: string);
  100062. /**
  100063. * Gets the current class name
  100064. * @returns the class name
  100065. */
  100066. getClassName(): string;
  100067. /**
  100068. * Gets the vector input
  100069. */
  100070. get vector(): NodeMaterialConnectionPoint;
  100071. /**
  100072. * Gets the output component
  100073. */
  100074. get output(): NodeMaterialConnectionPoint;
  100075. /**
  100076. * Gets the xyz output component
  100077. */
  100078. get xyz(): NodeMaterialConnectionPoint;
  100079. /**
  100080. * Gets the matrix transform input
  100081. */
  100082. get transform(): NodeMaterialConnectionPoint;
  100083. protected _buildBlock(state: NodeMaterialBuildState): this;
  100084. /**
  100085. * Update defines for shader compilation
  100086. * @param mesh defines the mesh to be rendered
  100087. * @param nodeMaterial defines the node material requesting the update
  100088. * @param defines defines the material defines to update
  100089. * @param useInstances specifies that instances should be used
  100090. * @param subMesh defines which submesh to render
  100091. */
  100092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100093. serialize(): any;
  100094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100095. protected _dumpPropertiesCode(): string;
  100096. }
  100097. }
  100098. declare module BABYLON {
  100099. /**
  100100. * Block used to output the vertex position
  100101. */
  100102. export class VertexOutputBlock extends NodeMaterialBlock {
  100103. /**
  100104. * Creates a new VertexOutputBlock
  100105. * @param name defines the block name
  100106. */
  100107. constructor(name: string);
  100108. /**
  100109. * Gets the current class name
  100110. * @returns the class name
  100111. */
  100112. getClassName(): string;
  100113. /**
  100114. * Gets the vector input component
  100115. */
  100116. get vector(): NodeMaterialConnectionPoint;
  100117. protected _buildBlock(state: NodeMaterialBuildState): this;
  100118. }
  100119. }
  100120. declare module BABYLON {
  100121. /**
  100122. * Block used to output the final color
  100123. */
  100124. export class FragmentOutputBlock extends NodeMaterialBlock {
  100125. /**
  100126. * Create a new FragmentOutputBlock
  100127. * @param name defines the block name
  100128. */
  100129. constructor(name: string);
  100130. /**
  100131. * Gets the current class name
  100132. * @returns the class name
  100133. */
  100134. getClassName(): string;
  100135. /**
  100136. * Gets the rgba input component
  100137. */
  100138. get rgba(): NodeMaterialConnectionPoint;
  100139. /**
  100140. * Gets the rgb input component
  100141. */
  100142. get rgb(): NodeMaterialConnectionPoint;
  100143. /**
  100144. * Gets the a input component
  100145. */
  100146. get a(): NodeMaterialConnectionPoint;
  100147. protected _buildBlock(state: NodeMaterialBuildState): this;
  100148. }
  100149. }
  100150. declare module BABYLON {
  100151. /**
  100152. * Block used for the particle ramp gradient section
  100153. */
  100154. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100155. /**
  100156. * Create a new ParticleRampGradientBlock
  100157. * @param name defines the block name
  100158. */
  100159. constructor(name: string);
  100160. /**
  100161. * Gets the current class name
  100162. * @returns the class name
  100163. */
  100164. getClassName(): string;
  100165. /**
  100166. * Gets the color input component
  100167. */
  100168. get color(): NodeMaterialConnectionPoint;
  100169. /**
  100170. * Gets the rampColor output component
  100171. */
  100172. get rampColor(): NodeMaterialConnectionPoint;
  100173. /**
  100174. * Initialize the block and prepare the context for build
  100175. * @param state defines the state that will be used for the build
  100176. */
  100177. initialize(state: NodeMaterialBuildState): void;
  100178. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100179. }
  100180. }
  100181. declare module BABYLON {
  100182. /**
  100183. * Block used for the particle blend multiply section
  100184. */
  100185. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100186. /**
  100187. * Create a new ParticleBlendMultiplyBlock
  100188. * @param name defines the block name
  100189. */
  100190. constructor(name: string);
  100191. /**
  100192. * Gets the current class name
  100193. * @returns the class name
  100194. */
  100195. getClassName(): string;
  100196. /**
  100197. * Gets the color input component
  100198. */
  100199. get color(): NodeMaterialConnectionPoint;
  100200. /**
  100201. * Gets the alphaTexture input component
  100202. */
  100203. get alphaTexture(): NodeMaterialConnectionPoint;
  100204. /**
  100205. * Gets the alphaColor input component
  100206. */
  100207. get alphaColor(): NodeMaterialConnectionPoint;
  100208. /**
  100209. * Gets the blendColor output component
  100210. */
  100211. get blendColor(): NodeMaterialConnectionPoint;
  100212. /**
  100213. * Initialize the block and prepare the context for build
  100214. * @param state defines the state that will be used for the build
  100215. */
  100216. initialize(state: NodeMaterialBuildState): void;
  100217. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100218. }
  100219. }
  100220. declare module BABYLON {
  100221. /**
  100222. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100223. */
  100224. export class VectorMergerBlock extends NodeMaterialBlock {
  100225. /**
  100226. * Create a new VectorMergerBlock
  100227. * @param name defines the block name
  100228. */
  100229. constructor(name: string);
  100230. /**
  100231. * Gets the current class name
  100232. * @returns the class name
  100233. */
  100234. getClassName(): string;
  100235. /**
  100236. * Gets the xyz component (input)
  100237. */
  100238. get xyzIn(): NodeMaterialConnectionPoint;
  100239. /**
  100240. * Gets the xy component (input)
  100241. */
  100242. get xyIn(): NodeMaterialConnectionPoint;
  100243. /**
  100244. * Gets the x component (input)
  100245. */
  100246. get x(): NodeMaterialConnectionPoint;
  100247. /**
  100248. * Gets the y component (input)
  100249. */
  100250. get y(): NodeMaterialConnectionPoint;
  100251. /**
  100252. * Gets the z component (input)
  100253. */
  100254. get z(): NodeMaterialConnectionPoint;
  100255. /**
  100256. * Gets the w component (input)
  100257. */
  100258. get w(): NodeMaterialConnectionPoint;
  100259. /**
  100260. * Gets the xyzw component (output)
  100261. */
  100262. get xyzw(): NodeMaterialConnectionPoint;
  100263. /**
  100264. * Gets the xyz component (output)
  100265. */
  100266. get xyzOut(): NodeMaterialConnectionPoint;
  100267. /**
  100268. * Gets the xy component (output)
  100269. */
  100270. get xyOut(): NodeMaterialConnectionPoint;
  100271. /**
  100272. * Gets the xy component (output)
  100273. * @deprecated Please use xyOut instead.
  100274. */
  100275. get xy(): NodeMaterialConnectionPoint;
  100276. /**
  100277. * Gets the xyz component (output)
  100278. * @deprecated Please use xyzOut instead.
  100279. */
  100280. get xyz(): NodeMaterialConnectionPoint;
  100281. protected _buildBlock(state: NodeMaterialBuildState): this;
  100282. }
  100283. }
  100284. declare module BABYLON {
  100285. /**
  100286. * Block used to remap a float from a range to a new one
  100287. */
  100288. export class RemapBlock extends NodeMaterialBlock {
  100289. /**
  100290. * Gets or sets the source range
  100291. */
  100292. sourceRange: Vector2;
  100293. /**
  100294. * Gets or sets the target range
  100295. */
  100296. targetRange: Vector2;
  100297. /**
  100298. * Creates a new RemapBlock
  100299. * @param name defines the block name
  100300. */
  100301. constructor(name: string);
  100302. /**
  100303. * Gets the current class name
  100304. * @returns the class name
  100305. */
  100306. getClassName(): string;
  100307. /**
  100308. * Gets the input component
  100309. */
  100310. get input(): NodeMaterialConnectionPoint;
  100311. /**
  100312. * Gets the source min input component
  100313. */
  100314. get sourceMin(): NodeMaterialConnectionPoint;
  100315. /**
  100316. * Gets the source max input component
  100317. */
  100318. get sourceMax(): NodeMaterialConnectionPoint;
  100319. /**
  100320. * Gets the target min input component
  100321. */
  100322. get targetMin(): NodeMaterialConnectionPoint;
  100323. /**
  100324. * Gets the target max input component
  100325. */
  100326. get targetMax(): NodeMaterialConnectionPoint;
  100327. /**
  100328. * Gets the output component
  100329. */
  100330. get output(): NodeMaterialConnectionPoint;
  100331. protected _buildBlock(state: NodeMaterialBuildState): this;
  100332. protected _dumpPropertiesCode(): string;
  100333. serialize(): any;
  100334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100335. }
  100336. }
  100337. declare module BABYLON {
  100338. /**
  100339. * Block used to multiply 2 values
  100340. */
  100341. export class MultiplyBlock extends NodeMaterialBlock {
  100342. /**
  100343. * Creates a new MultiplyBlock
  100344. * @param name defines the block name
  100345. */
  100346. constructor(name: string);
  100347. /**
  100348. * Gets the current class name
  100349. * @returns the class name
  100350. */
  100351. getClassName(): string;
  100352. /**
  100353. * Gets the left operand input component
  100354. */
  100355. get left(): NodeMaterialConnectionPoint;
  100356. /**
  100357. * Gets the right operand input component
  100358. */
  100359. get right(): NodeMaterialConnectionPoint;
  100360. /**
  100361. * Gets the output component
  100362. */
  100363. get output(): NodeMaterialConnectionPoint;
  100364. protected _buildBlock(state: NodeMaterialBuildState): this;
  100365. }
  100366. }
  100367. declare module BABYLON {
  100368. /**
  100369. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100370. */
  100371. export class ColorSplitterBlock extends NodeMaterialBlock {
  100372. /**
  100373. * Create a new ColorSplitterBlock
  100374. * @param name defines the block name
  100375. */
  100376. constructor(name: string);
  100377. /**
  100378. * Gets the current class name
  100379. * @returns the class name
  100380. */
  100381. getClassName(): string;
  100382. /**
  100383. * Gets the rgba component (input)
  100384. */
  100385. get rgba(): NodeMaterialConnectionPoint;
  100386. /**
  100387. * Gets the rgb component (input)
  100388. */
  100389. get rgbIn(): NodeMaterialConnectionPoint;
  100390. /**
  100391. * Gets the rgb component (output)
  100392. */
  100393. get rgbOut(): NodeMaterialConnectionPoint;
  100394. /**
  100395. * Gets the r component (output)
  100396. */
  100397. get r(): NodeMaterialConnectionPoint;
  100398. /**
  100399. * Gets the g component (output)
  100400. */
  100401. get g(): NodeMaterialConnectionPoint;
  100402. /**
  100403. * Gets the b component (output)
  100404. */
  100405. get b(): NodeMaterialConnectionPoint;
  100406. /**
  100407. * Gets the a component (output)
  100408. */
  100409. get a(): NodeMaterialConnectionPoint;
  100410. protected _inputRename(name: string): string;
  100411. protected _outputRename(name: string): string;
  100412. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100413. }
  100414. }
  100415. declare module BABYLON {
  100416. /**
  100417. * Interface used to configure the node material editor
  100418. */
  100419. export interface INodeMaterialEditorOptions {
  100420. /** Define the URl to load node editor script */
  100421. editorURL?: string;
  100422. }
  100423. /** @hidden */
  100424. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100425. NORMAL: boolean;
  100426. TANGENT: boolean;
  100427. UV1: boolean;
  100428. /** BONES */
  100429. NUM_BONE_INFLUENCERS: number;
  100430. BonesPerMesh: number;
  100431. BONETEXTURE: boolean;
  100432. /** MORPH TARGETS */
  100433. MORPHTARGETS: boolean;
  100434. MORPHTARGETS_NORMAL: boolean;
  100435. MORPHTARGETS_TANGENT: boolean;
  100436. MORPHTARGETS_UV: boolean;
  100437. NUM_MORPH_INFLUENCERS: number;
  100438. /** IMAGE PROCESSING */
  100439. IMAGEPROCESSING: boolean;
  100440. VIGNETTE: boolean;
  100441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100442. VIGNETTEBLENDMODEOPAQUE: boolean;
  100443. TONEMAPPING: boolean;
  100444. TONEMAPPING_ACES: boolean;
  100445. CONTRAST: boolean;
  100446. EXPOSURE: boolean;
  100447. COLORCURVES: boolean;
  100448. COLORGRADING: boolean;
  100449. COLORGRADING3D: boolean;
  100450. SAMPLER3DGREENDEPTH: boolean;
  100451. SAMPLER3DBGRMAP: boolean;
  100452. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100453. /** MISC. */
  100454. BUMPDIRECTUV: number;
  100455. constructor();
  100456. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100457. }
  100458. /**
  100459. * Class used to configure NodeMaterial
  100460. */
  100461. export interface INodeMaterialOptions {
  100462. /**
  100463. * Defines if blocks should emit comments
  100464. */
  100465. emitComments: boolean;
  100466. }
  100467. /**
  100468. * Class used to create a node based material built by assembling shader blocks
  100469. */
  100470. export class NodeMaterial extends PushMaterial {
  100471. private static _BuildIdGenerator;
  100472. private _options;
  100473. private _vertexCompilationState;
  100474. private _fragmentCompilationState;
  100475. private _sharedData;
  100476. private _buildId;
  100477. private _buildWasSuccessful;
  100478. private _cachedWorldViewMatrix;
  100479. private _cachedWorldViewProjectionMatrix;
  100480. private _optimizers;
  100481. private _animationFrame;
  100482. /** Define the Url to load node editor script */
  100483. static EditorURL: string;
  100484. /** Define the Url to load snippets */
  100485. static SnippetUrl: string;
  100486. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100487. static IgnoreTexturesAtLoadTime: boolean;
  100488. private BJSNODEMATERIALEDITOR;
  100489. /** Get the inspector from bundle or global */
  100490. private _getGlobalNodeMaterialEditor;
  100491. /**
  100492. * Snippet ID if the material was created from the snippet server
  100493. */
  100494. snippetId: string;
  100495. /**
  100496. * Gets or sets data used by visual editor
  100497. * @see https://nme.babylonjs.com
  100498. */
  100499. editorData: any;
  100500. /**
  100501. * 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)
  100502. */
  100503. ignoreAlpha: boolean;
  100504. /**
  100505. * Defines the maximum number of lights that can be used in the material
  100506. */
  100507. maxSimultaneousLights: number;
  100508. /**
  100509. * Observable raised when the material is built
  100510. */
  100511. onBuildObservable: Observable<NodeMaterial>;
  100512. /**
  100513. * Gets or sets the root nodes of the material vertex shader
  100514. */
  100515. _vertexOutputNodes: NodeMaterialBlock[];
  100516. /**
  100517. * Gets or sets the root nodes of the material fragment (pixel) shader
  100518. */
  100519. _fragmentOutputNodes: NodeMaterialBlock[];
  100520. /** Gets or sets options to control the node material overall behavior */
  100521. get options(): INodeMaterialOptions;
  100522. set options(options: INodeMaterialOptions);
  100523. /**
  100524. * Default configuration related to image processing available in the standard Material.
  100525. */
  100526. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100527. /**
  100528. * Gets the image processing configuration used either in this material.
  100529. */
  100530. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100531. /**
  100532. * Sets the Default image processing configuration used either in the this material.
  100533. *
  100534. * If sets to null, the scene one is in use.
  100535. */
  100536. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100537. /**
  100538. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100539. */
  100540. attachedBlocks: NodeMaterialBlock[];
  100541. /**
  100542. * Specifies the mode of the node material
  100543. * @hidden
  100544. */
  100545. _mode: NodeMaterialModes;
  100546. /**
  100547. * Gets the mode property
  100548. */
  100549. get mode(): NodeMaterialModes;
  100550. /**
  100551. * Create a new node based material
  100552. * @param name defines the material name
  100553. * @param scene defines the hosting scene
  100554. * @param options defines creation option
  100555. */
  100556. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100557. /**
  100558. * Gets the current class name of the material e.g. "NodeMaterial"
  100559. * @returns the class name
  100560. */
  100561. getClassName(): string;
  100562. /**
  100563. * Keep track of the image processing observer to allow dispose and replace.
  100564. */
  100565. private _imageProcessingObserver;
  100566. /**
  100567. * Attaches a new image processing configuration to the Standard Material.
  100568. * @param configuration
  100569. */
  100570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100571. /**
  100572. * Get a block by its name
  100573. * @param name defines the name of the block to retrieve
  100574. * @returns the required block or null if not found
  100575. */
  100576. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100577. /**
  100578. * Get a block by its name
  100579. * @param predicate defines the predicate used to find the good candidate
  100580. * @returns the required block or null if not found
  100581. */
  100582. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100583. /**
  100584. * Get an input block by its name
  100585. * @param predicate defines the predicate used to find the good candidate
  100586. * @returns the required input block or null if not found
  100587. */
  100588. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100589. /**
  100590. * Gets the list of input blocks attached to this material
  100591. * @returns an array of InputBlocks
  100592. */
  100593. getInputBlocks(): InputBlock[];
  100594. /**
  100595. * Adds a new optimizer to the list of optimizers
  100596. * @param optimizer defines the optimizers to add
  100597. * @returns the current material
  100598. */
  100599. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100600. /**
  100601. * Remove an optimizer from the list of optimizers
  100602. * @param optimizer defines the optimizers to remove
  100603. * @returns the current material
  100604. */
  100605. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100606. /**
  100607. * Add a new block to the list of output nodes
  100608. * @param node defines the node to add
  100609. * @returns the current material
  100610. */
  100611. addOutputNode(node: NodeMaterialBlock): this;
  100612. /**
  100613. * Remove a block from the list of root nodes
  100614. * @param node defines the node to remove
  100615. * @returns the current material
  100616. */
  100617. removeOutputNode(node: NodeMaterialBlock): this;
  100618. private _addVertexOutputNode;
  100619. private _removeVertexOutputNode;
  100620. private _addFragmentOutputNode;
  100621. private _removeFragmentOutputNode;
  100622. /**
  100623. * Specifies if the material will require alpha blending
  100624. * @returns a boolean specifying if alpha blending is needed
  100625. */
  100626. needAlphaBlending(): boolean;
  100627. /**
  100628. * Specifies if this material should be rendered in alpha test mode
  100629. * @returns a boolean specifying if an alpha test is needed.
  100630. */
  100631. needAlphaTesting(): boolean;
  100632. private _initializeBlock;
  100633. private _resetDualBlocks;
  100634. /**
  100635. * Remove a block from the current node material
  100636. * @param block defines the block to remove
  100637. */
  100638. removeBlock(block: NodeMaterialBlock): void;
  100639. /**
  100640. * Build the material and generates the inner effect
  100641. * @param verbose defines if the build should log activity
  100642. */
  100643. build(verbose?: boolean): void;
  100644. /**
  100645. * Runs an otpimization phase to try to improve the shader code
  100646. */
  100647. optimize(): void;
  100648. private _prepareDefinesForAttributes;
  100649. /**
  100650. * Create a post process from the material
  100651. * @param camera The camera to apply the render pass to.
  100652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100654. * @param engine The engine which the post process will be applied. (default: current engine)
  100655. * @param reusable If the post process can be reused on the same frame. (default: false)
  100656. * @param textureType Type of textures used when performing the post process. (default: 0)
  100657. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100658. * @returns the post process created
  100659. */
  100660. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100661. /**
  100662. * Create the post process effect from the material
  100663. * @param postProcess The post process to create the effect for
  100664. */
  100665. createEffectForPostProcess(postProcess: PostProcess): void;
  100666. private _createEffectOrPostProcess;
  100667. private _createEffectForParticles;
  100668. /**
  100669. * Create the effect to be used as the custom effect for a particle system
  100670. * @param particleSystem Particle system to create the effect for
  100671. * @param onCompiled defines a function to call when the effect creation is successful
  100672. * @param onError defines a function to call when the effect creation has failed
  100673. */
  100674. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100675. private _processDefines;
  100676. /**
  100677. * Get if the submesh is ready to be used and all its information available.
  100678. * Child classes can use it to update shaders
  100679. * @param mesh defines the mesh to check
  100680. * @param subMesh defines which submesh to check
  100681. * @param useInstances specifies that instances should be used
  100682. * @returns a boolean indicating that the submesh is ready or not
  100683. */
  100684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100685. /**
  100686. * Get a string representing the shaders built by the current node graph
  100687. */
  100688. get compiledShaders(): string;
  100689. /**
  100690. * Binds the world matrix to the material
  100691. * @param world defines the world transformation matrix
  100692. */
  100693. bindOnlyWorldMatrix(world: Matrix): void;
  100694. /**
  100695. * Binds the submesh to this material by preparing the effect and shader to draw
  100696. * @param world defines the world transformation matrix
  100697. * @param mesh defines the mesh containing the submesh
  100698. * @param subMesh defines the submesh to bind the material to
  100699. */
  100700. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100701. /**
  100702. * Gets the active textures from the material
  100703. * @returns an array of textures
  100704. */
  100705. getActiveTextures(): BaseTexture[];
  100706. /**
  100707. * Gets the list of texture blocks
  100708. * @returns an array of texture blocks
  100709. */
  100710. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100711. /**
  100712. * Specifies if the material uses a texture
  100713. * @param texture defines the texture to check against the material
  100714. * @returns a boolean specifying if the material uses the texture
  100715. */
  100716. hasTexture(texture: BaseTexture): boolean;
  100717. /**
  100718. * Disposes the material
  100719. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100720. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100721. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100722. */
  100723. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100724. /** Creates the node editor window. */
  100725. private _createNodeEditor;
  100726. /**
  100727. * Launch the node material editor
  100728. * @param config Define the configuration of the editor
  100729. * @return a promise fulfilled when the node editor is visible
  100730. */
  100731. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100732. /**
  100733. * Clear the current material
  100734. */
  100735. clear(): void;
  100736. /**
  100737. * Clear the current material and set it to a default state
  100738. */
  100739. setToDefault(): void;
  100740. /**
  100741. * Clear the current material and set it to a default state for post process
  100742. */
  100743. setToDefaultPostProcess(): void;
  100744. /**
  100745. * Clear the current material and set it to a default state for particle
  100746. */
  100747. setToDefaultParticle(): void;
  100748. /**
  100749. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100750. * @param url defines the url to load from
  100751. * @returns a promise that will fullfil when the material is fully loaded
  100752. */
  100753. loadAsync(url: string): Promise<void>;
  100754. private _gatherBlocks;
  100755. /**
  100756. * Generate a string containing the code declaration required to create an equivalent of this material
  100757. * @returns a string
  100758. */
  100759. generateCode(): string;
  100760. /**
  100761. * Serializes this material in a JSON representation
  100762. * @returns the serialized material object
  100763. */
  100764. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100765. private _restoreConnections;
  100766. /**
  100767. * Clear the current graph and load a new one from a serialization object
  100768. * @param source defines the JSON representation of the material
  100769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100770. * @param merge defines whether or not the source must be merged or replace the current content
  100771. */
  100772. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100773. /**
  100774. * Makes a duplicate of the current material.
  100775. * @param name - name to use for the new material.
  100776. */
  100777. clone(name: string): NodeMaterial;
  100778. /**
  100779. * Creates a node material from parsed material data
  100780. * @param source defines the JSON representation of the material
  100781. * @param scene defines the hosting scene
  100782. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100783. * @returns a new node material
  100784. */
  100785. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100786. /**
  100787. * Creates a node material from a snippet saved in a remote file
  100788. * @param name defines the name of the material to create
  100789. * @param url defines the url to load from
  100790. * @param scene defines the hosting scene
  100791. * @returns a promise that will resolve to the new node material
  100792. */
  100793. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100794. /**
  100795. * Creates a node material from a snippet saved by the node material editor
  100796. * @param snippetId defines the snippet to load
  100797. * @param scene defines the hosting scene
  100798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100799. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100800. * @returns a promise that will resolve to the new node material
  100801. */
  100802. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100803. /**
  100804. * Creates a new node material set to default basic configuration
  100805. * @param name defines the name of the material
  100806. * @param scene defines the hosting scene
  100807. * @returns a new NodeMaterial
  100808. */
  100809. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100810. }
  100811. }
  100812. declare module BABYLON {
  100813. /**
  100814. * Size options for a post process
  100815. */
  100816. export type PostProcessOptions = {
  100817. width: number;
  100818. height: number;
  100819. };
  100820. /**
  100821. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100822. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100823. */
  100824. export class PostProcess {
  100825. /** Name of the PostProcess. */
  100826. name: string;
  100827. /**
  100828. * Gets or sets the unique id of the post process
  100829. */
  100830. uniqueId: number;
  100831. /**
  100832. * Width of the texture to apply the post process on
  100833. */
  100834. width: number;
  100835. /**
  100836. * Height of the texture to apply the post process on
  100837. */
  100838. height: number;
  100839. /**
  100840. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100841. */
  100842. nodeMaterialSource: Nullable<NodeMaterial>;
  100843. /**
  100844. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100845. * @hidden
  100846. */
  100847. _outputTexture: Nullable<InternalTexture>;
  100848. /**
  100849. * Sampling mode used by the shader
  100850. * See https://doc.babylonjs.com/classes/3.1/texture
  100851. */
  100852. renderTargetSamplingMode: number;
  100853. /**
  100854. * Clear color to use when screen clearing
  100855. */
  100856. clearColor: Color4;
  100857. /**
  100858. * If the buffer needs to be cleared before applying the post process. (default: true)
  100859. * Should be set to false if shader will overwrite all previous pixels.
  100860. */
  100861. autoClear: boolean;
  100862. /**
  100863. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100864. */
  100865. alphaMode: number;
  100866. /**
  100867. * Sets the setAlphaBlendConstants of the babylon engine
  100868. */
  100869. alphaConstants: Color4;
  100870. /**
  100871. * Animations to be used for the post processing
  100872. */
  100873. animations: Animation[];
  100874. /**
  100875. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100876. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100877. */
  100878. enablePixelPerfectMode: boolean;
  100879. /**
  100880. * Force the postprocess to be applied without taking in account viewport
  100881. */
  100882. forceFullscreenViewport: boolean;
  100883. /**
  100884. * List of inspectable custom properties (used by the Inspector)
  100885. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100886. */
  100887. inspectableCustomProperties: IInspectable[];
  100888. /**
  100889. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100890. *
  100891. * | Value | Type | Description |
  100892. * | ----- | ----------------------------------- | ----------- |
  100893. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100894. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100895. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100896. *
  100897. */
  100898. scaleMode: number;
  100899. /**
  100900. * Force textures to be a power of two (default: false)
  100901. */
  100902. alwaysForcePOT: boolean;
  100903. private _samples;
  100904. /**
  100905. * Number of sample textures (default: 1)
  100906. */
  100907. get samples(): number;
  100908. set samples(n: number);
  100909. /**
  100910. * Modify the scale of the post process to be the same as the viewport (default: false)
  100911. */
  100912. adaptScaleToCurrentViewport: boolean;
  100913. private _camera;
  100914. protected _scene: Scene;
  100915. private _engine;
  100916. private _options;
  100917. private _reusable;
  100918. private _textureType;
  100919. private _textureFormat;
  100920. /**
  100921. * Smart array of input and output textures for the post process.
  100922. * @hidden
  100923. */
  100924. _textures: SmartArray<InternalTexture>;
  100925. /**
  100926. * The index in _textures that corresponds to the output texture.
  100927. * @hidden
  100928. */
  100929. _currentRenderTextureInd: number;
  100930. private _effect;
  100931. private _samplers;
  100932. private _fragmentUrl;
  100933. private _vertexUrl;
  100934. private _parameters;
  100935. private _scaleRatio;
  100936. protected _indexParameters: any;
  100937. private _shareOutputWithPostProcess;
  100938. private _texelSize;
  100939. private _forcedOutputTexture;
  100940. /**
  100941. * Returns the fragment url or shader name used in the post process.
  100942. * @returns the fragment url or name in the shader store.
  100943. */
  100944. getEffectName(): string;
  100945. /**
  100946. * An event triggered when the postprocess is activated.
  100947. */
  100948. onActivateObservable: Observable<Camera>;
  100949. private _onActivateObserver;
  100950. /**
  100951. * A function that is added to the onActivateObservable
  100952. */
  100953. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100954. /**
  100955. * An event triggered when the postprocess changes its size.
  100956. */
  100957. onSizeChangedObservable: Observable<PostProcess>;
  100958. private _onSizeChangedObserver;
  100959. /**
  100960. * A function that is added to the onSizeChangedObservable
  100961. */
  100962. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100963. /**
  100964. * An event triggered when the postprocess applies its effect.
  100965. */
  100966. onApplyObservable: Observable<Effect>;
  100967. private _onApplyObserver;
  100968. /**
  100969. * A function that is added to the onApplyObservable
  100970. */
  100971. set onApply(callback: (effect: Effect) => void);
  100972. /**
  100973. * An event triggered before rendering the postprocess
  100974. */
  100975. onBeforeRenderObservable: Observable<Effect>;
  100976. private _onBeforeRenderObserver;
  100977. /**
  100978. * A function that is added to the onBeforeRenderObservable
  100979. */
  100980. set onBeforeRender(callback: (effect: Effect) => void);
  100981. /**
  100982. * An event triggered after rendering the postprocess
  100983. */
  100984. onAfterRenderObservable: Observable<Effect>;
  100985. private _onAfterRenderObserver;
  100986. /**
  100987. * A function that is added to the onAfterRenderObservable
  100988. */
  100989. set onAfterRender(callback: (efect: Effect) => void);
  100990. /**
  100991. * 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
  100992. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100993. */
  100994. get inputTexture(): InternalTexture;
  100995. set inputTexture(value: InternalTexture);
  100996. /**
  100997. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  100998. * the only way to unset it is to use this function to restore its internal state
  100999. */
  101000. restoreDefaultInputTexture(): void;
  101001. /**
  101002. * Gets the camera which post process is applied to.
  101003. * @returns The camera the post process is applied to.
  101004. */
  101005. getCamera(): Camera;
  101006. /**
  101007. * Gets the texel size of the postprocess.
  101008. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101009. */
  101010. get texelSize(): Vector2;
  101011. /**
  101012. * Creates a new instance PostProcess
  101013. * @param name The name of the PostProcess.
  101014. * @param fragmentUrl The url of the fragment shader to be used.
  101015. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101016. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101018. * @param camera The camera to apply the render pass to.
  101019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101020. * @param engine The engine which the post process will be applied. (default: current engine)
  101021. * @param reusable If the post process can be reused on the same frame. (default: false)
  101022. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101023. * @param textureType Type of textures used when performing the post process. (default: 0)
  101024. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101025. * @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
  101026. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101027. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101028. */
  101029. constructor(
  101030. /** Name of the PostProcess. */
  101031. 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);
  101032. /**
  101033. * Gets a string idenfifying the name of the class
  101034. * @returns "PostProcess" string
  101035. */
  101036. getClassName(): string;
  101037. /**
  101038. * Gets the engine which this post process belongs to.
  101039. * @returns The engine the post process was enabled with.
  101040. */
  101041. getEngine(): Engine;
  101042. /**
  101043. * The effect that is created when initializing the post process.
  101044. * @returns The created effect corresponding the the postprocess.
  101045. */
  101046. getEffect(): Effect;
  101047. /**
  101048. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101049. * @param postProcess The post process to share the output with.
  101050. * @returns This post process.
  101051. */
  101052. shareOutputWith(postProcess: PostProcess): PostProcess;
  101053. /**
  101054. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101055. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101056. */
  101057. useOwnOutput(): void;
  101058. /**
  101059. * Updates the effect with the current post process compile time values and recompiles the shader.
  101060. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101061. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101062. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101063. * @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
  101064. * @param onCompiled Called when the shader has been compiled.
  101065. * @param onError Called if there is an error when compiling a shader.
  101066. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101067. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101068. */
  101069. 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;
  101070. /**
  101071. * The post process is reusable if it can be used multiple times within one frame.
  101072. * @returns If the post process is reusable
  101073. */
  101074. isReusable(): boolean;
  101075. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101076. markTextureDirty(): void;
  101077. /**
  101078. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101079. * 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.
  101080. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101081. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101082. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101083. * @returns The target texture that was bound to be written to.
  101084. */
  101085. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101086. /**
  101087. * If the post process is supported.
  101088. */
  101089. get isSupported(): boolean;
  101090. /**
  101091. * The aspect ratio of the output texture.
  101092. */
  101093. get aspectRatio(): number;
  101094. /**
  101095. * Get a value indicating if the post-process is ready to be used
  101096. * @returns true if the post-process is ready (shader is compiled)
  101097. */
  101098. isReady(): boolean;
  101099. /**
  101100. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101101. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101102. */
  101103. apply(): Nullable<Effect>;
  101104. private _disposeTextures;
  101105. /**
  101106. * Disposes the post process.
  101107. * @param camera The camera to dispose the post process on.
  101108. */
  101109. dispose(camera?: Camera): void;
  101110. }
  101111. }
  101112. declare module BABYLON {
  101113. /** @hidden */
  101114. export var kernelBlurVaryingDeclaration: {
  101115. name: string;
  101116. shader: string;
  101117. };
  101118. }
  101119. declare module BABYLON {
  101120. /** @hidden */
  101121. export var kernelBlurFragment: {
  101122. name: string;
  101123. shader: string;
  101124. };
  101125. }
  101126. declare module BABYLON {
  101127. /** @hidden */
  101128. export var kernelBlurFragment2: {
  101129. name: string;
  101130. shader: string;
  101131. };
  101132. }
  101133. declare module BABYLON {
  101134. /** @hidden */
  101135. export var kernelBlurPixelShader: {
  101136. name: string;
  101137. shader: string;
  101138. };
  101139. }
  101140. declare module BABYLON {
  101141. /** @hidden */
  101142. export var kernelBlurVertex: {
  101143. name: string;
  101144. shader: string;
  101145. };
  101146. }
  101147. declare module BABYLON {
  101148. /** @hidden */
  101149. export var kernelBlurVertexShader: {
  101150. name: string;
  101151. shader: string;
  101152. };
  101153. }
  101154. declare module BABYLON {
  101155. /**
  101156. * The Blur Post Process which blurs an image based on a kernel and direction.
  101157. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101158. */
  101159. export class BlurPostProcess extends PostProcess {
  101160. /** The direction in which to blur the image. */
  101161. direction: Vector2;
  101162. private blockCompilation;
  101163. protected _kernel: number;
  101164. protected _idealKernel: number;
  101165. protected _packedFloat: boolean;
  101166. private _staticDefines;
  101167. /**
  101168. * Sets the length in pixels of the blur sample region
  101169. */
  101170. set kernel(v: number);
  101171. /**
  101172. * Gets the length in pixels of the blur sample region
  101173. */
  101174. get kernel(): number;
  101175. /**
  101176. * Sets wether or not the blur needs to unpack/repack floats
  101177. */
  101178. set packedFloat(v: boolean);
  101179. /**
  101180. * Gets wether or not the blur is unpacking/repacking floats
  101181. */
  101182. get packedFloat(): boolean;
  101183. /**
  101184. * Creates a new instance BlurPostProcess
  101185. * @param name The name of the effect.
  101186. * @param direction The direction in which to blur the image.
  101187. * @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.
  101188. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101189. * @param camera The camera to apply the render pass to.
  101190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101191. * @param engine The engine which the post process will be applied. (default: current engine)
  101192. * @param reusable If the post process can be reused on the same frame. (default: false)
  101193. * @param textureType Type of textures used when performing the post process. (default: 0)
  101194. * @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)
  101195. */
  101196. constructor(name: string,
  101197. /** The direction in which to blur the image. */
  101198. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101199. /**
  101200. * Updates the effect with the current post process compile time values and recompiles the shader.
  101201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101204. * @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
  101205. * @param onCompiled Called when the shader has been compiled.
  101206. * @param onError Called if there is an error when compiling a shader.
  101207. */
  101208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101209. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101210. /**
  101211. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101212. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101213. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101214. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101215. * The gaps between physical kernels are compensated for in the weighting of the samples
  101216. * @param idealKernel Ideal blur kernel.
  101217. * @return Nearest best kernel.
  101218. */
  101219. protected _nearestBestKernel(idealKernel: number): number;
  101220. /**
  101221. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101222. * @param x The point on the Gaussian distribution to sample.
  101223. * @return the value of the Gaussian function at x.
  101224. */
  101225. protected _gaussianWeight(x: number): number;
  101226. /**
  101227. * Generates a string that can be used as a floating point number in GLSL.
  101228. * @param x Value to print.
  101229. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101230. * @return GLSL float string.
  101231. */
  101232. protected _glslFloat(x: number, decimalFigures?: number): string;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101238. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101239. * You can then easily use it as a reflectionTexture on a flat surface.
  101240. * In case the surface is not a plane, please consider relying on reflection probes.
  101241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101242. */
  101243. export class MirrorTexture extends RenderTargetTexture {
  101244. private scene;
  101245. /**
  101246. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101247. * 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.
  101248. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101249. */
  101250. mirrorPlane: Plane;
  101251. /**
  101252. * Define the blur ratio used to blur the reflection if needed.
  101253. */
  101254. set blurRatio(value: number);
  101255. get blurRatio(): number;
  101256. /**
  101257. * Define the adaptive blur kernel used to blur the reflection if needed.
  101258. * This will autocompute the closest best match for the `blurKernel`
  101259. */
  101260. set adaptiveBlurKernel(value: number);
  101261. /**
  101262. * Define the blur kernel used to blur the reflection if needed.
  101263. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101264. */
  101265. set blurKernel(value: number);
  101266. /**
  101267. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101268. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101269. */
  101270. set blurKernelX(value: number);
  101271. get blurKernelX(): number;
  101272. /**
  101273. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101274. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101275. */
  101276. set blurKernelY(value: number);
  101277. get blurKernelY(): number;
  101278. private _autoComputeBlurKernel;
  101279. protected _onRatioRescale(): void;
  101280. private _updateGammaSpace;
  101281. private _imageProcessingConfigChangeObserver;
  101282. private _transformMatrix;
  101283. private _mirrorMatrix;
  101284. private _savedViewMatrix;
  101285. private _blurX;
  101286. private _blurY;
  101287. private _adaptiveBlurKernel;
  101288. private _blurKernelX;
  101289. private _blurKernelY;
  101290. private _blurRatio;
  101291. /**
  101292. * Instantiates a Mirror Texture.
  101293. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101294. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101295. * You can then easily use it as a reflectionTexture on a flat surface.
  101296. * In case the surface is not a plane, please consider relying on reflection probes.
  101297. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101298. * @param name
  101299. * @param size
  101300. * @param scene
  101301. * @param generateMipMaps
  101302. * @param type
  101303. * @param samplingMode
  101304. * @param generateDepthBuffer
  101305. */
  101306. constructor(name: string, size: number | {
  101307. width: number;
  101308. height: number;
  101309. } | {
  101310. ratio: number;
  101311. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101312. private _preparePostProcesses;
  101313. /**
  101314. * Clone the mirror texture.
  101315. * @returns the cloned texture
  101316. */
  101317. clone(): MirrorTexture;
  101318. /**
  101319. * Serialize the texture to a JSON representation you could use in Parse later on
  101320. * @returns the serialized JSON representation
  101321. */
  101322. serialize(): any;
  101323. /**
  101324. * Dispose the texture and release its associated resources.
  101325. */
  101326. dispose(): void;
  101327. }
  101328. }
  101329. declare module BABYLON {
  101330. /**
  101331. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101332. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101333. */
  101334. export class Texture extends BaseTexture {
  101335. /**
  101336. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101337. */
  101338. static SerializeBuffers: boolean;
  101339. /** @hidden */
  101340. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101341. /** @hidden */
  101342. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101343. /** @hidden */
  101344. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101345. /** nearest is mag = nearest and min = nearest and mip = linear */
  101346. static readonly NEAREST_SAMPLINGMODE: number;
  101347. /** nearest is mag = nearest and min = nearest and mip = linear */
  101348. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101349. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101350. static readonly BILINEAR_SAMPLINGMODE: number;
  101351. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101352. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101353. /** Trilinear is mag = linear and min = linear and mip = linear */
  101354. static readonly TRILINEAR_SAMPLINGMODE: number;
  101355. /** Trilinear is mag = linear and min = linear and mip = linear */
  101356. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101357. /** mag = nearest and min = nearest and mip = nearest */
  101358. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101359. /** mag = nearest and min = linear and mip = nearest */
  101360. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101361. /** mag = nearest and min = linear and mip = linear */
  101362. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101363. /** mag = nearest and min = linear and mip = none */
  101364. static readonly NEAREST_LINEAR: number;
  101365. /** mag = nearest and min = nearest and mip = none */
  101366. static readonly NEAREST_NEAREST: number;
  101367. /** mag = linear and min = nearest and mip = nearest */
  101368. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101369. /** mag = linear and min = nearest and mip = linear */
  101370. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101371. /** mag = linear and min = linear and mip = none */
  101372. static readonly LINEAR_LINEAR: number;
  101373. /** mag = linear and min = nearest and mip = none */
  101374. static readonly LINEAR_NEAREST: number;
  101375. /** Explicit coordinates mode */
  101376. static readonly EXPLICIT_MODE: number;
  101377. /** Spherical coordinates mode */
  101378. static readonly SPHERICAL_MODE: number;
  101379. /** Planar coordinates mode */
  101380. static readonly PLANAR_MODE: number;
  101381. /** Cubic coordinates mode */
  101382. static readonly CUBIC_MODE: number;
  101383. /** Projection coordinates mode */
  101384. static readonly PROJECTION_MODE: number;
  101385. /** Inverse Cubic coordinates mode */
  101386. static readonly SKYBOX_MODE: number;
  101387. /** Inverse Cubic coordinates mode */
  101388. static readonly INVCUBIC_MODE: number;
  101389. /** Equirectangular coordinates mode */
  101390. static readonly EQUIRECTANGULAR_MODE: number;
  101391. /** Equirectangular Fixed coordinates mode */
  101392. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101393. /** Equirectangular Fixed Mirrored coordinates mode */
  101394. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101395. /** Texture is not repeating outside of 0..1 UVs */
  101396. static readonly CLAMP_ADDRESSMODE: number;
  101397. /** Texture is repeating outside of 0..1 UVs */
  101398. static readonly WRAP_ADDRESSMODE: number;
  101399. /** Texture is repeating and mirrored */
  101400. static readonly MIRROR_ADDRESSMODE: number;
  101401. /**
  101402. * 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
  101403. */
  101404. static UseSerializedUrlIfAny: boolean;
  101405. /**
  101406. * Define the url of the texture.
  101407. */
  101408. url: Nullable<string>;
  101409. /**
  101410. * Define an offset on the texture to offset the u coordinates of the UVs
  101411. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101412. */
  101413. uOffset: number;
  101414. /**
  101415. * Define an offset on the texture to offset the v coordinates of the UVs
  101416. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101417. */
  101418. vOffset: number;
  101419. /**
  101420. * Define an offset on the texture to scale the u coordinates of the UVs
  101421. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101422. */
  101423. uScale: number;
  101424. /**
  101425. * Define an offset on the texture to scale the v coordinates of the UVs
  101426. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101427. */
  101428. vScale: number;
  101429. /**
  101430. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101431. * @see https://doc.babylonjs.com/how_to/more_materials
  101432. */
  101433. uAng: number;
  101434. /**
  101435. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101436. * @see https://doc.babylonjs.com/how_to/more_materials
  101437. */
  101438. vAng: number;
  101439. /**
  101440. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101441. * @see https://doc.babylonjs.com/how_to/more_materials
  101442. */
  101443. wAng: number;
  101444. /**
  101445. * Defines the center of rotation (U)
  101446. */
  101447. uRotationCenter: number;
  101448. /**
  101449. * Defines the center of rotation (V)
  101450. */
  101451. vRotationCenter: number;
  101452. /**
  101453. * Defines the center of rotation (W)
  101454. */
  101455. wRotationCenter: number;
  101456. /**
  101457. * Are mip maps generated for this texture or not.
  101458. */
  101459. get noMipmap(): boolean;
  101460. /**
  101461. * List of inspectable custom properties (used by the Inspector)
  101462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101463. */
  101464. inspectableCustomProperties: Nullable<IInspectable[]>;
  101465. private _noMipmap;
  101466. /** @hidden */
  101467. _invertY: boolean;
  101468. private _rowGenerationMatrix;
  101469. private _cachedTextureMatrix;
  101470. private _projectionModeMatrix;
  101471. private _t0;
  101472. private _t1;
  101473. private _t2;
  101474. private _cachedUOffset;
  101475. private _cachedVOffset;
  101476. private _cachedUScale;
  101477. private _cachedVScale;
  101478. private _cachedUAng;
  101479. private _cachedVAng;
  101480. private _cachedWAng;
  101481. private _cachedProjectionMatrixId;
  101482. private _cachedCoordinatesMode;
  101483. /** @hidden */
  101484. protected _initialSamplingMode: number;
  101485. /** @hidden */
  101486. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101487. private _deleteBuffer;
  101488. protected _format: Nullable<number>;
  101489. private _delayedOnLoad;
  101490. private _delayedOnError;
  101491. private _mimeType?;
  101492. /**
  101493. * Observable triggered once the texture has been loaded.
  101494. */
  101495. onLoadObservable: Observable<Texture>;
  101496. protected _isBlocking: boolean;
  101497. /**
  101498. * Is the texture preventing material to render while loading.
  101499. * If false, a default texture will be used instead of the loading one during the preparation step.
  101500. */
  101501. set isBlocking(value: boolean);
  101502. get isBlocking(): boolean;
  101503. /**
  101504. * Get the current sampling mode associated with the texture.
  101505. */
  101506. get samplingMode(): number;
  101507. /**
  101508. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101509. */
  101510. get invertY(): boolean;
  101511. /**
  101512. * Instantiates a new texture.
  101513. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101514. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101515. * @param url defines the url of the picture to load as a texture
  101516. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101517. * @param noMipmap defines if the texture will require mip maps or not
  101518. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101519. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101520. * @param onLoad defines a callback triggered when the texture has been loaded
  101521. * @param onError defines a callback triggered when an error occurred during the loading session
  101522. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101523. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101524. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101525. * @param mimeType defines an optional mime type information
  101526. */
  101527. 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);
  101528. /**
  101529. * Update the url (and optional buffer) of this texture if url was null during construction.
  101530. * @param url the url of the texture
  101531. * @param buffer the buffer of the texture (defaults to null)
  101532. * @param onLoad callback called when the texture is loaded (defaults to null)
  101533. */
  101534. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101535. /**
  101536. * Finish the loading sequence of a texture flagged as delayed load.
  101537. * @hidden
  101538. */
  101539. delayLoad(): void;
  101540. private _prepareRowForTextureGeneration;
  101541. /**
  101542. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101543. * @returns the transform matrix of the texture.
  101544. */
  101545. getTextureMatrix(uBase?: number): Matrix;
  101546. /**
  101547. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101548. * @returns The reflection texture transform
  101549. */
  101550. getReflectionTextureMatrix(): Matrix;
  101551. /**
  101552. * Clones the texture.
  101553. * @returns the cloned texture
  101554. */
  101555. clone(): Texture;
  101556. /**
  101557. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101558. * @returns The JSON representation of the texture
  101559. */
  101560. serialize(): any;
  101561. /**
  101562. * Get the current class name of the texture useful for serialization or dynamic coding.
  101563. * @returns "Texture"
  101564. */
  101565. getClassName(): string;
  101566. /**
  101567. * Dispose the texture and release its associated resources.
  101568. */
  101569. dispose(): void;
  101570. /**
  101571. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101572. * @param parsedTexture Define the JSON representation of the texture
  101573. * @param scene Define the scene the parsed texture should be instantiated in
  101574. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101575. * @returns The parsed texture if successful
  101576. */
  101577. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101578. /**
  101579. * Creates a texture from its base 64 representation.
  101580. * @param data Define the base64 payload without the data: prefix
  101581. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101582. * @param scene Define the scene the texture should belong to
  101583. * @param noMipmap Forces the texture to not create mip map information if true
  101584. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101585. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101586. * @param onLoad define a callback triggered when the texture has been loaded
  101587. * @param onError define a callback triggered when an error occurred during the loading session
  101588. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101589. * @returns the created texture
  101590. */
  101591. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101592. /**
  101593. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101594. * @param data Define the base64 payload without the data: prefix
  101595. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101596. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101597. * @param scene Define the scene the texture should belong to
  101598. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101599. * @param noMipmap Forces the texture to not create mip map information if true
  101600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101602. * @param onLoad define a callback triggered when the texture has been loaded
  101603. * @param onError define a callback triggered when an error occurred during the loading session
  101604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101605. * @returns the created texture
  101606. */
  101607. 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;
  101608. }
  101609. }
  101610. declare module BABYLON {
  101611. /**
  101612. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101613. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101614. */
  101615. export class PostProcessManager {
  101616. private _scene;
  101617. private _indexBuffer;
  101618. private _vertexBuffers;
  101619. /**
  101620. * Creates a new instance PostProcess
  101621. * @param scene The scene that the post process is associated with.
  101622. */
  101623. constructor(scene: Scene);
  101624. private _prepareBuffers;
  101625. private _buildIndexBuffer;
  101626. /**
  101627. * Rebuilds the vertex buffers of the manager.
  101628. * @hidden
  101629. */
  101630. _rebuild(): void;
  101631. /**
  101632. * Prepares a frame to be run through a post process.
  101633. * @param sourceTexture The input texture to the post procesess. (default: null)
  101634. * @param postProcesses An array of post processes to be run. (default: null)
  101635. * @returns True if the post processes were able to be run.
  101636. * @hidden
  101637. */
  101638. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101639. /**
  101640. * Manually render a set of post processes to a texture.
  101641. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101642. * @param postProcesses An array of post processes to be run.
  101643. * @param targetTexture The target texture to render to.
  101644. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101645. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101646. * @param lodLevel defines which lod of the texture to render to
  101647. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101648. */
  101649. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101650. /**
  101651. * Finalize the result of the output of the postprocesses.
  101652. * @param doNotPresent If true the result will not be displayed to the screen.
  101653. * @param targetTexture The target texture to render to.
  101654. * @param faceIndex The index of the face to bind the target texture to.
  101655. * @param postProcesses The array of post processes to render.
  101656. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101657. * @hidden
  101658. */
  101659. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101660. /**
  101661. * Disposes of the post process manager.
  101662. */
  101663. dispose(): void;
  101664. }
  101665. }
  101666. declare module BABYLON {
  101667. /**
  101668. * This Helps creating a texture that will be created from a camera in your scene.
  101669. * It is basically a dynamic texture that could be used to create special effects for instance.
  101670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101671. */
  101672. export class RenderTargetTexture extends Texture {
  101673. isCube: boolean;
  101674. /**
  101675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101676. */
  101677. static readonly REFRESHRATE_RENDER_ONCE: number;
  101678. /**
  101679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101680. */
  101681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101682. /**
  101683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101684. * the central point of your effect and can save a lot of performances.
  101685. */
  101686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101687. /**
  101688. * Use this predicate to dynamically define the list of mesh you want to render.
  101689. * If set, the renderList property will be overwritten.
  101690. */
  101691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101692. private _renderList;
  101693. /**
  101694. * Use this list to define the list of mesh you want to render.
  101695. */
  101696. get renderList(): Nullable<Array<AbstractMesh>>;
  101697. set renderList(value: Nullable<Array<AbstractMesh>>);
  101698. /**
  101699. * Use this function to overload the renderList array at rendering time.
  101700. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101701. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101702. * the cube (if the RTT is a cube, else layerOrFace=0).
  101703. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101704. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101705. * hold dummy elements!
  101706. */
  101707. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101708. private _hookArray;
  101709. /**
  101710. * Define if particles should be rendered in your texture.
  101711. */
  101712. renderParticles: boolean;
  101713. /**
  101714. * Define if sprites should be rendered in your texture.
  101715. */
  101716. renderSprites: boolean;
  101717. /**
  101718. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101719. */
  101720. coordinatesMode: number;
  101721. /**
  101722. * Define the camera used to render the texture.
  101723. */
  101724. activeCamera: Nullable<Camera>;
  101725. /**
  101726. * Override the mesh isReady function with your own one.
  101727. */
  101728. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101729. /**
  101730. * Override the render function of the texture with your own one.
  101731. */
  101732. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101733. /**
  101734. * Define if camera post processes should be use while rendering the texture.
  101735. */
  101736. useCameraPostProcesses: boolean;
  101737. /**
  101738. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101739. */
  101740. ignoreCameraViewport: boolean;
  101741. private _postProcessManager;
  101742. private _postProcesses;
  101743. private _resizeObserver;
  101744. /**
  101745. * An event triggered when the texture is unbind.
  101746. */
  101747. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101748. /**
  101749. * An event triggered when the texture is unbind.
  101750. */
  101751. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101752. private _onAfterUnbindObserver;
  101753. /**
  101754. * Set a after unbind callback in the texture.
  101755. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101756. */
  101757. set onAfterUnbind(callback: () => void);
  101758. /**
  101759. * An event triggered before rendering the texture
  101760. */
  101761. onBeforeRenderObservable: Observable<number>;
  101762. private _onBeforeRenderObserver;
  101763. /**
  101764. * Set a before render callback in the texture.
  101765. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101766. */
  101767. set onBeforeRender(callback: (faceIndex: number) => void);
  101768. /**
  101769. * An event triggered after rendering the texture
  101770. */
  101771. onAfterRenderObservable: Observable<number>;
  101772. private _onAfterRenderObserver;
  101773. /**
  101774. * Set a after render callback in the texture.
  101775. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101776. */
  101777. set onAfterRender(callback: (faceIndex: number) => void);
  101778. /**
  101779. * An event triggered after the texture clear
  101780. */
  101781. onClearObservable: Observable<Engine>;
  101782. private _onClearObserver;
  101783. /**
  101784. * Set a clear callback in the texture.
  101785. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101786. */
  101787. set onClear(callback: (Engine: Engine) => void);
  101788. /**
  101789. * An event triggered when the texture is resized.
  101790. */
  101791. onResizeObservable: Observable<RenderTargetTexture>;
  101792. /**
  101793. * Define the clear color of the Render Target if it should be different from the scene.
  101794. */
  101795. clearColor: Color4;
  101796. protected _size: number | {
  101797. width: number;
  101798. height: number;
  101799. layers?: number;
  101800. };
  101801. protected _initialSizeParameter: number | {
  101802. width: number;
  101803. height: number;
  101804. } | {
  101805. ratio: number;
  101806. };
  101807. protected _sizeRatio: Nullable<number>;
  101808. /** @hidden */
  101809. _generateMipMaps: boolean;
  101810. protected _renderingManager: RenderingManager;
  101811. /** @hidden */
  101812. _waitingRenderList: string[];
  101813. protected _doNotChangeAspectRatio: boolean;
  101814. protected _currentRefreshId: number;
  101815. protected _refreshRate: number;
  101816. protected _textureMatrix: Matrix;
  101817. protected _samples: number;
  101818. protected _renderTargetOptions: RenderTargetCreationOptions;
  101819. /**
  101820. * Gets render target creation options that were used.
  101821. */
  101822. get renderTargetOptions(): RenderTargetCreationOptions;
  101823. protected _onRatioRescale(): void;
  101824. /**
  101825. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101826. * It must define where the camera used to render the texture is set
  101827. */
  101828. boundingBoxPosition: Vector3;
  101829. private _boundingBoxSize;
  101830. /**
  101831. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101832. * When defined, the cubemap will switch to local mode
  101833. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101834. * @example https://www.babylonjs-playground.com/#RNASML
  101835. */
  101836. set boundingBoxSize(value: Vector3);
  101837. get boundingBoxSize(): Vector3;
  101838. /**
  101839. * In case the RTT has been created with a depth texture, get the associated
  101840. * depth texture.
  101841. * Otherwise, return null.
  101842. */
  101843. get depthStencilTexture(): Nullable<InternalTexture>;
  101844. /**
  101845. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101846. * or used a shadow, depth texture...
  101847. * @param name The friendly name of the texture
  101848. * @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)
  101849. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101850. * @param generateMipMaps True if mip maps need to be generated after render.
  101851. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101852. * @param type The type of the buffer in the RTT (int, half float, float...)
  101853. * @param isCube True if a cube texture needs to be created
  101854. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101855. * @param generateDepthBuffer True to generate a depth buffer
  101856. * @param generateStencilBuffer True to generate a stencil buffer
  101857. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101858. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101859. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101860. */
  101861. constructor(name: string, size: number | {
  101862. width: number;
  101863. height: number;
  101864. layers?: number;
  101865. } | {
  101866. ratio: number;
  101867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101868. /**
  101869. * Creates a depth stencil texture.
  101870. * This is only available in WebGL 2 or with the depth texture extension available.
  101871. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101872. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101873. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101874. */
  101875. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101876. private _processSizeParameter;
  101877. /**
  101878. * Define the number of samples to use in case of MSAA.
  101879. * It defaults to one meaning no MSAA has been enabled.
  101880. */
  101881. get samples(): number;
  101882. set samples(value: number);
  101883. /**
  101884. * Resets the refresh counter of the texture and start bak from scratch.
  101885. * Could be useful to regenerate the texture if it is setup to render only once.
  101886. */
  101887. resetRefreshCounter(): void;
  101888. /**
  101889. * Define the refresh rate of the texture or the rendering frequency.
  101890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101891. */
  101892. get refreshRate(): number;
  101893. set refreshRate(value: number);
  101894. /**
  101895. * Adds a post process to the render target rendering passes.
  101896. * @param postProcess define the post process to add
  101897. */
  101898. addPostProcess(postProcess: PostProcess): void;
  101899. /**
  101900. * Clear all the post processes attached to the render target
  101901. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101902. */
  101903. clearPostProcesses(dispose?: boolean): void;
  101904. /**
  101905. * Remove one of the post process from the list of attached post processes to the texture
  101906. * @param postProcess define the post process to remove from the list
  101907. */
  101908. removePostProcess(postProcess: PostProcess): void;
  101909. /** @hidden */
  101910. _shouldRender(): boolean;
  101911. /**
  101912. * Gets the actual render size of the texture.
  101913. * @returns the width of the render size
  101914. */
  101915. getRenderSize(): number;
  101916. /**
  101917. * Gets the actual render width of the texture.
  101918. * @returns the width of the render size
  101919. */
  101920. getRenderWidth(): number;
  101921. /**
  101922. * Gets the actual render height of the texture.
  101923. * @returns the height of the render size
  101924. */
  101925. getRenderHeight(): number;
  101926. /**
  101927. * Gets the actual number of layers of the texture.
  101928. * @returns the number of layers
  101929. */
  101930. getRenderLayers(): number;
  101931. /**
  101932. * Get if the texture can be rescaled or not.
  101933. */
  101934. get canRescale(): boolean;
  101935. /**
  101936. * Resize the texture using a ratio.
  101937. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101938. */
  101939. scale(ratio: number): void;
  101940. /**
  101941. * Get the texture reflection matrix used to rotate/transform the reflection.
  101942. * @returns the reflection matrix
  101943. */
  101944. getReflectionTextureMatrix(): Matrix;
  101945. /**
  101946. * Resize the texture to a new desired size.
  101947. * Be carrefull as it will recreate all the data in the new texture.
  101948. * @param size Define the new size. It can be:
  101949. * - a number for squared texture,
  101950. * - an object containing { width: number, height: number }
  101951. * - or an object containing a ratio { ratio: number }
  101952. */
  101953. resize(size: number | {
  101954. width: number;
  101955. height: number;
  101956. } | {
  101957. ratio: number;
  101958. }): void;
  101959. private _defaultRenderListPrepared;
  101960. /**
  101961. * Renders all the objects from the render list into the texture.
  101962. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101963. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101964. */
  101965. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101966. private _bestReflectionRenderTargetDimension;
  101967. private _prepareRenderingManager;
  101968. /**
  101969. * @hidden
  101970. * @param faceIndex face index to bind to if this is a cubetexture
  101971. * @param layer defines the index of the texture to bind in the array
  101972. */
  101973. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101974. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101975. private renderToTarget;
  101976. /**
  101977. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101978. * This allowed control for front to back rendering or reversly depending of the special needs.
  101979. *
  101980. * @param renderingGroupId The rendering group id corresponding to its index
  101981. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101982. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101983. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101984. */
  101985. 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;
  101986. /**
  101987. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101988. *
  101989. * @param renderingGroupId The rendering group id corresponding to its index
  101990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101991. */
  101992. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101993. /**
  101994. * Clones the texture.
  101995. * @returns the cloned texture
  101996. */
  101997. clone(): RenderTargetTexture;
  101998. /**
  101999. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102000. * @returns The JSON representation of the texture
  102001. */
  102002. serialize(): any;
  102003. /**
  102004. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102005. */
  102006. disposeFramebufferObjects(): void;
  102007. /**
  102008. * Dispose the texture and release its associated resources.
  102009. */
  102010. dispose(): void;
  102011. /** @hidden */
  102012. _rebuild(): void;
  102013. /**
  102014. * Clear the info related to rendering groups preventing retention point in material dispose.
  102015. */
  102016. freeRenderingGroups(): void;
  102017. /**
  102018. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102019. * @returns the view count
  102020. */
  102021. getViewCount(): number;
  102022. }
  102023. }
  102024. declare module BABYLON {
  102025. /**
  102026. * Class used to manipulate GUIDs
  102027. */
  102028. export class GUID {
  102029. /**
  102030. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102031. * Be aware Math.random() could cause collisions, but:
  102032. * "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"
  102033. * @returns a pseudo random id
  102034. */
  102035. static RandomId(): string;
  102036. }
  102037. }
  102038. declare module BABYLON {
  102039. /**
  102040. * Options to be used when creating a shadow depth material
  102041. */
  102042. export interface IIOptionShadowDepthMaterial {
  102043. /** Variables in the vertex shader code that need to have their names remapped.
  102044. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102045. * "var_name" should be either: worldPos or vNormalW
  102046. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102047. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102048. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102049. */
  102050. remappedVariables?: string[];
  102051. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102052. standalone?: boolean;
  102053. }
  102054. /**
  102055. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102056. */
  102057. export class ShadowDepthWrapper {
  102058. private _scene;
  102059. private _options?;
  102060. private _baseMaterial;
  102061. private _onEffectCreatedObserver;
  102062. private _subMeshToEffect;
  102063. private _subMeshToDepthEffect;
  102064. private _meshes;
  102065. /** @hidden */
  102066. _matriceNames: any;
  102067. /** Gets the standalone status of the wrapper */
  102068. get standalone(): boolean;
  102069. /** Gets the base material the wrapper is built upon */
  102070. get baseMaterial(): Material;
  102071. /**
  102072. * Instantiate a new shadow depth wrapper.
  102073. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102074. * generate the shadow depth map. For more information, please refer to the documentation:
  102075. * https://doc.babylonjs.com/babylon101/shadows
  102076. * @param baseMaterial Material to wrap
  102077. * @param scene Define the scene the material belongs to
  102078. * @param options Options used to create the wrapper
  102079. */
  102080. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102081. /**
  102082. * Gets the effect to use to generate the depth map
  102083. * @param subMesh subMesh to get the effect for
  102084. * @param shadowGenerator shadow generator to get the effect for
  102085. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102086. */
  102087. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102088. /**
  102089. * Specifies that the submesh is ready to be used for depth rendering
  102090. * @param subMesh submesh to check
  102091. * @param defines the list of defines to take into account when checking the effect
  102092. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102093. * @param useInstances specifies that instances should be used
  102094. * @returns a boolean indicating that the submesh is ready or not
  102095. */
  102096. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102097. /**
  102098. * Disposes the resources
  102099. */
  102100. dispose(): void;
  102101. private _makeEffect;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /**
  102106. * Options for compiling materials.
  102107. */
  102108. export interface IMaterialCompilationOptions {
  102109. /**
  102110. * Defines whether clip planes are enabled.
  102111. */
  102112. clipPlane: boolean;
  102113. /**
  102114. * Defines whether instances are enabled.
  102115. */
  102116. useInstances: boolean;
  102117. }
  102118. /**
  102119. * Options passed when calling customShaderNameResolve
  102120. */
  102121. export interface ICustomShaderNameResolveOptions {
  102122. /**
  102123. * 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
  102124. */
  102125. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  102126. }
  102127. /**
  102128. * Base class for the main features of a material in Babylon.js
  102129. */
  102130. export class Material implements IAnimatable {
  102131. /**
  102132. * Returns the triangle fill mode
  102133. */
  102134. static readonly TriangleFillMode: number;
  102135. /**
  102136. * Returns the wireframe mode
  102137. */
  102138. static readonly WireFrameFillMode: number;
  102139. /**
  102140. * Returns the point fill mode
  102141. */
  102142. static readonly PointFillMode: number;
  102143. /**
  102144. * Returns the point list draw mode
  102145. */
  102146. static readonly PointListDrawMode: number;
  102147. /**
  102148. * Returns the line list draw mode
  102149. */
  102150. static readonly LineListDrawMode: number;
  102151. /**
  102152. * Returns the line loop draw mode
  102153. */
  102154. static readonly LineLoopDrawMode: number;
  102155. /**
  102156. * Returns the line strip draw mode
  102157. */
  102158. static readonly LineStripDrawMode: number;
  102159. /**
  102160. * Returns the triangle strip draw mode
  102161. */
  102162. static readonly TriangleStripDrawMode: number;
  102163. /**
  102164. * Returns the triangle fan draw mode
  102165. */
  102166. static readonly TriangleFanDrawMode: number;
  102167. /**
  102168. * Stores the clock-wise side orientation
  102169. */
  102170. static readonly ClockWiseSideOrientation: number;
  102171. /**
  102172. * Stores the counter clock-wise side orientation
  102173. */
  102174. static readonly CounterClockWiseSideOrientation: number;
  102175. /**
  102176. * The dirty texture flag value
  102177. */
  102178. static readonly TextureDirtyFlag: number;
  102179. /**
  102180. * The dirty light flag value
  102181. */
  102182. static readonly LightDirtyFlag: number;
  102183. /**
  102184. * The dirty fresnel flag value
  102185. */
  102186. static readonly FresnelDirtyFlag: number;
  102187. /**
  102188. * The dirty attribute flag value
  102189. */
  102190. static readonly AttributesDirtyFlag: number;
  102191. /**
  102192. * The dirty misc flag value
  102193. */
  102194. static readonly MiscDirtyFlag: number;
  102195. /**
  102196. * The all dirty flag value
  102197. */
  102198. static readonly AllDirtyFlag: number;
  102199. /**
  102200. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102201. */
  102202. static readonly MATERIAL_OPAQUE: number;
  102203. /**
  102204. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102205. */
  102206. static readonly MATERIAL_ALPHATEST: number;
  102207. /**
  102208. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102209. */
  102210. static readonly MATERIAL_ALPHABLEND: number;
  102211. /**
  102212. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102213. * They are also discarded below the alpha cutoff threshold to improve performances.
  102214. */
  102215. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  102216. /**
  102217. * The Whiteout method is used to blend normals.
  102218. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102219. */
  102220. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  102221. /**
  102222. * The Reoriented Normal Mapping method is used to blend normals.
  102223. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102224. */
  102225. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  102226. /**
  102227. * Custom callback helping to override the default shader used in the material.
  102228. */
  102229. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  102230. /**
  102231. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  102232. */
  102233. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  102234. /**
  102235. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  102236. * This means that the material can keep using a previous shader while a new one is being compiled.
  102237. * This is mostly used when shader parallel compilation is supported (true by default)
  102238. */
  102239. allowShaderHotSwapping: boolean;
  102240. /**
  102241. * The ID of the material
  102242. */
  102243. id: string;
  102244. /**
  102245. * Gets or sets the unique id of the material
  102246. */
  102247. uniqueId: number;
  102248. /**
  102249. * The name of the material
  102250. */
  102251. name: string;
  102252. /**
  102253. * Gets or sets user defined metadata
  102254. */
  102255. metadata: any;
  102256. /**
  102257. * For internal use only. Please do not use.
  102258. */
  102259. reservedDataStore: any;
  102260. /**
  102261. * Specifies if the ready state should be checked on each call
  102262. */
  102263. checkReadyOnEveryCall: boolean;
  102264. /**
  102265. * Specifies if the ready state should be checked once
  102266. */
  102267. checkReadyOnlyOnce: boolean;
  102268. /**
  102269. * The state of the material
  102270. */
  102271. state: string;
  102272. /**
  102273. * If the material should be rendered to several textures with MRT extension
  102274. */
  102275. get shouldRenderToMRT(): boolean;
  102276. /**
  102277. * The alpha value of the material
  102278. */
  102279. protected _alpha: number;
  102280. /**
  102281. * List of inspectable custom properties (used by the Inspector)
  102282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102283. */
  102284. inspectableCustomProperties: IInspectable[];
  102285. /**
  102286. * Sets the alpha value of the material
  102287. */
  102288. set alpha(value: number);
  102289. /**
  102290. * Gets the alpha value of the material
  102291. */
  102292. get alpha(): number;
  102293. /**
  102294. * Specifies if back face culling is enabled
  102295. */
  102296. protected _backFaceCulling: boolean;
  102297. /**
  102298. * Sets the back-face culling state
  102299. */
  102300. set backFaceCulling(value: boolean);
  102301. /**
  102302. * Gets the back-face culling state
  102303. */
  102304. get backFaceCulling(): boolean;
  102305. /**
  102306. * Stores the value for side orientation
  102307. */
  102308. sideOrientation: number;
  102309. /**
  102310. * Callback triggered when the material is compiled
  102311. */
  102312. onCompiled: Nullable<(effect: Effect) => void>;
  102313. /**
  102314. * Callback triggered when an error occurs
  102315. */
  102316. onError: Nullable<(effect: Effect, errors: string) => void>;
  102317. /**
  102318. * Callback triggered to get the render target textures
  102319. */
  102320. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102321. /**
  102322. * Gets a boolean indicating that current material needs to register RTT
  102323. */
  102324. get hasRenderTargetTextures(): boolean;
  102325. /**
  102326. * Specifies if the material should be serialized
  102327. */
  102328. doNotSerialize: boolean;
  102329. /**
  102330. * @hidden
  102331. */
  102332. _storeEffectOnSubMeshes: boolean;
  102333. /**
  102334. * Stores the animations for the material
  102335. */
  102336. animations: Nullable<Array<Animation>>;
  102337. /**
  102338. * An event triggered when the material is disposed
  102339. */
  102340. onDisposeObservable: Observable<Material>;
  102341. /**
  102342. * An observer which watches for dispose events
  102343. */
  102344. private _onDisposeObserver;
  102345. private _onUnBindObservable;
  102346. /**
  102347. * Called during a dispose event
  102348. */
  102349. set onDispose(callback: () => void);
  102350. private _onBindObservable;
  102351. /**
  102352. * An event triggered when the material is bound
  102353. */
  102354. get onBindObservable(): Observable<AbstractMesh>;
  102355. /**
  102356. * An observer which watches for bind events
  102357. */
  102358. private _onBindObserver;
  102359. /**
  102360. * Called during a bind event
  102361. */
  102362. set onBind(callback: (Mesh: AbstractMesh) => void);
  102363. /**
  102364. * An event triggered when the material is unbound
  102365. */
  102366. get onUnBindObservable(): Observable<Material>;
  102367. protected _onEffectCreatedObservable: Nullable<Observable<{
  102368. effect: Effect;
  102369. subMesh: Nullable<SubMesh>;
  102370. }>>;
  102371. /**
  102372. * An event triggered when the effect is (re)created
  102373. */
  102374. get onEffectCreatedObservable(): Observable<{
  102375. effect: Effect;
  102376. subMesh: Nullable<SubMesh>;
  102377. }>;
  102378. /**
  102379. * Stores the value of the alpha mode
  102380. */
  102381. private _alphaMode;
  102382. /**
  102383. * Sets the value of the alpha mode.
  102384. *
  102385. * | Value | Type | Description |
  102386. * | --- | --- | --- |
  102387. * | 0 | ALPHA_DISABLE | |
  102388. * | 1 | ALPHA_ADD | |
  102389. * | 2 | ALPHA_COMBINE | |
  102390. * | 3 | ALPHA_SUBTRACT | |
  102391. * | 4 | ALPHA_MULTIPLY | |
  102392. * | 5 | ALPHA_MAXIMIZED | |
  102393. * | 6 | ALPHA_ONEONE | |
  102394. * | 7 | ALPHA_PREMULTIPLIED | |
  102395. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102396. * | 9 | ALPHA_INTERPOLATE | |
  102397. * | 10 | ALPHA_SCREENMODE | |
  102398. *
  102399. */
  102400. set alphaMode(value: number);
  102401. /**
  102402. * Gets the value of the alpha mode
  102403. */
  102404. get alphaMode(): number;
  102405. /**
  102406. * Stores the state of the need depth pre-pass value
  102407. */
  102408. private _needDepthPrePass;
  102409. /**
  102410. * Sets the need depth pre-pass value
  102411. */
  102412. set needDepthPrePass(value: boolean);
  102413. /**
  102414. * Gets the depth pre-pass value
  102415. */
  102416. get needDepthPrePass(): boolean;
  102417. /**
  102418. * Specifies if depth writing should be disabled
  102419. */
  102420. disableDepthWrite: boolean;
  102421. /**
  102422. * Specifies if color writing should be disabled
  102423. */
  102424. disableColorWrite: boolean;
  102425. /**
  102426. * Specifies if depth writing should be forced
  102427. */
  102428. forceDepthWrite: boolean;
  102429. /**
  102430. * Specifies the depth function that should be used. 0 means the default engine function
  102431. */
  102432. depthFunction: number;
  102433. /**
  102434. * Specifies if there should be a separate pass for culling
  102435. */
  102436. separateCullingPass: boolean;
  102437. /**
  102438. * Stores the state specifing if fog should be enabled
  102439. */
  102440. private _fogEnabled;
  102441. /**
  102442. * Sets the state for enabling fog
  102443. */
  102444. set fogEnabled(value: boolean);
  102445. /**
  102446. * Gets the value of the fog enabled state
  102447. */
  102448. get fogEnabled(): boolean;
  102449. /**
  102450. * Stores the size of points
  102451. */
  102452. pointSize: number;
  102453. /**
  102454. * Stores the z offset value
  102455. */
  102456. zOffset: number;
  102457. get wireframe(): boolean;
  102458. /**
  102459. * Sets the state of wireframe mode
  102460. */
  102461. set wireframe(value: boolean);
  102462. /**
  102463. * Gets the value specifying if point clouds are enabled
  102464. */
  102465. get pointsCloud(): boolean;
  102466. /**
  102467. * Sets the state of point cloud mode
  102468. */
  102469. set pointsCloud(value: boolean);
  102470. /**
  102471. * Gets the material fill mode
  102472. */
  102473. get fillMode(): number;
  102474. /**
  102475. * Sets the material fill mode
  102476. */
  102477. set fillMode(value: number);
  102478. /**
  102479. * @hidden
  102480. * Stores the effects for the material
  102481. */
  102482. _effect: Nullable<Effect>;
  102483. /**
  102484. * Specifies if uniform buffers should be used
  102485. */
  102486. private _useUBO;
  102487. /**
  102488. * Stores a reference to the scene
  102489. */
  102490. private _scene;
  102491. /**
  102492. * Stores the fill mode state
  102493. */
  102494. private _fillMode;
  102495. /**
  102496. * Specifies if the depth write state should be cached
  102497. */
  102498. private _cachedDepthWriteState;
  102499. /**
  102500. * Specifies if the color write state should be cached
  102501. */
  102502. private _cachedColorWriteState;
  102503. /**
  102504. * Specifies if the depth function state should be cached
  102505. */
  102506. private _cachedDepthFunctionState;
  102507. /**
  102508. * Stores the uniform buffer
  102509. */
  102510. protected _uniformBuffer: UniformBuffer;
  102511. /** @hidden */
  102512. _indexInSceneMaterialArray: number;
  102513. /** @hidden */
  102514. meshMap: Nullable<{
  102515. [id: string]: AbstractMesh | undefined;
  102516. }>;
  102517. /**
  102518. * Creates a material instance
  102519. * @param name defines the name of the material
  102520. * @param scene defines the scene to reference
  102521. * @param doNotAdd specifies if the material should be added to the scene
  102522. */
  102523. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102524. /**
  102525. * Returns a string representation of the current material
  102526. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102527. * @returns a string with material information
  102528. */
  102529. toString(fullDetails?: boolean): string;
  102530. /**
  102531. * Gets the class name of the material
  102532. * @returns a string with the class name of the material
  102533. */
  102534. getClassName(): string;
  102535. /**
  102536. * Specifies if updates for the material been locked
  102537. */
  102538. get isFrozen(): boolean;
  102539. /**
  102540. * Locks updates for the material
  102541. */
  102542. freeze(): void;
  102543. /**
  102544. * Unlocks updates for the material
  102545. */
  102546. unfreeze(): void;
  102547. /**
  102548. * Specifies if the material is ready to be used
  102549. * @param mesh defines the mesh to check
  102550. * @param useInstances specifies if instances should be used
  102551. * @returns a boolean indicating if the material is ready to be used
  102552. */
  102553. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102554. /**
  102555. * Specifies that the submesh is ready to be used
  102556. * @param mesh defines the mesh to check
  102557. * @param subMesh defines which submesh to check
  102558. * @param useInstances specifies that instances should be used
  102559. * @returns a boolean indicating that the submesh is ready or not
  102560. */
  102561. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102562. /**
  102563. * Returns the material effect
  102564. * @returns the effect associated with the material
  102565. */
  102566. getEffect(): Nullable<Effect>;
  102567. /**
  102568. * Returns the current scene
  102569. * @returns a Scene
  102570. */
  102571. getScene(): Scene;
  102572. /**
  102573. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102574. */
  102575. protected _forceAlphaTest: boolean;
  102576. /**
  102577. * The transparency mode of the material.
  102578. */
  102579. protected _transparencyMode: Nullable<number>;
  102580. /**
  102581. * Gets the current transparency mode.
  102582. */
  102583. get transparencyMode(): Nullable<number>;
  102584. /**
  102585. * Sets the transparency mode of the material.
  102586. *
  102587. * | Value | Type | Description |
  102588. * | ----- | ----------------------------------- | ----------- |
  102589. * | 0 | OPAQUE | |
  102590. * | 1 | ALPHATEST | |
  102591. * | 2 | ALPHABLEND | |
  102592. * | 3 | ALPHATESTANDBLEND | |
  102593. *
  102594. */
  102595. set transparencyMode(value: Nullable<number>);
  102596. /**
  102597. * Returns true if alpha blending should be disabled.
  102598. */
  102599. protected get _disableAlphaBlending(): boolean;
  102600. /**
  102601. * Specifies whether or not this material should be rendered in alpha blend mode.
  102602. * @returns a boolean specifying if alpha blending is needed
  102603. */
  102604. needAlphaBlending(): boolean;
  102605. /**
  102606. * Specifies if the mesh will require alpha blending
  102607. * @param mesh defines the mesh to check
  102608. * @returns a boolean specifying if alpha blending is needed for the mesh
  102609. */
  102610. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102611. /**
  102612. * Specifies whether or not this material should be rendered in alpha test mode.
  102613. * @returns a boolean specifying if an alpha test is needed.
  102614. */
  102615. needAlphaTesting(): boolean;
  102616. /**
  102617. * Specifies if material alpha testing should be turned on for the mesh
  102618. * @param mesh defines the mesh to check
  102619. */
  102620. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102621. /**
  102622. * Gets the texture used for the alpha test
  102623. * @returns the texture to use for alpha testing
  102624. */
  102625. getAlphaTestTexture(): Nullable<BaseTexture>;
  102626. /**
  102627. * Marks the material to indicate that it needs to be re-calculated
  102628. */
  102629. markDirty(): void;
  102630. /** @hidden */
  102631. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102632. /**
  102633. * Binds the material to the mesh
  102634. * @param world defines the world transformation matrix
  102635. * @param mesh defines the mesh to bind the material to
  102636. */
  102637. bind(world: Matrix, mesh?: Mesh): void;
  102638. /**
  102639. * Binds the submesh to the material
  102640. * @param world defines the world transformation matrix
  102641. * @param mesh defines the mesh containing the submesh
  102642. * @param subMesh defines the submesh to bind the material to
  102643. */
  102644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102645. /**
  102646. * Binds the world matrix to the material
  102647. * @param world defines the world transformation matrix
  102648. */
  102649. bindOnlyWorldMatrix(world: Matrix): void;
  102650. /**
  102651. * Binds the scene's uniform buffer to the effect.
  102652. * @param effect defines the effect to bind to the scene uniform buffer
  102653. * @param sceneUbo defines the uniform buffer storing scene data
  102654. */
  102655. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102656. /**
  102657. * Binds the view matrix to the effect
  102658. * @param effect defines the effect to bind the view matrix to
  102659. */
  102660. bindView(effect: Effect): void;
  102661. /**
  102662. * Binds the view projection matrix to the effect
  102663. * @param effect defines the effect to bind the view projection matrix to
  102664. */
  102665. bindViewProjection(effect: Effect): void;
  102666. /**
  102667. * Processes to execute after binding the material to a mesh
  102668. * @param mesh defines the rendered mesh
  102669. */
  102670. protected _afterBind(mesh?: Mesh): void;
  102671. /**
  102672. * Unbinds the material from the mesh
  102673. */
  102674. unbind(): void;
  102675. /**
  102676. * Gets the active textures from the material
  102677. * @returns an array of textures
  102678. */
  102679. getActiveTextures(): BaseTexture[];
  102680. /**
  102681. * Specifies if the material uses a texture
  102682. * @param texture defines the texture to check against the material
  102683. * @returns a boolean specifying if the material uses the texture
  102684. */
  102685. hasTexture(texture: BaseTexture): boolean;
  102686. /**
  102687. * Makes a duplicate of the material, and gives it a new name
  102688. * @param name defines the new name for the duplicated material
  102689. * @returns the cloned material
  102690. */
  102691. clone(name: string): Nullable<Material>;
  102692. /**
  102693. * Gets the meshes bound to the material
  102694. * @returns an array of meshes bound to the material
  102695. */
  102696. getBindedMeshes(): AbstractMesh[];
  102697. /**
  102698. * Force shader compilation
  102699. * @param mesh defines the mesh associated with this material
  102700. * @param onCompiled defines a function to execute once the material is compiled
  102701. * @param options defines the options to configure the compilation
  102702. * @param onError defines a function to execute if the material fails compiling
  102703. */
  102704. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102705. /**
  102706. * Force shader compilation
  102707. * @param mesh defines the mesh that will use this material
  102708. * @param options defines additional options for compiling the shaders
  102709. * @returns a promise that resolves when the compilation completes
  102710. */
  102711. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102712. private static readonly _AllDirtyCallBack;
  102713. private static readonly _ImageProcessingDirtyCallBack;
  102714. private static readonly _TextureDirtyCallBack;
  102715. private static readonly _FresnelDirtyCallBack;
  102716. private static readonly _MiscDirtyCallBack;
  102717. private static readonly _LightsDirtyCallBack;
  102718. private static readonly _AttributeDirtyCallBack;
  102719. private static _FresnelAndMiscDirtyCallBack;
  102720. private static _TextureAndMiscDirtyCallBack;
  102721. private static readonly _DirtyCallbackArray;
  102722. private static readonly _RunDirtyCallBacks;
  102723. /**
  102724. * Marks a define in the material to indicate that it needs to be re-computed
  102725. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102726. */
  102727. markAsDirty(flag: number): void;
  102728. /**
  102729. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102730. * @param func defines a function which checks material defines against the submeshes
  102731. */
  102732. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102733. /**
  102734. * Indicates that the scene should check if the rendering now needs a prepass
  102735. */
  102736. protected _markScenePrePassDirty(): void;
  102737. /**
  102738. * Indicates that we need to re-calculated for all submeshes
  102739. */
  102740. protected _markAllSubMeshesAsAllDirty(): void;
  102741. /**
  102742. * Indicates that image processing needs to be re-calculated for all submeshes
  102743. */
  102744. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102745. /**
  102746. * Indicates that textures need to be re-calculated for all submeshes
  102747. */
  102748. protected _markAllSubMeshesAsTexturesDirty(): void;
  102749. /**
  102750. * Indicates that fresnel needs to be re-calculated for all submeshes
  102751. */
  102752. protected _markAllSubMeshesAsFresnelDirty(): void;
  102753. /**
  102754. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102755. */
  102756. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102757. /**
  102758. * Indicates that lights need to be re-calculated for all submeshes
  102759. */
  102760. protected _markAllSubMeshesAsLightsDirty(): void;
  102761. /**
  102762. * Indicates that attributes need to be re-calculated for all submeshes
  102763. */
  102764. protected _markAllSubMeshesAsAttributesDirty(): void;
  102765. /**
  102766. * Indicates that misc needs to be re-calculated for all submeshes
  102767. */
  102768. protected _markAllSubMeshesAsMiscDirty(): void;
  102769. /**
  102770. * Indicates that textures and misc need to be re-calculated for all submeshes
  102771. */
  102772. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102773. /**
  102774. * Disposes the material
  102775. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102776. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102777. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102778. */
  102779. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102780. /** @hidden */
  102781. private releaseVertexArrayObject;
  102782. /**
  102783. * Serializes this material
  102784. * @returns the serialized material object
  102785. */
  102786. serialize(): any;
  102787. /**
  102788. * Creates a material from parsed material data
  102789. * @param parsedMaterial defines parsed material data
  102790. * @param scene defines the hosting scene
  102791. * @param rootUrl defines the root URL to use to load textures
  102792. * @returns a new material
  102793. */
  102794. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102795. }
  102796. }
  102797. declare module BABYLON {
  102798. /**
  102799. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102800. * separate meshes. This can be use to improve performances.
  102801. * @see https://doc.babylonjs.com/how_to/multi_materials
  102802. */
  102803. export class MultiMaterial extends Material {
  102804. private _subMaterials;
  102805. /**
  102806. * Gets or Sets the list of Materials used within the multi material.
  102807. * They need to be ordered according to the submeshes order in the associated mesh
  102808. */
  102809. get subMaterials(): Nullable<Material>[];
  102810. set subMaterials(value: Nullable<Material>[]);
  102811. /**
  102812. * Function used to align with Node.getChildren()
  102813. * @returns the list of Materials used within the multi material
  102814. */
  102815. getChildren(): Nullable<Material>[];
  102816. /**
  102817. * Instantiates a new Multi Material
  102818. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102819. * separate meshes. This can be use to improve performances.
  102820. * @see https://doc.babylonjs.com/how_to/multi_materials
  102821. * @param name Define the name in the scene
  102822. * @param scene Define the scene the material belongs to
  102823. */
  102824. constructor(name: string, scene: Scene);
  102825. private _hookArray;
  102826. /**
  102827. * Get one of the submaterial by its index in the submaterials array
  102828. * @param index The index to look the sub material at
  102829. * @returns The Material if the index has been defined
  102830. */
  102831. getSubMaterial(index: number): Nullable<Material>;
  102832. /**
  102833. * Get the list of active textures for the whole sub materials list.
  102834. * @returns All the textures that will be used during the rendering
  102835. */
  102836. getActiveTextures(): BaseTexture[];
  102837. /**
  102838. * Gets the current class name of the material e.g. "MultiMaterial"
  102839. * Mainly use in serialization.
  102840. * @returns the class name
  102841. */
  102842. getClassName(): string;
  102843. /**
  102844. * Checks if the material is ready to render the requested sub mesh
  102845. * @param mesh Define the mesh the submesh belongs to
  102846. * @param subMesh Define the sub mesh to look readyness for
  102847. * @param useInstances Define whether or not the material is used with instances
  102848. * @returns true if ready, otherwise false
  102849. */
  102850. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102851. /**
  102852. * Clones the current material and its related sub materials
  102853. * @param name Define the name of the newly cloned material
  102854. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102855. * @returns the cloned material
  102856. */
  102857. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102858. /**
  102859. * Serializes the materials into a JSON representation.
  102860. * @returns the JSON representation
  102861. */
  102862. serialize(): any;
  102863. /**
  102864. * Dispose the material and release its associated resources
  102865. * @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)
  102866. * @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)
  102867. * @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)
  102868. */
  102869. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102870. /**
  102871. * Creates a MultiMaterial from parsed MultiMaterial data.
  102872. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102873. * @param scene defines the hosting scene
  102874. * @returns a new MultiMaterial
  102875. */
  102876. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102877. }
  102878. }
  102879. declare module BABYLON {
  102880. /**
  102881. * Defines a subdivision inside a mesh
  102882. */
  102883. export class SubMesh implements ICullable {
  102884. /** the material index to use */
  102885. materialIndex: number;
  102886. /** vertex index start */
  102887. verticesStart: number;
  102888. /** vertices count */
  102889. verticesCount: number;
  102890. /** index start */
  102891. indexStart: number;
  102892. /** indices count */
  102893. indexCount: number;
  102894. /** @hidden */
  102895. _materialDefines: Nullable<MaterialDefines>;
  102896. /** @hidden */
  102897. _materialEffect: Nullable<Effect>;
  102898. /** @hidden */
  102899. _effectOverride: Nullable<Effect>;
  102900. /**
  102901. * Gets material defines used by the effect associated to the sub mesh
  102902. */
  102903. get materialDefines(): Nullable<MaterialDefines>;
  102904. /**
  102905. * Sets material defines used by the effect associated to the sub mesh
  102906. */
  102907. set materialDefines(defines: Nullable<MaterialDefines>);
  102908. /**
  102909. * Gets associated effect
  102910. */
  102911. get effect(): Nullable<Effect>;
  102912. /**
  102913. * Sets associated effect (effect used to render this submesh)
  102914. * @param effect defines the effect to associate with
  102915. * @param defines defines the set of defines used to compile this effect
  102916. */
  102917. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102918. /** @hidden */
  102919. _linesIndexCount: number;
  102920. private _mesh;
  102921. private _renderingMesh;
  102922. private _boundingInfo;
  102923. private _linesIndexBuffer;
  102924. /** @hidden */
  102925. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102926. /** @hidden */
  102927. _trianglePlanes: Plane[];
  102928. /** @hidden */
  102929. _lastColliderTransformMatrix: Nullable<Matrix>;
  102930. /** @hidden */
  102931. _renderId: number;
  102932. /** @hidden */
  102933. _alphaIndex: number;
  102934. /** @hidden */
  102935. _distanceToCamera: number;
  102936. /** @hidden */
  102937. _id: number;
  102938. private _currentMaterial;
  102939. /**
  102940. * Add a new submesh to a mesh
  102941. * @param materialIndex defines the material index to use
  102942. * @param verticesStart defines vertex index start
  102943. * @param verticesCount defines vertices count
  102944. * @param indexStart defines index start
  102945. * @param indexCount defines indices count
  102946. * @param mesh defines the parent mesh
  102947. * @param renderingMesh defines an optional rendering mesh
  102948. * @param createBoundingBox defines if bounding box should be created for this submesh
  102949. * @returns the new submesh
  102950. */
  102951. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102952. /**
  102953. * Creates a new submesh
  102954. * @param materialIndex defines the material index to use
  102955. * @param verticesStart defines vertex index start
  102956. * @param verticesCount defines vertices count
  102957. * @param indexStart defines index start
  102958. * @param indexCount defines indices count
  102959. * @param mesh defines the parent mesh
  102960. * @param renderingMesh defines an optional rendering mesh
  102961. * @param createBoundingBox defines if bounding box should be created for this submesh
  102962. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102963. */
  102964. constructor(
  102965. /** the material index to use */
  102966. materialIndex: number,
  102967. /** vertex index start */
  102968. verticesStart: number,
  102969. /** vertices count */
  102970. verticesCount: number,
  102971. /** index start */
  102972. indexStart: number,
  102973. /** indices count */
  102974. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102975. /**
  102976. * Returns true if this submesh covers the entire parent mesh
  102977. * @ignorenaming
  102978. */
  102979. get IsGlobal(): boolean;
  102980. /**
  102981. * Returns the submesh BoudingInfo object
  102982. * @returns current bounding info (or mesh's one if the submesh is global)
  102983. */
  102984. getBoundingInfo(): BoundingInfo;
  102985. /**
  102986. * Sets the submesh BoundingInfo
  102987. * @param boundingInfo defines the new bounding info to use
  102988. * @returns the SubMesh
  102989. */
  102990. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102991. /**
  102992. * Returns the mesh of the current submesh
  102993. * @return the parent mesh
  102994. */
  102995. getMesh(): AbstractMesh;
  102996. /**
  102997. * Returns the rendering mesh of the submesh
  102998. * @returns the rendering mesh (could be different from parent mesh)
  102999. */
  103000. getRenderingMesh(): Mesh;
  103001. /**
  103002. * Returns the replacement mesh of the submesh
  103003. * @returns the replacement mesh (could be different from parent mesh)
  103004. */
  103005. getReplacementMesh(): Nullable<AbstractMesh>;
  103006. /**
  103007. * Returns the effective mesh of the submesh
  103008. * @returns the effective mesh (could be different from parent mesh)
  103009. */
  103010. getEffectiveMesh(): AbstractMesh;
  103011. /**
  103012. * Returns the submesh material
  103013. * @returns null or the current material
  103014. */
  103015. getMaterial(): Nullable<Material>;
  103016. private _IsMultiMaterial;
  103017. /**
  103018. * Sets a new updated BoundingInfo object to the submesh
  103019. * @param data defines an optional position array to use to determine the bounding info
  103020. * @returns the SubMesh
  103021. */
  103022. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  103023. /** @hidden */
  103024. _checkCollision(collider: Collider): boolean;
  103025. /**
  103026. * Updates the submesh BoundingInfo
  103027. * @param world defines the world matrix to use to update the bounding info
  103028. * @returns the submesh
  103029. */
  103030. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  103031. /**
  103032. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  103033. * @param frustumPlanes defines the frustum planes
  103034. * @returns true if the submesh is intersecting with the frustum
  103035. */
  103036. isInFrustum(frustumPlanes: Plane[]): boolean;
  103037. /**
  103038. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  103039. * @param frustumPlanes defines the frustum planes
  103040. * @returns true if the submesh is inside the frustum
  103041. */
  103042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  103043. /**
  103044. * Renders the submesh
  103045. * @param enableAlphaMode defines if alpha needs to be used
  103046. * @returns the submesh
  103047. */
  103048. render(enableAlphaMode: boolean): SubMesh;
  103049. /**
  103050. * @hidden
  103051. */
  103052. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  103053. /**
  103054. * Checks if the submesh intersects with a ray
  103055. * @param ray defines the ray to test
  103056. * @returns true is the passed ray intersects the submesh bounding box
  103057. */
  103058. canIntersects(ray: Ray): boolean;
  103059. /**
  103060. * Intersects current submesh with a ray
  103061. * @param ray defines the ray to test
  103062. * @param positions defines mesh's positions array
  103063. * @param indices defines mesh's indices array
  103064. * @param fastCheck defines if the first intersection will be used (and not the closest)
  103065. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103066. * @returns intersection info or null if no intersection
  103067. */
  103068. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  103069. /** @hidden */
  103070. private _intersectLines;
  103071. /** @hidden */
  103072. private _intersectUnIndexedLines;
  103073. /** @hidden */
  103074. private _intersectTriangles;
  103075. /** @hidden */
  103076. private _intersectUnIndexedTriangles;
  103077. /** @hidden */
  103078. _rebuild(): void;
  103079. /**
  103080. * Creates a new submesh from the passed mesh
  103081. * @param newMesh defines the new hosting mesh
  103082. * @param newRenderingMesh defines an optional rendering mesh
  103083. * @returns the new submesh
  103084. */
  103085. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  103086. /**
  103087. * Release associated resources
  103088. */
  103089. dispose(): void;
  103090. /**
  103091. * Gets the class name
  103092. * @returns the string "SubMesh".
  103093. */
  103094. getClassName(): string;
  103095. /**
  103096. * Creates a new submesh from indices data
  103097. * @param materialIndex the index of the main mesh material
  103098. * @param startIndex the index where to start the copy in the mesh indices array
  103099. * @param indexCount the number of indices to copy then from the startIndex
  103100. * @param mesh the main mesh to create the submesh from
  103101. * @param renderingMesh the optional rendering mesh
  103102. * @returns a new submesh
  103103. */
  103104. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  103105. }
  103106. }
  103107. declare module BABYLON {
  103108. /**
  103109. * Class used to represent data loading progression
  103110. */
  103111. export class SceneLoaderFlags {
  103112. private static _ForceFullSceneLoadingForIncremental;
  103113. private static _ShowLoadingScreen;
  103114. private static _CleanBoneMatrixWeights;
  103115. private static _loggingLevel;
  103116. /**
  103117. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  103118. */
  103119. static get ForceFullSceneLoadingForIncremental(): boolean;
  103120. static set ForceFullSceneLoadingForIncremental(value: boolean);
  103121. /**
  103122. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  103123. */
  103124. static get ShowLoadingScreen(): boolean;
  103125. static set ShowLoadingScreen(value: boolean);
  103126. /**
  103127. * Defines the current logging level (while loading the scene)
  103128. * @ignorenaming
  103129. */
  103130. static get loggingLevel(): number;
  103131. static set loggingLevel(value: number);
  103132. /**
  103133. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  103134. */
  103135. static get CleanBoneMatrixWeights(): boolean;
  103136. static set CleanBoneMatrixWeights(value: boolean);
  103137. }
  103138. }
  103139. declare module BABYLON {
  103140. /**
  103141. * Class used to store geometry data (vertex buffers + index buffer)
  103142. */
  103143. export class Geometry implements IGetSetVerticesData {
  103144. /**
  103145. * Gets or sets the ID of the geometry
  103146. */
  103147. id: string;
  103148. /**
  103149. * Gets or sets the unique ID of the geometry
  103150. */
  103151. uniqueId: number;
  103152. /**
  103153. * Gets the delay loading state of the geometry (none by default which means not delayed)
  103154. */
  103155. delayLoadState: number;
  103156. /**
  103157. * Gets the file containing the data to load when running in delay load state
  103158. */
  103159. delayLoadingFile: Nullable<string>;
  103160. /**
  103161. * Callback called when the geometry is updated
  103162. */
  103163. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  103164. private _scene;
  103165. private _engine;
  103166. private _meshes;
  103167. private _totalVertices;
  103168. /** @hidden */
  103169. _indices: IndicesArray;
  103170. /** @hidden */
  103171. _vertexBuffers: {
  103172. [key: string]: VertexBuffer;
  103173. };
  103174. private _isDisposed;
  103175. private _extend;
  103176. private _boundingBias;
  103177. /** @hidden */
  103178. _delayInfo: Array<string>;
  103179. private _indexBuffer;
  103180. private _indexBufferIsUpdatable;
  103181. /** @hidden */
  103182. _boundingInfo: Nullable<BoundingInfo>;
  103183. /** @hidden */
  103184. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  103185. /** @hidden */
  103186. _softwareSkinningFrameId: number;
  103187. private _vertexArrayObjects;
  103188. private _updatable;
  103189. /** @hidden */
  103190. _positions: Nullable<Vector3[]>;
  103191. /**
  103192. * 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
  103193. */
  103194. get boundingBias(): Vector2;
  103195. /**
  103196. * 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
  103197. */
  103198. set boundingBias(value: Vector2);
  103199. /**
  103200. * Static function used to attach a new empty geometry to a mesh
  103201. * @param mesh defines the mesh to attach the geometry to
  103202. * @returns the new Geometry
  103203. */
  103204. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  103205. /** Get the list of meshes using this geometry */
  103206. get meshes(): Mesh[];
  103207. /**
  103208. * 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
  103209. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  103210. */
  103211. useBoundingInfoFromGeometry: boolean;
  103212. /**
  103213. * Creates a new geometry
  103214. * @param id defines the unique ID
  103215. * @param scene defines the hosting scene
  103216. * @param vertexData defines the VertexData used to get geometry data
  103217. * @param updatable defines if geometry must be updatable (false by default)
  103218. * @param mesh defines the mesh that will be associated with the geometry
  103219. */
  103220. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  103221. /**
  103222. * Gets the current extend of the geometry
  103223. */
  103224. get extend(): {
  103225. minimum: Vector3;
  103226. maximum: Vector3;
  103227. };
  103228. /**
  103229. * Gets the hosting scene
  103230. * @returns the hosting Scene
  103231. */
  103232. getScene(): Scene;
  103233. /**
  103234. * Gets the hosting engine
  103235. * @returns the hosting Engine
  103236. */
  103237. getEngine(): Engine;
  103238. /**
  103239. * Defines if the geometry is ready to use
  103240. * @returns true if the geometry is ready to be used
  103241. */
  103242. isReady(): boolean;
  103243. /**
  103244. * Gets a value indicating that the geometry should not be serialized
  103245. */
  103246. get doNotSerialize(): boolean;
  103247. /** @hidden */
  103248. _rebuild(): void;
  103249. /**
  103250. * Affects all geometry data in one call
  103251. * @param vertexData defines the geometry data
  103252. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  103253. */
  103254. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  103255. /**
  103256. * Set specific vertex data
  103257. * @param kind defines the data kind (Position, normal, etc...)
  103258. * @param data defines the vertex data to use
  103259. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103260. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103261. */
  103262. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  103263. /**
  103264. * Removes a specific vertex data
  103265. * @param kind defines the data kind (Position, normal, etc...)
  103266. */
  103267. removeVerticesData(kind: string): void;
  103268. /**
  103269. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  103270. * @param buffer defines the vertex buffer to use
  103271. * @param totalVertices defines the total number of vertices for position kind (could be null)
  103272. */
  103273. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  103274. /**
  103275. * Update a specific vertex buffer
  103276. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  103277. * It will do nothing if the buffer is not updatable
  103278. * @param kind defines the data kind (Position, normal, etc...)
  103279. * @param data defines the data to use
  103280. * @param offset defines the offset in the target buffer where to store the data
  103281. * @param useBytes set to true if the offset is in bytes
  103282. */
  103283. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  103284. /**
  103285. * Update a specific vertex buffer
  103286. * This function will create a new buffer if the current one is not updatable
  103287. * @param kind defines the data kind (Position, normal, etc...)
  103288. * @param data defines the data to use
  103289. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  103290. */
  103291. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  103292. private _updateBoundingInfo;
  103293. /** @hidden */
  103294. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  103295. /**
  103296. * Gets total number of vertices
  103297. * @returns the total number of vertices
  103298. */
  103299. getTotalVertices(): number;
  103300. /**
  103301. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103302. * @param kind defines the data kind (Position, normal, etc...)
  103303. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103304. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103305. * @returns a float array containing vertex data
  103306. */
  103307. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103308. /**
  103309. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103310. * @param kind defines the data kind (Position, normal, etc...)
  103311. * @returns true if the vertex buffer with the specified kind is updatable
  103312. */
  103313. isVertexBufferUpdatable(kind: string): boolean;
  103314. /**
  103315. * Gets a specific vertex buffer
  103316. * @param kind defines the data kind (Position, normal, etc...)
  103317. * @returns a VertexBuffer
  103318. */
  103319. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103320. /**
  103321. * Returns all vertex buffers
  103322. * @return an object holding all vertex buffers indexed by kind
  103323. */
  103324. getVertexBuffers(): Nullable<{
  103325. [key: string]: VertexBuffer;
  103326. }>;
  103327. /**
  103328. * Gets a boolean indicating if specific vertex buffer is present
  103329. * @param kind defines the data kind (Position, normal, etc...)
  103330. * @returns true if data is present
  103331. */
  103332. isVerticesDataPresent(kind: string): boolean;
  103333. /**
  103334. * Gets a list of all attached data kinds (Position, normal, etc...)
  103335. * @returns a list of string containing all kinds
  103336. */
  103337. getVerticesDataKinds(): string[];
  103338. /**
  103339. * Update index buffer
  103340. * @param indices defines the indices to store in the index buffer
  103341. * @param offset defines the offset in the target buffer where to store the data
  103342. * @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)
  103343. */
  103344. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103345. /**
  103346. * Creates a new index buffer
  103347. * @param indices defines the indices to store in the index buffer
  103348. * @param totalVertices defines the total number of vertices (could be null)
  103349. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103350. */
  103351. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103352. /**
  103353. * Return the total number of indices
  103354. * @returns the total number of indices
  103355. */
  103356. getTotalIndices(): number;
  103357. /**
  103358. * Gets the index buffer array
  103359. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103361. * @returns the index buffer array
  103362. */
  103363. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103364. /**
  103365. * Gets the index buffer
  103366. * @return the index buffer
  103367. */
  103368. getIndexBuffer(): Nullable<DataBuffer>;
  103369. /** @hidden */
  103370. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103371. /**
  103372. * Release the associated resources for a specific mesh
  103373. * @param mesh defines the source mesh
  103374. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103375. */
  103376. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103377. /**
  103378. * Apply current geometry to a given mesh
  103379. * @param mesh defines the mesh to apply geometry to
  103380. */
  103381. applyToMesh(mesh: Mesh): void;
  103382. private _updateExtend;
  103383. private _applyToMesh;
  103384. private notifyUpdate;
  103385. /**
  103386. * Load the geometry if it was flagged as delay loaded
  103387. * @param scene defines the hosting scene
  103388. * @param onLoaded defines a callback called when the geometry is loaded
  103389. */
  103390. load(scene: Scene, onLoaded?: () => void): void;
  103391. private _queueLoad;
  103392. /**
  103393. * Invert the geometry to move from a right handed system to a left handed one.
  103394. */
  103395. toLeftHanded(): void;
  103396. /** @hidden */
  103397. _resetPointsArrayCache(): void;
  103398. /** @hidden */
  103399. _generatePointsArray(): boolean;
  103400. /**
  103401. * Gets a value indicating if the geometry is disposed
  103402. * @returns true if the geometry was disposed
  103403. */
  103404. isDisposed(): boolean;
  103405. private _disposeVertexArrayObjects;
  103406. /**
  103407. * Free all associated resources
  103408. */
  103409. dispose(): void;
  103410. /**
  103411. * Clone the current geometry into a new geometry
  103412. * @param id defines the unique ID of the new geometry
  103413. * @returns a new geometry object
  103414. */
  103415. copy(id: string): Geometry;
  103416. /**
  103417. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103418. * @return a JSON representation of the current geometry data (without the vertices data)
  103419. */
  103420. serialize(): any;
  103421. private toNumberArray;
  103422. /**
  103423. * Serialize all vertices data into a JSON oject
  103424. * @returns a JSON representation of the current geometry data
  103425. */
  103426. serializeVerticeData(): any;
  103427. /**
  103428. * Extracts a clone of a mesh geometry
  103429. * @param mesh defines the source mesh
  103430. * @param id defines the unique ID of the new geometry object
  103431. * @returns the new geometry object
  103432. */
  103433. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103434. /**
  103435. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103436. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103437. * Be aware Math.random() could cause collisions, but:
  103438. * "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"
  103439. * @returns a string containing a new GUID
  103440. */
  103441. static RandomId(): string;
  103442. /** @hidden */
  103443. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103444. private static _CleanMatricesWeights;
  103445. /**
  103446. * Create a new geometry from persisted data (Using .babylon file format)
  103447. * @param parsedVertexData defines the persisted data
  103448. * @param scene defines the hosting scene
  103449. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103450. * @returns the new geometry object
  103451. */
  103452. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103453. }
  103454. }
  103455. declare module BABYLON {
  103456. /**
  103457. * Define an interface for all classes that will get and set the data on vertices
  103458. */
  103459. export interface IGetSetVerticesData {
  103460. /**
  103461. * Gets a boolean indicating if specific vertex data is present
  103462. * @param kind defines the vertex data kind to use
  103463. * @returns true is data kind is present
  103464. */
  103465. isVerticesDataPresent(kind: string): boolean;
  103466. /**
  103467. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103468. * @param kind defines the data kind (Position, normal, etc...)
  103469. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103470. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103471. * @returns a float array containing vertex data
  103472. */
  103473. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103474. /**
  103475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103476. * @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.
  103477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103478. * @returns the indices array or an empty array if the mesh has no geometry
  103479. */
  103480. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103481. /**
  103482. * Set specific vertex data
  103483. * @param kind defines the data kind (Position, normal, etc...)
  103484. * @param data defines the vertex data to use
  103485. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103486. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103487. */
  103488. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103489. /**
  103490. * Update a specific associated vertex buffer
  103491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103492. * - VertexBuffer.PositionKind
  103493. * - VertexBuffer.UVKind
  103494. * - VertexBuffer.UV2Kind
  103495. * - VertexBuffer.UV3Kind
  103496. * - VertexBuffer.UV4Kind
  103497. * - VertexBuffer.UV5Kind
  103498. * - VertexBuffer.UV6Kind
  103499. * - VertexBuffer.ColorKind
  103500. * - VertexBuffer.MatricesIndicesKind
  103501. * - VertexBuffer.MatricesIndicesExtraKind
  103502. * - VertexBuffer.MatricesWeightsKind
  103503. * - VertexBuffer.MatricesWeightsExtraKind
  103504. * @param data defines the data source
  103505. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103506. * @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)
  103507. */
  103508. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103509. /**
  103510. * Creates a new index buffer
  103511. * @param indices defines the indices to store in the index buffer
  103512. * @param totalVertices defines the total number of vertices (could be null)
  103513. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103514. */
  103515. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103516. }
  103517. /**
  103518. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103519. */
  103520. export class VertexData {
  103521. /**
  103522. * Mesh side orientation : usually the external or front surface
  103523. */
  103524. static readonly FRONTSIDE: number;
  103525. /**
  103526. * Mesh side orientation : usually the internal or back surface
  103527. */
  103528. static readonly BACKSIDE: number;
  103529. /**
  103530. * Mesh side orientation : both internal and external or front and back surfaces
  103531. */
  103532. static readonly DOUBLESIDE: number;
  103533. /**
  103534. * Mesh side orientation : by default, `FRONTSIDE`
  103535. */
  103536. static readonly DEFAULTSIDE: number;
  103537. /**
  103538. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103539. */
  103540. positions: Nullable<FloatArray>;
  103541. /**
  103542. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103543. */
  103544. normals: Nullable<FloatArray>;
  103545. /**
  103546. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103547. */
  103548. tangents: Nullable<FloatArray>;
  103549. /**
  103550. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103551. */
  103552. uvs: Nullable<FloatArray>;
  103553. /**
  103554. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103555. */
  103556. uvs2: Nullable<FloatArray>;
  103557. /**
  103558. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103559. */
  103560. uvs3: Nullable<FloatArray>;
  103561. /**
  103562. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103563. */
  103564. uvs4: Nullable<FloatArray>;
  103565. /**
  103566. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103567. */
  103568. uvs5: Nullable<FloatArray>;
  103569. /**
  103570. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103571. */
  103572. uvs6: Nullable<FloatArray>;
  103573. /**
  103574. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103575. */
  103576. colors: Nullable<FloatArray>;
  103577. /**
  103578. * 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).
  103579. */
  103580. matricesIndices: Nullable<FloatArray>;
  103581. /**
  103582. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103583. */
  103584. matricesWeights: Nullable<FloatArray>;
  103585. /**
  103586. * An array extending the number of possible indices
  103587. */
  103588. matricesIndicesExtra: Nullable<FloatArray>;
  103589. /**
  103590. * An array extending the number of possible weights when the number of indices is extended
  103591. */
  103592. matricesWeightsExtra: Nullable<FloatArray>;
  103593. /**
  103594. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103595. */
  103596. indices: Nullable<IndicesArray>;
  103597. /**
  103598. * Uses the passed data array to set the set the values for the specified kind of data
  103599. * @param data a linear array of floating numbers
  103600. * @param kind the type of data that is being set, eg positions, colors etc
  103601. */
  103602. set(data: FloatArray, kind: string): void;
  103603. /**
  103604. * Associates the vertexData to the passed Mesh.
  103605. * Sets it as updatable or not (default `false`)
  103606. * @param mesh the mesh the vertexData is applied to
  103607. * @param updatable when used and having the value true allows new data to update the vertexData
  103608. * @returns the VertexData
  103609. */
  103610. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103611. /**
  103612. * Associates the vertexData to the passed Geometry.
  103613. * Sets it as updatable or not (default `false`)
  103614. * @param geometry the geometry the vertexData is applied to
  103615. * @param updatable when used and having the value true allows new data to update the vertexData
  103616. * @returns VertexData
  103617. */
  103618. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103619. /**
  103620. * Updates the associated mesh
  103621. * @param mesh the mesh to be updated
  103622. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103623. * @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
  103624. * @returns VertexData
  103625. */
  103626. updateMesh(mesh: Mesh): VertexData;
  103627. /**
  103628. * Updates the associated geometry
  103629. * @param geometry the geometry to be updated
  103630. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103631. * @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
  103632. * @returns VertexData.
  103633. */
  103634. updateGeometry(geometry: Geometry): VertexData;
  103635. private _applyTo;
  103636. private _update;
  103637. /**
  103638. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103639. * @param matrix the transforming matrix
  103640. * @returns the VertexData
  103641. */
  103642. transform(matrix: Matrix): VertexData;
  103643. /**
  103644. * Merges the passed VertexData into the current one
  103645. * @param other the VertexData to be merged into the current one
  103646. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103647. * @returns the modified VertexData
  103648. */
  103649. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103650. private _mergeElement;
  103651. private _validate;
  103652. /**
  103653. * Serializes the VertexData
  103654. * @returns a serialized object
  103655. */
  103656. serialize(): any;
  103657. /**
  103658. * Extracts the vertexData from a mesh
  103659. * @param mesh the mesh from which to extract the VertexData
  103660. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103661. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103662. * @returns the object VertexData associated to the passed mesh
  103663. */
  103664. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103665. /**
  103666. * Extracts the vertexData from the geometry
  103667. * @param geometry the geometry from which to extract the VertexData
  103668. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103669. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103670. * @returns the object VertexData associated to the passed mesh
  103671. */
  103672. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103673. private static _ExtractFrom;
  103674. /**
  103675. * Creates the VertexData for a Ribbon
  103676. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103677. * * pathArray array of paths, each of which an array of successive Vector3
  103678. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103679. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103680. * * 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
  103681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103682. * * 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)
  103683. * * 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)
  103684. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103685. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103686. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103687. * @returns the VertexData of the ribbon
  103688. */
  103689. static CreateRibbon(options: {
  103690. pathArray: Vector3[][];
  103691. closeArray?: boolean;
  103692. closePath?: boolean;
  103693. offset?: number;
  103694. sideOrientation?: number;
  103695. frontUVs?: Vector4;
  103696. backUVs?: Vector4;
  103697. invertUV?: boolean;
  103698. uvs?: Vector2[];
  103699. colors?: Color4[];
  103700. }): VertexData;
  103701. /**
  103702. * Creates the VertexData for a box
  103703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103704. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103705. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103706. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103707. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103708. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103709. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103711. * * 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)
  103712. * * 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)
  103713. * @returns the VertexData of the box
  103714. */
  103715. static CreateBox(options: {
  103716. size?: number;
  103717. width?: number;
  103718. height?: number;
  103719. depth?: number;
  103720. faceUV?: Vector4[];
  103721. faceColors?: Color4[];
  103722. sideOrientation?: number;
  103723. frontUVs?: Vector4;
  103724. backUVs?: Vector4;
  103725. }): VertexData;
  103726. /**
  103727. * Creates the VertexData for a tiled box
  103728. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103729. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103730. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103731. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103732. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103733. * @returns the VertexData of the box
  103734. */
  103735. static CreateTiledBox(options: {
  103736. pattern?: number;
  103737. width?: number;
  103738. height?: number;
  103739. depth?: number;
  103740. tileSize?: number;
  103741. tileWidth?: number;
  103742. tileHeight?: number;
  103743. alignHorizontal?: number;
  103744. alignVertical?: number;
  103745. faceUV?: Vector4[];
  103746. faceColors?: Color4[];
  103747. sideOrientation?: number;
  103748. }): VertexData;
  103749. /**
  103750. * Creates the VertexData for a tiled plane
  103751. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103752. * * pattern a limited pattern arrangement depending on the number
  103753. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103754. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103755. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103756. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103757. * * 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)
  103758. * * 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)
  103759. * @returns the VertexData of the tiled plane
  103760. */
  103761. static CreateTiledPlane(options: {
  103762. pattern?: number;
  103763. tileSize?: number;
  103764. tileWidth?: number;
  103765. tileHeight?: number;
  103766. size?: number;
  103767. width?: number;
  103768. height?: number;
  103769. alignHorizontal?: number;
  103770. alignVertical?: number;
  103771. sideOrientation?: number;
  103772. frontUVs?: Vector4;
  103773. backUVs?: Vector4;
  103774. }): VertexData;
  103775. /**
  103776. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103778. * * segments sets the number of horizontal strips optional, default 32
  103779. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103780. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103781. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103782. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103783. * * 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
  103784. * * 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
  103785. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103786. * * 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)
  103787. * * 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)
  103788. * @returns the VertexData of the ellipsoid
  103789. */
  103790. static CreateSphere(options: {
  103791. segments?: number;
  103792. diameter?: number;
  103793. diameterX?: number;
  103794. diameterY?: number;
  103795. diameterZ?: number;
  103796. arc?: number;
  103797. slice?: number;
  103798. sideOrientation?: number;
  103799. frontUVs?: Vector4;
  103800. backUVs?: Vector4;
  103801. }): VertexData;
  103802. /**
  103803. * Creates the VertexData for a cylinder, cone or prism
  103804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103805. * * height sets the height (y direction) of the cylinder, optional, default 2
  103806. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103807. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103808. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103809. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103810. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103811. * * 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
  103812. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103813. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103814. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103815. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103817. * * 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)
  103818. * * 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)
  103819. * @returns the VertexData of the cylinder, cone or prism
  103820. */
  103821. static CreateCylinder(options: {
  103822. height?: number;
  103823. diameterTop?: number;
  103824. diameterBottom?: number;
  103825. diameter?: number;
  103826. tessellation?: number;
  103827. subdivisions?: number;
  103828. arc?: number;
  103829. faceColors?: Color4[];
  103830. faceUV?: Vector4[];
  103831. hasRings?: boolean;
  103832. enclose?: boolean;
  103833. sideOrientation?: number;
  103834. frontUVs?: Vector4;
  103835. backUVs?: Vector4;
  103836. }): VertexData;
  103837. /**
  103838. * Creates the VertexData for a torus
  103839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103840. * * diameter the diameter of the torus, optional default 1
  103841. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103842. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103844. * * 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)
  103845. * * 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)
  103846. * @returns the VertexData of the torus
  103847. */
  103848. static CreateTorus(options: {
  103849. diameter?: number;
  103850. thickness?: number;
  103851. tessellation?: number;
  103852. sideOrientation?: number;
  103853. frontUVs?: Vector4;
  103854. backUVs?: Vector4;
  103855. }): VertexData;
  103856. /**
  103857. * Creates the VertexData of the LineSystem
  103858. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103859. * - lines an array of lines, each line being an array of successive Vector3
  103860. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103861. * @returns the VertexData of the LineSystem
  103862. */
  103863. static CreateLineSystem(options: {
  103864. lines: Vector3[][];
  103865. colors?: Nullable<Color4[][]>;
  103866. }): VertexData;
  103867. /**
  103868. * Create the VertexData for a DashedLines
  103869. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103870. * - points an array successive Vector3
  103871. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103872. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103873. * - dashNb the intended total number of dashes, optional, default 200
  103874. * @returns the VertexData for the DashedLines
  103875. */
  103876. static CreateDashedLines(options: {
  103877. points: Vector3[];
  103878. dashSize?: number;
  103879. gapSize?: number;
  103880. dashNb?: number;
  103881. }): VertexData;
  103882. /**
  103883. * Creates the VertexData for a Ground
  103884. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103885. * - width the width (x direction) of the ground, optional, default 1
  103886. * - height the height (z direction) of the ground, optional, default 1
  103887. * - subdivisions the number of subdivisions per side, optional, default 1
  103888. * @returns the VertexData of the Ground
  103889. */
  103890. static CreateGround(options: {
  103891. width?: number;
  103892. height?: number;
  103893. subdivisions?: number;
  103894. subdivisionsX?: number;
  103895. subdivisionsY?: number;
  103896. }): VertexData;
  103897. /**
  103898. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103899. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103900. * * xmin the ground minimum X coordinate, optional, default -1
  103901. * * zmin the ground minimum Z coordinate, optional, default -1
  103902. * * xmax the ground maximum X coordinate, optional, default 1
  103903. * * zmax the ground maximum Z coordinate, optional, default 1
  103904. * * 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}
  103905. * * 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}
  103906. * @returns the VertexData of the TiledGround
  103907. */
  103908. static CreateTiledGround(options: {
  103909. xmin: number;
  103910. zmin: number;
  103911. xmax: number;
  103912. zmax: number;
  103913. subdivisions?: {
  103914. w: number;
  103915. h: number;
  103916. };
  103917. precision?: {
  103918. w: number;
  103919. h: number;
  103920. };
  103921. }): VertexData;
  103922. /**
  103923. * Creates the VertexData of the Ground designed from a heightmap
  103924. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103925. * * width the width (x direction) of the ground
  103926. * * height the height (z direction) of the ground
  103927. * * subdivisions the number of subdivisions per side
  103928. * * minHeight the minimum altitude on the ground, optional, default 0
  103929. * * maxHeight the maximum altitude on the ground, optional default 1
  103930. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103931. * * buffer the array holding the image color data
  103932. * * bufferWidth the width of image
  103933. * * bufferHeight the height of image
  103934. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103935. * @returns the VertexData of the Ground designed from a heightmap
  103936. */
  103937. static CreateGroundFromHeightMap(options: {
  103938. width: number;
  103939. height: number;
  103940. subdivisions: number;
  103941. minHeight: number;
  103942. maxHeight: number;
  103943. colorFilter: Color3;
  103944. buffer: Uint8Array;
  103945. bufferWidth: number;
  103946. bufferHeight: number;
  103947. alphaFilter: number;
  103948. }): VertexData;
  103949. /**
  103950. * Creates the VertexData for a Plane
  103951. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103952. * * size sets the width and height of the plane to the value of size, optional default 1
  103953. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103954. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103956. * * 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)
  103957. * * 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)
  103958. * @returns the VertexData of the box
  103959. */
  103960. static CreatePlane(options: {
  103961. size?: number;
  103962. width?: number;
  103963. height?: number;
  103964. sideOrientation?: number;
  103965. frontUVs?: Vector4;
  103966. backUVs?: Vector4;
  103967. }): VertexData;
  103968. /**
  103969. * Creates the VertexData of the Disc or regular Polygon
  103970. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103971. * * radius the radius of the disc, optional default 0.5
  103972. * * tessellation the number of polygon sides, optional, default 64
  103973. * * 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
  103974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103975. * * 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)
  103976. * * 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)
  103977. * @returns the VertexData of the box
  103978. */
  103979. static CreateDisc(options: {
  103980. radius?: number;
  103981. tessellation?: number;
  103982. arc?: number;
  103983. sideOrientation?: number;
  103984. frontUVs?: Vector4;
  103985. backUVs?: Vector4;
  103986. }): VertexData;
  103987. /**
  103988. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103989. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103990. * @param polygon a mesh built from polygonTriangulation.build()
  103991. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103992. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103993. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103994. * @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)
  103995. * @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)
  103996. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103997. * @returns the VertexData of the Polygon
  103998. */
  103999. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  104000. /**
  104001. * Creates the VertexData of the IcoSphere
  104002. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  104003. * * radius the radius of the IcoSphere, optional default 1
  104004. * * radiusX allows stretching in the x direction, optional, default radius
  104005. * * radiusY allows stretching in the y direction, optional, default radius
  104006. * * radiusZ allows stretching in the z direction, optional, default radius
  104007. * * flat when true creates a flat shaded mesh, optional, default true
  104008. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104010. * * 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)
  104011. * * 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)
  104012. * @returns the VertexData of the IcoSphere
  104013. */
  104014. static CreateIcoSphere(options: {
  104015. radius?: number;
  104016. radiusX?: number;
  104017. radiusY?: number;
  104018. radiusZ?: number;
  104019. flat?: boolean;
  104020. subdivisions?: number;
  104021. sideOrientation?: number;
  104022. frontUVs?: Vector4;
  104023. backUVs?: Vector4;
  104024. }): VertexData;
  104025. /**
  104026. * Creates the VertexData for a Polyhedron
  104027. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  104028. * * type provided types are:
  104029. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  104030. * * 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)
  104031. * * size the size of the IcoSphere, optional default 1
  104032. * * sizeX allows stretching in the x direction, optional, default size
  104033. * * sizeY allows stretching in the y direction, optional, default size
  104034. * * sizeZ allows stretching in the z direction, optional, default size
  104035. * * 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
  104036. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104037. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104038. * * flat when true creates a flat shaded mesh, optional, default true
  104039. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104041. * * 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)
  104042. * * 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)
  104043. * @returns the VertexData of the Polyhedron
  104044. */
  104045. static CreatePolyhedron(options: {
  104046. type?: number;
  104047. size?: number;
  104048. sizeX?: number;
  104049. sizeY?: number;
  104050. sizeZ?: number;
  104051. custom?: any;
  104052. faceUV?: Vector4[];
  104053. faceColors?: Color4[];
  104054. flat?: boolean;
  104055. sideOrientation?: number;
  104056. frontUVs?: Vector4;
  104057. backUVs?: Vector4;
  104058. }): VertexData;
  104059. /**
  104060. * Creates the VertexData for a TorusKnot
  104061. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  104062. * * radius the radius of the torus knot, optional, default 2
  104063. * * tube the thickness of the tube, optional, default 0.5
  104064. * * radialSegments the number of sides on each tube segments, optional, default 32
  104065. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  104066. * * p the number of windings around the z axis, optional, default 2
  104067. * * q the number of windings around the x axis, optional, default 3
  104068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104069. * * 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)
  104070. * * 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)
  104071. * @returns the VertexData of the Torus Knot
  104072. */
  104073. static CreateTorusKnot(options: {
  104074. radius?: number;
  104075. tube?: number;
  104076. radialSegments?: number;
  104077. tubularSegments?: number;
  104078. p?: number;
  104079. q?: number;
  104080. sideOrientation?: number;
  104081. frontUVs?: Vector4;
  104082. backUVs?: Vector4;
  104083. }): VertexData;
  104084. /**
  104085. * Compute normals for given positions and indices
  104086. * @param positions an array of vertex positions, [...., x, y, z, ......]
  104087. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  104088. * @param normals an array of vertex normals, [...., x, y, z, ......]
  104089. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  104090. * * facetNormals : optional array of facet normals (vector3)
  104091. * * facetPositions : optional array of facet positions (vector3)
  104092. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  104093. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  104094. * * bInfo : optional bounding info, required for facetPartitioning computation
  104095. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  104096. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  104097. * * useRightHandedSystem: optional boolean to for right handed system computation
  104098. * * depthSort : optional boolean to enable the facet depth sort computation
  104099. * * distanceTo : optional Vector3 to compute the facet depth from this location
  104100. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  104101. */
  104102. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  104103. facetNormals?: any;
  104104. facetPositions?: any;
  104105. facetPartitioning?: any;
  104106. ratio?: number;
  104107. bInfo?: any;
  104108. bbSize?: Vector3;
  104109. subDiv?: any;
  104110. useRightHandedSystem?: boolean;
  104111. depthSort?: boolean;
  104112. distanceTo?: Vector3;
  104113. depthSortedFacets?: any;
  104114. }): void;
  104115. /** @hidden */
  104116. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  104117. /**
  104118. * Applies VertexData created from the imported parameters to the geometry
  104119. * @param parsedVertexData the parsed data from an imported file
  104120. * @param geometry the geometry to apply the VertexData to
  104121. */
  104122. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  104123. }
  104124. }
  104125. declare module BABYLON {
  104126. /**
  104127. * Defines a target to use with MorphTargetManager
  104128. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104129. */
  104130. export class MorphTarget implements IAnimatable {
  104131. /** defines the name of the target */
  104132. name: string;
  104133. /**
  104134. * Gets or sets the list of animations
  104135. */
  104136. animations: Animation[];
  104137. private _scene;
  104138. private _positions;
  104139. private _normals;
  104140. private _tangents;
  104141. private _uvs;
  104142. private _influence;
  104143. private _uniqueId;
  104144. /**
  104145. * Observable raised when the influence changes
  104146. */
  104147. onInfluenceChanged: Observable<boolean>;
  104148. /** @hidden */
  104149. _onDataLayoutChanged: Observable<void>;
  104150. /**
  104151. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  104152. */
  104153. get influence(): number;
  104154. set influence(influence: number);
  104155. /**
  104156. * Gets or sets the id of the morph Target
  104157. */
  104158. id: string;
  104159. private _animationPropertiesOverride;
  104160. /**
  104161. * Gets or sets the animation properties override
  104162. */
  104163. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  104164. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  104165. /**
  104166. * Creates a new MorphTarget
  104167. * @param name defines the name of the target
  104168. * @param influence defines the influence to use
  104169. * @param scene defines the scene the morphtarget belongs to
  104170. */
  104171. constructor(
  104172. /** defines the name of the target */
  104173. name: string, influence?: number, scene?: Nullable<Scene>);
  104174. /**
  104175. * Gets the unique ID of this manager
  104176. */
  104177. get uniqueId(): number;
  104178. /**
  104179. * Gets a boolean defining if the target contains position data
  104180. */
  104181. get hasPositions(): boolean;
  104182. /**
  104183. * Gets a boolean defining if the target contains normal data
  104184. */
  104185. get hasNormals(): boolean;
  104186. /**
  104187. * Gets a boolean defining if the target contains tangent data
  104188. */
  104189. get hasTangents(): boolean;
  104190. /**
  104191. * Gets a boolean defining if the target contains texture coordinates data
  104192. */
  104193. get hasUVs(): boolean;
  104194. /**
  104195. * Affects position data to this target
  104196. * @param data defines the position data to use
  104197. */
  104198. setPositions(data: Nullable<FloatArray>): void;
  104199. /**
  104200. * Gets the position data stored in this target
  104201. * @returns a FloatArray containing the position data (or null if not present)
  104202. */
  104203. getPositions(): Nullable<FloatArray>;
  104204. /**
  104205. * Affects normal data to this target
  104206. * @param data defines the normal data to use
  104207. */
  104208. setNormals(data: Nullable<FloatArray>): void;
  104209. /**
  104210. * Gets the normal data stored in this target
  104211. * @returns a FloatArray containing the normal data (or null if not present)
  104212. */
  104213. getNormals(): Nullable<FloatArray>;
  104214. /**
  104215. * Affects tangent data to this target
  104216. * @param data defines the tangent data to use
  104217. */
  104218. setTangents(data: Nullable<FloatArray>): void;
  104219. /**
  104220. * Gets the tangent data stored in this target
  104221. * @returns a FloatArray containing the tangent data (or null if not present)
  104222. */
  104223. getTangents(): Nullable<FloatArray>;
  104224. /**
  104225. * Affects texture coordinates data to this target
  104226. * @param data defines the texture coordinates data to use
  104227. */
  104228. setUVs(data: Nullable<FloatArray>): void;
  104229. /**
  104230. * Gets the texture coordinates data stored in this target
  104231. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  104232. */
  104233. getUVs(): Nullable<FloatArray>;
  104234. /**
  104235. * Clone the current target
  104236. * @returns a new MorphTarget
  104237. */
  104238. clone(): MorphTarget;
  104239. /**
  104240. * Serializes the current target into a Serialization object
  104241. * @returns the serialized object
  104242. */
  104243. serialize(): any;
  104244. /**
  104245. * Returns the string "MorphTarget"
  104246. * @returns "MorphTarget"
  104247. */
  104248. getClassName(): string;
  104249. /**
  104250. * Creates a new target from serialized data
  104251. * @param serializationObject defines the serialized data to use
  104252. * @returns a new MorphTarget
  104253. */
  104254. static Parse(serializationObject: any): MorphTarget;
  104255. /**
  104256. * Creates a MorphTarget from mesh data
  104257. * @param mesh defines the source mesh
  104258. * @param name defines the name to use for the new target
  104259. * @param influence defines the influence to attach to the target
  104260. * @returns a new MorphTarget
  104261. */
  104262. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  104263. }
  104264. }
  104265. declare module BABYLON {
  104266. /**
  104267. * This class is used to deform meshes using morphing between different targets
  104268. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104269. */
  104270. export class MorphTargetManager {
  104271. private _targets;
  104272. private _targetInfluenceChangedObservers;
  104273. private _targetDataLayoutChangedObservers;
  104274. private _activeTargets;
  104275. private _scene;
  104276. private _influences;
  104277. private _supportsNormals;
  104278. private _supportsTangents;
  104279. private _supportsUVs;
  104280. private _vertexCount;
  104281. private _uniqueId;
  104282. private _tempInfluences;
  104283. /**
  104284. * Gets or sets a boolean indicating if normals must be morphed
  104285. */
  104286. enableNormalMorphing: boolean;
  104287. /**
  104288. * Gets or sets a boolean indicating if tangents must be morphed
  104289. */
  104290. enableTangentMorphing: boolean;
  104291. /**
  104292. * Gets or sets a boolean indicating if UV must be morphed
  104293. */
  104294. enableUVMorphing: boolean;
  104295. /**
  104296. * Creates a new MorphTargetManager
  104297. * @param scene defines the current scene
  104298. */
  104299. constructor(scene?: Nullable<Scene>);
  104300. /**
  104301. * Gets the unique ID of this manager
  104302. */
  104303. get uniqueId(): number;
  104304. /**
  104305. * Gets the number of vertices handled by this manager
  104306. */
  104307. get vertexCount(): number;
  104308. /**
  104309. * Gets a boolean indicating if this manager supports morphing of normals
  104310. */
  104311. get supportsNormals(): boolean;
  104312. /**
  104313. * Gets a boolean indicating if this manager supports morphing of tangents
  104314. */
  104315. get supportsTangents(): boolean;
  104316. /**
  104317. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104318. */
  104319. get supportsUVs(): boolean;
  104320. /**
  104321. * Gets the number of targets stored in this manager
  104322. */
  104323. get numTargets(): number;
  104324. /**
  104325. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104326. */
  104327. get numInfluencers(): number;
  104328. /**
  104329. * Gets the list of influences (one per target)
  104330. */
  104331. get influences(): Float32Array;
  104332. /**
  104333. * Gets the active target at specified index. An active target is a target with an influence > 0
  104334. * @param index defines the index to check
  104335. * @returns the requested target
  104336. */
  104337. getActiveTarget(index: number): MorphTarget;
  104338. /**
  104339. * Gets the target at specified index
  104340. * @param index defines the index to check
  104341. * @returns the requested target
  104342. */
  104343. getTarget(index: number): MorphTarget;
  104344. /**
  104345. * Add a new target to this manager
  104346. * @param target defines the target to add
  104347. */
  104348. addTarget(target: MorphTarget): void;
  104349. /**
  104350. * Removes a target from the manager
  104351. * @param target defines the target to remove
  104352. */
  104353. removeTarget(target: MorphTarget): void;
  104354. /**
  104355. * Clone the current manager
  104356. * @returns a new MorphTargetManager
  104357. */
  104358. clone(): MorphTargetManager;
  104359. /**
  104360. * Serializes the current manager into a Serialization object
  104361. * @returns the serialized object
  104362. */
  104363. serialize(): any;
  104364. private _syncActiveTargets;
  104365. /**
  104366. * Syncrhonize the targets with all the meshes using this morph target manager
  104367. */
  104368. synchronize(): void;
  104369. /**
  104370. * Creates a new MorphTargetManager from serialized data
  104371. * @param serializationObject defines the serialized data
  104372. * @param scene defines the hosting scene
  104373. * @returns the new MorphTargetManager
  104374. */
  104375. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104376. }
  104377. }
  104378. declare module BABYLON {
  104379. /**
  104380. * Class used to represent a specific level of detail of a mesh
  104381. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104382. */
  104383. export class MeshLODLevel {
  104384. /** Defines the distance where this level should start being displayed */
  104385. distance: number;
  104386. /** Defines the mesh to use to render this level */
  104387. mesh: Nullable<Mesh>;
  104388. /**
  104389. * Creates a new LOD level
  104390. * @param distance defines the distance where this level should star being displayed
  104391. * @param mesh defines the mesh to use to render this level
  104392. */
  104393. constructor(
  104394. /** Defines the distance where this level should start being displayed */
  104395. distance: number,
  104396. /** Defines the mesh to use to render this level */
  104397. mesh: Nullable<Mesh>);
  104398. }
  104399. }
  104400. declare module BABYLON {
  104401. /**
  104402. * Helper class used to generate a canvas to manipulate images
  104403. */
  104404. export class CanvasGenerator {
  104405. /**
  104406. * Create a new canvas (or offscreen canvas depending on the context)
  104407. * @param width defines the expected width
  104408. * @param height defines the expected height
  104409. * @return a new canvas or offscreen canvas
  104410. */
  104411. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104412. }
  104413. }
  104414. declare module BABYLON {
  104415. /**
  104416. * Mesh representing the gorund
  104417. */
  104418. export class GroundMesh extends Mesh {
  104419. /** If octree should be generated */
  104420. generateOctree: boolean;
  104421. private _heightQuads;
  104422. /** @hidden */
  104423. _subdivisionsX: number;
  104424. /** @hidden */
  104425. _subdivisionsY: number;
  104426. /** @hidden */
  104427. _width: number;
  104428. /** @hidden */
  104429. _height: number;
  104430. /** @hidden */
  104431. _minX: number;
  104432. /** @hidden */
  104433. _maxX: number;
  104434. /** @hidden */
  104435. _minZ: number;
  104436. /** @hidden */
  104437. _maxZ: number;
  104438. constructor(name: string, scene: Scene);
  104439. /**
  104440. * "GroundMesh"
  104441. * @returns "GroundMesh"
  104442. */
  104443. getClassName(): string;
  104444. /**
  104445. * The minimum of x and y subdivisions
  104446. */
  104447. get subdivisions(): number;
  104448. /**
  104449. * X subdivisions
  104450. */
  104451. get subdivisionsX(): number;
  104452. /**
  104453. * Y subdivisions
  104454. */
  104455. get subdivisionsY(): number;
  104456. /**
  104457. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104458. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104459. * @param chunksCount the number of subdivisions for x and y
  104460. * @param octreeBlocksSize (Default: 32)
  104461. */
  104462. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104463. /**
  104464. * Returns a height (y) value in the Worl system :
  104465. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104466. * @param x x coordinate
  104467. * @param z z coordinate
  104468. * @returns the ground y position if (x, z) are outside the ground surface.
  104469. */
  104470. getHeightAtCoordinates(x: number, z: number): number;
  104471. /**
  104472. * Returns a normalized vector (Vector3) orthogonal to the ground
  104473. * at the ground coordinates (x, z) expressed in the World system.
  104474. * @param x x coordinate
  104475. * @param z z coordinate
  104476. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104477. */
  104478. getNormalAtCoordinates(x: number, z: number): Vector3;
  104479. /**
  104480. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104481. * at the ground coordinates (x, z) expressed in the World system.
  104482. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104483. * @param x x coordinate
  104484. * @param z z coordinate
  104485. * @param ref vector to store the result
  104486. * @returns the GroundMesh.
  104487. */
  104488. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104489. /**
  104490. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104491. * if the ground has been updated.
  104492. * This can be used in the render loop.
  104493. * @returns the GroundMesh.
  104494. */
  104495. updateCoordinateHeights(): GroundMesh;
  104496. private _getFacetAt;
  104497. private _initHeightQuads;
  104498. private _computeHeightQuads;
  104499. /**
  104500. * Serializes this ground mesh
  104501. * @param serializationObject object to write serialization to
  104502. */
  104503. serialize(serializationObject: any): void;
  104504. /**
  104505. * Parses a serialized ground mesh
  104506. * @param parsedMesh the serialized mesh
  104507. * @param scene the scene to create the ground mesh in
  104508. * @returns the created ground mesh
  104509. */
  104510. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104511. }
  104512. }
  104513. declare module BABYLON {
  104514. /**
  104515. * Interface for Physics-Joint data
  104516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104517. */
  104518. export interface PhysicsJointData {
  104519. /**
  104520. * The main pivot of the joint
  104521. */
  104522. mainPivot?: Vector3;
  104523. /**
  104524. * The connected pivot of the joint
  104525. */
  104526. connectedPivot?: Vector3;
  104527. /**
  104528. * The main axis of the joint
  104529. */
  104530. mainAxis?: Vector3;
  104531. /**
  104532. * The connected axis of the joint
  104533. */
  104534. connectedAxis?: Vector3;
  104535. /**
  104536. * The collision of the joint
  104537. */
  104538. collision?: boolean;
  104539. /**
  104540. * Native Oimo/Cannon/Energy data
  104541. */
  104542. nativeParams?: any;
  104543. }
  104544. /**
  104545. * This is a holder class for the physics joint created by the physics plugin
  104546. * It holds a set of functions to control the underlying joint
  104547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104548. */
  104549. export class PhysicsJoint {
  104550. /**
  104551. * The type of the physics joint
  104552. */
  104553. type: number;
  104554. /**
  104555. * The data for the physics joint
  104556. */
  104557. jointData: PhysicsJointData;
  104558. private _physicsJoint;
  104559. protected _physicsPlugin: IPhysicsEnginePlugin;
  104560. /**
  104561. * Initializes the physics joint
  104562. * @param type The type of the physics joint
  104563. * @param jointData The data for the physics joint
  104564. */
  104565. constructor(
  104566. /**
  104567. * The type of the physics joint
  104568. */
  104569. type: number,
  104570. /**
  104571. * The data for the physics joint
  104572. */
  104573. jointData: PhysicsJointData);
  104574. /**
  104575. * Gets the physics joint
  104576. */
  104577. get physicsJoint(): any;
  104578. /**
  104579. * Sets the physics joint
  104580. */
  104581. set physicsJoint(newJoint: any);
  104582. /**
  104583. * Sets the physics plugin
  104584. */
  104585. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104586. /**
  104587. * Execute a function that is physics-plugin specific.
  104588. * @param {Function} func the function that will be executed.
  104589. * It accepts two parameters: the physics world and the physics joint
  104590. */
  104591. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104592. /**
  104593. * Distance-Joint type
  104594. */
  104595. static DistanceJoint: number;
  104596. /**
  104597. * Hinge-Joint type
  104598. */
  104599. static HingeJoint: number;
  104600. /**
  104601. * Ball-and-Socket joint type
  104602. */
  104603. static BallAndSocketJoint: number;
  104604. /**
  104605. * Wheel-Joint type
  104606. */
  104607. static WheelJoint: number;
  104608. /**
  104609. * Slider-Joint type
  104610. */
  104611. static SliderJoint: number;
  104612. /**
  104613. * Prismatic-Joint type
  104614. */
  104615. static PrismaticJoint: number;
  104616. /**
  104617. * Universal-Joint type
  104618. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104619. */
  104620. static UniversalJoint: number;
  104621. /**
  104622. * Hinge-Joint 2 type
  104623. */
  104624. static Hinge2Joint: number;
  104625. /**
  104626. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104627. */
  104628. static PointToPointJoint: number;
  104629. /**
  104630. * Spring-Joint type
  104631. */
  104632. static SpringJoint: number;
  104633. /**
  104634. * Lock-Joint type
  104635. */
  104636. static LockJoint: number;
  104637. }
  104638. /**
  104639. * A class representing a physics distance joint
  104640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104641. */
  104642. export class DistanceJoint extends PhysicsJoint {
  104643. /**
  104644. *
  104645. * @param jointData The data for the Distance-Joint
  104646. */
  104647. constructor(jointData: DistanceJointData);
  104648. /**
  104649. * Update the predefined distance.
  104650. * @param maxDistance The maximum preferred distance
  104651. * @param minDistance The minimum preferred distance
  104652. */
  104653. updateDistance(maxDistance: number, minDistance?: number): void;
  104654. }
  104655. /**
  104656. * Represents a Motor-Enabled Joint
  104657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104658. */
  104659. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104660. /**
  104661. * Initializes the Motor-Enabled Joint
  104662. * @param type The type of the joint
  104663. * @param jointData The physica joint data for the joint
  104664. */
  104665. constructor(type: number, jointData: PhysicsJointData);
  104666. /**
  104667. * Set the motor values.
  104668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104669. * @param force the force to apply
  104670. * @param maxForce max force for this motor.
  104671. */
  104672. setMotor(force?: number, maxForce?: number): void;
  104673. /**
  104674. * Set the motor's limits.
  104675. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104676. * @param upperLimit The upper limit of the motor
  104677. * @param lowerLimit The lower limit of the motor
  104678. */
  104679. setLimit(upperLimit: number, lowerLimit?: number): void;
  104680. }
  104681. /**
  104682. * This class represents a single physics Hinge-Joint
  104683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104684. */
  104685. export class HingeJoint extends MotorEnabledJoint {
  104686. /**
  104687. * Initializes the Hinge-Joint
  104688. * @param jointData The joint data for the Hinge-Joint
  104689. */
  104690. constructor(jointData: PhysicsJointData);
  104691. /**
  104692. * Set the motor values.
  104693. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104694. * @param {number} force the force to apply
  104695. * @param {number} maxForce max force for this motor.
  104696. */
  104697. setMotor(force?: number, maxForce?: number): void;
  104698. /**
  104699. * Set the motor's limits.
  104700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104701. * @param upperLimit The upper limit of the motor
  104702. * @param lowerLimit The lower limit of the motor
  104703. */
  104704. setLimit(upperLimit: number, lowerLimit?: number): void;
  104705. }
  104706. /**
  104707. * This class represents a dual hinge physics joint (same as wheel joint)
  104708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104709. */
  104710. export class Hinge2Joint extends MotorEnabledJoint {
  104711. /**
  104712. * Initializes the Hinge2-Joint
  104713. * @param jointData The joint data for the Hinge2-Joint
  104714. */
  104715. constructor(jointData: PhysicsJointData);
  104716. /**
  104717. * Set the motor values.
  104718. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104719. * @param {number} targetSpeed the speed the motor is to reach
  104720. * @param {number} maxForce max force for this motor.
  104721. * @param {motorIndex} the motor's index, 0 or 1.
  104722. */
  104723. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104724. /**
  104725. * Set the motor limits.
  104726. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104727. * @param {number} upperLimit the upper limit
  104728. * @param {number} lowerLimit lower limit
  104729. * @param {motorIndex} the motor's index, 0 or 1.
  104730. */
  104731. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104732. }
  104733. /**
  104734. * Interface for a motor enabled joint
  104735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104736. */
  104737. export interface IMotorEnabledJoint {
  104738. /**
  104739. * Physics joint
  104740. */
  104741. physicsJoint: any;
  104742. /**
  104743. * Sets the motor of the motor-enabled joint
  104744. * @param force The force of the motor
  104745. * @param maxForce The maximum force of the motor
  104746. * @param motorIndex The index of the motor
  104747. */
  104748. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104749. /**
  104750. * Sets the limit of the motor
  104751. * @param upperLimit The upper limit of the motor
  104752. * @param lowerLimit The lower limit of the motor
  104753. * @param motorIndex The index of the motor
  104754. */
  104755. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104756. }
  104757. /**
  104758. * Joint data for a Distance-Joint
  104759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104760. */
  104761. export interface DistanceJointData extends PhysicsJointData {
  104762. /**
  104763. * Max distance the 2 joint objects can be apart
  104764. */
  104765. maxDistance: number;
  104766. }
  104767. /**
  104768. * Joint data from a spring joint
  104769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104770. */
  104771. export interface SpringJointData extends PhysicsJointData {
  104772. /**
  104773. * Length of the spring
  104774. */
  104775. length: number;
  104776. /**
  104777. * Stiffness of the spring
  104778. */
  104779. stiffness: number;
  104780. /**
  104781. * Damping of the spring
  104782. */
  104783. damping: number;
  104784. /** this callback will be called when applying the force to the impostors. */
  104785. forceApplicationCallback: () => void;
  104786. }
  104787. }
  104788. declare module BABYLON {
  104789. /**
  104790. * Holds the data for the raycast result
  104791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104792. */
  104793. export class PhysicsRaycastResult {
  104794. private _hasHit;
  104795. private _hitDistance;
  104796. private _hitNormalWorld;
  104797. private _hitPointWorld;
  104798. private _rayFromWorld;
  104799. private _rayToWorld;
  104800. /**
  104801. * Gets if there was a hit
  104802. */
  104803. get hasHit(): boolean;
  104804. /**
  104805. * Gets the distance from the hit
  104806. */
  104807. get hitDistance(): number;
  104808. /**
  104809. * Gets the hit normal/direction in the world
  104810. */
  104811. get hitNormalWorld(): Vector3;
  104812. /**
  104813. * Gets the hit point in the world
  104814. */
  104815. get hitPointWorld(): Vector3;
  104816. /**
  104817. * Gets the ray "start point" of the ray in the world
  104818. */
  104819. get rayFromWorld(): Vector3;
  104820. /**
  104821. * Gets the ray "end point" of the ray in the world
  104822. */
  104823. get rayToWorld(): Vector3;
  104824. /**
  104825. * Sets the hit data (normal & point in world space)
  104826. * @param hitNormalWorld defines the normal in world space
  104827. * @param hitPointWorld defines the point in world space
  104828. */
  104829. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104830. /**
  104831. * Sets the distance from the start point to the hit point
  104832. * @param distance
  104833. */
  104834. setHitDistance(distance: number): void;
  104835. /**
  104836. * Calculates the distance manually
  104837. */
  104838. calculateHitDistance(): void;
  104839. /**
  104840. * Resets all the values to default
  104841. * @param from The from point on world space
  104842. * @param to The to point on world space
  104843. */
  104844. reset(from?: Vector3, to?: Vector3): void;
  104845. }
  104846. /**
  104847. * Interface for the size containing width and height
  104848. */
  104849. interface IXYZ {
  104850. /**
  104851. * X
  104852. */
  104853. x: number;
  104854. /**
  104855. * Y
  104856. */
  104857. y: number;
  104858. /**
  104859. * Z
  104860. */
  104861. z: number;
  104862. }
  104863. }
  104864. declare module BABYLON {
  104865. /**
  104866. * Interface used to describe a physics joint
  104867. */
  104868. export interface PhysicsImpostorJoint {
  104869. /** Defines the main impostor to which the joint is linked */
  104870. mainImpostor: PhysicsImpostor;
  104871. /** Defines the impostor that is connected to the main impostor using this joint */
  104872. connectedImpostor: PhysicsImpostor;
  104873. /** Defines the joint itself */
  104874. joint: PhysicsJoint;
  104875. }
  104876. /** @hidden */
  104877. export interface IPhysicsEnginePlugin {
  104878. world: any;
  104879. name: string;
  104880. setGravity(gravity: Vector3): void;
  104881. setTimeStep(timeStep: number): void;
  104882. getTimeStep(): number;
  104883. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104884. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104885. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104886. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104887. removePhysicsBody(impostor: PhysicsImpostor): void;
  104888. generateJoint(joint: PhysicsImpostorJoint): void;
  104889. removeJoint(joint: PhysicsImpostorJoint): void;
  104890. isSupported(): boolean;
  104891. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104893. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104894. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104895. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104896. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104897. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104898. getBodyMass(impostor: PhysicsImpostor): number;
  104899. getBodyFriction(impostor: PhysicsImpostor): number;
  104900. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104901. getBodyRestitution(impostor: PhysicsImpostor): number;
  104902. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104903. getBodyPressure?(impostor: PhysicsImpostor): number;
  104904. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104905. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104906. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104907. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104908. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104909. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104910. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104911. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104912. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104913. sleepBody(impostor: PhysicsImpostor): void;
  104914. wakeUpBody(impostor: PhysicsImpostor): void;
  104915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104917. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104918. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104919. getRadius(impostor: PhysicsImpostor): number;
  104920. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104922. dispose(): void;
  104923. }
  104924. /**
  104925. * Interface used to define a physics engine
  104926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104927. */
  104928. export interface IPhysicsEngine {
  104929. /**
  104930. * Gets the gravity vector used by the simulation
  104931. */
  104932. gravity: Vector3;
  104933. /**
  104934. * Sets the gravity vector used by the simulation
  104935. * @param gravity defines the gravity vector to use
  104936. */
  104937. setGravity(gravity: Vector3): void;
  104938. /**
  104939. * Set the time step of the physics engine.
  104940. * Default is 1/60.
  104941. * To slow it down, enter 1/600 for example.
  104942. * To speed it up, 1/30
  104943. * @param newTimeStep the new timestep to apply to this world.
  104944. */
  104945. setTimeStep(newTimeStep: number): void;
  104946. /**
  104947. * Get the time step of the physics engine.
  104948. * @returns the current time step
  104949. */
  104950. getTimeStep(): number;
  104951. /**
  104952. * Set the sub time step of the physics engine.
  104953. * Default is 0 meaning there is no sub steps
  104954. * To increase physics resolution precision, set a small value (like 1 ms)
  104955. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104956. */
  104957. setSubTimeStep(subTimeStep: number): void;
  104958. /**
  104959. * Get the sub time step of the physics engine.
  104960. * @returns the current sub time step
  104961. */
  104962. getSubTimeStep(): number;
  104963. /**
  104964. * Release all resources
  104965. */
  104966. dispose(): void;
  104967. /**
  104968. * Gets the name of the current physics plugin
  104969. * @returns the name of the plugin
  104970. */
  104971. getPhysicsPluginName(): string;
  104972. /**
  104973. * Adding a new impostor for the impostor tracking.
  104974. * This will be done by the impostor itself.
  104975. * @param impostor the impostor to add
  104976. */
  104977. addImpostor(impostor: PhysicsImpostor): void;
  104978. /**
  104979. * Remove an impostor from the engine.
  104980. * This impostor and its mesh will not longer be updated by the physics engine.
  104981. * @param impostor the impostor to remove
  104982. */
  104983. removeImpostor(impostor: PhysicsImpostor): void;
  104984. /**
  104985. * Add a joint to the physics engine
  104986. * @param mainImpostor defines the main impostor to which the joint is added.
  104987. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104988. * @param joint defines the joint that will connect both impostors.
  104989. */
  104990. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104991. /**
  104992. * Removes a joint from the simulation
  104993. * @param mainImpostor defines the impostor used with the joint
  104994. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104995. * @param joint defines the joint to remove
  104996. */
  104997. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104998. /**
  104999. * Gets the current plugin used to run the simulation
  105000. * @returns current plugin
  105001. */
  105002. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105003. /**
  105004. * Gets the list of physic impostors
  105005. * @returns an array of PhysicsImpostor
  105006. */
  105007. getImpostors(): Array<PhysicsImpostor>;
  105008. /**
  105009. * Gets the impostor for a physics enabled object
  105010. * @param object defines the object impersonated by the impostor
  105011. * @returns the PhysicsImpostor or null if not found
  105012. */
  105013. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105014. /**
  105015. * Gets the impostor for a physics body object
  105016. * @param body defines physics body used by the impostor
  105017. * @returns the PhysicsImpostor or null if not found
  105018. */
  105019. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105020. /**
  105021. * Does a raycast in the physics world
  105022. * @param from when should the ray start?
  105023. * @param to when should the ray end?
  105024. * @returns PhysicsRaycastResult
  105025. */
  105026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105027. /**
  105028. * Called by the scene. No need to call it.
  105029. * @param delta defines the timespam between frames
  105030. */
  105031. _step(delta: number): void;
  105032. }
  105033. }
  105034. declare module BABYLON {
  105035. /**
  105036. * The interface for the physics imposter parameters
  105037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105038. */
  105039. export interface PhysicsImpostorParameters {
  105040. /**
  105041. * The mass of the physics imposter
  105042. */
  105043. mass: number;
  105044. /**
  105045. * The friction of the physics imposter
  105046. */
  105047. friction?: number;
  105048. /**
  105049. * The coefficient of restitution of the physics imposter
  105050. */
  105051. restitution?: number;
  105052. /**
  105053. * The native options of the physics imposter
  105054. */
  105055. nativeOptions?: any;
  105056. /**
  105057. * Specifies if the parent should be ignored
  105058. */
  105059. ignoreParent?: boolean;
  105060. /**
  105061. * Specifies if bi-directional transformations should be disabled
  105062. */
  105063. disableBidirectionalTransformation?: boolean;
  105064. /**
  105065. * The pressure inside the physics imposter, soft object only
  105066. */
  105067. pressure?: number;
  105068. /**
  105069. * The stiffness the physics imposter, soft object only
  105070. */
  105071. stiffness?: number;
  105072. /**
  105073. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  105074. */
  105075. velocityIterations?: number;
  105076. /**
  105077. * The number of iterations used in maintaining consistent vertex positions, soft object only
  105078. */
  105079. positionIterations?: number;
  105080. /**
  105081. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  105082. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  105083. * Add to fix multiple points
  105084. */
  105085. fixedPoints?: number;
  105086. /**
  105087. * The collision margin around a soft object
  105088. */
  105089. margin?: number;
  105090. /**
  105091. * The collision margin around a soft object
  105092. */
  105093. damping?: number;
  105094. /**
  105095. * The path for a rope based on an extrusion
  105096. */
  105097. path?: any;
  105098. /**
  105099. * The shape of an extrusion used for a rope based on an extrusion
  105100. */
  105101. shape?: any;
  105102. }
  105103. /**
  105104. * Interface for a physics-enabled object
  105105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105106. */
  105107. export interface IPhysicsEnabledObject {
  105108. /**
  105109. * The position of the physics-enabled object
  105110. */
  105111. position: Vector3;
  105112. /**
  105113. * The rotation of the physics-enabled object
  105114. */
  105115. rotationQuaternion: Nullable<Quaternion>;
  105116. /**
  105117. * The scale of the physics-enabled object
  105118. */
  105119. scaling: Vector3;
  105120. /**
  105121. * The rotation of the physics-enabled object
  105122. */
  105123. rotation?: Vector3;
  105124. /**
  105125. * The parent of the physics-enabled object
  105126. */
  105127. parent?: any;
  105128. /**
  105129. * The bounding info of the physics-enabled object
  105130. * @returns The bounding info of the physics-enabled object
  105131. */
  105132. getBoundingInfo(): BoundingInfo;
  105133. /**
  105134. * Computes the world matrix
  105135. * @param force Specifies if the world matrix should be computed by force
  105136. * @returns A world matrix
  105137. */
  105138. computeWorldMatrix(force: boolean): Matrix;
  105139. /**
  105140. * Gets the world matrix
  105141. * @returns A world matrix
  105142. */
  105143. getWorldMatrix?(): Matrix;
  105144. /**
  105145. * Gets the child meshes
  105146. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  105147. * @returns An array of abstract meshes
  105148. */
  105149. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  105150. /**
  105151. * Gets the vertex data
  105152. * @param kind The type of vertex data
  105153. * @returns A nullable array of numbers, or a float32 array
  105154. */
  105155. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  105156. /**
  105157. * Gets the indices from the mesh
  105158. * @returns A nullable array of index arrays
  105159. */
  105160. getIndices?(): Nullable<IndicesArray>;
  105161. /**
  105162. * Gets the scene from the mesh
  105163. * @returns the indices array or null
  105164. */
  105165. getScene?(): Scene;
  105166. /**
  105167. * Gets the absolute position from the mesh
  105168. * @returns the absolute position
  105169. */
  105170. getAbsolutePosition(): Vector3;
  105171. /**
  105172. * Gets the absolute pivot point from the mesh
  105173. * @returns the absolute pivot point
  105174. */
  105175. getAbsolutePivotPoint(): Vector3;
  105176. /**
  105177. * Rotates the mesh
  105178. * @param axis The axis of rotation
  105179. * @param amount The amount of rotation
  105180. * @param space The space of the rotation
  105181. * @returns The rotation transform node
  105182. */
  105183. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  105184. /**
  105185. * Translates the mesh
  105186. * @param axis The axis of translation
  105187. * @param distance The distance of translation
  105188. * @param space The space of the translation
  105189. * @returns The transform node
  105190. */
  105191. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  105192. /**
  105193. * Sets the absolute position of the mesh
  105194. * @param absolutePosition The absolute position of the mesh
  105195. * @returns The transform node
  105196. */
  105197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  105198. /**
  105199. * Gets the class name of the mesh
  105200. * @returns The class name
  105201. */
  105202. getClassName(): string;
  105203. }
  105204. /**
  105205. * Represents a physics imposter
  105206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105207. */
  105208. export class PhysicsImpostor {
  105209. /**
  105210. * The physics-enabled object used as the physics imposter
  105211. */
  105212. object: IPhysicsEnabledObject;
  105213. /**
  105214. * The type of the physics imposter
  105215. */
  105216. type: number;
  105217. private _options;
  105218. private _scene?;
  105219. /**
  105220. * The default object size of the imposter
  105221. */
  105222. static DEFAULT_OBJECT_SIZE: Vector3;
  105223. /**
  105224. * The identity quaternion of the imposter
  105225. */
  105226. static IDENTITY_QUATERNION: Quaternion;
  105227. /** @hidden */
  105228. _pluginData: any;
  105229. private _physicsEngine;
  105230. private _physicsBody;
  105231. private _bodyUpdateRequired;
  105232. private _onBeforePhysicsStepCallbacks;
  105233. private _onAfterPhysicsStepCallbacks;
  105234. /** @hidden */
  105235. _onPhysicsCollideCallbacks: Array<{
  105236. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  105237. otherImpostors: Array<PhysicsImpostor>;
  105238. }>;
  105239. private _deltaPosition;
  105240. private _deltaRotation;
  105241. private _deltaRotationConjugated;
  105242. /** @hidden */
  105243. _isFromLine: boolean;
  105244. private _parent;
  105245. private _isDisposed;
  105246. private static _tmpVecs;
  105247. private static _tmpQuat;
  105248. /**
  105249. * Specifies if the physics imposter is disposed
  105250. */
  105251. get isDisposed(): boolean;
  105252. /**
  105253. * Gets the mass of the physics imposter
  105254. */
  105255. get mass(): number;
  105256. set mass(value: number);
  105257. /**
  105258. * Gets the coefficient of friction
  105259. */
  105260. get friction(): number;
  105261. /**
  105262. * Sets the coefficient of friction
  105263. */
  105264. set friction(value: number);
  105265. /**
  105266. * Gets the coefficient of restitution
  105267. */
  105268. get restitution(): number;
  105269. /**
  105270. * Sets the coefficient of restitution
  105271. */
  105272. set restitution(value: number);
  105273. /**
  105274. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  105275. */
  105276. get pressure(): number;
  105277. /**
  105278. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  105279. */
  105280. set pressure(value: number);
  105281. /**
  105282. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  105283. */
  105284. get stiffness(): number;
  105285. /**
  105286. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  105287. */
  105288. set stiffness(value: number);
  105289. /**
  105290. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  105291. */
  105292. get velocityIterations(): number;
  105293. /**
  105294. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  105295. */
  105296. set velocityIterations(value: number);
  105297. /**
  105298. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105299. */
  105300. get positionIterations(): number;
  105301. /**
  105302. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105303. */
  105304. set positionIterations(value: number);
  105305. /**
  105306. * The unique id of the physics imposter
  105307. * set by the physics engine when adding this impostor to the array
  105308. */
  105309. uniqueId: number;
  105310. /**
  105311. * @hidden
  105312. */
  105313. soft: boolean;
  105314. /**
  105315. * @hidden
  105316. */
  105317. segments: number;
  105318. private _joints;
  105319. /**
  105320. * Initializes the physics imposter
  105321. * @param object The physics-enabled object used as the physics imposter
  105322. * @param type The type of the physics imposter
  105323. * @param _options The options for the physics imposter
  105324. * @param _scene The Babylon scene
  105325. */
  105326. constructor(
  105327. /**
  105328. * The physics-enabled object used as the physics imposter
  105329. */
  105330. object: IPhysicsEnabledObject,
  105331. /**
  105332. * The type of the physics imposter
  105333. */
  105334. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105335. /**
  105336. * This function will completly initialize this impostor.
  105337. * It will create a new body - but only if this mesh has no parent.
  105338. * If it has, this impostor will not be used other than to define the impostor
  105339. * of the child mesh.
  105340. * @hidden
  105341. */
  105342. _init(): void;
  105343. private _getPhysicsParent;
  105344. /**
  105345. * Should a new body be generated.
  105346. * @returns boolean specifying if body initialization is required
  105347. */
  105348. isBodyInitRequired(): boolean;
  105349. /**
  105350. * Sets the updated scaling
  105351. * @param updated Specifies if the scaling is updated
  105352. */
  105353. setScalingUpdated(): void;
  105354. /**
  105355. * Force a regeneration of this or the parent's impostor's body.
  105356. * Use under cautious - This will remove all joints already implemented.
  105357. */
  105358. forceUpdate(): void;
  105359. /**
  105360. * Gets the body that holds this impostor. Either its own, or its parent.
  105361. */
  105362. get physicsBody(): any;
  105363. /**
  105364. * Get the parent of the physics imposter
  105365. * @returns Physics imposter or null
  105366. */
  105367. get parent(): Nullable<PhysicsImpostor>;
  105368. /**
  105369. * Sets the parent of the physics imposter
  105370. */
  105371. set parent(value: Nullable<PhysicsImpostor>);
  105372. /**
  105373. * Set the physics body. Used mainly by the physics engine/plugin
  105374. */
  105375. set physicsBody(physicsBody: any);
  105376. /**
  105377. * Resets the update flags
  105378. */
  105379. resetUpdateFlags(): void;
  105380. /**
  105381. * Gets the object extend size
  105382. * @returns the object extend size
  105383. */
  105384. getObjectExtendSize(): Vector3;
  105385. /**
  105386. * Gets the object center
  105387. * @returns The object center
  105388. */
  105389. getObjectCenter(): Vector3;
  105390. /**
  105391. * Get a specific parameter from the options parameters
  105392. * @param paramName The object parameter name
  105393. * @returns The object parameter
  105394. */
  105395. getParam(paramName: string): any;
  105396. /**
  105397. * Sets a specific parameter in the options given to the physics plugin
  105398. * @param paramName The parameter name
  105399. * @param value The value of the parameter
  105400. */
  105401. setParam(paramName: string, value: number): void;
  105402. /**
  105403. * Specifically change the body's mass option. Won't recreate the physics body object
  105404. * @param mass The mass of the physics imposter
  105405. */
  105406. setMass(mass: number): void;
  105407. /**
  105408. * Gets the linear velocity
  105409. * @returns linear velocity or null
  105410. */
  105411. getLinearVelocity(): Nullable<Vector3>;
  105412. /**
  105413. * Sets the linear velocity
  105414. * @param velocity linear velocity or null
  105415. */
  105416. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105417. /**
  105418. * Gets the angular velocity
  105419. * @returns angular velocity or null
  105420. */
  105421. getAngularVelocity(): Nullable<Vector3>;
  105422. /**
  105423. * Sets the angular velocity
  105424. * @param velocity The velocity or null
  105425. */
  105426. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105427. /**
  105428. * Execute a function with the physics plugin native code
  105429. * Provide a function the will have two variables - the world object and the physics body object
  105430. * @param func The function to execute with the physics plugin native code
  105431. */
  105432. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105433. /**
  105434. * Register a function that will be executed before the physics world is stepping forward
  105435. * @param func The function to execute before the physics world is stepped forward
  105436. */
  105437. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105438. /**
  105439. * Unregister a function that will be executed before the physics world is stepping forward
  105440. * @param func The function to execute before the physics world is stepped forward
  105441. */
  105442. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105443. /**
  105444. * Register a function that will be executed after the physics step
  105445. * @param func The function to execute after physics step
  105446. */
  105447. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105448. /**
  105449. * Unregisters a function that will be executed after the physics step
  105450. * @param func The function to execute after physics step
  105451. */
  105452. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105453. /**
  105454. * register a function that will be executed when this impostor collides against a different body
  105455. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105456. * @param func Callback that is executed on collision
  105457. */
  105458. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105459. /**
  105460. * Unregisters the physics imposter on contact
  105461. * @param collideAgainst The physics object to collide against
  105462. * @param func Callback to execute on collision
  105463. */
  105464. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105465. private _tmpQuat;
  105466. private _tmpQuat2;
  105467. /**
  105468. * Get the parent rotation
  105469. * @returns The parent rotation
  105470. */
  105471. getParentsRotation(): Quaternion;
  105472. /**
  105473. * this function is executed by the physics engine.
  105474. */
  105475. beforeStep: () => void;
  105476. /**
  105477. * this function is executed by the physics engine
  105478. */
  105479. afterStep: () => void;
  105480. /**
  105481. * Legacy collision detection event support
  105482. */
  105483. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105484. /**
  105485. * event and body object due to cannon's event-based architecture.
  105486. */
  105487. onCollide: (e: {
  105488. body: any;
  105489. }) => void;
  105490. /**
  105491. * Apply a force
  105492. * @param force The force to apply
  105493. * @param contactPoint The contact point for the force
  105494. * @returns The physics imposter
  105495. */
  105496. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105497. /**
  105498. * Apply an impulse
  105499. * @param force The impulse force
  105500. * @param contactPoint The contact point for the impulse force
  105501. * @returns The physics imposter
  105502. */
  105503. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105504. /**
  105505. * A help function to create a joint
  105506. * @param otherImpostor A physics imposter used to create a joint
  105507. * @param jointType The type of joint
  105508. * @param jointData The data for the joint
  105509. * @returns The physics imposter
  105510. */
  105511. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105512. /**
  105513. * Add a joint to this impostor with a different impostor
  105514. * @param otherImpostor A physics imposter used to add a joint
  105515. * @param joint The joint to add
  105516. * @returns The physics imposter
  105517. */
  105518. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105519. /**
  105520. * Add an anchor to a cloth impostor
  105521. * @param otherImpostor rigid impostor to anchor to
  105522. * @param width ratio across width from 0 to 1
  105523. * @param height ratio up height from 0 to 1
  105524. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105525. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105526. * @returns impostor the soft imposter
  105527. */
  105528. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105529. /**
  105530. * Add a hook to a rope impostor
  105531. * @param otherImpostor rigid impostor to anchor to
  105532. * @param length ratio across rope from 0 to 1
  105533. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105534. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105535. * @returns impostor the rope imposter
  105536. */
  105537. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105538. /**
  105539. * Will keep this body still, in a sleep mode.
  105540. * @returns the physics imposter
  105541. */
  105542. sleep(): PhysicsImpostor;
  105543. /**
  105544. * Wake the body up.
  105545. * @returns The physics imposter
  105546. */
  105547. wakeUp(): PhysicsImpostor;
  105548. /**
  105549. * Clones the physics imposter
  105550. * @param newObject The physics imposter clones to this physics-enabled object
  105551. * @returns A nullable physics imposter
  105552. */
  105553. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105554. /**
  105555. * Disposes the physics imposter
  105556. */
  105557. dispose(): void;
  105558. /**
  105559. * Sets the delta position
  105560. * @param position The delta position amount
  105561. */
  105562. setDeltaPosition(position: Vector3): void;
  105563. /**
  105564. * Sets the delta rotation
  105565. * @param rotation The delta rotation amount
  105566. */
  105567. setDeltaRotation(rotation: Quaternion): void;
  105568. /**
  105569. * Gets the box size of the physics imposter and stores the result in the input parameter
  105570. * @param result Stores the box size
  105571. * @returns The physics imposter
  105572. */
  105573. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105574. /**
  105575. * Gets the radius of the physics imposter
  105576. * @returns Radius of the physics imposter
  105577. */
  105578. getRadius(): number;
  105579. /**
  105580. * Sync a bone with this impostor
  105581. * @param bone The bone to sync to the impostor.
  105582. * @param boneMesh The mesh that the bone is influencing.
  105583. * @param jointPivot The pivot of the joint / bone in local space.
  105584. * @param distToJoint Optional distance from the impostor to the joint.
  105585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105586. */
  105587. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105588. /**
  105589. * Sync impostor to a bone
  105590. * @param bone The bone that the impostor will be synced to.
  105591. * @param boneMesh The mesh that the bone is influencing.
  105592. * @param jointPivot The pivot of the joint / bone in local space.
  105593. * @param distToJoint Optional distance from the impostor to the joint.
  105594. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105595. * @param boneAxis Optional vector3 axis the bone is aligned with
  105596. */
  105597. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105598. /**
  105599. * No-Imposter type
  105600. */
  105601. static NoImpostor: number;
  105602. /**
  105603. * Sphere-Imposter type
  105604. */
  105605. static SphereImpostor: number;
  105606. /**
  105607. * Box-Imposter type
  105608. */
  105609. static BoxImpostor: number;
  105610. /**
  105611. * Plane-Imposter type
  105612. */
  105613. static PlaneImpostor: number;
  105614. /**
  105615. * Mesh-imposter type
  105616. */
  105617. static MeshImpostor: number;
  105618. /**
  105619. * Capsule-Impostor type (Ammo.js plugin only)
  105620. */
  105621. static CapsuleImpostor: number;
  105622. /**
  105623. * Cylinder-Imposter type
  105624. */
  105625. static CylinderImpostor: number;
  105626. /**
  105627. * Particle-Imposter type
  105628. */
  105629. static ParticleImpostor: number;
  105630. /**
  105631. * Heightmap-Imposter type
  105632. */
  105633. static HeightmapImpostor: number;
  105634. /**
  105635. * ConvexHull-Impostor type (Ammo.js plugin only)
  105636. */
  105637. static ConvexHullImpostor: number;
  105638. /**
  105639. * Custom-Imposter type (Ammo.js plugin only)
  105640. */
  105641. static CustomImpostor: number;
  105642. /**
  105643. * Rope-Imposter type
  105644. */
  105645. static RopeImpostor: number;
  105646. /**
  105647. * Cloth-Imposter type
  105648. */
  105649. static ClothImpostor: number;
  105650. /**
  105651. * Softbody-Imposter type
  105652. */
  105653. static SoftbodyImpostor: number;
  105654. }
  105655. }
  105656. declare module BABYLON {
  105657. /**
  105658. * @hidden
  105659. **/
  105660. export class _CreationDataStorage {
  105661. closePath?: boolean;
  105662. closeArray?: boolean;
  105663. idx: number[];
  105664. dashSize: number;
  105665. gapSize: number;
  105666. path3D: Path3D;
  105667. pathArray: Vector3[][];
  105668. arc: number;
  105669. radius: number;
  105670. cap: number;
  105671. tessellation: number;
  105672. }
  105673. /**
  105674. * @hidden
  105675. **/
  105676. class _InstanceDataStorage {
  105677. visibleInstances: any;
  105678. batchCache: _InstancesBatch;
  105679. instancesBufferSize: number;
  105680. instancesBuffer: Nullable<Buffer>;
  105681. instancesData: Float32Array;
  105682. overridenInstanceCount: number;
  105683. isFrozen: boolean;
  105684. previousBatch: Nullable<_InstancesBatch>;
  105685. hardwareInstancedRendering: boolean;
  105686. sideOrientation: number;
  105687. manualUpdate: boolean;
  105688. }
  105689. /**
  105690. * @hidden
  105691. **/
  105692. export class _InstancesBatch {
  105693. mustReturn: boolean;
  105694. visibleInstances: Nullable<InstancedMesh[]>[];
  105695. renderSelf: boolean[];
  105696. hardwareInstancedRendering: boolean[];
  105697. }
  105698. /**
  105699. * @hidden
  105700. **/
  105701. class _ThinInstanceDataStorage {
  105702. instancesCount: number;
  105703. matrixBuffer: Nullable<Buffer>;
  105704. matrixBufferSize: number;
  105705. matrixData: Nullable<Float32Array>;
  105706. boundingVectors: Array<Vector3>;
  105707. }
  105708. /**
  105709. * Class used to represent renderable models
  105710. */
  105711. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105712. /**
  105713. * Mesh side orientation : usually the external or front surface
  105714. */
  105715. static readonly FRONTSIDE: number;
  105716. /**
  105717. * Mesh side orientation : usually the internal or back surface
  105718. */
  105719. static readonly BACKSIDE: number;
  105720. /**
  105721. * Mesh side orientation : both internal and external or front and back surfaces
  105722. */
  105723. static readonly DOUBLESIDE: number;
  105724. /**
  105725. * Mesh side orientation : by default, `FRONTSIDE`
  105726. */
  105727. static readonly DEFAULTSIDE: number;
  105728. /**
  105729. * Mesh cap setting : no cap
  105730. */
  105731. static readonly NO_CAP: number;
  105732. /**
  105733. * Mesh cap setting : one cap at the beginning of the mesh
  105734. */
  105735. static readonly CAP_START: number;
  105736. /**
  105737. * Mesh cap setting : one cap at the end of the mesh
  105738. */
  105739. static readonly CAP_END: number;
  105740. /**
  105741. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105742. */
  105743. static readonly CAP_ALL: number;
  105744. /**
  105745. * Mesh pattern setting : no flip or rotate
  105746. */
  105747. static readonly NO_FLIP: number;
  105748. /**
  105749. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105750. */
  105751. static readonly FLIP_TILE: number;
  105752. /**
  105753. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105754. */
  105755. static readonly ROTATE_TILE: number;
  105756. /**
  105757. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105758. */
  105759. static readonly FLIP_ROW: number;
  105760. /**
  105761. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105762. */
  105763. static readonly ROTATE_ROW: number;
  105764. /**
  105765. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105766. */
  105767. static readonly FLIP_N_ROTATE_TILE: number;
  105768. /**
  105769. * Mesh pattern setting : rotate pattern and rotate
  105770. */
  105771. static readonly FLIP_N_ROTATE_ROW: number;
  105772. /**
  105773. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105774. */
  105775. static readonly CENTER: number;
  105776. /**
  105777. * Mesh tile positioning : part tiles on left
  105778. */
  105779. static readonly LEFT: number;
  105780. /**
  105781. * Mesh tile positioning : part tiles on right
  105782. */
  105783. static readonly RIGHT: number;
  105784. /**
  105785. * Mesh tile positioning : part tiles on top
  105786. */
  105787. static readonly TOP: number;
  105788. /**
  105789. * Mesh tile positioning : part tiles on bottom
  105790. */
  105791. static readonly BOTTOM: number;
  105792. /**
  105793. * Gets the default side orientation.
  105794. * @param orientation the orientation to value to attempt to get
  105795. * @returns the default orientation
  105796. * @hidden
  105797. */
  105798. static _GetDefaultSideOrientation(orientation?: number): number;
  105799. private _internalMeshDataInfo;
  105800. /**
  105801. * An event triggered before rendering the mesh
  105802. */
  105803. get onBeforeRenderObservable(): Observable<Mesh>;
  105804. /**
  105805. * An event triggered before binding the mesh
  105806. */
  105807. get onBeforeBindObservable(): Observable<Mesh>;
  105808. /**
  105809. * An event triggered after rendering the mesh
  105810. */
  105811. get onAfterRenderObservable(): Observable<Mesh>;
  105812. /**
  105813. * An event triggered before drawing the mesh
  105814. */
  105815. get onBeforeDrawObservable(): Observable<Mesh>;
  105816. private _onBeforeDrawObserver;
  105817. /**
  105818. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105819. */
  105820. set onBeforeDraw(callback: () => void);
  105821. get hasInstances(): boolean;
  105822. get hasThinInstances(): boolean;
  105823. /**
  105824. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105825. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105826. */
  105827. delayLoadState: number;
  105828. /**
  105829. * Gets the list of instances created from this mesh
  105830. * it is not supposed to be modified manually.
  105831. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105832. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105833. */
  105834. instances: InstancedMesh[];
  105835. /**
  105836. * Gets the file containing delay loading data for this mesh
  105837. */
  105838. delayLoadingFile: string;
  105839. /** @hidden */
  105840. _binaryInfo: any;
  105841. /**
  105842. * User defined function used to change how LOD level selection is done
  105843. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105844. */
  105845. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105846. /**
  105847. * Gets or sets the morph target manager
  105848. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105849. */
  105850. get morphTargetManager(): Nullable<MorphTargetManager>;
  105851. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105852. /** @hidden */
  105853. _creationDataStorage: Nullable<_CreationDataStorage>;
  105854. /** @hidden */
  105855. _geometry: Nullable<Geometry>;
  105856. /** @hidden */
  105857. _delayInfo: Array<string>;
  105858. /** @hidden */
  105859. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105860. /** @hidden */
  105861. _instanceDataStorage: _InstanceDataStorage;
  105862. /** @hidden */
  105863. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105864. private _effectiveMaterial;
  105865. /** @hidden */
  105866. _shouldGenerateFlatShading: boolean;
  105867. /** @hidden */
  105868. _originalBuilderSideOrientation: number;
  105869. /**
  105870. * Use this property to change the original side orientation defined at construction time
  105871. */
  105872. overrideMaterialSideOrientation: Nullable<number>;
  105873. /**
  105874. * Gets the source mesh (the one used to clone this one from)
  105875. */
  105876. get source(): Nullable<Mesh>;
  105877. /**
  105878. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105879. */
  105880. get isUnIndexed(): boolean;
  105881. set isUnIndexed(value: boolean);
  105882. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105883. get worldMatrixInstancedBuffer(): Float32Array;
  105884. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105885. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105886. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105887. /**
  105888. * @constructor
  105889. * @param name The value used by scene.getMeshByName() to do a lookup.
  105890. * @param scene The scene to add this mesh to.
  105891. * @param parent The parent of this mesh, if it has one
  105892. * @param source An optional Mesh from which geometry is shared, cloned.
  105893. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105894. * When false, achieved by calling a clone(), also passing False.
  105895. * This will make creation of children, recursive.
  105896. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105897. */
  105898. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105899. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105900. doNotInstantiate: boolean;
  105901. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105902. /**
  105903. * Gets the class name
  105904. * @returns the string "Mesh".
  105905. */
  105906. getClassName(): string;
  105907. /** @hidden */
  105908. get _isMesh(): boolean;
  105909. /**
  105910. * Returns a description of this mesh
  105911. * @param fullDetails define if full details about this mesh must be used
  105912. * @returns a descriptive string representing this mesh
  105913. */
  105914. toString(fullDetails?: boolean): string;
  105915. /** @hidden */
  105916. _unBindEffect(): void;
  105917. /**
  105918. * Gets a boolean indicating if this mesh has LOD
  105919. */
  105920. get hasLODLevels(): boolean;
  105921. /**
  105922. * Gets the list of MeshLODLevel associated with the current mesh
  105923. * @returns an array of MeshLODLevel
  105924. */
  105925. getLODLevels(): MeshLODLevel[];
  105926. private _sortLODLevels;
  105927. /**
  105928. * Add a mesh as LOD level triggered at the given distance.
  105929. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105930. * @param distance The distance from the center of the object to show this level
  105931. * @param mesh The mesh to be added as LOD level (can be null)
  105932. * @return This mesh (for chaining)
  105933. */
  105934. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105935. /**
  105936. * Returns the LOD level mesh at the passed distance or null if not found.
  105937. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105938. * @param distance The distance from the center of the object to show this level
  105939. * @returns a Mesh or `null`
  105940. */
  105941. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105942. /**
  105943. * Remove a mesh from the LOD array
  105944. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105945. * @param mesh defines the mesh to be removed
  105946. * @return This mesh (for chaining)
  105947. */
  105948. removeLODLevel(mesh: Mesh): Mesh;
  105949. /**
  105950. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105951. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105952. * @param camera defines the camera to use to compute distance
  105953. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105954. * @return This mesh (for chaining)
  105955. */
  105956. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105957. /**
  105958. * Gets the mesh internal Geometry object
  105959. */
  105960. get geometry(): Nullable<Geometry>;
  105961. /**
  105962. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105963. * @returns the total number of vertices
  105964. */
  105965. getTotalVertices(): number;
  105966. /**
  105967. * Returns the content of an associated vertex buffer
  105968. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105969. * - VertexBuffer.PositionKind
  105970. * - VertexBuffer.UVKind
  105971. * - VertexBuffer.UV2Kind
  105972. * - VertexBuffer.UV3Kind
  105973. * - VertexBuffer.UV4Kind
  105974. * - VertexBuffer.UV5Kind
  105975. * - VertexBuffer.UV6Kind
  105976. * - VertexBuffer.ColorKind
  105977. * - VertexBuffer.MatricesIndicesKind
  105978. * - VertexBuffer.MatricesIndicesExtraKind
  105979. * - VertexBuffer.MatricesWeightsKind
  105980. * - VertexBuffer.MatricesWeightsExtraKind
  105981. * @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
  105982. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105983. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105984. */
  105985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105986. /**
  105987. * Returns the mesh VertexBuffer object from the requested `kind`
  105988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105989. * - VertexBuffer.PositionKind
  105990. * - VertexBuffer.NormalKind
  105991. * - VertexBuffer.UVKind
  105992. * - VertexBuffer.UV2Kind
  105993. * - VertexBuffer.UV3Kind
  105994. * - VertexBuffer.UV4Kind
  105995. * - VertexBuffer.UV5Kind
  105996. * - VertexBuffer.UV6Kind
  105997. * - VertexBuffer.ColorKind
  105998. * - VertexBuffer.MatricesIndicesKind
  105999. * - VertexBuffer.MatricesIndicesExtraKind
  106000. * - VertexBuffer.MatricesWeightsKind
  106001. * - VertexBuffer.MatricesWeightsExtraKind
  106002. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  106003. */
  106004. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106005. /**
  106006. * Tests if a specific vertex buffer is associated with this mesh
  106007. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106008. * - VertexBuffer.PositionKind
  106009. * - VertexBuffer.NormalKind
  106010. * - VertexBuffer.UVKind
  106011. * - VertexBuffer.UV2Kind
  106012. * - VertexBuffer.UV3Kind
  106013. * - VertexBuffer.UV4Kind
  106014. * - VertexBuffer.UV5Kind
  106015. * - VertexBuffer.UV6Kind
  106016. * - VertexBuffer.ColorKind
  106017. * - VertexBuffer.MatricesIndicesKind
  106018. * - VertexBuffer.MatricesIndicesExtraKind
  106019. * - VertexBuffer.MatricesWeightsKind
  106020. * - VertexBuffer.MatricesWeightsExtraKind
  106021. * @returns a boolean
  106022. */
  106023. isVerticesDataPresent(kind: string): boolean;
  106024. /**
  106025. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  106026. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106027. * - VertexBuffer.PositionKind
  106028. * - VertexBuffer.UVKind
  106029. * - VertexBuffer.UV2Kind
  106030. * - VertexBuffer.UV3Kind
  106031. * - VertexBuffer.UV4Kind
  106032. * - VertexBuffer.UV5Kind
  106033. * - VertexBuffer.UV6Kind
  106034. * - VertexBuffer.ColorKind
  106035. * - VertexBuffer.MatricesIndicesKind
  106036. * - VertexBuffer.MatricesIndicesExtraKind
  106037. * - VertexBuffer.MatricesWeightsKind
  106038. * - VertexBuffer.MatricesWeightsExtraKind
  106039. * @returns a boolean
  106040. */
  106041. isVertexBufferUpdatable(kind: string): boolean;
  106042. /**
  106043. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  106044. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106045. * - VertexBuffer.PositionKind
  106046. * - VertexBuffer.NormalKind
  106047. * - VertexBuffer.UVKind
  106048. * - VertexBuffer.UV2Kind
  106049. * - VertexBuffer.UV3Kind
  106050. * - VertexBuffer.UV4Kind
  106051. * - VertexBuffer.UV5Kind
  106052. * - VertexBuffer.UV6Kind
  106053. * - VertexBuffer.ColorKind
  106054. * - VertexBuffer.MatricesIndicesKind
  106055. * - VertexBuffer.MatricesIndicesExtraKind
  106056. * - VertexBuffer.MatricesWeightsKind
  106057. * - VertexBuffer.MatricesWeightsExtraKind
  106058. * @returns an array of strings
  106059. */
  106060. getVerticesDataKinds(): string[];
  106061. /**
  106062. * Returns a positive integer : the total number of indices in this mesh geometry.
  106063. * @returns the numner of indices or zero if the mesh has no geometry.
  106064. */
  106065. getTotalIndices(): number;
  106066. /**
  106067. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106068. * @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.
  106069. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106070. * @returns the indices array or an empty array if the mesh has no geometry
  106071. */
  106072. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106073. get isBlocked(): boolean;
  106074. /**
  106075. * Determine if the current mesh is ready to be rendered
  106076. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  106077. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  106078. * @returns true if all associated assets are ready (material, textures, shaders)
  106079. */
  106080. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  106081. /**
  106082. * 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.
  106083. */
  106084. get areNormalsFrozen(): boolean;
  106085. /**
  106086. * 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.
  106087. * @returns the current mesh
  106088. */
  106089. freezeNormals(): Mesh;
  106090. /**
  106091. * 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
  106092. * @returns the current mesh
  106093. */
  106094. unfreezeNormals(): Mesh;
  106095. /**
  106096. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  106097. */
  106098. set overridenInstanceCount(count: number);
  106099. /** @hidden */
  106100. _preActivate(): Mesh;
  106101. /** @hidden */
  106102. _preActivateForIntermediateRendering(renderId: number): Mesh;
  106103. /** @hidden */
  106104. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  106105. protected _afterComputeWorldMatrix(): void;
  106106. /** @hidden */
  106107. _postActivate(): void;
  106108. /**
  106109. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  106110. * This means the mesh underlying bounding box and sphere are recomputed.
  106111. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  106112. * @returns the current mesh
  106113. */
  106114. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  106115. /** @hidden */
  106116. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  106117. /**
  106118. * This function will subdivide the mesh into multiple submeshes
  106119. * @param count defines the expected number of submeshes
  106120. */
  106121. subdivide(count: number): void;
  106122. /**
  106123. * Copy a FloatArray into a specific associated vertex buffer
  106124. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106125. * - VertexBuffer.PositionKind
  106126. * - VertexBuffer.UVKind
  106127. * - VertexBuffer.UV2Kind
  106128. * - VertexBuffer.UV3Kind
  106129. * - VertexBuffer.UV4Kind
  106130. * - VertexBuffer.UV5Kind
  106131. * - VertexBuffer.UV6Kind
  106132. * - VertexBuffer.ColorKind
  106133. * - VertexBuffer.MatricesIndicesKind
  106134. * - VertexBuffer.MatricesIndicesExtraKind
  106135. * - VertexBuffer.MatricesWeightsKind
  106136. * - VertexBuffer.MatricesWeightsExtraKind
  106137. * @param data defines the data source
  106138. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106139. * @param stride defines the data stride size (can be null)
  106140. * @returns the current mesh
  106141. */
  106142. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  106143. /**
  106144. * Delete a vertex buffer associated with this mesh
  106145. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  106146. * - VertexBuffer.PositionKind
  106147. * - VertexBuffer.UVKind
  106148. * - VertexBuffer.UV2Kind
  106149. * - VertexBuffer.UV3Kind
  106150. * - VertexBuffer.UV4Kind
  106151. * - VertexBuffer.UV5Kind
  106152. * - VertexBuffer.UV6Kind
  106153. * - VertexBuffer.ColorKind
  106154. * - VertexBuffer.MatricesIndicesKind
  106155. * - VertexBuffer.MatricesIndicesExtraKind
  106156. * - VertexBuffer.MatricesWeightsKind
  106157. * - VertexBuffer.MatricesWeightsExtraKind
  106158. */
  106159. removeVerticesData(kind: string): void;
  106160. /**
  106161. * Flags an associated vertex buffer as updatable
  106162. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  106163. * - VertexBuffer.PositionKind
  106164. * - VertexBuffer.UVKind
  106165. * - VertexBuffer.UV2Kind
  106166. * - VertexBuffer.UV3Kind
  106167. * - VertexBuffer.UV4Kind
  106168. * - VertexBuffer.UV5Kind
  106169. * - VertexBuffer.UV6Kind
  106170. * - VertexBuffer.ColorKind
  106171. * - VertexBuffer.MatricesIndicesKind
  106172. * - VertexBuffer.MatricesIndicesExtraKind
  106173. * - VertexBuffer.MatricesWeightsKind
  106174. * - VertexBuffer.MatricesWeightsExtraKind
  106175. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106176. */
  106177. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  106178. /**
  106179. * Sets the mesh global Vertex Buffer
  106180. * @param buffer defines the buffer to use
  106181. * @returns the current mesh
  106182. */
  106183. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  106184. /**
  106185. * Update a specific associated vertex buffer
  106186. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106187. * - VertexBuffer.PositionKind
  106188. * - VertexBuffer.UVKind
  106189. * - VertexBuffer.UV2Kind
  106190. * - VertexBuffer.UV3Kind
  106191. * - VertexBuffer.UV4Kind
  106192. * - VertexBuffer.UV5Kind
  106193. * - VertexBuffer.UV6Kind
  106194. * - VertexBuffer.ColorKind
  106195. * - VertexBuffer.MatricesIndicesKind
  106196. * - VertexBuffer.MatricesIndicesExtraKind
  106197. * - VertexBuffer.MatricesWeightsKind
  106198. * - VertexBuffer.MatricesWeightsExtraKind
  106199. * @param data defines the data source
  106200. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106201. * @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)
  106202. * @returns the current mesh
  106203. */
  106204. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  106205. /**
  106206. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  106207. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  106208. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  106209. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  106210. * @returns the current mesh
  106211. */
  106212. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  106213. /**
  106214. * Creates a un-shared specific occurence of the geometry for the mesh.
  106215. * @returns the current mesh
  106216. */
  106217. makeGeometryUnique(): Mesh;
  106218. /**
  106219. * Set the index buffer of this mesh
  106220. * @param indices defines the source data
  106221. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  106222. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  106223. * @returns the current mesh
  106224. */
  106225. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  106226. /**
  106227. * Update the current index buffer
  106228. * @param indices defines the source data
  106229. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  106230. * @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)
  106231. * @returns the current mesh
  106232. */
  106233. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  106234. /**
  106235. * Invert the geometry to move from a right handed system to a left handed one.
  106236. * @returns the current mesh
  106237. */
  106238. toLeftHanded(): Mesh;
  106239. /** @hidden */
  106240. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  106241. /** @hidden */
  106242. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  106243. /**
  106244. * Registers for this mesh a javascript function called just before the rendering process
  106245. * @param func defines the function to call before rendering this mesh
  106246. * @returns the current mesh
  106247. */
  106248. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106249. /**
  106250. * Disposes a previously registered javascript function called before the rendering
  106251. * @param func defines the function to remove
  106252. * @returns the current mesh
  106253. */
  106254. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106255. /**
  106256. * Registers for this mesh a javascript function called just after the rendering is complete
  106257. * @param func defines the function to call after rendering this mesh
  106258. * @returns the current mesh
  106259. */
  106260. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  106261. /**
  106262. * Disposes a previously registered javascript function called after the rendering.
  106263. * @param func defines the function to remove
  106264. * @returns the current mesh
  106265. */
  106266. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  106267. /** @hidden */
  106268. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  106269. /** @hidden */
  106270. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  106271. /** @hidden */
  106272. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  106273. /** @hidden */
  106274. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  106275. /** @hidden */
  106276. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  106277. /** @hidden */
  106278. _rebuild(): void;
  106279. /** @hidden */
  106280. _freeze(): void;
  106281. /** @hidden */
  106282. _unFreeze(): void;
  106283. /**
  106284. * 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
  106285. * @param subMesh defines the subMesh to render
  106286. * @param enableAlphaMode defines if alpha mode can be changed
  106287. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  106288. * @returns the current mesh
  106289. */
  106290. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  106291. private _onBeforeDraw;
  106292. /**
  106293. * Renormalize the mesh and patch it up if there are no weights
  106294. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  106295. * However in the case of zero weights then we set just a single influence to 1.
  106296. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  106297. */
  106298. cleanMatrixWeights(): void;
  106299. private normalizeSkinFourWeights;
  106300. private normalizeSkinWeightsAndExtra;
  106301. /**
  106302. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106303. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106304. * the user know there was an issue with importing the mesh
  106305. * @returns a validation object with skinned, valid and report string
  106306. */
  106307. validateSkinning(): {
  106308. skinned: boolean;
  106309. valid: boolean;
  106310. report: string;
  106311. };
  106312. /** @hidden */
  106313. _checkDelayState(): Mesh;
  106314. private _queueLoad;
  106315. /**
  106316. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106317. * A mesh is in the frustum if its bounding box intersects the frustum
  106318. * @param frustumPlanes defines the frustum to test
  106319. * @returns true if the mesh is in the frustum planes
  106320. */
  106321. isInFrustum(frustumPlanes: Plane[]): boolean;
  106322. /**
  106323. * Sets the mesh material by the material or multiMaterial `id` property
  106324. * @param id is a string identifying the material or the multiMaterial
  106325. * @returns the current mesh
  106326. */
  106327. setMaterialByID(id: string): Mesh;
  106328. /**
  106329. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106330. * @returns an array of IAnimatable
  106331. */
  106332. getAnimatables(): IAnimatable[];
  106333. /**
  106334. * Modifies the mesh geometry according to the passed transformation matrix.
  106335. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106336. * The mesh normals are modified using the same transformation.
  106337. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106338. * @param transform defines the transform matrix to use
  106339. * @see https://doc.babylonjs.com/resources/baking_transformations
  106340. * @returns the current mesh
  106341. */
  106342. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106343. /**
  106344. * Modifies the mesh geometry according to its own current World Matrix.
  106345. * The mesh World Matrix is then reset.
  106346. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106347. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106348. * @see https://doc.babylonjs.com/resources/baking_transformations
  106349. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106350. * @returns the current mesh
  106351. */
  106352. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106353. /** @hidden */
  106354. get _positions(): Nullable<Vector3[]>;
  106355. /** @hidden */
  106356. _resetPointsArrayCache(): Mesh;
  106357. /** @hidden */
  106358. _generatePointsArray(): boolean;
  106359. /**
  106360. * Returns a new Mesh object generated from the current mesh properties.
  106361. * This method must not get confused with createInstance()
  106362. * @param name is a string, the name given to the new mesh
  106363. * @param newParent can be any Node object (default `null`)
  106364. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106365. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106366. * @returns a new mesh
  106367. */
  106368. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106369. /**
  106370. * Releases resources associated with this mesh.
  106371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106373. */
  106374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106375. /** @hidden */
  106376. _disposeInstanceSpecificData(): void;
  106377. /** @hidden */
  106378. _disposeThinInstanceSpecificData(): void;
  106379. /**
  106380. * Modifies the mesh geometry according to a displacement map.
  106381. * 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.
  106382. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106383. * @param url is a string, the URL from the image file is to be downloaded.
  106384. * @param minHeight is the lower limit of the displacement.
  106385. * @param maxHeight is the upper limit of the displacement.
  106386. * @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.
  106387. * @param uvOffset is an optional vector2 used to offset UV.
  106388. * @param uvScale is an optional vector2 used to scale UV.
  106389. * @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.
  106390. * @returns the Mesh.
  106391. */
  106392. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106393. /**
  106394. * Modifies the mesh geometry according to a displacementMap buffer.
  106395. * 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.
  106396. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106397. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106398. * @param heightMapWidth is the width of the buffer image.
  106399. * @param heightMapHeight is the height of the buffer image.
  106400. * @param minHeight is the lower limit of the displacement.
  106401. * @param maxHeight is the upper limit of the displacement.
  106402. * @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.
  106403. * @param uvOffset is an optional vector2 used to offset UV.
  106404. * @param uvScale is an optional vector2 used to scale UV.
  106405. * @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.
  106406. * @returns the Mesh.
  106407. */
  106408. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106409. /**
  106410. * Modify the mesh to get a flat shading rendering.
  106411. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106412. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106413. * @returns current mesh
  106414. */
  106415. convertToFlatShadedMesh(): Mesh;
  106416. /**
  106417. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106418. * In other words, more vertices, no more indices and a single bigger VBO.
  106419. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106420. * @returns current mesh
  106421. */
  106422. convertToUnIndexedMesh(): Mesh;
  106423. /**
  106424. * Inverses facet orientations.
  106425. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106426. * @param flipNormals will also inverts the normals
  106427. * @returns current mesh
  106428. */
  106429. flipFaces(flipNormals?: boolean): Mesh;
  106430. /**
  106431. * Increase the number of facets and hence vertices in a mesh
  106432. * Vertex normals are interpolated from existing vertex normals
  106433. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106434. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106435. */
  106436. increaseVertices(numberPerEdge: number): void;
  106437. /**
  106438. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106439. * This will undo any application of covertToFlatShadedMesh
  106440. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106441. */
  106442. forceSharedVertices(): void;
  106443. /** @hidden */
  106444. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106445. /** @hidden */
  106446. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106447. /**
  106448. * Creates a new InstancedMesh object from the mesh model.
  106449. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106450. * @param name defines the name of the new instance
  106451. * @returns a new InstancedMesh
  106452. */
  106453. createInstance(name: string): InstancedMesh;
  106454. /**
  106455. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106456. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106457. * @returns the current mesh
  106458. */
  106459. synchronizeInstances(): Mesh;
  106460. /**
  106461. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106462. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106463. * This should be used together with the simplification to avoid disappearing triangles.
  106464. * @param successCallback an optional success callback to be called after the optimization finished.
  106465. * @returns the current mesh
  106466. */
  106467. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106468. /**
  106469. * Serialize current mesh
  106470. * @param serializationObject defines the object which will receive the serialization data
  106471. */
  106472. serialize(serializationObject: any): void;
  106473. /** @hidden */
  106474. _syncGeometryWithMorphTargetManager(): void;
  106475. /** @hidden */
  106476. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106477. /**
  106478. * Returns a new Mesh object parsed from the source provided.
  106479. * @param parsedMesh is the source
  106480. * @param scene defines the hosting scene
  106481. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106482. * @returns a new Mesh
  106483. */
  106484. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106485. /**
  106486. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106488. * @param name defines the name of the mesh to create
  106489. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106490. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106491. * @param closePath creates a seam between the first and the last points of each path of the path array
  106492. * @param offset is taken in account only if the `pathArray` is containing a single path
  106493. * @param scene defines the hosting scene
  106494. * @param updatable defines if the mesh must be flagged as updatable
  106495. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106496. * @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)
  106497. * @returns a new Mesh
  106498. */
  106499. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106500. /**
  106501. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106502. * @param name defines the name of the mesh to create
  106503. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106504. * @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
  106505. * @param scene defines the hosting scene
  106506. * @param updatable defines if the mesh must be flagged as updatable
  106507. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106508. * @returns a new Mesh
  106509. */
  106510. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106511. /**
  106512. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106513. * @param name defines the name of the mesh to create
  106514. * @param size sets the size (float) of each box side (default 1)
  106515. * @param scene defines the hosting scene
  106516. * @param updatable defines if the mesh must be flagged as updatable
  106517. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106518. * @returns a new Mesh
  106519. */
  106520. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106521. /**
  106522. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106523. * @param name defines the name of the mesh to create
  106524. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106525. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106526. * @param scene defines the hosting scene
  106527. * @param updatable defines if the mesh must be flagged as updatable
  106528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106529. * @returns a new Mesh
  106530. */
  106531. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106532. /**
  106533. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106534. * @param name defines the name of the mesh to create
  106535. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106536. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106537. * @param scene defines the hosting scene
  106538. * @returns a new Mesh
  106539. */
  106540. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106541. /**
  106542. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106543. * @param name defines the name of the mesh to create
  106544. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106545. * @param diameterTop set the top cap diameter (floats, default 1)
  106546. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106547. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106548. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106549. * @param scene defines the hosting scene
  106550. * @param updatable defines if the mesh must be flagged as updatable
  106551. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106552. * @returns a new Mesh
  106553. */
  106554. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106555. /**
  106556. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106557. * @param name defines the name of the mesh to create
  106558. * @param diameter sets the diameter size (float) of the torus (default 1)
  106559. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106560. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106561. * @param scene defines the hosting scene
  106562. * @param updatable defines if the mesh must be flagged as updatable
  106563. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106564. * @returns a new Mesh
  106565. */
  106566. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106567. /**
  106568. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106569. * @param name defines the name of the mesh to create
  106570. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106571. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106572. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106573. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106574. * @param p the number of windings on X axis (positive integers, default 2)
  106575. * @param q the number of windings on Y axis (positive integers, default 3)
  106576. * @param scene defines the hosting scene
  106577. * @param updatable defines if the mesh must be flagged as updatable
  106578. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106579. * @returns a new Mesh
  106580. */
  106581. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106582. /**
  106583. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106584. * @param name defines the name of the mesh to create
  106585. * @param points is an array successive Vector3
  106586. * @param scene defines the hosting scene
  106587. * @param updatable defines if the mesh must be flagged as updatable
  106588. * @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).
  106589. * @returns a new Mesh
  106590. */
  106591. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106592. /**
  106593. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106594. * @param name defines the name of the mesh to create
  106595. * @param points is an array successive Vector3
  106596. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106597. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106598. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106599. * @param scene defines the hosting scene
  106600. * @param updatable defines if the mesh must be flagged as updatable
  106601. * @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)
  106602. * @returns a new Mesh
  106603. */
  106604. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106605. /**
  106606. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106607. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106608. * 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.
  106609. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106610. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106611. * Remember you can only change the shape positions, not their number when updating a polygon.
  106612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106613. * @param name defines the name of the mesh to create
  106614. * @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
  106615. * @param scene defines the hosting scene
  106616. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106617. * @param updatable defines if the mesh must be flagged as updatable
  106618. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106619. * @param earcutInjection can be used to inject your own earcut reference
  106620. * @returns a new Mesh
  106621. */
  106622. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106623. /**
  106624. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106626. * @param name defines the name of the mesh to create
  106627. * @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
  106628. * @param depth defines the height of extrusion
  106629. * @param scene defines the hosting scene
  106630. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106631. * @param updatable defines if the mesh must be flagged as updatable
  106632. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106633. * @param earcutInjection can be used to inject your own earcut reference
  106634. * @returns a new Mesh
  106635. */
  106636. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106637. /**
  106638. * Creates an extruded shape mesh.
  106639. * 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
  106640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106642. * @param name defines the name of the mesh to create
  106643. * @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
  106644. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106645. * @param scale is the value to scale the shape
  106646. * @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
  106647. * @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
  106648. * @param scene defines the hosting scene
  106649. * @param updatable defines if the mesh must be flagged as updatable
  106650. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106651. * @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)
  106652. * @returns a new Mesh
  106653. */
  106654. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106655. /**
  106656. * Creates an custom extruded shape mesh.
  106657. * The custom extrusion is a parametric shape.
  106658. * It has no predefined shape. Its final shape will depend on the input parameters.
  106659. * Please consider using the same method from the MeshBuilder class instead
  106660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106661. * @param name defines the name of the mesh to create
  106662. * @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
  106663. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106664. * @param scaleFunction is a custom Javascript function called on each path point
  106665. * @param rotationFunction is a custom Javascript function called on each path point
  106666. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106667. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106668. * @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
  106669. * @param scene defines the hosting scene
  106670. * @param updatable defines if the mesh must be flagged as updatable
  106671. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106672. * @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)
  106673. * @returns a new Mesh
  106674. */
  106675. 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;
  106676. /**
  106677. * Creates lathe mesh.
  106678. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106679. * Please consider using the same method from the MeshBuilder class instead
  106680. * @param name defines the name of the mesh to create
  106681. * @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
  106682. * @param radius is the radius value of the lathe
  106683. * @param tessellation is the side number of the lathe.
  106684. * @param scene defines the hosting scene
  106685. * @param updatable defines if the mesh must be flagged as updatable
  106686. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106687. * @returns a new Mesh
  106688. */
  106689. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106690. /**
  106691. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106692. * @param name defines the name of the mesh to create
  106693. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106694. * @param scene defines the hosting scene
  106695. * @param updatable defines if the mesh must be flagged as updatable
  106696. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106697. * @returns a new Mesh
  106698. */
  106699. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106700. /**
  106701. * Creates a ground mesh.
  106702. * Please consider using the same method from the MeshBuilder class instead
  106703. * @param name defines the name of the mesh to create
  106704. * @param width set the width of the ground
  106705. * @param height set the height of the ground
  106706. * @param subdivisions sets the number of subdivisions per side
  106707. * @param scene defines the hosting scene
  106708. * @param updatable defines if the mesh must be flagged as updatable
  106709. * @returns a new Mesh
  106710. */
  106711. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106712. /**
  106713. * Creates a tiled ground mesh.
  106714. * Please consider using the same method from the MeshBuilder class instead
  106715. * @param name defines the name of the mesh to create
  106716. * @param xmin set the ground minimum X coordinate
  106717. * @param zmin set the ground minimum Y coordinate
  106718. * @param xmax set the ground maximum X coordinate
  106719. * @param zmax set the ground maximum Z coordinate
  106720. * @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
  106721. * @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
  106722. * @param scene defines the hosting scene
  106723. * @param updatable defines if the mesh must be flagged as updatable
  106724. * @returns a new Mesh
  106725. */
  106726. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106727. w: number;
  106728. h: number;
  106729. }, precision: {
  106730. w: number;
  106731. h: number;
  106732. }, scene: Scene, updatable?: boolean): Mesh;
  106733. /**
  106734. * Creates a ground mesh from a height map.
  106735. * Please consider using the same method from the MeshBuilder class instead
  106736. * @see https://doc.babylonjs.com/babylon101/height_map
  106737. * @param name defines the name of the mesh to create
  106738. * @param url sets the URL of the height map image resource
  106739. * @param width set the ground width size
  106740. * @param height set the ground height size
  106741. * @param subdivisions sets the number of subdivision per side
  106742. * @param minHeight is the minimum altitude on the ground
  106743. * @param maxHeight is the maximum altitude on the ground
  106744. * @param scene defines the hosting scene
  106745. * @param updatable defines if the mesh must be flagged as updatable
  106746. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106747. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106748. * @returns a new Mesh
  106749. */
  106750. 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;
  106751. /**
  106752. * Creates a tube mesh.
  106753. * The tube is a parametric shape.
  106754. * It has no predefined shape. Its final shape will depend on the input parameters.
  106755. * Please consider using the same method from the MeshBuilder class instead
  106756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106757. * @param name defines the name of the mesh to create
  106758. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106759. * @param radius sets the tube radius size
  106760. * @param tessellation is the number of sides on the tubular surface
  106761. * @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
  106762. * @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
  106763. * @param scene defines the hosting scene
  106764. * @param updatable defines if the mesh must be flagged as updatable
  106765. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106766. * @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)
  106767. * @returns a new Mesh
  106768. */
  106769. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106770. (i: number, distance: number): number;
  106771. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106772. /**
  106773. * Creates a polyhedron mesh.
  106774. * Please consider using the same method from the MeshBuilder class instead.
  106775. * * 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
  106776. * * The parameter `size` (positive float, default 1) sets the polygon size
  106777. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106778. * * 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`
  106779. * * 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
  106780. * * 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)`)
  106781. * * 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
  106782. * * 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
  106783. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106786. * @param name defines the name of the mesh to create
  106787. * @param options defines the options used to create the mesh
  106788. * @param scene defines the hosting scene
  106789. * @returns a new Mesh
  106790. */
  106791. static CreatePolyhedron(name: string, options: {
  106792. type?: number;
  106793. size?: number;
  106794. sizeX?: number;
  106795. sizeY?: number;
  106796. sizeZ?: number;
  106797. custom?: any;
  106798. faceUV?: Vector4[];
  106799. faceColors?: Color4[];
  106800. updatable?: boolean;
  106801. sideOrientation?: number;
  106802. }, scene: Scene): Mesh;
  106803. /**
  106804. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106805. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106806. * * 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`)
  106807. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106808. * * 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
  106809. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106812. * @param name defines the name of the mesh
  106813. * @param options defines the options used to create the mesh
  106814. * @param scene defines the hosting scene
  106815. * @returns a new Mesh
  106816. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106817. */
  106818. static CreateIcoSphere(name: string, options: {
  106819. radius?: number;
  106820. flat?: boolean;
  106821. subdivisions?: number;
  106822. sideOrientation?: number;
  106823. updatable?: boolean;
  106824. }, scene: Scene): Mesh;
  106825. /**
  106826. * Creates a decal mesh.
  106827. * Please consider using the same method from the MeshBuilder class instead.
  106828. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106829. * @param name defines the name of the mesh
  106830. * @param sourceMesh defines the mesh receiving the decal
  106831. * @param position sets the position of the decal in world coordinates
  106832. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106833. * @param size sets the decal scaling
  106834. * @param angle sets the angle to rotate the decal
  106835. * @returns a new Mesh
  106836. */
  106837. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106838. /**
  106839. * Prepare internal position array for software CPU skinning
  106840. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106841. */
  106842. setPositionsForCPUSkinning(): Float32Array;
  106843. /**
  106844. * Prepare internal normal array for software CPU skinning
  106845. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106846. */
  106847. setNormalsForCPUSkinning(): Float32Array;
  106848. /**
  106849. * Updates the vertex buffer by applying transformation from the bones
  106850. * @param skeleton defines the skeleton to apply to current mesh
  106851. * @returns the current mesh
  106852. */
  106853. applySkeleton(skeleton: Skeleton): Mesh;
  106854. /**
  106855. * 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
  106856. * @param meshes defines the list of meshes to scan
  106857. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106858. */
  106859. static MinMax(meshes: AbstractMesh[]): {
  106860. min: Vector3;
  106861. max: Vector3;
  106862. };
  106863. /**
  106864. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106865. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106866. * @returns a vector3
  106867. */
  106868. static Center(meshesOrMinMaxVector: {
  106869. min: Vector3;
  106870. max: Vector3;
  106871. } | AbstractMesh[]): Vector3;
  106872. /**
  106873. * Merge the array of meshes into a single mesh for performance reasons.
  106874. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106875. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106876. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106877. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106878. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106879. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106880. * @returns a new mesh
  106881. */
  106882. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106883. /** @hidden */
  106884. addInstance(instance: InstancedMesh): void;
  106885. /** @hidden */
  106886. removeInstance(instance: InstancedMesh): void;
  106887. }
  106888. }
  106889. declare module BABYLON {
  106890. /**
  106891. * This is the base class of all the camera used in the application.
  106892. * @see https://doc.babylonjs.com/features/cameras
  106893. */
  106894. export class Camera extends Node {
  106895. /** @hidden */
  106896. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106897. /**
  106898. * This is the default projection mode used by the cameras.
  106899. * It helps recreating a feeling of perspective and better appreciate depth.
  106900. * This is the best way to simulate real life cameras.
  106901. */
  106902. static readonly PERSPECTIVE_CAMERA: number;
  106903. /**
  106904. * This helps creating camera with an orthographic mode.
  106905. * 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.
  106906. */
  106907. static readonly ORTHOGRAPHIC_CAMERA: number;
  106908. /**
  106909. * This is the default FOV mode for perspective cameras.
  106910. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106911. */
  106912. static readonly FOVMODE_VERTICAL_FIXED: number;
  106913. /**
  106914. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106915. */
  106916. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106917. /**
  106918. * This specifies ther is no need for a camera rig.
  106919. * Basically only one eye is rendered corresponding to the camera.
  106920. */
  106921. static readonly RIG_MODE_NONE: number;
  106922. /**
  106923. * Simulates a camera Rig with one blue eye and one red eye.
  106924. * This can be use with 3d blue and red glasses.
  106925. */
  106926. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106927. /**
  106928. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106929. */
  106930. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106931. /**
  106932. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106933. */
  106934. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106935. /**
  106936. * Defines that both eyes of the camera will be rendered over under each other.
  106937. */
  106938. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106939. /**
  106940. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106941. */
  106942. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106943. /**
  106944. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106945. */
  106946. static readonly RIG_MODE_VR: number;
  106947. /**
  106948. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106949. */
  106950. static readonly RIG_MODE_WEBVR: number;
  106951. /**
  106952. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106953. */
  106954. static readonly RIG_MODE_CUSTOM: number;
  106955. /**
  106956. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106957. */
  106958. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106959. /**
  106960. * Define the input manager associated with the camera.
  106961. */
  106962. inputs: CameraInputsManager<Camera>;
  106963. /** @hidden */
  106964. _position: Vector3;
  106965. /**
  106966. * Define the current local position of the camera in the scene
  106967. */
  106968. get position(): Vector3;
  106969. set position(newPosition: Vector3);
  106970. /**
  106971. * The vector the camera should consider as up.
  106972. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106973. */
  106974. upVector: Vector3;
  106975. /**
  106976. * Define the current limit on the left side for an orthographic camera
  106977. * In scene unit
  106978. */
  106979. orthoLeft: Nullable<number>;
  106980. /**
  106981. * Define the current limit on the right side for an orthographic camera
  106982. * In scene unit
  106983. */
  106984. orthoRight: Nullable<number>;
  106985. /**
  106986. * Define the current limit on the bottom side for an orthographic camera
  106987. * In scene unit
  106988. */
  106989. orthoBottom: Nullable<number>;
  106990. /**
  106991. * Define the current limit on the top side for an orthographic camera
  106992. * In scene unit
  106993. */
  106994. orthoTop: Nullable<number>;
  106995. /**
  106996. * Field Of View is set in Radians. (default is 0.8)
  106997. */
  106998. fov: number;
  106999. /**
  107000. * Define the minimum distance the camera can see from.
  107001. * This is important to note that the depth buffer are not infinite and the closer it starts
  107002. * the more your scene might encounter depth fighting issue.
  107003. */
  107004. minZ: number;
  107005. /**
  107006. * Define the maximum distance the camera can see to.
  107007. * This is important to note that the depth buffer are not infinite and the further it end
  107008. * the more your scene might encounter depth fighting issue.
  107009. */
  107010. maxZ: number;
  107011. /**
  107012. * Define the default inertia of the camera.
  107013. * This helps giving a smooth feeling to the camera movement.
  107014. */
  107015. inertia: number;
  107016. /**
  107017. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  107018. */
  107019. mode: number;
  107020. /**
  107021. * Define whether the camera is intermediate.
  107022. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  107023. */
  107024. isIntermediate: boolean;
  107025. /**
  107026. * Define the viewport of the camera.
  107027. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  107028. */
  107029. viewport: Viewport;
  107030. /**
  107031. * Restricts the camera to viewing objects with the same layerMask.
  107032. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  107033. */
  107034. layerMask: number;
  107035. /**
  107036. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  107037. */
  107038. fovMode: number;
  107039. /**
  107040. * Rig mode of the camera.
  107041. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  107042. * This is normally controlled byt the camera themselves as internal use.
  107043. */
  107044. cameraRigMode: number;
  107045. /**
  107046. * Defines the distance between both "eyes" in case of a RIG
  107047. */
  107048. interaxialDistance: number;
  107049. /**
  107050. * Defines if stereoscopic rendering is done side by side or over under.
  107051. */
  107052. isStereoscopicSideBySide: boolean;
  107053. /**
  107054. * 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
  107055. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  107056. * else in the scene. (Eg. security camera)
  107057. *
  107058. * 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)
  107059. */
  107060. customRenderTargets: RenderTargetTexture[];
  107061. /**
  107062. * When set, the camera will render to this render target instead of the default canvas
  107063. *
  107064. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  107065. */
  107066. outputRenderTarget: Nullable<RenderTargetTexture>;
  107067. /**
  107068. * Observable triggered when the camera view matrix has changed.
  107069. */
  107070. onViewMatrixChangedObservable: Observable<Camera>;
  107071. /**
  107072. * Observable triggered when the camera Projection matrix has changed.
  107073. */
  107074. onProjectionMatrixChangedObservable: Observable<Camera>;
  107075. /**
  107076. * Observable triggered when the inputs have been processed.
  107077. */
  107078. onAfterCheckInputsObservable: Observable<Camera>;
  107079. /**
  107080. * Observable triggered when reset has been called and applied to the camera.
  107081. */
  107082. onRestoreStateObservable: Observable<Camera>;
  107083. /**
  107084. * Is this camera a part of a rig system?
  107085. */
  107086. isRigCamera: boolean;
  107087. /**
  107088. * If isRigCamera set to true this will be set with the parent camera.
  107089. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  107090. */
  107091. rigParent?: Camera;
  107092. /** @hidden */
  107093. _cameraRigParams: any;
  107094. /** @hidden */
  107095. _rigCameras: Camera[];
  107096. /** @hidden */
  107097. _rigPostProcess: Nullable<PostProcess>;
  107098. protected _webvrViewMatrix: Matrix;
  107099. /** @hidden */
  107100. _skipRendering: boolean;
  107101. /** @hidden */
  107102. _projectionMatrix: Matrix;
  107103. /** @hidden */
  107104. _postProcesses: Nullable<PostProcess>[];
  107105. /** @hidden */
  107106. _activeMeshes: SmartArray<AbstractMesh>;
  107107. protected _globalPosition: Vector3;
  107108. /** @hidden */
  107109. _computedViewMatrix: Matrix;
  107110. private _doNotComputeProjectionMatrix;
  107111. private _transformMatrix;
  107112. private _frustumPlanes;
  107113. private _refreshFrustumPlanes;
  107114. private _storedFov;
  107115. private _stateStored;
  107116. /**
  107117. * Instantiates a new camera object.
  107118. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  107119. * @see https://doc.babylonjs.com/features/cameras
  107120. * @param name Defines the name of the camera in the scene
  107121. * @param position Defines the position of the camera
  107122. * @param scene Defines the scene the camera belongs too
  107123. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  107124. */
  107125. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107126. /**
  107127. * Store current camera state (fov, position, etc..)
  107128. * @returns the camera
  107129. */
  107130. storeState(): Camera;
  107131. /**
  107132. * Restores the camera state values if it has been stored. You must call storeState() first
  107133. */
  107134. protected _restoreStateValues(): boolean;
  107135. /**
  107136. * Restored camera state. You must call storeState() first.
  107137. * @returns true if restored and false otherwise
  107138. */
  107139. restoreState(): boolean;
  107140. /**
  107141. * Gets the class name of the camera.
  107142. * @returns the class name
  107143. */
  107144. getClassName(): string;
  107145. /** @hidden */
  107146. readonly _isCamera: boolean;
  107147. /**
  107148. * Gets a string representation of the camera useful for debug purpose.
  107149. * @param fullDetails Defines that a more verboe level of logging is required
  107150. * @returns the string representation
  107151. */
  107152. toString(fullDetails?: boolean): string;
  107153. /**
  107154. * Gets the current world space position of the camera.
  107155. */
  107156. get globalPosition(): Vector3;
  107157. /**
  107158. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  107159. * @returns the active meshe list
  107160. */
  107161. getActiveMeshes(): SmartArray<AbstractMesh>;
  107162. /**
  107163. * Check whether a mesh is part of the current active mesh list of the camera
  107164. * @param mesh Defines the mesh to check
  107165. * @returns true if active, false otherwise
  107166. */
  107167. isActiveMesh(mesh: Mesh): boolean;
  107168. /**
  107169. * Is this camera ready to be used/rendered
  107170. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  107171. * @return true if the camera is ready
  107172. */
  107173. isReady(completeCheck?: boolean): boolean;
  107174. /** @hidden */
  107175. _initCache(): void;
  107176. /** @hidden */
  107177. _updateCache(ignoreParentClass?: boolean): void;
  107178. /** @hidden */
  107179. _isSynchronized(): boolean;
  107180. /** @hidden */
  107181. _isSynchronizedViewMatrix(): boolean;
  107182. /** @hidden */
  107183. _isSynchronizedProjectionMatrix(): boolean;
  107184. /**
  107185. * Attach the input controls to a specific dom element to get the input from.
  107186. * @param element Defines the element the controls should be listened from
  107187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107188. */
  107189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107190. /**
  107191. * Detach the current controls from the specified dom element.
  107192. * @param element Defines the element to stop listening the inputs from
  107193. */
  107194. detachControl(element: HTMLElement): void;
  107195. /**
  107196. * Update the camera state according to the different inputs gathered during the frame.
  107197. */
  107198. update(): void;
  107199. /** @hidden */
  107200. _checkInputs(): void;
  107201. /** @hidden */
  107202. get rigCameras(): Camera[];
  107203. /**
  107204. * Gets the post process used by the rig cameras
  107205. */
  107206. get rigPostProcess(): Nullable<PostProcess>;
  107207. /**
  107208. * Internal, gets the first post proces.
  107209. * @returns the first post process to be run on this camera.
  107210. */
  107211. _getFirstPostProcess(): Nullable<PostProcess>;
  107212. private _cascadePostProcessesToRigCams;
  107213. /**
  107214. * Attach a post process to the camera.
  107215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107216. * @param postProcess The post process to attach to the camera
  107217. * @param insertAt The position of the post process in case several of them are in use in the scene
  107218. * @returns the position the post process has been inserted at
  107219. */
  107220. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  107221. /**
  107222. * Detach a post process to the camera.
  107223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107224. * @param postProcess The post process to detach from the camera
  107225. */
  107226. detachPostProcess(postProcess: PostProcess): void;
  107227. /**
  107228. * Gets the current world matrix of the camera
  107229. */
  107230. getWorldMatrix(): Matrix;
  107231. /** @hidden */
  107232. _getViewMatrix(): Matrix;
  107233. /**
  107234. * Gets the current view matrix of the camera.
  107235. * @param force forces the camera to recompute the matrix without looking at the cached state
  107236. * @returns the view matrix
  107237. */
  107238. getViewMatrix(force?: boolean): Matrix;
  107239. /**
  107240. * Freeze the projection matrix.
  107241. * It will prevent the cache check of the camera projection compute and can speed up perf
  107242. * if no parameter of the camera are meant to change
  107243. * @param projection Defines manually a projection if necessary
  107244. */
  107245. freezeProjectionMatrix(projection?: Matrix): void;
  107246. /**
  107247. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  107248. */
  107249. unfreezeProjectionMatrix(): void;
  107250. /**
  107251. * Gets the current projection matrix of the camera.
  107252. * @param force forces the camera to recompute the matrix without looking at the cached state
  107253. * @returns the projection matrix
  107254. */
  107255. getProjectionMatrix(force?: boolean): Matrix;
  107256. /**
  107257. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  107258. * @returns a Matrix
  107259. */
  107260. getTransformationMatrix(): Matrix;
  107261. private _updateFrustumPlanes;
  107262. /**
  107263. * Checks if a cullable object (mesh...) is in the camera frustum
  107264. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  107265. * @param target The object to check
  107266. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  107267. * @returns true if the object is in frustum otherwise false
  107268. */
  107269. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  107270. /**
  107271. * Checks if a cullable object (mesh...) is in the camera frustum
  107272. * Unlike isInFrustum this cheks the full bounding box
  107273. * @param target The object to check
  107274. * @returns true if the object is in frustum otherwise false
  107275. */
  107276. isCompletelyInFrustum(target: ICullable): boolean;
  107277. /**
  107278. * Gets a ray in the forward direction from the camera.
  107279. * @param length Defines the length of the ray to create
  107280. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  107281. * @param origin Defines the start point of the ray which defaults to the camera position
  107282. * @returns the forward ray
  107283. */
  107284. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  107285. /**
  107286. * Releases resources associated with this node.
  107287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107289. */
  107290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107291. /** @hidden */
  107292. _isLeftCamera: boolean;
  107293. /**
  107294. * Gets the left camera of a rig setup in case of Rigged Camera
  107295. */
  107296. get isLeftCamera(): boolean;
  107297. /** @hidden */
  107298. _isRightCamera: boolean;
  107299. /**
  107300. * Gets the right camera of a rig setup in case of Rigged Camera
  107301. */
  107302. get isRightCamera(): boolean;
  107303. /**
  107304. * Gets the left camera of a rig setup in case of Rigged Camera
  107305. */
  107306. get leftCamera(): Nullable<FreeCamera>;
  107307. /**
  107308. * Gets the right camera of a rig setup in case of Rigged Camera
  107309. */
  107310. get rightCamera(): Nullable<FreeCamera>;
  107311. /**
  107312. * Gets the left camera target of a rig setup in case of Rigged Camera
  107313. * @returns the target position
  107314. */
  107315. getLeftTarget(): Nullable<Vector3>;
  107316. /**
  107317. * Gets the right camera target of a rig setup in case of Rigged Camera
  107318. * @returns the target position
  107319. */
  107320. getRightTarget(): Nullable<Vector3>;
  107321. /**
  107322. * @hidden
  107323. */
  107324. setCameraRigMode(mode: number, rigParams: any): void;
  107325. /** @hidden */
  107326. static _setStereoscopicRigMode(camera: Camera): void;
  107327. /** @hidden */
  107328. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107329. /** @hidden */
  107330. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107331. /** @hidden */
  107332. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107333. /** @hidden */
  107334. _getVRProjectionMatrix(): Matrix;
  107335. protected _updateCameraRotationMatrix(): void;
  107336. protected _updateWebVRCameraRotationMatrix(): void;
  107337. /**
  107338. * This function MUST be overwritten by the different WebVR cameras available.
  107339. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107340. * @hidden
  107341. */
  107342. _getWebVRProjectionMatrix(): Matrix;
  107343. /**
  107344. * This function MUST be overwritten by the different WebVR cameras available.
  107345. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107346. * @hidden
  107347. */
  107348. _getWebVRViewMatrix(): Matrix;
  107349. /** @hidden */
  107350. setCameraRigParameter(name: string, value: any): void;
  107351. /**
  107352. * needs to be overridden by children so sub has required properties to be copied
  107353. * @hidden
  107354. */
  107355. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107356. /**
  107357. * May need to be overridden by children
  107358. * @hidden
  107359. */
  107360. _updateRigCameras(): void;
  107361. /** @hidden */
  107362. _setupInputs(): void;
  107363. /**
  107364. * Serialiaze the camera setup to a json represention
  107365. * @returns the JSON representation
  107366. */
  107367. serialize(): any;
  107368. /**
  107369. * Clones the current camera.
  107370. * @param name The cloned camera name
  107371. * @returns the cloned camera
  107372. */
  107373. clone(name: string): Camera;
  107374. /**
  107375. * Gets the direction of the camera relative to a given local axis.
  107376. * @param localAxis Defines the reference axis to provide a relative direction.
  107377. * @return the direction
  107378. */
  107379. getDirection(localAxis: Vector3): Vector3;
  107380. /**
  107381. * Returns the current camera absolute rotation
  107382. */
  107383. get absoluteRotation(): Quaternion;
  107384. /**
  107385. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107386. * @param localAxis Defines the reference axis to provide a relative direction.
  107387. * @param result Defines the vector to store the result in
  107388. */
  107389. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107390. /**
  107391. * Gets a camera constructor for a given camera type
  107392. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107393. * @param name The name of the camera the result will be able to instantiate
  107394. * @param scene The scene the result will construct the camera in
  107395. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107396. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107397. * @returns a factory method to construc the camera
  107398. */
  107399. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107400. /**
  107401. * Compute the world matrix of the camera.
  107402. * @returns the camera world matrix
  107403. */
  107404. computeWorldMatrix(): Matrix;
  107405. /**
  107406. * Parse a JSON and creates the camera from the parsed information
  107407. * @param parsedCamera The JSON to parse
  107408. * @param scene The scene to instantiate the camera in
  107409. * @returns the newly constructed camera
  107410. */
  107411. static Parse(parsedCamera: any, scene: Scene): Camera;
  107412. }
  107413. }
  107414. declare module BABYLON {
  107415. /**
  107416. * Class containing static functions to help procedurally build meshes
  107417. */
  107418. export class DiscBuilder {
  107419. /**
  107420. * Creates a plane polygonal mesh. By default, this is a disc
  107421. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107422. * * 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
  107423. * * 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
  107424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107427. * @param name defines the name of the mesh
  107428. * @param options defines the options used to create the mesh
  107429. * @param scene defines the hosting scene
  107430. * @returns the plane polygonal mesh
  107431. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107432. */
  107433. static CreateDisc(name: string, options: {
  107434. radius?: number;
  107435. tessellation?: number;
  107436. arc?: number;
  107437. updatable?: boolean;
  107438. sideOrientation?: number;
  107439. frontUVs?: Vector4;
  107440. backUVs?: Vector4;
  107441. }, scene?: Nullable<Scene>): Mesh;
  107442. }
  107443. }
  107444. declare module BABYLON {
  107445. /**
  107446. * Options to be used when creating a FresnelParameters.
  107447. */
  107448. export type IFresnelParametersCreationOptions = {
  107449. /**
  107450. * Define the color used on edges (grazing angle)
  107451. */
  107452. leftColor?: Color3;
  107453. /**
  107454. * Define the color used on center
  107455. */
  107456. rightColor?: Color3;
  107457. /**
  107458. * Define bias applied to computed fresnel term
  107459. */
  107460. bias?: number;
  107461. /**
  107462. * Defined the power exponent applied to fresnel term
  107463. */
  107464. power?: number;
  107465. /**
  107466. * Define if the fresnel effect is enable or not.
  107467. */
  107468. isEnabled?: boolean;
  107469. };
  107470. /**
  107471. * Serialized format for FresnelParameters.
  107472. */
  107473. export type IFresnelParametersSerialized = {
  107474. /**
  107475. * Define the color used on edges (grazing angle) [as an array]
  107476. */
  107477. leftColor: number[];
  107478. /**
  107479. * Define the color used on center [as an array]
  107480. */
  107481. rightColor: number[];
  107482. /**
  107483. * Define bias applied to computed fresnel term
  107484. */
  107485. bias: number;
  107486. /**
  107487. * Defined the power exponent applied to fresnel term
  107488. */
  107489. power?: number;
  107490. /**
  107491. * Define if the fresnel effect is enable or not.
  107492. */
  107493. isEnabled: boolean;
  107494. };
  107495. /**
  107496. * This represents all the required information to add a fresnel effect on a material:
  107497. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107498. */
  107499. export class FresnelParameters {
  107500. private _isEnabled;
  107501. /**
  107502. * Define if the fresnel effect is enable or not.
  107503. */
  107504. get isEnabled(): boolean;
  107505. set isEnabled(value: boolean);
  107506. /**
  107507. * Define the color used on edges (grazing angle)
  107508. */
  107509. leftColor: Color3;
  107510. /**
  107511. * Define the color used on center
  107512. */
  107513. rightColor: Color3;
  107514. /**
  107515. * Define bias applied to computed fresnel term
  107516. */
  107517. bias: number;
  107518. /**
  107519. * Defined the power exponent applied to fresnel term
  107520. */
  107521. power: number;
  107522. /**
  107523. * Creates a new FresnelParameters object.
  107524. *
  107525. * @param options provide your own settings to optionally to override defaults
  107526. */
  107527. constructor(options?: IFresnelParametersCreationOptions);
  107528. /**
  107529. * Clones the current fresnel and its valuues
  107530. * @returns a clone fresnel configuration
  107531. */
  107532. clone(): FresnelParameters;
  107533. /**
  107534. * Determines equality between FresnelParameters objects
  107535. * @param otherFresnelParameters defines the second operand
  107536. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107537. */
  107538. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107539. /**
  107540. * Serializes the current fresnel parameters to a JSON representation.
  107541. * @return the JSON serialization
  107542. */
  107543. serialize(): IFresnelParametersSerialized;
  107544. /**
  107545. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107546. * @param parsedFresnelParameters Define the JSON representation
  107547. * @returns the parsed parameters
  107548. */
  107549. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107550. }
  107551. }
  107552. declare module BABYLON {
  107553. /**
  107554. * This groups all the flags used to control the materials channel.
  107555. */
  107556. export class MaterialFlags {
  107557. private static _DiffuseTextureEnabled;
  107558. /**
  107559. * Are diffuse textures enabled in the application.
  107560. */
  107561. static get DiffuseTextureEnabled(): boolean;
  107562. static set DiffuseTextureEnabled(value: boolean);
  107563. private static _DetailTextureEnabled;
  107564. /**
  107565. * Are detail textures enabled in the application.
  107566. */
  107567. static get DetailTextureEnabled(): boolean;
  107568. static set DetailTextureEnabled(value: boolean);
  107569. private static _AmbientTextureEnabled;
  107570. /**
  107571. * Are ambient textures enabled in the application.
  107572. */
  107573. static get AmbientTextureEnabled(): boolean;
  107574. static set AmbientTextureEnabled(value: boolean);
  107575. private static _OpacityTextureEnabled;
  107576. /**
  107577. * Are opacity textures enabled in the application.
  107578. */
  107579. static get OpacityTextureEnabled(): boolean;
  107580. static set OpacityTextureEnabled(value: boolean);
  107581. private static _ReflectionTextureEnabled;
  107582. /**
  107583. * Are reflection textures enabled in the application.
  107584. */
  107585. static get ReflectionTextureEnabled(): boolean;
  107586. static set ReflectionTextureEnabled(value: boolean);
  107587. private static _EmissiveTextureEnabled;
  107588. /**
  107589. * Are emissive textures enabled in the application.
  107590. */
  107591. static get EmissiveTextureEnabled(): boolean;
  107592. static set EmissiveTextureEnabled(value: boolean);
  107593. private static _SpecularTextureEnabled;
  107594. /**
  107595. * Are specular textures enabled in the application.
  107596. */
  107597. static get SpecularTextureEnabled(): boolean;
  107598. static set SpecularTextureEnabled(value: boolean);
  107599. private static _BumpTextureEnabled;
  107600. /**
  107601. * Are bump textures enabled in the application.
  107602. */
  107603. static get BumpTextureEnabled(): boolean;
  107604. static set BumpTextureEnabled(value: boolean);
  107605. private static _LightmapTextureEnabled;
  107606. /**
  107607. * Are lightmap textures enabled in the application.
  107608. */
  107609. static get LightmapTextureEnabled(): boolean;
  107610. static set LightmapTextureEnabled(value: boolean);
  107611. private static _RefractionTextureEnabled;
  107612. /**
  107613. * Are refraction textures enabled in the application.
  107614. */
  107615. static get RefractionTextureEnabled(): boolean;
  107616. static set RefractionTextureEnabled(value: boolean);
  107617. private static _ColorGradingTextureEnabled;
  107618. /**
  107619. * Are color grading textures enabled in the application.
  107620. */
  107621. static get ColorGradingTextureEnabled(): boolean;
  107622. static set ColorGradingTextureEnabled(value: boolean);
  107623. private static _FresnelEnabled;
  107624. /**
  107625. * Are fresnels enabled in the application.
  107626. */
  107627. static get FresnelEnabled(): boolean;
  107628. static set FresnelEnabled(value: boolean);
  107629. private static _ClearCoatTextureEnabled;
  107630. /**
  107631. * Are clear coat textures enabled in the application.
  107632. */
  107633. static get ClearCoatTextureEnabled(): boolean;
  107634. static set ClearCoatTextureEnabled(value: boolean);
  107635. private static _ClearCoatBumpTextureEnabled;
  107636. /**
  107637. * Are clear coat bump textures enabled in the application.
  107638. */
  107639. static get ClearCoatBumpTextureEnabled(): boolean;
  107640. static set ClearCoatBumpTextureEnabled(value: boolean);
  107641. private static _ClearCoatTintTextureEnabled;
  107642. /**
  107643. * Are clear coat tint textures enabled in the application.
  107644. */
  107645. static get ClearCoatTintTextureEnabled(): boolean;
  107646. static set ClearCoatTintTextureEnabled(value: boolean);
  107647. private static _SheenTextureEnabled;
  107648. /**
  107649. * Are sheen textures enabled in the application.
  107650. */
  107651. static get SheenTextureEnabled(): boolean;
  107652. static set SheenTextureEnabled(value: boolean);
  107653. private static _AnisotropicTextureEnabled;
  107654. /**
  107655. * Are anisotropic textures enabled in the application.
  107656. */
  107657. static get AnisotropicTextureEnabled(): boolean;
  107658. static set AnisotropicTextureEnabled(value: boolean);
  107659. private static _ThicknessTextureEnabled;
  107660. /**
  107661. * Are thickness textures enabled in the application.
  107662. */
  107663. static get ThicknessTextureEnabled(): boolean;
  107664. static set ThicknessTextureEnabled(value: boolean);
  107665. }
  107666. }
  107667. declare module BABYLON {
  107668. /** @hidden */
  107669. export var defaultFragmentDeclaration: {
  107670. name: string;
  107671. shader: string;
  107672. };
  107673. }
  107674. declare module BABYLON {
  107675. /** @hidden */
  107676. export var defaultUboDeclaration: {
  107677. name: string;
  107678. shader: string;
  107679. };
  107680. }
  107681. declare module BABYLON {
  107682. /** @hidden */
  107683. export var prePassDeclaration: {
  107684. name: string;
  107685. shader: string;
  107686. };
  107687. }
  107688. declare module BABYLON {
  107689. /** @hidden */
  107690. export var lightFragmentDeclaration: {
  107691. name: string;
  107692. shader: string;
  107693. };
  107694. }
  107695. declare module BABYLON {
  107696. /** @hidden */
  107697. export var lightUboDeclaration: {
  107698. name: string;
  107699. shader: string;
  107700. };
  107701. }
  107702. declare module BABYLON {
  107703. /** @hidden */
  107704. export var lightsFragmentFunctions: {
  107705. name: string;
  107706. shader: string;
  107707. };
  107708. }
  107709. declare module BABYLON {
  107710. /** @hidden */
  107711. export var shadowsFragmentFunctions: {
  107712. name: string;
  107713. shader: string;
  107714. };
  107715. }
  107716. declare module BABYLON {
  107717. /** @hidden */
  107718. export var fresnelFunction: {
  107719. name: string;
  107720. shader: string;
  107721. };
  107722. }
  107723. declare module BABYLON {
  107724. /** @hidden */
  107725. export var bumpFragmentMainFunctions: {
  107726. name: string;
  107727. shader: string;
  107728. };
  107729. }
  107730. declare module BABYLON {
  107731. /** @hidden */
  107732. export var bumpFragmentFunctions: {
  107733. name: string;
  107734. shader: string;
  107735. };
  107736. }
  107737. declare module BABYLON {
  107738. /** @hidden */
  107739. export var logDepthDeclaration: {
  107740. name: string;
  107741. shader: string;
  107742. };
  107743. }
  107744. declare module BABYLON {
  107745. /** @hidden */
  107746. export var bumpFragment: {
  107747. name: string;
  107748. shader: string;
  107749. };
  107750. }
  107751. declare module BABYLON {
  107752. /** @hidden */
  107753. export var depthPrePass: {
  107754. name: string;
  107755. shader: string;
  107756. };
  107757. }
  107758. declare module BABYLON {
  107759. /** @hidden */
  107760. export var lightFragment: {
  107761. name: string;
  107762. shader: string;
  107763. };
  107764. }
  107765. declare module BABYLON {
  107766. /** @hidden */
  107767. export var logDepthFragment: {
  107768. name: string;
  107769. shader: string;
  107770. };
  107771. }
  107772. declare module BABYLON {
  107773. /** @hidden */
  107774. export var defaultPixelShader: {
  107775. name: string;
  107776. shader: string;
  107777. };
  107778. }
  107779. declare module BABYLON {
  107780. /** @hidden */
  107781. export var defaultVertexDeclaration: {
  107782. name: string;
  107783. shader: string;
  107784. };
  107785. }
  107786. declare module BABYLON {
  107787. /** @hidden */
  107788. export var bumpVertexDeclaration: {
  107789. name: string;
  107790. shader: string;
  107791. };
  107792. }
  107793. declare module BABYLON {
  107794. /** @hidden */
  107795. export var bumpVertex: {
  107796. name: string;
  107797. shader: string;
  107798. };
  107799. }
  107800. declare module BABYLON {
  107801. /** @hidden */
  107802. export var fogVertex: {
  107803. name: string;
  107804. shader: string;
  107805. };
  107806. }
  107807. declare module BABYLON {
  107808. /** @hidden */
  107809. export var shadowsVertex: {
  107810. name: string;
  107811. shader: string;
  107812. };
  107813. }
  107814. declare module BABYLON {
  107815. /** @hidden */
  107816. export var pointCloudVertex: {
  107817. name: string;
  107818. shader: string;
  107819. };
  107820. }
  107821. declare module BABYLON {
  107822. /** @hidden */
  107823. export var logDepthVertex: {
  107824. name: string;
  107825. shader: string;
  107826. };
  107827. }
  107828. declare module BABYLON {
  107829. /** @hidden */
  107830. export var defaultVertexShader: {
  107831. name: string;
  107832. shader: string;
  107833. };
  107834. }
  107835. declare module BABYLON {
  107836. /**
  107837. * @hidden
  107838. */
  107839. export interface IMaterialDetailMapDefines {
  107840. DETAIL: boolean;
  107841. DETAILDIRECTUV: number;
  107842. DETAIL_NORMALBLENDMETHOD: number;
  107843. /** @hidden */
  107844. _areTexturesDirty: boolean;
  107845. }
  107846. /**
  107847. * Define the code related to the detail map parameters of a material
  107848. *
  107849. * Inspired from:
  107850. * 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
  107851. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107852. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107853. */
  107854. export class DetailMapConfiguration {
  107855. private _texture;
  107856. /**
  107857. * The detail texture of the material.
  107858. */
  107859. texture: Nullable<BaseTexture>;
  107860. /**
  107861. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107862. * Bigger values mean stronger blending
  107863. */
  107864. diffuseBlendLevel: number;
  107865. /**
  107866. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107867. * Bigger values mean stronger blending. Only used with PBR materials
  107868. */
  107869. roughnessBlendLevel: number;
  107870. /**
  107871. * Defines how strong the bump effect from the detail map is
  107872. * Bigger values mean stronger effect
  107873. */
  107874. bumpLevel: number;
  107875. private _normalBlendMethod;
  107876. /**
  107877. * The method used to blend the bump and detail normals together
  107878. */
  107879. normalBlendMethod: number;
  107880. private _isEnabled;
  107881. /**
  107882. * Enable or disable the detail map on this material
  107883. */
  107884. isEnabled: boolean;
  107885. /** @hidden */
  107886. private _internalMarkAllSubMeshesAsTexturesDirty;
  107887. /** @hidden */
  107888. _markAllSubMeshesAsTexturesDirty(): void;
  107889. /**
  107890. * Instantiate a new detail map
  107891. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107892. */
  107893. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107894. /**
  107895. * Gets whether the submesh is ready to be used or not.
  107896. * @param defines the list of "defines" to update.
  107897. * @param scene defines the scene the material belongs to.
  107898. * @returns - boolean indicating that the submesh is ready or not.
  107899. */
  107900. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107901. /**
  107902. * Update the defines for detail map usage
  107903. * @param defines the list of "defines" to update.
  107904. * @param scene defines the scene the material belongs to.
  107905. */
  107906. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107907. /**
  107908. * Binds the material data.
  107909. * @param uniformBuffer defines the Uniform buffer to fill in.
  107910. * @param scene defines the scene the material belongs to.
  107911. * @param isFrozen defines whether the material is frozen or not.
  107912. */
  107913. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107914. /**
  107915. * Checks to see if a texture is used in the material.
  107916. * @param texture - Base texture to use.
  107917. * @returns - Boolean specifying if a texture is used in the material.
  107918. */
  107919. hasTexture(texture: BaseTexture): boolean;
  107920. /**
  107921. * Returns an array of the actively used textures.
  107922. * @param activeTextures Array of BaseTextures
  107923. */
  107924. getActiveTextures(activeTextures: BaseTexture[]): void;
  107925. /**
  107926. * Returns the animatable textures.
  107927. * @param animatables Array of animatable textures.
  107928. */
  107929. getAnimatables(animatables: IAnimatable[]): void;
  107930. /**
  107931. * Disposes the resources of the material.
  107932. * @param forceDisposeTextures - Forces the disposal of all textures.
  107933. */
  107934. dispose(forceDisposeTextures?: boolean): void;
  107935. /**
  107936. * Get the current class name useful for serialization or dynamic coding.
  107937. * @returns "DetailMap"
  107938. */
  107939. getClassName(): string;
  107940. /**
  107941. * Add the required uniforms to the current list.
  107942. * @param uniforms defines the current uniform list.
  107943. */
  107944. static AddUniforms(uniforms: string[]): void;
  107945. /**
  107946. * Add the required samplers to the current list.
  107947. * @param samplers defines the current sampler list.
  107948. */
  107949. static AddSamplers(samplers: string[]): void;
  107950. /**
  107951. * Add the required uniforms to the current buffer.
  107952. * @param uniformBuffer defines the current uniform buffer.
  107953. */
  107954. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107955. /**
  107956. * Makes a duplicate of the current instance into another one.
  107957. * @param detailMap define the instance where to copy the info
  107958. */
  107959. copyTo(detailMap: DetailMapConfiguration): void;
  107960. /**
  107961. * Serializes this detail map instance
  107962. * @returns - An object with the serialized instance.
  107963. */
  107964. serialize(): any;
  107965. /**
  107966. * Parses a detail map setting from a serialized object.
  107967. * @param source - Serialized object.
  107968. * @param scene Defines the scene we are parsing for
  107969. * @param rootUrl Defines the rootUrl to load from
  107970. */
  107971. parse(source: any, scene: Scene, rootUrl: string): void;
  107972. }
  107973. }
  107974. declare module BABYLON {
  107975. /** @hidden */
  107976. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107977. MAINUV1: boolean;
  107978. MAINUV2: boolean;
  107979. DIFFUSE: boolean;
  107980. DIFFUSEDIRECTUV: number;
  107981. DETAIL: boolean;
  107982. DETAILDIRECTUV: number;
  107983. DETAIL_NORMALBLENDMETHOD: number;
  107984. AMBIENT: boolean;
  107985. AMBIENTDIRECTUV: number;
  107986. OPACITY: boolean;
  107987. OPACITYDIRECTUV: number;
  107988. OPACITYRGB: boolean;
  107989. REFLECTION: boolean;
  107990. EMISSIVE: boolean;
  107991. EMISSIVEDIRECTUV: number;
  107992. SPECULAR: boolean;
  107993. SPECULARDIRECTUV: number;
  107994. BUMP: boolean;
  107995. BUMPDIRECTUV: number;
  107996. PARALLAX: boolean;
  107997. PARALLAXOCCLUSION: boolean;
  107998. SPECULAROVERALPHA: boolean;
  107999. CLIPPLANE: boolean;
  108000. CLIPPLANE2: boolean;
  108001. CLIPPLANE3: boolean;
  108002. CLIPPLANE4: boolean;
  108003. CLIPPLANE5: boolean;
  108004. CLIPPLANE6: boolean;
  108005. ALPHATEST: boolean;
  108006. DEPTHPREPASS: boolean;
  108007. ALPHAFROMDIFFUSE: boolean;
  108008. POINTSIZE: boolean;
  108009. FOG: boolean;
  108010. SPECULARTERM: boolean;
  108011. DIFFUSEFRESNEL: boolean;
  108012. OPACITYFRESNEL: boolean;
  108013. REFLECTIONFRESNEL: boolean;
  108014. REFRACTIONFRESNEL: boolean;
  108015. EMISSIVEFRESNEL: boolean;
  108016. FRESNEL: boolean;
  108017. NORMAL: boolean;
  108018. UV1: boolean;
  108019. UV2: boolean;
  108020. VERTEXCOLOR: boolean;
  108021. VERTEXALPHA: boolean;
  108022. NUM_BONE_INFLUENCERS: number;
  108023. BonesPerMesh: number;
  108024. BONETEXTURE: boolean;
  108025. INSTANCES: boolean;
  108026. THIN_INSTANCES: boolean;
  108027. GLOSSINESS: boolean;
  108028. ROUGHNESS: boolean;
  108029. EMISSIVEASILLUMINATION: boolean;
  108030. LINKEMISSIVEWITHDIFFUSE: boolean;
  108031. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108032. LIGHTMAP: boolean;
  108033. LIGHTMAPDIRECTUV: number;
  108034. OBJECTSPACE_NORMALMAP: boolean;
  108035. USELIGHTMAPASSHADOWMAP: boolean;
  108036. REFLECTIONMAP_3D: boolean;
  108037. REFLECTIONMAP_SPHERICAL: boolean;
  108038. REFLECTIONMAP_PLANAR: boolean;
  108039. REFLECTIONMAP_CUBIC: boolean;
  108040. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108041. REFLECTIONMAP_PROJECTION: boolean;
  108042. REFLECTIONMAP_SKYBOX: boolean;
  108043. REFLECTIONMAP_EXPLICIT: boolean;
  108044. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108045. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108046. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108047. INVERTCUBICMAP: boolean;
  108048. LOGARITHMICDEPTH: boolean;
  108049. REFRACTION: boolean;
  108050. REFRACTIONMAP_3D: boolean;
  108051. REFLECTIONOVERALPHA: boolean;
  108052. TWOSIDEDLIGHTING: boolean;
  108053. SHADOWFLOAT: boolean;
  108054. MORPHTARGETS: boolean;
  108055. MORPHTARGETS_NORMAL: boolean;
  108056. MORPHTARGETS_TANGENT: boolean;
  108057. MORPHTARGETS_UV: boolean;
  108058. NUM_MORPH_INFLUENCERS: number;
  108059. NONUNIFORMSCALING: boolean;
  108060. PREMULTIPLYALPHA: boolean;
  108061. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  108062. ALPHABLEND: boolean;
  108063. PREPASS: boolean;
  108064. SCENE_MRT_COUNT: number;
  108065. RGBDLIGHTMAP: boolean;
  108066. RGBDREFLECTION: boolean;
  108067. RGBDREFRACTION: boolean;
  108068. IMAGEPROCESSING: boolean;
  108069. VIGNETTE: boolean;
  108070. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108071. VIGNETTEBLENDMODEOPAQUE: boolean;
  108072. TONEMAPPING: boolean;
  108073. TONEMAPPING_ACES: boolean;
  108074. CONTRAST: boolean;
  108075. COLORCURVES: boolean;
  108076. COLORGRADING: boolean;
  108077. COLORGRADING3D: boolean;
  108078. SAMPLER3DGREENDEPTH: boolean;
  108079. SAMPLER3DBGRMAP: boolean;
  108080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108081. MULTIVIEW: boolean;
  108082. /**
  108083. * If the reflection texture on this material is in linear color space
  108084. * @hidden
  108085. */
  108086. IS_REFLECTION_LINEAR: boolean;
  108087. /**
  108088. * If the refraction texture on this material is in linear color space
  108089. * @hidden
  108090. */
  108091. IS_REFRACTION_LINEAR: boolean;
  108092. EXPOSURE: boolean;
  108093. constructor();
  108094. setReflectionMode(modeToEnable: string): void;
  108095. }
  108096. /**
  108097. * This is the default material used in Babylon. It is the best trade off between quality
  108098. * and performances.
  108099. * @see https://doc.babylonjs.com/babylon101/materials
  108100. */
  108101. export class StandardMaterial extends PushMaterial {
  108102. private _diffuseTexture;
  108103. /**
  108104. * The basic texture of the material as viewed under a light.
  108105. */
  108106. diffuseTexture: Nullable<BaseTexture>;
  108107. private _ambientTexture;
  108108. /**
  108109. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108110. */
  108111. ambientTexture: Nullable<BaseTexture>;
  108112. private _opacityTexture;
  108113. /**
  108114. * Define the transparency of the material from a texture.
  108115. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108116. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108117. */
  108118. opacityTexture: Nullable<BaseTexture>;
  108119. private _reflectionTexture;
  108120. /**
  108121. * Define the texture used to display the reflection.
  108122. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108123. */
  108124. reflectionTexture: Nullable<BaseTexture>;
  108125. private _emissiveTexture;
  108126. /**
  108127. * Define texture of the material as if self lit.
  108128. * This will be mixed in the final result even in the absence of light.
  108129. */
  108130. emissiveTexture: Nullable<BaseTexture>;
  108131. private _specularTexture;
  108132. /**
  108133. * Define how the color and intensity of the highlight given by the light in the material.
  108134. */
  108135. specularTexture: Nullable<BaseTexture>;
  108136. private _bumpTexture;
  108137. /**
  108138. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108139. * 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.
  108140. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  108141. */
  108142. bumpTexture: Nullable<BaseTexture>;
  108143. private _lightmapTexture;
  108144. /**
  108145. * Complex lighting can be computationally expensive to compute at runtime.
  108146. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108147. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  108148. */
  108149. lightmapTexture: Nullable<BaseTexture>;
  108150. private _refractionTexture;
  108151. /**
  108152. * Define the texture used to display the refraction.
  108153. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108154. */
  108155. refractionTexture: Nullable<BaseTexture>;
  108156. /**
  108157. * The color of the material lit by the environmental background lighting.
  108158. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108159. */
  108160. ambientColor: Color3;
  108161. /**
  108162. * The basic color of the material as viewed under a light.
  108163. */
  108164. diffuseColor: Color3;
  108165. /**
  108166. * Define how the color and intensity of the highlight given by the light in the material.
  108167. */
  108168. specularColor: Color3;
  108169. /**
  108170. * Define the color of the material as if self lit.
  108171. * This will be mixed in the final result even in the absence of light.
  108172. */
  108173. emissiveColor: Color3;
  108174. /**
  108175. * Defines how sharp are the highlights in the material.
  108176. * The bigger the value the sharper giving a more glossy feeling to the result.
  108177. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108178. */
  108179. specularPower: number;
  108180. private _useAlphaFromDiffuseTexture;
  108181. /**
  108182. * Does the transparency come from the diffuse texture alpha channel.
  108183. */
  108184. useAlphaFromDiffuseTexture: boolean;
  108185. private _useEmissiveAsIllumination;
  108186. /**
  108187. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108188. */
  108189. useEmissiveAsIllumination: boolean;
  108190. private _linkEmissiveWithDiffuse;
  108191. /**
  108192. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108193. * the emissive level when the final color is close to one.
  108194. */
  108195. linkEmissiveWithDiffuse: boolean;
  108196. private _useSpecularOverAlpha;
  108197. /**
  108198. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108199. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108200. */
  108201. useSpecularOverAlpha: boolean;
  108202. private _useReflectionOverAlpha;
  108203. /**
  108204. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108205. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108206. */
  108207. useReflectionOverAlpha: boolean;
  108208. private _disableLighting;
  108209. /**
  108210. * Does lights from the scene impacts this material.
  108211. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108212. */
  108213. disableLighting: boolean;
  108214. private _useObjectSpaceNormalMap;
  108215. /**
  108216. * Allows using an object space normal map (instead of tangent space).
  108217. */
  108218. useObjectSpaceNormalMap: boolean;
  108219. private _useParallax;
  108220. /**
  108221. * Is parallax enabled or not.
  108222. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108223. */
  108224. useParallax: boolean;
  108225. private _useParallaxOcclusion;
  108226. /**
  108227. * Is parallax occlusion enabled or not.
  108228. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108229. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108230. */
  108231. useParallaxOcclusion: boolean;
  108232. /**
  108233. * 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.
  108234. */
  108235. parallaxScaleBias: number;
  108236. private _roughness;
  108237. /**
  108238. * Helps to define how blurry the reflections should appears in the material.
  108239. */
  108240. roughness: number;
  108241. /**
  108242. * In case of refraction, define the value of the index of refraction.
  108243. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108244. */
  108245. indexOfRefraction: number;
  108246. /**
  108247. * Invert the refraction texture alongside the y axis.
  108248. * It can be useful with procedural textures or probe for instance.
  108249. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108250. */
  108251. invertRefractionY: boolean;
  108252. /**
  108253. * Defines the alpha limits in alpha test mode.
  108254. */
  108255. alphaCutOff: number;
  108256. private _useLightmapAsShadowmap;
  108257. /**
  108258. * In case of light mapping, define whether the map contains light or shadow informations.
  108259. */
  108260. useLightmapAsShadowmap: boolean;
  108261. private _diffuseFresnelParameters;
  108262. /**
  108263. * Define the diffuse fresnel parameters of the material.
  108264. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108265. */
  108266. diffuseFresnelParameters: FresnelParameters;
  108267. private _opacityFresnelParameters;
  108268. /**
  108269. * Define the opacity fresnel parameters of the material.
  108270. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108271. */
  108272. opacityFresnelParameters: FresnelParameters;
  108273. private _reflectionFresnelParameters;
  108274. /**
  108275. * Define the reflection fresnel parameters of the material.
  108276. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108277. */
  108278. reflectionFresnelParameters: FresnelParameters;
  108279. private _refractionFresnelParameters;
  108280. /**
  108281. * Define the refraction fresnel parameters of the material.
  108282. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108283. */
  108284. refractionFresnelParameters: FresnelParameters;
  108285. private _emissiveFresnelParameters;
  108286. /**
  108287. * Define the emissive fresnel parameters of the material.
  108288. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108289. */
  108290. emissiveFresnelParameters: FresnelParameters;
  108291. private _useReflectionFresnelFromSpecular;
  108292. /**
  108293. * If true automatically deducts the fresnels values from the material specularity.
  108294. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108295. */
  108296. useReflectionFresnelFromSpecular: boolean;
  108297. private _useGlossinessFromSpecularMapAlpha;
  108298. /**
  108299. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108300. */
  108301. useGlossinessFromSpecularMapAlpha: boolean;
  108302. private _maxSimultaneousLights;
  108303. /**
  108304. * Defines the maximum number of lights that can be used in the material
  108305. */
  108306. maxSimultaneousLights: number;
  108307. private _invertNormalMapX;
  108308. /**
  108309. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108310. */
  108311. invertNormalMapX: boolean;
  108312. private _invertNormalMapY;
  108313. /**
  108314. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108315. */
  108316. invertNormalMapY: boolean;
  108317. private _twoSidedLighting;
  108318. /**
  108319. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108320. */
  108321. twoSidedLighting: boolean;
  108322. /**
  108323. * Default configuration related to image processing available in the standard Material.
  108324. */
  108325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108326. /**
  108327. * Gets the image processing configuration used either in this material.
  108328. */
  108329. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108330. /**
  108331. * Sets the Default image processing configuration used either in the this material.
  108332. *
  108333. * If sets to null, the scene one is in use.
  108334. */
  108335. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108336. /**
  108337. * Keep track of the image processing observer to allow dispose and replace.
  108338. */
  108339. private _imageProcessingObserver;
  108340. /**
  108341. * Attaches a new image processing configuration to the Standard Material.
  108342. * @param configuration
  108343. */
  108344. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108345. /**
  108346. * Gets wether the color curves effect is enabled.
  108347. */
  108348. get cameraColorCurvesEnabled(): boolean;
  108349. /**
  108350. * Sets wether the color curves effect is enabled.
  108351. */
  108352. set cameraColorCurvesEnabled(value: boolean);
  108353. /**
  108354. * Gets wether the color grading effect is enabled.
  108355. */
  108356. get cameraColorGradingEnabled(): boolean;
  108357. /**
  108358. * Gets wether the color grading effect is enabled.
  108359. */
  108360. set cameraColorGradingEnabled(value: boolean);
  108361. /**
  108362. * Gets wether tonemapping is enabled or not.
  108363. */
  108364. get cameraToneMappingEnabled(): boolean;
  108365. /**
  108366. * Sets wether tonemapping is enabled or not
  108367. */
  108368. set cameraToneMappingEnabled(value: boolean);
  108369. /**
  108370. * The camera exposure used on this material.
  108371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108372. * This corresponds to a photographic exposure.
  108373. */
  108374. get cameraExposure(): number;
  108375. /**
  108376. * The camera exposure used on this material.
  108377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108378. * This corresponds to a photographic exposure.
  108379. */
  108380. set cameraExposure(value: number);
  108381. /**
  108382. * Gets The camera contrast used on this material.
  108383. */
  108384. get cameraContrast(): number;
  108385. /**
  108386. * Sets The camera contrast used on this material.
  108387. */
  108388. set cameraContrast(value: number);
  108389. /**
  108390. * Gets the Color Grading 2D Lookup Texture.
  108391. */
  108392. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108393. /**
  108394. * Sets the Color Grading 2D Lookup Texture.
  108395. */
  108396. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108397. /**
  108398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108400. * 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;
  108401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108402. */
  108403. get cameraColorCurves(): Nullable<ColorCurves>;
  108404. /**
  108405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108407. * 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;
  108408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108409. */
  108410. set cameraColorCurves(value: Nullable<ColorCurves>);
  108411. /**
  108412. * Should this material render to several textures at once
  108413. */
  108414. get shouldRenderToMRT(): boolean;
  108415. /**
  108416. * Defines the detail map parameters for the material.
  108417. */
  108418. readonly detailMap: DetailMapConfiguration;
  108419. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108420. protected _worldViewProjectionMatrix: Matrix;
  108421. protected _globalAmbientColor: Color3;
  108422. protected _useLogarithmicDepth: boolean;
  108423. protected _rebuildInParallel: boolean;
  108424. /**
  108425. * Instantiates a new standard material.
  108426. * This is the default material used in Babylon. It is the best trade off between quality
  108427. * and performances.
  108428. * @see https://doc.babylonjs.com/babylon101/materials
  108429. * @param name Define the name of the material in the scene
  108430. * @param scene Define the scene the material belong to
  108431. */
  108432. constructor(name: string, scene: Scene);
  108433. /**
  108434. * Gets a boolean indicating that current material needs to register RTT
  108435. */
  108436. get hasRenderTargetTextures(): boolean;
  108437. /**
  108438. * Gets the current class name of the material e.g. "StandardMaterial"
  108439. * Mainly use in serialization.
  108440. * @returns the class name
  108441. */
  108442. getClassName(): string;
  108443. /**
  108444. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108445. * You can try switching to logarithmic depth.
  108446. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108447. */
  108448. get useLogarithmicDepth(): boolean;
  108449. set useLogarithmicDepth(value: boolean);
  108450. /**
  108451. * Specifies if the material will require alpha blending
  108452. * @returns a boolean specifying if alpha blending is needed
  108453. */
  108454. needAlphaBlending(): boolean;
  108455. /**
  108456. * Specifies if this material should be rendered in alpha test mode
  108457. * @returns a boolean specifying if an alpha test is needed.
  108458. */
  108459. needAlphaTesting(): boolean;
  108460. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108461. /**
  108462. * Get the texture used for alpha test purpose.
  108463. * @returns the diffuse texture in case of the standard material.
  108464. */
  108465. getAlphaTestTexture(): Nullable<BaseTexture>;
  108466. /**
  108467. * Get if the submesh is ready to be used and all its information available.
  108468. * Child classes can use it to update shaders
  108469. * @param mesh defines the mesh to check
  108470. * @param subMesh defines which submesh to check
  108471. * @param useInstances specifies that instances should be used
  108472. * @returns a boolean indicating that the submesh is ready or not
  108473. */
  108474. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108475. /**
  108476. * Builds the material UBO layouts.
  108477. * Used internally during the effect preparation.
  108478. */
  108479. buildUniformLayout(): void;
  108480. /**
  108481. * Unbinds the material from the mesh
  108482. */
  108483. unbind(): void;
  108484. /**
  108485. * Binds the submesh to this material by preparing the effect and shader to draw
  108486. * @param world defines the world transformation matrix
  108487. * @param mesh defines the mesh containing the submesh
  108488. * @param subMesh defines the submesh to bind the material to
  108489. */
  108490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108491. /**
  108492. * Get the list of animatables in the material.
  108493. * @returns the list of animatables object used in the material
  108494. */
  108495. getAnimatables(): IAnimatable[];
  108496. /**
  108497. * Gets the active textures from the material
  108498. * @returns an array of textures
  108499. */
  108500. getActiveTextures(): BaseTexture[];
  108501. /**
  108502. * Specifies if the material uses a texture
  108503. * @param texture defines the texture to check against the material
  108504. * @returns a boolean specifying if the material uses the texture
  108505. */
  108506. hasTexture(texture: BaseTexture): boolean;
  108507. /**
  108508. * Disposes the material
  108509. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108510. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108511. */
  108512. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108513. /**
  108514. * Makes a duplicate of the material, and gives it a new name
  108515. * @param name defines the new name for the duplicated material
  108516. * @returns the cloned material
  108517. */
  108518. clone(name: string): StandardMaterial;
  108519. /**
  108520. * Serializes this material in a JSON representation
  108521. * @returns the serialized material object
  108522. */
  108523. serialize(): any;
  108524. /**
  108525. * Creates a standard material from parsed material data
  108526. * @param source defines the JSON representation of the material
  108527. * @param scene defines the hosting scene
  108528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108529. * @returns a new standard material
  108530. */
  108531. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108532. /**
  108533. * Are diffuse textures enabled in the application.
  108534. */
  108535. static get DiffuseTextureEnabled(): boolean;
  108536. static set DiffuseTextureEnabled(value: boolean);
  108537. /**
  108538. * Are detail textures enabled in the application.
  108539. */
  108540. static get DetailTextureEnabled(): boolean;
  108541. static set DetailTextureEnabled(value: boolean);
  108542. /**
  108543. * Are ambient textures enabled in the application.
  108544. */
  108545. static get AmbientTextureEnabled(): boolean;
  108546. static set AmbientTextureEnabled(value: boolean);
  108547. /**
  108548. * Are opacity textures enabled in the application.
  108549. */
  108550. static get OpacityTextureEnabled(): boolean;
  108551. static set OpacityTextureEnabled(value: boolean);
  108552. /**
  108553. * Are reflection textures enabled in the application.
  108554. */
  108555. static get ReflectionTextureEnabled(): boolean;
  108556. static set ReflectionTextureEnabled(value: boolean);
  108557. /**
  108558. * Are emissive textures enabled in the application.
  108559. */
  108560. static get EmissiveTextureEnabled(): boolean;
  108561. static set EmissiveTextureEnabled(value: boolean);
  108562. /**
  108563. * Are specular textures enabled in the application.
  108564. */
  108565. static get SpecularTextureEnabled(): boolean;
  108566. static set SpecularTextureEnabled(value: boolean);
  108567. /**
  108568. * Are bump textures enabled in the application.
  108569. */
  108570. static get BumpTextureEnabled(): boolean;
  108571. static set BumpTextureEnabled(value: boolean);
  108572. /**
  108573. * Are lightmap textures enabled in the application.
  108574. */
  108575. static get LightmapTextureEnabled(): boolean;
  108576. static set LightmapTextureEnabled(value: boolean);
  108577. /**
  108578. * Are refraction textures enabled in the application.
  108579. */
  108580. static get RefractionTextureEnabled(): boolean;
  108581. static set RefractionTextureEnabled(value: boolean);
  108582. /**
  108583. * Are color grading textures enabled in the application.
  108584. */
  108585. static get ColorGradingTextureEnabled(): boolean;
  108586. static set ColorGradingTextureEnabled(value: boolean);
  108587. /**
  108588. * Are fresnels enabled in the application.
  108589. */
  108590. static get FresnelEnabled(): boolean;
  108591. static set FresnelEnabled(value: boolean);
  108592. }
  108593. }
  108594. declare module BABYLON {
  108595. /**
  108596. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108597. *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.
  108598. * The SPS is also a particle system. It provides some methods to manage the particles.
  108599. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108600. *
  108601. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108602. */
  108603. export class SolidParticleSystem implements IDisposable {
  108604. /**
  108605. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108606. * Example : var p = SPS.particles[i];
  108607. */
  108608. particles: SolidParticle[];
  108609. /**
  108610. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108611. */
  108612. nbParticles: number;
  108613. /**
  108614. * If the particles must ever face the camera (default false). Useful for planar particles.
  108615. */
  108616. billboard: boolean;
  108617. /**
  108618. * Recompute normals when adding a shape
  108619. */
  108620. recomputeNormals: boolean;
  108621. /**
  108622. * This a counter ofr your own usage. It's not set by any SPS functions.
  108623. */
  108624. counter: number;
  108625. /**
  108626. * The SPS name. This name is also given to the underlying mesh.
  108627. */
  108628. name: string;
  108629. /**
  108630. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108631. */
  108632. mesh: Mesh;
  108633. /**
  108634. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108635. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108636. */
  108637. vars: any;
  108638. /**
  108639. * This array is populated when the SPS is set as 'pickable'.
  108640. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108641. * Each element of this array is an object `{idx: int, faceId: int}`.
  108642. * `idx` is the picked particle index in the `SPS.particles` array
  108643. * `faceId` is the picked face index counted within this particle.
  108644. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108645. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108646. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108647. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108648. */
  108649. pickedParticles: {
  108650. idx: number;
  108651. faceId: number;
  108652. }[];
  108653. /**
  108654. * This array is populated when the SPS is set as 'pickable'
  108655. * Each key of this array is a submesh index.
  108656. * Each element of this array is a second array defined like this :
  108657. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108658. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108659. * `idx` is the picked particle index in the `SPS.particles` array
  108660. * `faceId` is the picked face index counted within this particle.
  108661. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108662. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108663. */
  108664. pickedBySubMesh: {
  108665. idx: number;
  108666. faceId: number;
  108667. }[][];
  108668. /**
  108669. * This array is populated when `enableDepthSort` is set to true.
  108670. * Each element of this array is an instance of the class DepthSortedParticle.
  108671. */
  108672. depthSortedParticles: DepthSortedParticle[];
  108673. /**
  108674. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108675. * @hidden
  108676. */
  108677. _bSphereOnly: boolean;
  108678. /**
  108679. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108680. * @hidden
  108681. */
  108682. _bSphereRadiusFactor: number;
  108683. private _scene;
  108684. private _positions;
  108685. private _indices;
  108686. private _normals;
  108687. private _colors;
  108688. private _uvs;
  108689. private _indices32;
  108690. private _positions32;
  108691. private _normals32;
  108692. private _fixedNormal32;
  108693. private _colors32;
  108694. private _uvs32;
  108695. private _index;
  108696. private _updatable;
  108697. private _pickable;
  108698. private _isVisibilityBoxLocked;
  108699. private _alwaysVisible;
  108700. private _depthSort;
  108701. private _expandable;
  108702. private _shapeCounter;
  108703. private _copy;
  108704. private _color;
  108705. private _computeParticleColor;
  108706. private _computeParticleTexture;
  108707. private _computeParticleRotation;
  108708. private _computeParticleVertex;
  108709. private _computeBoundingBox;
  108710. private _depthSortParticles;
  108711. private _camera;
  108712. private _mustUnrotateFixedNormals;
  108713. private _particlesIntersect;
  108714. private _needs32Bits;
  108715. private _isNotBuilt;
  108716. private _lastParticleId;
  108717. private _idxOfId;
  108718. private _multimaterialEnabled;
  108719. private _useModelMaterial;
  108720. private _indicesByMaterial;
  108721. private _materialIndexes;
  108722. private _depthSortFunction;
  108723. private _materialSortFunction;
  108724. private _materials;
  108725. private _multimaterial;
  108726. private _materialIndexesById;
  108727. private _defaultMaterial;
  108728. private _autoUpdateSubMeshes;
  108729. private _tmpVertex;
  108730. /**
  108731. * Creates a SPS (Solid Particle System) object.
  108732. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108733. * @param scene (Scene) is the scene in which the SPS is added.
  108734. * @param options defines the options of the sps e.g.
  108735. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108736. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108737. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108738. * * 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.
  108739. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108740. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108741. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108742. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108743. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108744. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108745. */
  108746. constructor(name: string, scene: Scene, options?: {
  108747. updatable?: boolean;
  108748. isPickable?: boolean;
  108749. enableDepthSort?: boolean;
  108750. particleIntersection?: boolean;
  108751. boundingSphereOnly?: boolean;
  108752. bSphereRadiusFactor?: number;
  108753. expandable?: boolean;
  108754. useModelMaterial?: boolean;
  108755. enableMultiMaterial?: boolean;
  108756. });
  108757. /**
  108758. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108759. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108760. * @returns the created mesh
  108761. */
  108762. buildMesh(): Mesh;
  108763. /**
  108764. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108765. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108766. * Thus the particles generated from `digest()` have their property `position` set yet.
  108767. * @param mesh ( Mesh ) is the mesh to be digested
  108768. * @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
  108769. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108770. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108771. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108772. * @returns the current SPS
  108773. */
  108774. digest(mesh: Mesh, options?: {
  108775. facetNb?: number;
  108776. number?: number;
  108777. delta?: number;
  108778. storage?: [];
  108779. }): SolidParticleSystem;
  108780. /**
  108781. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108782. * @hidden
  108783. */
  108784. private _unrotateFixedNormals;
  108785. /**
  108786. * Resets the temporary working copy particle
  108787. * @hidden
  108788. */
  108789. private _resetCopy;
  108790. /**
  108791. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108792. * @param p the current index in the positions array to be updated
  108793. * @param ind the current index in the indices array
  108794. * @param shape a Vector3 array, the shape geometry
  108795. * @param positions the positions array to be updated
  108796. * @param meshInd the shape indices array
  108797. * @param indices the indices array to be updated
  108798. * @param meshUV the shape uv array
  108799. * @param uvs the uv array to be updated
  108800. * @param meshCol the shape color array
  108801. * @param colors the color array to be updated
  108802. * @param meshNor the shape normals array
  108803. * @param normals the normals array to be updated
  108804. * @param idx the particle index
  108805. * @param idxInShape the particle index in its shape
  108806. * @param options the addShape() method passed options
  108807. * @model the particle model
  108808. * @hidden
  108809. */
  108810. private _meshBuilder;
  108811. /**
  108812. * Returns a shape Vector3 array from positions float array
  108813. * @param positions float array
  108814. * @returns a vector3 array
  108815. * @hidden
  108816. */
  108817. private _posToShape;
  108818. /**
  108819. * Returns a shapeUV array from a float uvs (array deep copy)
  108820. * @param uvs as a float array
  108821. * @returns a shapeUV array
  108822. * @hidden
  108823. */
  108824. private _uvsToShapeUV;
  108825. /**
  108826. * Adds a new particle object in the particles array
  108827. * @param idx particle index in particles array
  108828. * @param id particle id
  108829. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108830. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108831. * @param model particle ModelShape object
  108832. * @param shapeId model shape identifier
  108833. * @param idxInShape index of the particle in the current model
  108834. * @param bInfo model bounding info object
  108835. * @param storage target storage array, if any
  108836. * @hidden
  108837. */
  108838. private _addParticle;
  108839. /**
  108840. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108841. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108842. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108843. * @param nb (positive integer) the number of particles to be created from this model
  108844. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108845. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108846. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108847. * @returns the number of shapes in the system
  108848. */
  108849. addShape(mesh: Mesh, nb: number, options?: {
  108850. positionFunction?: any;
  108851. vertexFunction?: any;
  108852. storage?: [];
  108853. }): number;
  108854. /**
  108855. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108856. * @hidden
  108857. */
  108858. private _rebuildParticle;
  108859. /**
  108860. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108861. * @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.
  108862. * @returns the SPS.
  108863. */
  108864. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108865. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108866. * Returns an array with the removed particles.
  108867. * 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.
  108868. * The SPS can't be empty so at least one particle needs to remain in place.
  108869. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108870. * @param start index of the first particle to remove
  108871. * @param end index of the last particle to remove (included)
  108872. * @returns an array populated with the removed particles
  108873. */
  108874. removeParticles(start: number, end: number): SolidParticle[];
  108875. /**
  108876. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108877. * @param solidParticleArray an array populated with Solid Particles objects
  108878. * @returns the SPS
  108879. */
  108880. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108881. /**
  108882. * Creates a new particle and modifies the SPS mesh geometry :
  108883. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108884. * - calls _addParticle() to populate the particle array
  108885. * factorized code from addShape() and insertParticlesFromArray()
  108886. * @param idx particle index in the particles array
  108887. * @param i particle index in its shape
  108888. * @param modelShape particle ModelShape object
  108889. * @param shape shape vertex array
  108890. * @param meshInd shape indices array
  108891. * @param meshUV shape uv array
  108892. * @param meshCol shape color array
  108893. * @param meshNor shape normals array
  108894. * @param bbInfo shape bounding info
  108895. * @param storage target particle storage
  108896. * @options addShape() passed options
  108897. * @hidden
  108898. */
  108899. private _insertNewParticle;
  108900. /**
  108901. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108902. * This method calls `updateParticle()` for each particle of the SPS.
  108903. * For an animated SPS, it is usually called within the render loop.
  108904. * 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.
  108905. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108906. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108907. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108908. * @returns the SPS.
  108909. */
  108910. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108911. /**
  108912. * Disposes the SPS.
  108913. */
  108914. dispose(): void;
  108915. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108916. * idx is the particle index in the SPS
  108917. * faceId is the picked face index counted within this particle.
  108918. * Returns null if the pickInfo can't identify a picked particle.
  108919. * @param pickingInfo (PickingInfo object)
  108920. * @returns {idx: number, faceId: number} or null
  108921. */
  108922. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108923. idx: number;
  108924. faceId: number;
  108925. }>;
  108926. /**
  108927. * Returns a SolidParticle object from its identifier : particle.id
  108928. * @param id (integer) the particle Id
  108929. * @returns the searched particle or null if not found in the SPS.
  108930. */
  108931. getParticleById(id: number): Nullable<SolidParticle>;
  108932. /**
  108933. * Returns a new array populated with the particles having the passed shapeId.
  108934. * @param shapeId (integer) the shape identifier
  108935. * @returns a new solid particle array
  108936. */
  108937. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108938. /**
  108939. * Populates the passed array "ref" with the particles having the passed shapeId.
  108940. * @param shapeId the shape identifier
  108941. * @returns the SPS
  108942. * @param ref
  108943. */
  108944. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108945. /**
  108946. * Computes the required SubMeshes according the materials assigned to the particles.
  108947. * @returns the solid particle system.
  108948. * Does nothing if called before the SPS mesh is built.
  108949. */
  108950. computeSubMeshes(): SolidParticleSystem;
  108951. /**
  108952. * Sorts the solid particles by material when MultiMaterial is enabled.
  108953. * Updates the indices32 array.
  108954. * Updates the indicesByMaterial array.
  108955. * Updates the mesh indices array.
  108956. * @returns the SPS
  108957. * @hidden
  108958. */
  108959. private _sortParticlesByMaterial;
  108960. /**
  108961. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108962. * @hidden
  108963. */
  108964. private _setMaterialIndexesById;
  108965. /**
  108966. * Returns an array with unique values of Materials from the passed array
  108967. * @param array the material array to be checked and filtered
  108968. * @hidden
  108969. */
  108970. private _filterUniqueMaterialId;
  108971. /**
  108972. * Sets a new Standard Material as _defaultMaterial if not already set.
  108973. * @hidden
  108974. */
  108975. private _setDefaultMaterial;
  108976. /**
  108977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108978. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108979. * @returns the SPS.
  108980. */
  108981. refreshVisibleSize(): SolidParticleSystem;
  108982. /**
  108983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108984. * @param size the size (float) of the visibility box
  108985. * note : this doesn't lock the SPS mesh bounding box.
  108986. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108987. */
  108988. setVisibilityBox(size: number): void;
  108989. /**
  108990. * Gets whether the SPS as always visible or not
  108991. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108992. */
  108993. get isAlwaysVisible(): boolean;
  108994. /**
  108995. * Sets the SPS as always visible or not
  108996. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108997. */
  108998. set isAlwaysVisible(val: boolean);
  108999. /**
  109000. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109001. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109002. */
  109003. set isVisibilityBoxLocked(val: boolean);
  109004. /**
  109005. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109006. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109007. */
  109008. get isVisibilityBoxLocked(): boolean;
  109009. /**
  109010. * Tells to `setParticles()` to compute the particle rotations or not.
  109011. * Default value : true. The SPS is faster when it's set to false.
  109012. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109013. */
  109014. set computeParticleRotation(val: boolean);
  109015. /**
  109016. * Tells to `setParticles()` to compute the particle colors or not.
  109017. * Default value : true. The SPS is faster when it's set to false.
  109018. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109019. */
  109020. set computeParticleColor(val: boolean);
  109021. set computeParticleTexture(val: boolean);
  109022. /**
  109023. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  109024. * Default value : false. The SPS is faster when it's set to false.
  109025. * Note : the particle custom vertex positions aren't stored values.
  109026. */
  109027. set computeParticleVertex(val: boolean);
  109028. /**
  109029. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  109030. */
  109031. set computeBoundingBox(val: boolean);
  109032. /**
  109033. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  109034. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109035. * Default : `true`
  109036. */
  109037. set depthSortParticles(val: boolean);
  109038. /**
  109039. * Gets if `setParticles()` computes the particle rotations or not.
  109040. * Default value : true. The SPS is faster when it's set to false.
  109041. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109042. */
  109043. get computeParticleRotation(): boolean;
  109044. /**
  109045. * Gets if `setParticles()` computes the particle colors or not.
  109046. * Default value : true. The SPS is faster when it's set to false.
  109047. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109048. */
  109049. get computeParticleColor(): boolean;
  109050. /**
  109051. * Gets if `setParticles()` computes the particle textures or not.
  109052. * Default value : true. The SPS is faster when it's set to false.
  109053. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  109054. */
  109055. get computeParticleTexture(): boolean;
  109056. /**
  109057. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  109058. * Default value : false. The SPS is faster when it's set to false.
  109059. * Note : the particle custom vertex positions aren't stored values.
  109060. */
  109061. get computeParticleVertex(): boolean;
  109062. /**
  109063. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  109064. */
  109065. get computeBoundingBox(): boolean;
  109066. /**
  109067. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  109068. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109069. * Default : `true`
  109070. */
  109071. get depthSortParticles(): boolean;
  109072. /**
  109073. * Gets if the SPS is created as expandable at construction time.
  109074. * Default : `false`
  109075. */
  109076. get expandable(): boolean;
  109077. /**
  109078. * Gets if the SPS supports the Multi Materials
  109079. */
  109080. get multimaterialEnabled(): boolean;
  109081. /**
  109082. * Gets if the SPS uses the model materials for its own multimaterial.
  109083. */
  109084. get useModelMaterial(): boolean;
  109085. /**
  109086. * The SPS used material array.
  109087. */
  109088. get materials(): Material[];
  109089. /**
  109090. * Sets the SPS MultiMaterial from the passed materials.
  109091. * Note : the passed array is internally copied and not used then by reference.
  109092. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  109093. */
  109094. setMultiMaterial(materials: Material[]): void;
  109095. /**
  109096. * The SPS computed multimaterial object
  109097. */
  109098. get multimaterial(): MultiMaterial;
  109099. set multimaterial(mm: MultiMaterial);
  109100. /**
  109101. * If the subMeshes must be updated on the next call to setParticles()
  109102. */
  109103. get autoUpdateSubMeshes(): boolean;
  109104. set autoUpdateSubMeshes(val: boolean);
  109105. /**
  109106. * This function does nothing. It may be overwritten to set all the particle first values.
  109107. * The SPS doesn't call this function, you may have to call it by your own.
  109108. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109109. */
  109110. initParticles(): void;
  109111. /**
  109112. * This function does nothing. It may be overwritten to recycle a particle.
  109113. * The SPS doesn't call this function, you may have to call it by your own.
  109114. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109115. * @param particle The particle to recycle
  109116. * @returns the recycled particle
  109117. */
  109118. recycleParticle(particle: SolidParticle): SolidParticle;
  109119. /**
  109120. * Updates a particle : this function should be overwritten by the user.
  109121. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  109122. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109123. * @example : just set a particle position or velocity and recycle conditions
  109124. * @param particle The particle to update
  109125. * @returns the updated particle
  109126. */
  109127. updateParticle(particle: SolidParticle): SolidParticle;
  109128. /**
  109129. * Updates a vertex of a particle : it can be overwritten by the user.
  109130. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  109131. * @param particle the current particle
  109132. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  109133. * @param pt the index of the current vertex in the particle shape
  109134. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  109135. * @example : just set a vertex particle position or color
  109136. * @returns the sps
  109137. */
  109138. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  109139. /**
  109140. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  109141. * This does nothing and may be overwritten by the user.
  109142. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109143. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109144. * @param update the boolean update value actually passed to setParticles()
  109145. */
  109146. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109147. /**
  109148. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  109149. * This will be passed three parameters.
  109150. * This does nothing and may be overwritten by the user.
  109151. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109152. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109153. * @param update the boolean update value actually passed to setParticles()
  109154. */
  109155. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109156. }
  109157. }
  109158. declare module BABYLON {
  109159. /**
  109160. * Represents one particle of a solid particle system.
  109161. */
  109162. export class SolidParticle {
  109163. /**
  109164. * particle global index
  109165. */
  109166. idx: number;
  109167. /**
  109168. * particle identifier
  109169. */
  109170. id: number;
  109171. /**
  109172. * The color of the particle
  109173. */
  109174. color: Nullable<Color4>;
  109175. /**
  109176. * The world space position of the particle.
  109177. */
  109178. position: Vector3;
  109179. /**
  109180. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  109181. */
  109182. rotation: Vector3;
  109183. /**
  109184. * The world space rotation quaternion of the particle.
  109185. */
  109186. rotationQuaternion: Nullable<Quaternion>;
  109187. /**
  109188. * The scaling of the particle.
  109189. */
  109190. scaling: Vector3;
  109191. /**
  109192. * The uvs of the particle.
  109193. */
  109194. uvs: Vector4;
  109195. /**
  109196. * The current speed of the particle.
  109197. */
  109198. velocity: Vector3;
  109199. /**
  109200. * The pivot point in the particle local space.
  109201. */
  109202. pivot: Vector3;
  109203. /**
  109204. * Must the particle be translated from its pivot point in its local space ?
  109205. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  109206. * Default : false
  109207. */
  109208. translateFromPivot: boolean;
  109209. /**
  109210. * Is the particle active or not ?
  109211. */
  109212. alive: boolean;
  109213. /**
  109214. * Is the particle visible or not ?
  109215. */
  109216. isVisible: boolean;
  109217. /**
  109218. * Index of this particle in the global "positions" array (Internal use)
  109219. * @hidden
  109220. */
  109221. _pos: number;
  109222. /**
  109223. * @hidden Index of this particle in the global "indices" array (Internal use)
  109224. */
  109225. _ind: number;
  109226. /**
  109227. * @hidden ModelShape of this particle (Internal use)
  109228. */
  109229. _model: ModelShape;
  109230. /**
  109231. * ModelShape id of this particle
  109232. */
  109233. shapeId: number;
  109234. /**
  109235. * Index of the particle in its shape id
  109236. */
  109237. idxInShape: number;
  109238. /**
  109239. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  109240. */
  109241. _modelBoundingInfo: BoundingInfo;
  109242. /**
  109243. * @hidden Particle BoundingInfo object (Internal use)
  109244. */
  109245. _boundingInfo: BoundingInfo;
  109246. /**
  109247. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  109248. */
  109249. _sps: SolidParticleSystem;
  109250. /**
  109251. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  109252. */
  109253. _stillInvisible: boolean;
  109254. /**
  109255. * @hidden Last computed particle rotation matrix
  109256. */
  109257. _rotationMatrix: number[];
  109258. /**
  109259. * Parent particle Id, if any.
  109260. * Default null.
  109261. */
  109262. parentId: Nullable<number>;
  109263. /**
  109264. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  109265. */
  109266. materialIndex: Nullable<number>;
  109267. /**
  109268. * Custom object or properties.
  109269. */
  109270. props: Nullable<any>;
  109271. /**
  109272. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  109273. * The possible values are :
  109274. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109275. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109276. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109278. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109279. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  109280. * */
  109281. cullingStrategy: number;
  109282. /**
  109283. * @hidden Internal global position in the SPS.
  109284. */
  109285. _globalPosition: Vector3;
  109286. /**
  109287. * Creates a Solid Particle object.
  109288. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  109289. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  109290. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  109291. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  109292. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  109293. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  109294. * @param shapeId (integer) is the model shape identifier in the SPS.
  109295. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  109296. * @param sps defines the sps it is associated to
  109297. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  109298. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  109299. */
  109300. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  109301. /**
  109302. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  109303. * @param target the particle target
  109304. * @returns the current particle
  109305. */
  109306. copyToRef(target: SolidParticle): SolidParticle;
  109307. /**
  109308. * Legacy support, changed scale to scaling
  109309. */
  109310. get scale(): Vector3;
  109311. /**
  109312. * Legacy support, changed scale to scaling
  109313. */
  109314. set scale(scale: Vector3);
  109315. /**
  109316. * Legacy support, changed quaternion to rotationQuaternion
  109317. */
  109318. get quaternion(): Nullable<Quaternion>;
  109319. /**
  109320. * Legacy support, changed quaternion to rotationQuaternion
  109321. */
  109322. set quaternion(q: Nullable<Quaternion>);
  109323. /**
  109324. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109325. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109326. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109327. * @returns true if it intersects
  109328. */
  109329. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109330. /**
  109331. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109332. * A particle is in the frustum if its bounding box intersects the frustum
  109333. * @param frustumPlanes defines the frustum to test
  109334. * @returns true if the particle is in the frustum planes
  109335. */
  109336. isInFrustum(frustumPlanes: Plane[]): boolean;
  109337. /**
  109338. * get the rotation matrix of the particle
  109339. * @hidden
  109340. */
  109341. getRotationMatrix(m: Matrix): void;
  109342. }
  109343. /**
  109344. * Represents the shape of the model used by one particle of a solid particle system.
  109345. * SPS internal tool, don't use it manually.
  109346. */
  109347. export class ModelShape {
  109348. /**
  109349. * The shape id
  109350. * @hidden
  109351. */
  109352. shapeID: number;
  109353. /**
  109354. * flat array of model positions (internal use)
  109355. * @hidden
  109356. */
  109357. _shape: Vector3[];
  109358. /**
  109359. * flat array of model UVs (internal use)
  109360. * @hidden
  109361. */
  109362. _shapeUV: number[];
  109363. /**
  109364. * color array of the model
  109365. * @hidden
  109366. */
  109367. _shapeColors: number[];
  109368. /**
  109369. * indices array of the model
  109370. * @hidden
  109371. */
  109372. _indices: number[];
  109373. /**
  109374. * normals array of the model
  109375. * @hidden
  109376. */
  109377. _normals: number[];
  109378. /**
  109379. * length of the shape in the model indices array (internal use)
  109380. * @hidden
  109381. */
  109382. _indicesLength: number;
  109383. /**
  109384. * Custom position function (internal use)
  109385. * @hidden
  109386. */
  109387. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109388. /**
  109389. * Custom vertex function (internal use)
  109390. * @hidden
  109391. */
  109392. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109393. /**
  109394. * Model material (internal use)
  109395. * @hidden
  109396. */
  109397. _material: Nullable<Material>;
  109398. /**
  109399. * 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.
  109400. * SPS internal tool, don't use it manually.
  109401. * @hidden
  109402. */
  109403. 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>);
  109404. }
  109405. /**
  109406. * Represents a Depth Sorted Particle in the solid particle system.
  109407. * @hidden
  109408. */
  109409. export class DepthSortedParticle {
  109410. /**
  109411. * Particle index
  109412. */
  109413. idx: number;
  109414. /**
  109415. * Index of the particle in the "indices" array
  109416. */
  109417. ind: number;
  109418. /**
  109419. * Length of the particle shape in the "indices" array
  109420. */
  109421. indicesLength: number;
  109422. /**
  109423. * Squared distance from the particle to the camera
  109424. */
  109425. sqDistance: number;
  109426. /**
  109427. * Material index when used with MultiMaterials
  109428. */
  109429. materialIndex: number;
  109430. /**
  109431. * Creates a new sorted particle
  109432. * @param materialIndex
  109433. */
  109434. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109435. }
  109436. /**
  109437. * Represents a solid particle vertex
  109438. */
  109439. export class SolidParticleVertex {
  109440. /**
  109441. * Vertex position
  109442. */
  109443. position: Vector3;
  109444. /**
  109445. * Vertex color
  109446. */
  109447. color: Color4;
  109448. /**
  109449. * Vertex UV
  109450. */
  109451. uv: Vector2;
  109452. /**
  109453. * Creates a new solid particle vertex
  109454. */
  109455. constructor();
  109456. /** Vertex x coordinate */
  109457. get x(): number;
  109458. set x(val: number);
  109459. /** Vertex y coordinate */
  109460. get y(): number;
  109461. set y(val: number);
  109462. /** Vertex z coordinate */
  109463. get z(): number;
  109464. set z(val: number);
  109465. }
  109466. }
  109467. declare module BABYLON {
  109468. /**
  109469. * @hidden
  109470. */
  109471. export class _MeshCollisionData {
  109472. _checkCollisions: boolean;
  109473. _collisionMask: number;
  109474. _collisionGroup: number;
  109475. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109476. _collider: Nullable<Collider>;
  109477. _oldPositionForCollisions: Vector3;
  109478. _diffPositionForCollisions: Vector3;
  109479. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109480. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109481. }
  109482. }
  109483. declare module BABYLON {
  109484. /** @hidden */
  109485. class _FacetDataStorage {
  109486. facetPositions: Vector3[];
  109487. facetNormals: Vector3[];
  109488. facetPartitioning: number[][];
  109489. facetNb: number;
  109490. partitioningSubdivisions: number;
  109491. partitioningBBoxRatio: number;
  109492. facetDataEnabled: boolean;
  109493. facetParameters: any;
  109494. bbSize: Vector3;
  109495. subDiv: {
  109496. max: number;
  109497. X: number;
  109498. Y: number;
  109499. Z: number;
  109500. };
  109501. facetDepthSort: boolean;
  109502. facetDepthSortEnabled: boolean;
  109503. depthSortedIndices: IndicesArray;
  109504. depthSortedFacets: {
  109505. ind: number;
  109506. sqDistance: number;
  109507. }[];
  109508. facetDepthSortFunction: (f1: {
  109509. ind: number;
  109510. sqDistance: number;
  109511. }, f2: {
  109512. ind: number;
  109513. sqDistance: number;
  109514. }) => number;
  109515. facetDepthSortFrom: Vector3;
  109516. facetDepthSortOrigin: Vector3;
  109517. invertedMatrix: Matrix;
  109518. }
  109519. /**
  109520. * @hidden
  109521. **/
  109522. class _InternalAbstractMeshDataInfo {
  109523. _hasVertexAlpha: boolean;
  109524. _useVertexColors: boolean;
  109525. _numBoneInfluencers: number;
  109526. _applyFog: boolean;
  109527. _receiveShadows: boolean;
  109528. _facetData: _FacetDataStorage;
  109529. _visibility: number;
  109530. _skeleton: Nullable<Skeleton>;
  109531. _layerMask: number;
  109532. _computeBonesUsingShaders: boolean;
  109533. _isActive: boolean;
  109534. _onlyForInstances: boolean;
  109535. _isActiveIntermediate: boolean;
  109536. _onlyForInstancesIntermediate: boolean;
  109537. _actAsRegularMesh: boolean;
  109538. }
  109539. /**
  109540. * Class used to store all common mesh properties
  109541. */
  109542. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109543. /** No occlusion */
  109544. static OCCLUSION_TYPE_NONE: number;
  109545. /** Occlusion set to optimisitic */
  109546. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109547. /** Occlusion set to strict */
  109548. static OCCLUSION_TYPE_STRICT: number;
  109549. /** Use an accurante occlusion algorithm */
  109550. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109551. /** Use a conservative occlusion algorithm */
  109552. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109553. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109554. * Test order :
  109555. * Is the bounding sphere outside the frustum ?
  109556. * If not, are the bounding box vertices outside the frustum ?
  109557. * It not, then the cullable object is in the frustum.
  109558. */
  109559. static readonly CULLINGSTRATEGY_STANDARD: number;
  109560. /** Culling strategy : Bounding Sphere Only.
  109561. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109562. * It's also less accurate than the standard because some not visible objects can still be selected.
  109563. * Test : is the bounding sphere outside the frustum ?
  109564. * If not, then the cullable object is in the frustum.
  109565. */
  109566. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109567. /** Culling strategy : Optimistic Inclusion.
  109568. * This in an inclusion test first, then the standard exclusion test.
  109569. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109570. * 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.
  109571. * Anyway, it's as accurate as the standard strategy.
  109572. * Test :
  109573. * Is the cullable object bounding sphere center in the frustum ?
  109574. * If not, apply the default culling strategy.
  109575. */
  109576. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109577. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109578. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109579. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109580. * 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.
  109581. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109582. * Test :
  109583. * Is the cullable object bounding sphere center in the frustum ?
  109584. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109585. */
  109586. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109587. /**
  109588. * No billboard
  109589. */
  109590. static get BILLBOARDMODE_NONE(): number;
  109591. /** Billboard on X axis */
  109592. static get BILLBOARDMODE_X(): number;
  109593. /** Billboard on Y axis */
  109594. static get BILLBOARDMODE_Y(): number;
  109595. /** Billboard on Z axis */
  109596. static get BILLBOARDMODE_Z(): number;
  109597. /** Billboard on all axes */
  109598. static get BILLBOARDMODE_ALL(): number;
  109599. /** Billboard on using position instead of orientation */
  109600. static get BILLBOARDMODE_USE_POSITION(): number;
  109601. /** @hidden */
  109602. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109603. /**
  109604. * The culling strategy to use to check whether the mesh must be rendered or not.
  109605. * This value can be changed at any time and will be used on the next render mesh selection.
  109606. * The possible values are :
  109607. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109608. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109609. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109610. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109611. * Please read each static variable documentation to get details about the culling process.
  109612. * */
  109613. cullingStrategy: number;
  109614. /**
  109615. * Gets the number of facets in the mesh
  109616. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109617. */
  109618. get facetNb(): number;
  109619. /**
  109620. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109622. */
  109623. get partitioningSubdivisions(): number;
  109624. set partitioningSubdivisions(nb: number);
  109625. /**
  109626. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109627. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109628. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109629. */
  109630. get partitioningBBoxRatio(): number;
  109631. set partitioningBBoxRatio(ratio: number);
  109632. /**
  109633. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109634. * Works only for updatable meshes.
  109635. * Doesn't work with multi-materials
  109636. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109637. */
  109638. get mustDepthSortFacets(): boolean;
  109639. set mustDepthSortFacets(sort: boolean);
  109640. /**
  109641. * The location (Vector3) where the facet depth sort must be computed from.
  109642. * By default, the active camera position.
  109643. * Used only when facet depth sort is enabled
  109644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109645. */
  109646. get facetDepthSortFrom(): Vector3;
  109647. set facetDepthSortFrom(location: Vector3);
  109648. /**
  109649. * gets a boolean indicating if facetData is enabled
  109650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109651. */
  109652. get isFacetDataEnabled(): boolean;
  109653. /** @hidden */
  109654. _updateNonUniformScalingState(value: boolean): boolean;
  109655. /**
  109656. * An event triggered when this mesh collides with another one
  109657. */
  109658. onCollideObservable: Observable<AbstractMesh>;
  109659. /** Set a function to call when this mesh collides with another one */
  109660. set onCollide(callback: () => void);
  109661. /**
  109662. * An event triggered when the collision's position changes
  109663. */
  109664. onCollisionPositionChangeObservable: Observable<Vector3>;
  109665. /** Set a function to call when the collision's position changes */
  109666. set onCollisionPositionChange(callback: () => void);
  109667. /**
  109668. * An event triggered when material is changed
  109669. */
  109670. onMaterialChangedObservable: Observable<AbstractMesh>;
  109671. /**
  109672. * Gets or sets the orientation for POV movement & rotation
  109673. */
  109674. definedFacingForward: boolean;
  109675. /** @hidden */
  109676. _occlusionQuery: Nullable<WebGLQuery>;
  109677. /** @hidden */
  109678. _renderingGroup: Nullable<RenderingGroup>;
  109679. /**
  109680. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109681. */
  109682. get visibility(): number;
  109683. /**
  109684. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109685. */
  109686. set visibility(value: number);
  109687. /** Gets or sets the alpha index used to sort transparent meshes
  109688. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109689. */
  109690. alphaIndex: number;
  109691. /**
  109692. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109693. */
  109694. isVisible: boolean;
  109695. /**
  109696. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109697. */
  109698. isPickable: boolean;
  109699. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109700. showSubMeshesBoundingBox: boolean;
  109701. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109702. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109703. */
  109704. isBlocker: boolean;
  109705. /**
  109706. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109707. */
  109708. enablePointerMoveEvents: boolean;
  109709. /**
  109710. * Specifies the rendering group id for this mesh (0 by default)
  109711. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109712. */
  109713. renderingGroupId: number;
  109714. private _material;
  109715. /** Gets or sets current material */
  109716. get material(): Nullable<Material>;
  109717. set material(value: Nullable<Material>);
  109718. /**
  109719. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109720. * @see https://doc.babylonjs.com/babylon101/shadows
  109721. */
  109722. get receiveShadows(): boolean;
  109723. set receiveShadows(value: boolean);
  109724. /** Defines color to use when rendering outline */
  109725. outlineColor: Color3;
  109726. /** Define width to use when rendering outline */
  109727. outlineWidth: number;
  109728. /** Defines color to use when rendering overlay */
  109729. overlayColor: Color3;
  109730. /** Defines alpha to use when rendering overlay */
  109731. overlayAlpha: number;
  109732. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109733. get hasVertexAlpha(): boolean;
  109734. set hasVertexAlpha(value: boolean);
  109735. /** 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) */
  109736. get useVertexColors(): boolean;
  109737. set useVertexColors(value: boolean);
  109738. /**
  109739. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109740. */
  109741. get computeBonesUsingShaders(): boolean;
  109742. set computeBonesUsingShaders(value: boolean);
  109743. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109744. get numBoneInfluencers(): number;
  109745. set numBoneInfluencers(value: number);
  109746. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109747. get applyFog(): boolean;
  109748. set applyFog(value: boolean);
  109749. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109750. useOctreeForRenderingSelection: boolean;
  109751. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109752. useOctreeForPicking: boolean;
  109753. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109754. useOctreeForCollisions: boolean;
  109755. /**
  109756. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109757. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109758. */
  109759. get layerMask(): number;
  109760. set layerMask(value: number);
  109761. /**
  109762. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109763. */
  109764. alwaysSelectAsActiveMesh: boolean;
  109765. /**
  109766. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109767. */
  109768. doNotSyncBoundingInfo: boolean;
  109769. /**
  109770. * Gets or sets the current action manager
  109771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109772. */
  109773. actionManager: Nullable<AbstractActionManager>;
  109774. private _meshCollisionData;
  109775. /**
  109776. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109777. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109778. */
  109779. ellipsoid: Vector3;
  109780. /**
  109781. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109782. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109783. */
  109784. ellipsoidOffset: Vector3;
  109785. /**
  109786. * Gets or sets a collision mask used to mask collisions (default is -1).
  109787. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109788. */
  109789. get collisionMask(): number;
  109790. set collisionMask(mask: number);
  109791. /**
  109792. * Gets or sets the current collision group mask (-1 by default).
  109793. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109794. */
  109795. get collisionGroup(): number;
  109796. set collisionGroup(mask: number);
  109797. /**
  109798. * Gets or sets current surrounding meshes (null by default).
  109799. *
  109800. * By default collision detection is tested against every mesh in the scene.
  109801. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109802. * meshes will be tested for the collision.
  109803. *
  109804. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109805. */
  109806. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109807. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109808. /**
  109809. * Defines edge width used when edgesRenderer is enabled
  109810. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109811. */
  109812. edgesWidth: number;
  109813. /**
  109814. * Defines edge color used when edgesRenderer is enabled
  109815. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109816. */
  109817. edgesColor: Color4;
  109818. /** @hidden */
  109819. _edgesRenderer: Nullable<IEdgesRenderer>;
  109820. /** @hidden */
  109821. _masterMesh: Nullable<AbstractMesh>;
  109822. /** @hidden */
  109823. _boundingInfo: Nullable<BoundingInfo>;
  109824. /** @hidden */
  109825. _renderId: number;
  109826. /**
  109827. * Gets or sets the list of subMeshes
  109828. * @see https://doc.babylonjs.com/how_to/multi_materials
  109829. */
  109830. subMeshes: SubMesh[];
  109831. /** @hidden */
  109832. _intersectionsInProgress: AbstractMesh[];
  109833. /** @hidden */
  109834. _unIndexed: boolean;
  109835. /** @hidden */
  109836. _lightSources: Light[];
  109837. /** Gets the list of lights affecting that mesh */
  109838. get lightSources(): Light[];
  109839. /** @hidden */
  109840. get _positions(): Nullable<Vector3[]>;
  109841. /** @hidden */
  109842. _waitingData: {
  109843. lods: Nullable<any>;
  109844. actions: Nullable<any>;
  109845. freezeWorldMatrix: Nullable<boolean>;
  109846. };
  109847. /** @hidden */
  109848. _bonesTransformMatrices: Nullable<Float32Array>;
  109849. /** @hidden */
  109850. _transformMatrixTexture: Nullable<RawTexture>;
  109851. /**
  109852. * Gets or sets a skeleton to apply skining transformations
  109853. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109854. */
  109855. set skeleton(value: Nullable<Skeleton>);
  109856. get skeleton(): Nullable<Skeleton>;
  109857. /**
  109858. * An event triggered when the mesh is rebuilt.
  109859. */
  109860. onRebuildObservable: Observable<AbstractMesh>;
  109861. /**
  109862. * Creates a new AbstractMesh
  109863. * @param name defines the name of the mesh
  109864. * @param scene defines the hosting scene
  109865. */
  109866. constructor(name: string, scene?: Nullable<Scene>);
  109867. /**
  109868. * Returns the string "AbstractMesh"
  109869. * @returns "AbstractMesh"
  109870. */
  109871. getClassName(): string;
  109872. /**
  109873. * Gets a string representation of the current mesh
  109874. * @param fullDetails defines a boolean indicating if full details must be included
  109875. * @returns a string representation of the current mesh
  109876. */
  109877. toString(fullDetails?: boolean): string;
  109878. /**
  109879. * @hidden
  109880. */
  109881. protected _getEffectiveParent(): Nullable<Node>;
  109882. /** @hidden */
  109883. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109884. /** @hidden */
  109885. _rebuild(): void;
  109886. /** @hidden */
  109887. _resyncLightSources(): void;
  109888. /** @hidden */
  109889. _resyncLightSource(light: Light): void;
  109890. /** @hidden */
  109891. _unBindEffect(): void;
  109892. /** @hidden */
  109893. _removeLightSource(light: Light, dispose: boolean): void;
  109894. private _markSubMeshesAsDirty;
  109895. /** @hidden */
  109896. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109897. /** @hidden */
  109898. _markSubMeshesAsAttributesDirty(): void;
  109899. /** @hidden */
  109900. _markSubMeshesAsMiscDirty(): void;
  109901. /**
  109902. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109903. */
  109904. get scaling(): Vector3;
  109905. set scaling(newScaling: Vector3);
  109906. /**
  109907. * Returns true if the mesh is blocked. Implemented by child classes
  109908. */
  109909. get isBlocked(): boolean;
  109910. /**
  109911. * Returns the mesh itself by default. Implemented by child classes
  109912. * @param camera defines the camera to use to pick the right LOD level
  109913. * @returns the currentAbstractMesh
  109914. */
  109915. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109916. /**
  109917. * Returns 0 by default. Implemented by child classes
  109918. * @returns an integer
  109919. */
  109920. getTotalVertices(): number;
  109921. /**
  109922. * Returns a positive integer : the total number of indices in this mesh geometry.
  109923. * @returns the numner of indices or zero if the mesh has no geometry.
  109924. */
  109925. getTotalIndices(): number;
  109926. /**
  109927. * Returns null by default. Implemented by child classes
  109928. * @returns null
  109929. */
  109930. getIndices(): Nullable<IndicesArray>;
  109931. /**
  109932. * Returns the array of the requested vertex data kind. Implemented by child classes
  109933. * @param kind defines the vertex data kind to use
  109934. * @returns null
  109935. */
  109936. getVerticesData(kind: string): Nullable<FloatArray>;
  109937. /**
  109938. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109939. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109940. * Note that a new underlying VertexBuffer object is created each call.
  109941. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109942. * @param kind defines vertex data kind:
  109943. * * VertexBuffer.PositionKind
  109944. * * VertexBuffer.UVKind
  109945. * * VertexBuffer.UV2Kind
  109946. * * VertexBuffer.UV3Kind
  109947. * * VertexBuffer.UV4Kind
  109948. * * VertexBuffer.UV5Kind
  109949. * * VertexBuffer.UV6Kind
  109950. * * VertexBuffer.ColorKind
  109951. * * VertexBuffer.MatricesIndicesKind
  109952. * * VertexBuffer.MatricesIndicesExtraKind
  109953. * * VertexBuffer.MatricesWeightsKind
  109954. * * VertexBuffer.MatricesWeightsExtraKind
  109955. * @param data defines the data source
  109956. * @param updatable defines if the data must be flagged as updatable (or static)
  109957. * @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
  109958. * @returns the current mesh
  109959. */
  109960. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109961. /**
  109962. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109963. * If the mesh has no geometry, it is simply returned as it is.
  109964. * @param kind defines vertex data kind:
  109965. * * VertexBuffer.PositionKind
  109966. * * VertexBuffer.UVKind
  109967. * * VertexBuffer.UV2Kind
  109968. * * VertexBuffer.UV3Kind
  109969. * * VertexBuffer.UV4Kind
  109970. * * VertexBuffer.UV5Kind
  109971. * * VertexBuffer.UV6Kind
  109972. * * VertexBuffer.ColorKind
  109973. * * VertexBuffer.MatricesIndicesKind
  109974. * * VertexBuffer.MatricesIndicesExtraKind
  109975. * * VertexBuffer.MatricesWeightsKind
  109976. * * VertexBuffer.MatricesWeightsExtraKind
  109977. * @param data defines the data source
  109978. * @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
  109979. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109980. * @returns the current mesh
  109981. */
  109982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109983. /**
  109984. * Sets the mesh indices,
  109985. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109986. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109987. * @param totalVertices Defines the total number of vertices
  109988. * @returns the current mesh
  109989. */
  109990. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109991. /**
  109992. * Gets a boolean indicating if specific vertex data is present
  109993. * @param kind defines the vertex data kind to use
  109994. * @returns true is data kind is present
  109995. */
  109996. isVerticesDataPresent(kind: string): boolean;
  109997. /**
  109998. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109999. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  110000. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  110001. * @returns a BoundingInfo
  110002. */
  110003. getBoundingInfo(): BoundingInfo;
  110004. /**
  110005. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  110006. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  110007. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  110008. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  110009. * @returns the current mesh
  110010. */
  110011. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  110012. /**
  110013. * Overwrite the current bounding info
  110014. * @param boundingInfo defines the new bounding info
  110015. * @returns the current mesh
  110016. */
  110017. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  110018. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  110019. get useBones(): boolean;
  110020. /** @hidden */
  110021. _preActivate(): void;
  110022. /** @hidden */
  110023. _preActivateForIntermediateRendering(renderId: number): void;
  110024. /** @hidden */
  110025. _activate(renderId: number, intermediateRendering: boolean): boolean;
  110026. /** @hidden */
  110027. _postActivate(): void;
  110028. /** @hidden */
  110029. _freeze(): void;
  110030. /** @hidden */
  110031. _unFreeze(): void;
  110032. /**
  110033. * Gets the current world matrix
  110034. * @returns a Matrix
  110035. */
  110036. getWorldMatrix(): Matrix;
  110037. /** @hidden */
  110038. _getWorldMatrixDeterminant(): number;
  110039. /**
  110040. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  110041. */
  110042. get isAnInstance(): boolean;
  110043. /**
  110044. * Gets a boolean indicating if this mesh has instances
  110045. */
  110046. get hasInstances(): boolean;
  110047. /**
  110048. * Gets a boolean indicating if this mesh has thin instances
  110049. */
  110050. get hasThinInstances(): boolean;
  110051. /**
  110052. * Perform relative position change from the point of view of behind the front of the mesh.
  110053. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110054. * Supports definition of mesh facing forward or backward
  110055. * @param amountRight defines the distance on the right axis
  110056. * @param amountUp defines the distance on the up axis
  110057. * @param amountForward defines the distance on the forward axis
  110058. * @returns the current mesh
  110059. */
  110060. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  110061. /**
  110062. * Calculate relative position change from the point of view of behind the front of the mesh.
  110063. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110064. * Supports definition of mesh facing forward or backward
  110065. * @param amountRight defines the distance on the right axis
  110066. * @param amountUp defines the distance on the up axis
  110067. * @param amountForward defines the distance on the forward axis
  110068. * @returns the new displacement vector
  110069. */
  110070. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  110071. /**
  110072. * Perform relative rotation change from the point of view of behind the front of the mesh.
  110073. * Supports definition of mesh facing forward or backward
  110074. * @param flipBack defines the flip
  110075. * @param twirlClockwise defines the twirl
  110076. * @param tiltRight defines the tilt
  110077. * @returns the current mesh
  110078. */
  110079. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  110080. /**
  110081. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  110082. * Supports definition of mesh facing forward or backward.
  110083. * @param flipBack defines the flip
  110084. * @param twirlClockwise defines the twirl
  110085. * @param tiltRight defines the tilt
  110086. * @returns the new rotation vector
  110087. */
  110088. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  110089. /**
  110090. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  110091. * This means the mesh underlying bounding box and sphere are recomputed.
  110092. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  110093. * @returns the current mesh
  110094. */
  110095. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  110096. /** @hidden */
  110097. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  110098. /** @hidden */
  110099. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  110100. /** @hidden */
  110101. _updateBoundingInfo(): AbstractMesh;
  110102. /** @hidden */
  110103. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  110104. /** @hidden */
  110105. protected _afterComputeWorldMatrix(): void;
  110106. /** @hidden */
  110107. get _effectiveMesh(): AbstractMesh;
  110108. /**
  110109. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  110110. * A mesh is in the frustum if its bounding box intersects the frustum
  110111. * @param frustumPlanes defines the frustum to test
  110112. * @returns true if the mesh is in the frustum planes
  110113. */
  110114. isInFrustum(frustumPlanes: Plane[]): boolean;
  110115. /**
  110116. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  110117. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  110118. * @param frustumPlanes defines the frustum to test
  110119. * @returns true if the mesh is completely in the frustum planes
  110120. */
  110121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110122. /**
  110123. * True if the mesh intersects another mesh or a SolidParticle object
  110124. * @param mesh defines a target mesh or SolidParticle to test
  110125. * @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)
  110126. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  110127. * @returns true if there is an intersection
  110128. */
  110129. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  110130. /**
  110131. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  110132. * @param point defines the point to test
  110133. * @returns true if there is an intersection
  110134. */
  110135. intersectsPoint(point: Vector3): boolean;
  110136. /**
  110137. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  110138. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110139. */
  110140. get checkCollisions(): boolean;
  110141. set checkCollisions(collisionEnabled: boolean);
  110142. /**
  110143. * Gets Collider object used to compute collisions (not physics)
  110144. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110145. */
  110146. get collider(): Nullable<Collider>;
  110147. /**
  110148. * Move the mesh using collision engine
  110149. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110150. * @param displacement defines the requested displacement vector
  110151. * @returns the current mesh
  110152. */
  110153. moveWithCollisions(displacement: Vector3): AbstractMesh;
  110154. private _onCollisionPositionChange;
  110155. /** @hidden */
  110156. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  110157. /** @hidden */
  110158. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  110159. /** @hidden */
  110160. _checkCollision(collider: Collider): AbstractMesh;
  110161. /** @hidden */
  110162. _generatePointsArray(): boolean;
  110163. /**
  110164. * Checks if the passed Ray intersects with the mesh
  110165. * @param ray defines the ray to use
  110166. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  110167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110168. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  110169. * @returns the picking info
  110170. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  110171. */
  110172. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  110173. /**
  110174. * Clones the current mesh
  110175. * @param name defines the mesh name
  110176. * @param newParent defines the new mesh parent
  110177. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  110178. * @returns the new mesh
  110179. */
  110180. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  110181. /**
  110182. * Disposes all the submeshes of the current meshnp
  110183. * @returns the current mesh
  110184. */
  110185. releaseSubMeshes(): AbstractMesh;
  110186. /**
  110187. * Releases resources associated with this abstract mesh.
  110188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110190. */
  110191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110192. /**
  110193. * Adds the passed mesh as a child to the current mesh
  110194. * @param mesh defines the child mesh
  110195. * @returns the current mesh
  110196. */
  110197. addChild(mesh: AbstractMesh): AbstractMesh;
  110198. /**
  110199. * Removes the passed mesh from the current mesh children list
  110200. * @param mesh defines the child mesh
  110201. * @returns the current mesh
  110202. */
  110203. removeChild(mesh: AbstractMesh): AbstractMesh;
  110204. /** @hidden */
  110205. private _initFacetData;
  110206. /**
  110207. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  110208. * This method can be called within the render loop.
  110209. * 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
  110210. * @returns the current mesh
  110211. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110212. */
  110213. updateFacetData(): AbstractMesh;
  110214. /**
  110215. * Returns the facetLocalNormals array.
  110216. * The normals are expressed in the mesh local spac
  110217. * @returns an array of Vector3
  110218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110219. */
  110220. getFacetLocalNormals(): Vector3[];
  110221. /**
  110222. * Returns the facetLocalPositions array.
  110223. * The facet positions are expressed in the mesh local space
  110224. * @returns an array of Vector3
  110225. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110226. */
  110227. getFacetLocalPositions(): Vector3[];
  110228. /**
  110229. * Returns the facetLocalPartioning array
  110230. * @returns an array of array of numbers
  110231. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110232. */
  110233. getFacetLocalPartitioning(): number[][];
  110234. /**
  110235. * Returns the i-th facet position in the world system.
  110236. * This method allocates a new Vector3 per call
  110237. * @param i defines the facet index
  110238. * @returns a new Vector3
  110239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110240. */
  110241. getFacetPosition(i: number): Vector3;
  110242. /**
  110243. * Sets the reference Vector3 with the i-th facet position in the world system
  110244. * @param i defines the facet index
  110245. * @param ref defines the target vector
  110246. * @returns the current mesh
  110247. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110248. */
  110249. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  110250. /**
  110251. * Returns the i-th facet normal in the world system.
  110252. * This method allocates a new Vector3 per call
  110253. * @param i defines the facet index
  110254. * @returns a new Vector3
  110255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110256. */
  110257. getFacetNormal(i: number): Vector3;
  110258. /**
  110259. * Sets the reference Vector3 with the i-th facet normal in the world system
  110260. * @param i defines the facet index
  110261. * @param ref defines the target vector
  110262. * @returns the current mesh
  110263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110264. */
  110265. getFacetNormalToRef(i: number, ref: Vector3): this;
  110266. /**
  110267. * 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)
  110268. * @param x defines x coordinate
  110269. * @param y defines y coordinate
  110270. * @param z defines z coordinate
  110271. * @returns the array of facet indexes
  110272. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110273. */
  110274. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  110275. /**
  110276. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  110277. * @param projected sets as the (x,y,z) world projection on the facet
  110278. * @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
  110279. * @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
  110280. * @param x defines x coordinate
  110281. * @param y defines y coordinate
  110282. * @param z defines z coordinate
  110283. * @returns the face index if found (or null instead)
  110284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110285. */
  110286. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  110287. /**
  110288. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  110289. * @param projected sets as the (x,y,z) local projection on the facet
  110290. * @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
  110291. * @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
  110292. * @param x defines x coordinate
  110293. * @param y defines y coordinate
  110294. * @param z defines z coordinate
  110295. * @returns the face index if found (or null instead)
  110296. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110297. */
  110298. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  110299. /**
  110300. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  110301. * @returns the parameters
  110302. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110303. */
  110304. getFacetDataParameters(): any;
  110305. /**
  110306. * Disables the feature FacetData and frees the related memory
  110307. * @returns the current mesh
  110308. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110309. */
  110310. disableFacetData(): AbstractMesh;
  110311. /**
  110312. * Updates the AbstractMesh indices array
  110313. * @param indices defines the data source
  110314. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110315. * @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)
  110316. * @returns the current mesh
  110317. */
  110318. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110319. /**
  110320. * Creates new normals data for the mesh
  110321. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110322. * @returns the current mesh
  110323. */
  110324. createNormals(updatable: boolean): AbstractMesh;
  110325. /**
  110326. * Align the mesh with a normal
  110327. * @param normal defines the normal to use
  110328. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110329. * @returns the current mesh
  110330. */
  110331. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110332. /** @hidden */
  110333. _checkOcclusionQuery(): boolean;
  110334. /**
  110335. * Disables the mesh edge rendering mode
  110336. * @returns the currentAbstractMesh
  110337. */
  110338. disableEdgesRendering(): AbstractMesh;
  110339. /**
  110340. * Enables the edge rendering mode on the mesh.
  110341. * This mode makes the mesh edges visible
  110342. * @param epsilon defines the maximal distance between two angles to detect a face
  110343. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110344. * @returns the currentAbstractMesh
  110345. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110346. */
  110347. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110348. /**
  110349. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110350. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110351. */
  110352. getConnectedParticleSystems(): IParticleSystem[];
  110353. }
  110354. }
  110355. declare module BABYLON {
  110356. /**
  110357. * Interface used to define ActionEvent
  110358. */
  110359. export interface IActionEvent {
  110360. /** The mesh or sprite that triggered the action */
  110361. source: any;
  110362. /** The X mouse cursor position at the time of the event */
  110363. pointerX: number;
  110364. /** The Y mouse cursor position at the time of the event */
  110365. pointerY: number;
  110366. /** The mesh that is currently pointed at (can be null) */
  110367. meshUnderPointer: Nullable<AbstractMesh>;
  110368. /** the original (browser) event that triggered the ActionEvent */
  110369. sourceEvent?: any;
  110370. /** additional data for the event */
  110371. additionalData?: any;
  110372. }
  110373. /**
  110374. * ActionEvent is the event being sent when an action is triggered.
  110375. */
  110376. export class ActionEvent implements IActionEvent {
  110377. /** The mesh or sprite that triggered the action */
  110378. source: any;
  110379. /** The X mouse cursor position at the time of the event */
  110380. pointerX: number;
  110381. /** The Y mouse cursor position at the time of the event */
  110382. pointerY: number;
  110383. /** The mesh that is currently pointed at (can be null) */
  110384. meshUnderPointer: Nullable<AbstractMesh>;
  110385. /** the original (browser) event that triggered the ActionEvent */
  110386. sourceEvent?: any;
  110387. /** additional data for the event */
  110388. additionalData?: any;
  110389. /**
  110390. * Creates a new ActionEvent
  110391. * @param source The mesh or sprite that triggered the action
  110392. * @param pointerX The X mouse cursor position at the time of the event
  110393. * @param pointerY The Y mouse cursor position at the time of the event
  110394. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110395. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110396. * @param additionalData additional data for the event
  110397. */
  110398. constructor(
  110399. /** The mesh or sprite that triggered the action */
  110400. source: any,
  110401. /** The X mouse cursor position at the time of the event */
  110402. pointerX: number,
  110403. /** The Y mouse cursor position at the time of the event */
  110404. pointerY: number,
  110405. /** The mesh that is currently pointed at (can be null) */
  110406. meshUnderPointer: Nullable<AbstractMesh>,
  110407. /** the original (browser) event that triggered the ActionEvent */
  110408. sourceEvent?: any,
  110409. /** additional data for the event */
  110410. additionalData?: any);
  110411. /**
  110412. * Helper function to auto-create an ActionEvent from a source mesh.
  110413. * @param source The source mesh that triggered the event
  110414. * @param evt The original (browser) event
  110415. * @param additionalData additional data for the event
  110416. * @returns the new ActionEvent
  110417. */
  110418. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110419. /**
  110420. * Helper function to auto-create an ActionEvent from a source sprite
  110421. * @param source The source sprite that triggered the event
  110422. * @param scene Scene associated with the sprite
  110423. * @param evt The original (browser) event
  110424. * @param additionalData additional data for the event
  110425. * @returns the new ActionEvent
  110426. */
  110427. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110428. /**
  110429. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110430. * @param scene the scene where the event occurred
  110431. * @param evt The original (browser) event
  110432. * @returns the new ActionEvent
  110433. */
  110434. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110435. /**
  110436. * Helper function to auto-create an ActionEvent from a primitive
  110437. * @param prim defines the target primitive
  110438. * @param pointerPos defines the pointer position
  110439. * @param evt The original (browser) event
  110440. * @param additionalData additional data for the event
  110441. * @returns the new ActionEvent
  110442. */
  110443. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110444. }
  110445. }
  110446. declare module BABYLON {
  110447. /**
  110448. * Abstract class used to decouple action Manager from scene and meshes.
  110449. * Do not instantiate.
  110450. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110451. */
  110452. export abstract class AbstractActionManager implements IDisposable {
  110453. /** Gets the list of active triggers */
  110454. static Triggers: {
  110455. [key: string]: number;
  110456. };
  110457. /** Gets the cursor to use when hovering items */
  110458. hoverCursor: string;
  110459. /** Gets the list of actions */
  110460. actions: IAction[];
  110461. /**
  110462. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110463. */
  110464. isRecursive: boolean;
  110465. /**
  110466. * Releases all associated resources
  110467. */
  110468. abstract dispose(): void;
  110469. /**
  110470. * Does this action manager has pointer triggers
  110471. */
  110472. abstract get hasPointerTriggers(): boolean;
  110473. /**
  110474. * Does this action manager has pick triggers
  110475. */
  110476. abstract get hasPickTriggers(): boolean;
  110477. /**
  110478. * Process a specific trigger
  110479. * @param trigger defines the trigger to process
  110480. * @param evt defines the event details to be processed
  110481. */
  110482. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110483. /**
  110484. * Does this action manager handles actions of any of the given triggers
  110485. * @param triggers defines the triggers to be tested
  110486. * @return a boolean indicating whether one (or more) of the triggers is handled
  110487. */
  110488. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110489. /**
  110490. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110491. * speed.
  110492. * @param triggerA defines the trigger to be tested
  110493. * @param triggerB defines the trigger to be tested
  110494. * @return a boolean indicating whether one (or more) of the triggers is handled
  110495. */
  110496. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110497. /**
  110498. * Does this action manager handles actions of a given trigger
  110499. * @param trigger defines the trigger to be tested
  110500. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110501. * @return whether the trigger is handled
  110502. */
  110503. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110504. /**
  110505. * Serialize this manager to a JSON object
  110506. * @param name defines the property name to store this manager
  110507. * @returns a JSON representation of this manager
  110508. */
  110509. abstract serialize(name: string): any;
  110510. /**
  110511. * Registers an action to this action manager
  110512. * @param action defines the action to be registered
  110513. * @return the action amended (prepared) after registration
  110514. */
  110515. abstract registerAction(action: IAction): Nullable<IAction>;
  110516. /**
  110517. * Unregisters an action to this action manager
  110518. * @param action defines the action to be unregistered
  110519. * @return a boolean indicating whether the action has been unregistered
  110520. */
  110521. abstract unregisterAction(action: IAction): Boolean;
  110522. /**
  110523. * Does exist one action manager with at least one trigger
  110524. **/
  110525. static get HasTriggers(): boolean;
  110526. /**
  110527. * Does exist one action manager with at least one pick trigger
  110528. **/
  110529. static get HasPickTriggers(): boolean;
  110530. /**
  110531. * Does exist one action manager that handles actions of a given trigger
  110532. * @param trigger defines the trigger to be tested
  110533. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110534. **/
  110535. static HasSpecificTrigger(trigger: number): boolean;
  110536. }
  110537. }
  110538. declare module BABYLON {
  110539. /**
  110540. * Defines how a node can be built from a string name.
  110541. */
  110542. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110543. /**
  110544. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110545. */
  110546. export class Node implements IBehaviorAware<Node> {
  110547. /** @hidden */
  110548. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110549. private static _NodeConstructors;
  110550. /**
  110551. * Add a new node constructor
  110552. * @param type defines the type name of the node to construct
  110553. * @param constructorFunc defines the constructor function
  110554. */
  110555. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110556. /**
  110557. * Returns a node constructor based on type name
  110558. * @param type defines the type name
  110559. * @param name defines the new node name
  110560. * @param scene defines the hosting scene
  110561. * @param options defines optional options to transmit to constructors
  110562. * @returns the new constructor or null
  110563. */
  110564. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110565. /**
  110566. * Gets or sets the name of the node
  110567. */
  110568. name: string;
  110569. /**
  110570. * Gets or sets the id of the node
  110571. */
  110572. id: string;
  110573. /**
  110574. * Gets or sets the unique id of the node
  110575. */
  110576. uniqueId: number;
  110577. /**
  110578. * Gets or sets a string used to store user defined state for the node
  110579. */
  110580. state: string;
  110581. /**
  110582. * Gets or sets an object used to store user defined information for the node
  110583. */
  110584. metadata: any;
  110585. /**
  110586. * For internal use only. Please do not use.
  110587. */
  110588. reservedDataStore: any;
  110589. /**
  110590. * List of inspectable custom properties (used by the Inspector)
  110591. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110592. */
  110593. inspectableCustomProperties: IInspectable[];
  110594. private _doNotSerialize;
  110595. /**
  110596. * Gets or sets a boolean used to define if the node must be serialized
  110597. */
  110598. get doNotSerialize(): boolean;
  110599. set doNotSerialize(value: boolean);
  110600. /** @hidden */
  110601. _isDisposed: boolean;
  110602. /**
  110603. * Gets a list of Animations associated with the node
  110604. */
  110605. animations: Animation[];
  110606. protected _ranges: {
  110607. [name: string]: Nullable<AnimationRange>;
  110608. };
  110609. /**
  110610. * Callback raised when the node is ready to be used
  110611. */
  110612. onReady: Nullable<(node: Node) => void>;
  110613. private _isEnabled;
  110614. private _isParentEnabled;
  110615. private _isReady;
  110616. /** @hidden */
  110617. _currentRenderId: number;
  110618. private _parentUpdateId;
  110619. /** @hidden */
  110620. _childUpdateId: number;
  110621. /** @hidden */
  110622. _waitingParentId: Nullable<string>;
  110623. /** @hidden */
  110624. _scene: Scene;
  110625. /** @hidden */
  110626. _cache: any;
  110627. private _parentNode;
  110628. private _children;
  110629. /** @hidden */
  110630. _worldMatrix: Matrix;
  110631. /** @hidden */
  110632. _worldMatrixDeterminant: number;
  110633. /** @hidden */
  110634. _worldMatrixDeterminantIsDirty: boolean;
  110635. /** @hidden */
  110636. private _sceneRootNodesIndex;
  110637. /**
  110638. * Gets a boolean indicating if the node has been disposed
  110639. * @returns true if the node was disposed
  110640. */
  110641. isDisposed(): boolean;
  110642. /**
  110643. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110644. * @see https://doc.babylonjs.com/how_to/parenting
  110645. */
  110646. set parent(parent: Nullable<Node>);
  110647. get parent(): Nullable<Node>;
  110648. /** @hidden */
  110649. _addToSceneRootNodes(): void;
  110650. /** @hidden */
  110651. _removeFromSceneRootNodes(): void;
  110652. private _animationPropertiesOverride;
  110653. /**
  110654. * Gets or sets the animation properties override
  110655. */
  110656. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110657. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110658. /**
  110659. * Gets a string idenfifying the name of the class
  110660. * @returns "Node" string
  110661. */
  110662. getClassName(): string;
  110663. /** @hidden */
  110664. readonly _isNode: boolean;
  110665. /**
  110666. * An event triggered when the mesh is disposed
  110667. */
  110668. onDisposeObservable: Observable<Node>;
  110669. private _onDisposeObserver;
  110670. /**
  110671. * Sets a callback that will be raised when the node will be disposed
  110672. */
  110673. set onDispose(callback: () => void);
  110674. /**
  110675. * Creates a new Node
  110676. * @param name the name and id to be given to this node
  110677. * @param scene the scene this node will be added to
  110678. */
  110679. constructor(name: string, scene?: Nullable<Scene>);
  110680. /**
  110681. * Gets the scene of the node
  110682. * @returns a scene
  110683. */
  110684. getScene(): Scene;
  110685. /**
  110686. * Gets the engine of the node
  110687. * @returns a Engine
  110688. */
  110689. getEngine(): Engine;
  110690. private _behaviors;
  110691. /**
  110692. * Attach a behavior to the node
  110693. * @see https://doc.babylonjs.com/features/behaviour
  110694. * @param behavior defines the behavior to attach
  110695. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110696. * @returns the current Node
  110697. */
  110698. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110699. /**
  110700. * Remove an attached behavior
  110701. * @see https://doc.babylonjs.com/features/behaviour
  110702. * @param behavior defines the behavior to attach
  110703. * @returns the current Node
  110704. */
  110705. removeBehavior(behavior: Behavior<Node>): Node;
  110706. /**
  110707. * Gets the list of attached behaviors
  110708. * @see https://doc.babylonjs.com/features/behaviour
  110709. */
  110710. get behaviors(): Behavior<Node>[];
  110711. /**
  110712. * Gets an attached behavior by name
  110713. * @param name defines the name of the behavior to look for
  110714. * @see https://doc.babylonjs.com/features/behaviour
  110715. * @returns null if behavior was not found else the requested behavior
  110716. */
  110717. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110718. /**
  110719. * Returns the latest update of the World matrix
  110720. * @returns a Matrix
  110721. */
  110722. getWorldMatrix(): Matrix;
  110723. /** @hidden */
  110724. _getWorldMatrixDeterminant(): number;
  110725. /**
  110726. * Returns directly the latest state of the mesh World matrix.
  110727. * A Matrix is returned.
  110728. */
  110729. get worldMatrixFromCache(): Matrix;
  110730. /** @hidden */
  110731. _initCache(): void;
  110732. /** @hidden */
  110733. updateCache(force?: boolean): void;
  110734. /** @hidden */
  110735. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110736. /** @hidden */
  110737. _updateCache(ignoreParentClass?: boolean): void;
  110738. /** @hidden */
  110739. _isSynchronized(): boolean;
  110740. /** @hidden */
  110741. _markSyncedWithParent(): void;
  110742. /** @hidden */
  110743. isSynchronizedWithParent(): boolean;
  110744. /** @hidden */
  110745. isSynchronized(): boolean;
  110746. /**
  110747. * Is this node ready to be used/rendered
  110748. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110749. * @return true if the node is ready
  110750. */
  110751. isReady(completeCheck?: boolean): boolean;
  110752. /**
  110753. * Is this node enabled?
  110754. * 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
  110755. * @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
  110756. * @return whether this node (and its parent) is enabled
  110757. */
  110758. isEnabled(checkAncestors?: boolean): boolean;
  110759. /** @hidden */
  110760. protected _syncParentEnabledState(): void;
  110761. /**
  110762. * Set the enabled state of this node
  110763. * @param value defines the new enabled state
  110764. */
  110765. setEnabled(value: boolean): void;
  110766. /**
  110767. * Is this node a descendant of the given node?
  110768. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110769. * @param ancestor defines the parent node to inspect
  110770. * @returns a boolean indicating if this node is a descendant of the given node
  110771. */
  110772. isDescendantOf(ancestor: Node): boolean;
  110773. /** @hidden */
  110774. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110775. /**
  110776. * Will return all nodes that have this node as ascendant
  110777. * @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
  110778. * @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
  110779. * @return all children nodes of all types
  110780. */
  110781. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110782. /**
  110783. * Get all child-meshes of this node
  110784. * @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)
  110785. * @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
  110786. * @returns an array of AbstractMesh
  110787. */
  110788. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110789. /**
  110790. * Get all direct children of this node
  110791. * @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
  110792. * @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)
  110793. * @returns an array of Node
  110794. */
  110795. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110796. /** @hidden */
  110797. _setReady(state: boolean): void;
  110798. /**
  110799. * Get an animation by name
  110800. * @param name defines the name of the animation to look for
  110801. * @returns null if not found else the requested animation
  110802. */
  110803. getAnimationByName(name: string): Nullable<Animation>;
  110804. /**
  110805. * Creates an animation range for this node
  110806. * @param name defines the name of the range
  110807. * @param from defines the starting key
  110808. * @param to defines the end key
  110809. */
  110810. createAnimationRange(name: string, from: number, to: number): void;
  110811. /**
  110812. * Delete a specific animation range
  110813. * @param name defines the name of the range to delete
  110814. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110815. */
  110816. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110817. /**
  110818. * Get an animation range by name
  110819. * @param name defines the name of the animation range to look for
  110820. * @returns null if not found else the requested animation range
  110821. */
  110822. getAnimationRange(name: string): Nullable<AnimationRange>;
  110823. /**
  110824. * Gets the list of all animation ranges defined on this node
  110825. * @returns an array
  110826. */
  110827. getAnimationRanges(): Nullable<AnimationRange>[];
  110828. /**
  110829. * Will start the animation sequence
  110830. * @param name defines the range frames for animation sequence
  110831. * @param loop defines if the animation should loop (false by default)
  110832. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110833. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110834. * @returns the object created for this animation. If range does not exist, it will return null
  110835. */
  110836. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110837. /**
  110838. * Serialize animation ranges into a JSON compatible object
  110839. * @returns serialization object
  110840. */
  110841. serializeAnimationRanges(): any;
  110842. /**
  110843. * Computes the world matrix of the node
  110844. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110845. * @returns the world matrix
  110846. */
  110847. computeWorldMatrix(force?: boolean): Matrix;
  110848. /**
  110849. * Releases resources associated with this node.
  110850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110852. */
  110853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110854. /**
  110855. * Parse animation range data from a serialization object and store them into a given node
  110856. * @param node defines where to store the animation ranges
  110857. * @param parsedNode defines the serialization object to read data from
  110858. * @param scene defines the hosting scene
  110859. */
  110860. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110861. /**
  110862. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110863. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110864. * @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
  110865. * @returns the new bounding vectors
  110866. */
  110867. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110868. min: Vector3;
  110869. max: Vector3;
  110870. };
  110871. }
  110872. }
  110873. declare module BABYLON {
  110874. /**
  110875. * @hidden
  110876. */
  110877. export class _IAnimationState {
  110878. key: number;
  110879. repeatCount: number;
  110880. workValue?: any;
  110881. loopMode?: number;
  110882. offsetValue?: any;
  110883. highLimitValue?: any;
  110884. }
  110885. /**
  110886. * Class used to store any kind of animation
  110887. */
  110888. export class Animation {
  110889. /**Name of the animation */
  110890. name: string;
  110891. /**Property to animate */
  110892. targetProperty: string;
  110893. /**The frames per second of the animation */
  110894. framePerSecond: number;
  110895. /**The data type of the animation */
  110896. dataType: number;
  110897. /**The loop mode of the animation */
  110898. loopMode?: number | undefined;
  110899. /**Specifies if blending should be enabled */
  110900. enableBlending?: boolean | undefined;
  110901. /**
  110902. * Use matrix interpolation instead of using direct key value when animating matrices
  110903. */
  110904. static AllowMatricesInterpolation: boolean;
  110905. /**
  110906. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110907. */
  110908. static AllowMatrixDecomposeForInterpolation: boolean;
  110909. /** Define the Url to load snippets */
  110910. static SnippetUrl: string;
  110911. /** Snippet ID if the animation was created from the snippet server */
  110912. snippetId: string;
  110913. /**
  110914. * Stores the key frames of the animation
  110915. */
  110916. private _keys;
  110917. /**
  110918. * Stores the easing function of the animation
  110919. */
  110920. private _easingFunction;
  110921. /**
  110922. * @hidden Internal use only
  110923. */
  110924. _runtimeAnimations: RuntimeAnimation[];
  110925. /**
  110926. * The set of event that will be linked to this animation
  110927. */
  110928. private _events;
  110929. /**
  110930. * Stores an array of target property paths
  110931. */
  110932. targetPropertyPath: string[];
  110933. /**
  110934. * Stores the blending speed of the animation
  110935. */
  110936. blendingSpeed: number;
  110937. /**
  110938. * Stores the animation ranges for the animation
  110939. */
  110940. private _ranges;
  110941. /**
  110942. * @hidden Internal use
  110943. */
  110944. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110945. /**
  110946. * Sets up an animation
  110947. * @param property The property to animate
  110948. * @param animationType The animation type to apply
  110949. * @param framePerSecond The frames per second of the animation
  110950. * @param easingFunction The easing function used in the animation
  110951. * @returns The created animation
  110952. */
  110953. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110954. /**
  110955. * Create and start an animation on a node
  110956. * @param name defines the name of the global animation that will be run on all nodes
  110957. * @param node defines the root node where the animation will take place
  110958. * @param targetProperty defines property to animate
  110959. * @param framePerSecond defines the number of frame per second yo use
  110960. * @param totalFrame defines the number of frames in total
  110961. * @param from defines the initial value
  110962. * @param to defines the final value
  110963. * @param loopMode defines which loop mode you want to use (off by default)
  110964. * @param easingFunction defines the easing function to use (linear by default)
  110965. * @param onAnimationEnd defines the callback to call when animation end
  110966. * @returns the animatable created for this animation
  110967. */
  110968. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110969. /**
  110970. * Create and start an animation on a node and its descendants
  110971. * @param name defines the name of the global animation that will be run on all nodes
  110972. * @param node defines the root node where the animation will take place
  110973. * @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
  110974. * @param targetProperty defines property to animate
  110975. * @param framePerSecond defines the number of frame per second to use
  110976. * @param totalFrame defines the number of frames in total
  110977. * @param from defines the initial value
  110978. * @param to defines the final value
  110979. * @param loopMode defines which loop mode you want to use (off by default)
  110980. * @param easingFunction defines the easing function to use (linear by default)
  110981. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110982. * @returns the list of animatables created for all nodes
  110983. * @example https://www.babylonjs-playground.com/#MH0VLI
  110984. */
  110985. 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[]>;
  110986. /**
  110987. * Creates a new animation, merges it with the existing animations and starts it
  110988. * @param name Name of the animation
  110989. * @param node Node which contains the scene that begins the animations
  110990. * @param targetProperty Specifies which property to animate
  110991. * @param framePerSecond The frames per second of the animation
  110992. * @param totalFrame The total number of frames
  110993. * @param from The frame at the beginning of the animation
  110994. * @param to The frame at the end of the animation
  110995. * @param loopMode Specifies the loop mode of the animation
  110996. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110997. * @param onAnimationEnd Callback to run once the animation is complete
  110998. * @returns Nullable animation
  110999. */
  111000. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  111001. /**
  111002. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111003. * @param sourceAnimation defines the Animation containing keyframes to convert
  111004. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111005. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  111006. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  111007. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  111008. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  111009. */
  111010. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  111011. /**
  111012. * Transition property of an host to the target Value
  111013. * @param property The property to transition
  111014. * @param targetValue The target Value of the property
  111015. * @param host The object where the property to animate belongs
  111016. * @param scene Scene used to run the animation
  111017. * @param frameRate Framerate (in frame/s) to use
  111018. * @param transition The transition type we want to use
  111019. * @param duration The duration of the animation, in milliseconds
  111020. * @param onAnimationEnd Callback trigger at the end of the animation
  111021. * @returns Nullable animation
  111022. */
  111023. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  111024. /**
  111025. * Return the array of runtime animations currently using this animation
  111026. */
  111027. get runtimeAnimations(): RuntimeAnimation[];
  111028. /**
  111029. * Specifies if any of the runtime animations are currently running
  111030. */
  111031. get hasRunningRuntimeAnimations(): boolean;
  111032. /**
  111033. * Initializes the animation
  111034. * @param name Name of the animation
  111035. * @param targetProperty Property to animate
  111036. * @param framePerSecond The frames per second of the animation
  111037. * @param dataType The data type of the animation
  111038. * @param loopMode The loop mode of the animation
  111039. * @param enableBlending Specifies if blending should be enabled
  111040. */
  111041. constructor(
  111042. /**Name of the animation */
  111043. name: string,
  111044. /**Property to animate */
  111045. targetProperty: string,
  111046. /**The frames per second of the animation */
  111047. framePerSecond: number,
  111048. /**The data type of the animation */
  111049. dataType: number,
  111050. /**The loop mode of the animation */
  111051. loopMode?: number | undefined,
  111052. /**Specifies if blending should be enabled */
  111053. enableBlending?: boolean | undefined);
  111054. /**
  111055. * Converts the animation to a string
  111056. * @param fullDetails support for multiple levels of logging within scene loading
  111057. * @returns String form of the animation
  111058. */
  111059. toString(fullDetails?: boolean): string;
  111060. /**
  111061. * Add an event to this animation
  111062. * @param event Event to add
  111063. */
  111064. addEvent(event: AnimationEvent): void;
  111065. /**
  111066. * Remove all events found at the given frame
  111067. * @param frame The frame to remove events from
  111068. */
  111069. removeEvents(frame: number): void;
  111070. /**
  111071. * Retrieves all the events from the animation
  111072. * @returns Events from the animation
  111073. */
  111074. getEvents(): AnimationEvent[];
  111075. /**
  111076. * Creates an animation range
  111077. * @param name Name of the animation range
  111078. * @param from Starting frame of the animation range
  111079. * @param to Ending frame of the animation
  111080. */
  111081. createRange(name: string, from: number, to: number): void;
  111082. /**
  111083. * Deletes an animation range by name
  111084. * @param name Name of the animation range to delete
  111085. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  111086. */
  111087. deleteRange(name: string, deleteFrames?: boolean): void;
  111088. /**
  111089. * Gets the animation range by name, or null if not defined
  111090. * @param name Name of the animation range
  111091. * @returns Nullable animation range
  111092. */
  111093. getRange(name: string): Nullable<AnimationRange>;
  111094. /**
  111095. * Gets the key frames from the animation
  111096. * @returns The key frames of the animation
  111097. */
  111098. getKeys(): Array<IAnimationKey>;
  111099. /**
  111100. * Gets the highest frame rate of the animation
  111101. * @returns Highest frame rate of the animation
  111102. */
  111103. getHighestFrame(): number;
  111104. /**
  111105. * Gets the easing function of the animation
  111106. * @returns Easing function of the animation
  111107. */
  111108. getEasingFunction(): IEasingFunction;
  111109. /**
  111110. * Sets the easing function of the animation
  111111. * @param easingFunction A custom mathematical formula for animation
  111112. */
  111113. setEasingFunction(easingFunction: EasingFunction): void;
  111114. /**
  111115. * Interpolates a scalar linearly
  111116. * @param startValue Start value of the animation curve
  111117. * @param endValue End value of the animation curve
  111118. * @param gradient Scalar amount to interpolate
  111119. * @returns Interpolated scalar value
  111120. */
  111121. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  111122. /**
  111123. * Interpolates a scalar cubically
  111124. * @param startValue Start value of the animation curve
  111125. * @param outTangent End tangent of the animation
  111126. * @param endValue End value of the animation curve
  111127. * @param inTangent Start tangent of the animation curve
  111128. * @param gradient Scalar amount to interpolate
  111129. * @returns Interpolated scalar value
  111130. */
  111131. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  111132. /**
  111133. * Interpolates a quaternion using a spherical linear interpolation
  111134. * @param startValue Start value of the animation curve
  111135. * @param endValue End value of the animation curve
  111136. * @param gradient Scalar amount to interpolate
  111137. * @returns Interpolated quaternion value
  111138. */
  111139. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  111140. /**
  111141. * Interpolates a quaternion cubically
  111142. * @param startValue Start value of the animation curve
  111143. * @param outTangent End tangent of the animation curve
  111144. * @param endValue End value of the animation curve
  111145. * @param inTangent Start tangent of the animation curve
  111146. * @param gradient Scalar amount to interpolate
  111147. * @returns Interpolated quaternion value
  111148. */
  111149. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  111150. /**
  111151. * Interpolates a Vector3 linearl
  111152. * @param startValue Start value of the animation curve
  111153. * @param endValue End value of the animation curve
  111154. * @param gradient Scalar amount to interpolate
  111155. * @returns Interpolated scalar value
  111156. */
  111157. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  111158. /**
  111159. * Interpolates a Vector3 cubically
  111160. * @param startValue Start value of the animation curve
  111161. * @param outTangent End tangent of the animation
  111162. * @param endValue End value of the animation curve
  111163. * @param inTangent Start tangent of the animation curve
  111164. * @param gradient Scalar amount to interpolate
  111165. * @returns InterpolatedVector3 value
  111166. */
  111167. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  111168. /**
  111169. * Interpolates a Vector2 linearly
  111170. * @param startValue Start value of the animation curve
  111171. * @param endValue End value of the animation curve
  111172. * @param gradient Scalar amount to interpolate
  111173. * @returns Interpolated Vector2 value
  111174. */
  111175. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  111176. /**
  111177. * Interpolates a Vector2 cubically
  111178. * @param startValue Start value of the animation curve
  111179. * @param outTangent End tangent of the animation
  111180. * @param endValue End value of the animation curve
  111181. * @param inTangent Start tangent of the animation curve
  111182. * @param gradient Scalar amount to interpolate
  111183. * @returns Interpolated Vector2 value
  111184. */
  111185. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  111186. /**
  111187. * Interpolates a size linearly
  111188. * @param startValue Start value of the animation curve
  111189. * @param endValue End value of the animation curve
  111190. * @param gradient Scalar amount to interpolate
  111191. * @returns Interpolated Size value
  111192. */
  111193. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  111194. /**
  111195. * Interpolates a Color3 linearly
  111196. * @param startValue Start value of the animation curve
  111197. * @param endValue End value of the animation curve
  111198. * @param gradient Scalar amount to interpolate
  111199. * @returns Interpolated Color3 value
  111200. */
  111201. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  111202. /**
  111203. * Interpolates a Color4 linearly
  111204. * @param startValue Start value of the animation curve
  111205. * @param endValue End value of the animation curve
  111206. * @param gradient Scalar amount to interpolate
  111207. * @returns Interpolated Color3 value
  111208. */
  111209. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  111210. /**
  111211. * @hidden Internal use only
  111212. */
  111213. _getKeyValue(value: any): any;
  111214. /**
  111215. * @hidden Internal use only
  111216. */
  111217. _interpolate(currentFrame: number, state: _IAnimationState): any;
  111218. /**
  111219. * Defines the function to use to interpolate matrices
  111220. * @param startValue defines the start matrix
  111221. * @param endValue defines the end matrix
  111222. * @param gradient defines the gradient between both matrices
  111223. * @param result defines an optional target matrix where to store the interpolation
  111224. * @returns the interpolated matrix
  111225. */
  111226. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  111227. /**
  111228. * Makes a copy of the animation
  111229. * @returns Cloned animation
  111230. */
  111231. clone(): Animation;
  111232. /**
  111233. * Sets the key frames of the animation
  111234. * @param values The animation key frames to set
  111235. */
  111236. setKeys(values: Array<IAnimationKey>): void;
  111237. /**
  111238. * Serializes the animation to an object
  111239. * @returns Serialized object
  111240. */
  111241. serialize(): any;
  111242. /**
  111243. * Float animation type
  111244. */
  111245. static readonly ANIMATIONTYPE_FLOAT: number;
  111246. /**
  111247. * Vector3 animation type
  111248. */
  111249. static readonly ANIMATIONTYPE_VECTOR3: number;
  111250. /**
  111251. * Quaternion animation type
  111252. */
  111253. static readonly ANIMATIONTYPE_QUATERNION: number;
  111254. /**
  111255. * Matrix animation type
  111256. */
  111257. static readonly ANIMATIONTYPE_MATRIX: number;
  111258. /**
  111259. * Color3 animation type
  111260. */
  111261. static readonly ANIMATIONTYPE_COLOR3: number;
  111262. /**
  111263. * Color3 animation type
  111264. */
  111265. static readonly ANIMATIONTYPE_COLOR4: number;
  111266. /**
  111267. * Vector2 animation type
  111268. */
  111269. static readonly ANIMATIONTYPE_VECTOR2: number;
  111270. /**
  111271. * Size animation type
  111272. */
  111273. static readonly ANIMATIONTYPE_SIZE: number;
  111274. /**
  111275. * Relative Loop Mode
  111276. */
  111277. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  111278. /**
  111279. * Cycle Loop Mode
  111280. */
  111281. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  111282. /**
  111283. * Constant Loop Mode
  111284. */
  111285. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  111286. /** @hidden */
  111287. static _UniversalLerp(left: any, right: any, amount: number): any;
  111288. /**
  111289. * Parses an animation object and creates an animation
  111290. * @param parsedAnimation Parsed animation object
  111291. * @returns Animation object
  111292. */
  111293. static Parse(parsedAnimation: any): Animation;
  111294. /**
  111295. * Appends the serialized animations from the source animations
  111296. * @param source Source containing the animations
  111297. * @param destination Target to store the animations
  111298. */
  111299. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111300. /**
  111301. * Creates a new animation or an array of animations from a snippet saved in a remote file
  111302. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  111303. * @param url defines the url to load from
  111304. * @returns a promise that will resolve to the new animation or an array of animations
  111305. */
  111306. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  111307. /**
  111308. * Creates an animation or an array of animations from a snippet saved by the Inspector
  111309. * @param snippetId defines the snippet to load
  111310. * @returns a promise that will resolve to the new animation or a new array of animations
  111311. */
  111312. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111313. }
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * Interface containing an array of animations
  111318. */
  111319. export interface IAnimatable {
  111320. /**
  111321. * Array of animations
  111322. */
  111323. animations: Nullable<Array<Animation>>;
  111324. }
  111325. }
  111326. declare module BABYLON {
  111327. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111328. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111329. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111330. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111331. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111332. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111333. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111334. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111335. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111336. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111337. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111338. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111339. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111340. /**
  111341. * Decorator used to define property that can be serialized as reference to a camera
  111342. * @param sourceName defines the name of the property to decorate
  111343. */
  111344. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111345. /**
  111346. * Class used to help serialization objects
  111347. */
  111348. export class SerializationHelper {
  111349. /** @hidden */
  111350. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111351. /** @hidden */
  111352. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111353. /** @hidden */
  111354. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111355. /** @hidden */
  111356. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111357. /**
  111358. * Appends the serialized animations from the source animations
  111359. * @param source Source containing the animations
  111360. * @param destination Target to store the animations
  111361. */
  111362. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111363. /**
  111364. * Static function used to serialized a specific entity
  111365. * @param entity defines the entity to serialize
  111366. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111367. * @returns a JSON compatible object representing the serialization of the entity
  111368. */
  111369. static Serialize<T>(entity: T, serializationObject?: any): any;
  111370. /**
  111371. * Creates a new entity from a serialization data object
  111372. * @param creationFunction defines a function used to instanciated the new entity
  111373. * @param source defines the source serialization data
  111374. * @param scene defines the hosting scene
  111375. * @param rootUrl defines the root url for resources
  111376. * @returns a new entity
  111377. */
  111378. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111379. /**
  111380. * Clones an object
  111381. * @param creationFunction defines the function used to instanciate the new object
  111382. * @param source defines the source object
  111383. * @returns the cloned object
  111384. */
  111385. static Clone<T>(creationFunction: () => T, source: T): T;
  111386. /**
  111387. * Instanciates a new object based on a source one (some data will be shared between both object)
  111388. * @param creationFunction defines the function used to instanciate the new object
  111389. * @param source defines the source object
  111390. * @returns the new object
  111391. */
  111392. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111393. }
  111394. }
  111395. declare module BABYLON {
  111396. /**
  111397. * Base class of all the textures in babylon.
  111398. * It groups all the common properties the materials, post process, lights... might need
  111399. * in order to make a correct use of the texture.
  111400. */
  111401. export class BaseTexture implements IAnimatable {
  111402. /**
  111403. * Default anisotropic filtering level for the application.
  111404. * It is set to 4 as a good tradeoff between perf and quality.
  111405. */
  111406. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111407. /**
  111408. * Gets or sets the unique id of the texture
  111409. */
  111410. uniqueId: number;
  111411. /**
  111412. * Define the name of the texture.
  111413. */
  111414. name: string;
  111415. /**
  111416. * Gets or sets an object used to store user defined information.
  111417. */
  111418. metadata: any;
  111419. /**
  111420. * For internal use only. Please do not use.
  111421. */
  111422. reservedDataStore: any;
  111423. private _hasAlpha;
  111424. /**
  111425. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111426. */
  111427. set hasAlpha(value: boolean);
  111428. get hasAlpha(): boolean;
  111429. /**
  111430. * Defines if the alpha value should be determined via the rgb values.
  111431. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111432. */
  111433. getAlphaFromRGB: boolean;
  111434. /**
  111435. * Intensity or strength of the texture.
  111436. * It is commonly used by materials to fine tune the intensity of the texture
  111437. */
  111438. level: number;
  111439. /**
  111440. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111441. * This is part of the texture as textures usually maps to one uv set.
  111442. */
  111443. coordinatesIndex: number;
  111444. private _coordinatesMode;
  111445. /**
  111446. * How a texture is mapped.
  111447. *
  111448. * | Value | Type | Description |
  111449. * | ----- | ----------------------------------- | ----------- |
  111450. * | 0 | EXPLICIT_MODE | |
  111451. * | 1 | SPHERICAL_MODE | |
  111452. * | 2 | PLANAR_MODE | |
  111453. * | 3 | CUBIC_MODE | |
  111454. * | 4 | PROJECTION_MODE | |
  111455. * | 5 | SKYBOX_MODE | |
  111456. * | 6 | INVCUBIC_MODE | |
  111457. * | 7 | EQUIRECTANGULAR_MODE | |
  111458. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111459. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111460. */
  111461. set coordinatesMode(value: number);
  111462. get coordinatesMode(): number;
  111463. /**
  111464. * | Value | Type | Description |
  111465. * | ----- | ------------------ | ----------- |
  111466. * | 0 | CLAMP_ADDRESSMODE | |
  111467. * | 1 | WRAP_ADDRESSMODE | |
  111468. * | 2 | MIRROR_ADDRESSMODE | |
  111469. */
  111470. wrapU: number;
  111471. /**
  111472. * | Value | Type | Description |
  111473. * | ----- | ------------------ | ----------- |
  111474. * | 0 | CLAMP_ADDRESSMODE | |
  111475. * | 1 | WRAP_ADDRESSMODE | |
  111476. * | 2 | MIRROR_ADDRESSMODE | |
  111477. */
  111478. wrapV: number;
  111479. /**
  111480. * | Value | Type | Description |
  111481. * | ----- | ------------------ | ----------- |
  111482. * | 0 | CLAMP_ADDRESSMODE | |
  111483. * | 1 | WRAP_ADDRESSMODE | |
  111484. * | 2 | MIRROR_ADDRESSMODE | |
  111485. */
  111486. wrapR: number;
  111487. /**
  111488. * With compliant hardware and browser (supporting anisotropic filtering)
  111489. * this defines the level of anisotropic filtering in the texture.
  111490. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111491. */
  111492. anisotropicFilteringLevel: number;
  111493. /**
  111494. * Define if the texture is a cube texture or if false a 2d texture.
  111495. */
  111496. get isCube(): boolean;
  111497. set isCube(value: boolean);
  111498. /**
  111499. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111500. */
  111501. get is3D(): boolean;
  111502. set is3D(value: boolean);
  111503. /**
  111504. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111505. */
  111506. get is2DArray(): boolean;
  111507. set is2DArray(value: boolean);
  111508. /**
  111509. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111510. * HDR texture are usually stored in linear space.
  111511. * This only impacts the PBR and Background materials
  111512. */
  111513. gammaSpace: boolean;
  111514. /**
  111515. * Gets or sets whether or not the texture contains RGBD data.
  111516. */
  111517. get isRGBD(): boolean;
  111518. set isRGBD(value: boolean);
  111519. /**
  111520. * Is Z inverted in the texture (useful in a cube texture).
  111521. */
  111522. invertZ: boolean;
  111523. /**
  111524. * Are mip maps generated for this texture or not.
  111525. */
  111526. get noMipmap(): boolean;
  111527. /**
  111528. * @hidden
  111529. */
  111530. lodLevelInAlpha: boolean;
  111531. /**
  111532. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111533. */
  111534. get lodGenerationOffset(): number;
  111535. set lodGenerationOffset(value: number);
  111536. /**
  111537. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111538. */
  111539. get lodGenerationScale(): number;
  111540. set lodGenerationScale(value: number);
  111541. /**
  111542. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111543. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111544. * average roughness values.
  111545. */
  111546. get linearSpecularLOD(): boolean;
  111547. set linearSpecularLOD(value: boolean);
  111548. /**
  111549. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111550. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111551. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111552. */
  111553. get irradianceTexture(): Nullable<BaseTexture>;
  111554. set irradianceTexture(value: Nullable<BaseTexture>);
  111555. /**
  111556. * Define if the texture is a render target.
  111557. */
  111558. isRenderTarget: boolean;
  111559. /**
  111560. * Define the unique id of the texture in the scene.
  111561. */
  111562. get uid(): string;
  111563. /** @hidden */
  111564. _prefiltered: boolean;
  111565. /**
  111566. * Return a string representation of the texture.
  111567. * @returns the texture as a string
  111568. */
  111569. toString(): string;
  111570. /**
  111571. * Get the class name of the texture.
  111572. * @returns "BaseTexture"
  111573. */
  111574. getClassName(): string;
  111575. /**
  111576. * Define the list of animation attached to the texture.
  111577. */
  111578. animations: Animation[];
  111579. /**
  111580. * An event triggered when the texture is disposed.
  111581. */
  111582. onDisposeObservable: Observable<BaseTexture>;
  111583. private _onDisposeObserver;
  111584. /**
  111585. * Callback triggered when the texture has been disposed.
  111586. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111587. */
  111588. set onDispose(callback: () => void);
  111589. /**
  111590. * Define the current state of the loading sequence when in delayed load mode.
  111591. */
  111592. delayLoadState: number;
  111593. private _scene;
  111594. private _engine;
  111595. /** @hidden */
  111596. _texture: Nullable<InternalTexture>;
  111597. private _uid;
  111598. /**
  111599. * Define if the texture is preventinga material to render or not.
  111600. * If not and the texture is not ready, the engine will use a default black texture instead.
  111601. */
  111602. get isBlocking(): boolean;
  111603. /**
  111604. * Instantiates a new BaseTexture.
  111605. * Base class of all the textures in babylon.
  111606. * It groups all the common properties the materials, post process, lights... might need
  111607. * in order to make a correct use of the texture.
  111608. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111609. */
  111610. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111611. /**
  111612. * Get the scene the texture belongs to.
  111613. * @returns the scene or null if undefined
  111614. */
  111615. getScene(): Nullable<Scene>;
  111616. /** @hidden */
  111617. protected _getEngine(): Nullable<ThinEngine>;
  111618. /**
  111619. * Get the texture transform matrix used to offset tile the texture for istance.
  111620. * @returns the transformation matrix
  111621. */
  111622. getTextureMatrix(): Matrix;
  111623. /**
  111624. * Get the texture reflection matrix used to rotate/transform the reflection.
  111625. * @returns the reflection matrix
  111626. */
  111627. getReflectionTextureMatrix(): Matrix;
  111628. /**
  111629. * Get the underlying lower level texture from Babylon.
  111630. * @returns the insternal texture
  111631. */
  111632. getInternalTexture(): Nullable<InternalTexture>;
  111633. /**
  111634. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111635. * @returns true if ready or not blocking
  111636. */
  111637. isReadyOrNotBlocking(): boolean;
  111638. /**
  111639. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111640. * @returns true if fully ready
  111641. */
  111642. isReady(): boolean;
  111643. private _cachedSize;
  111644. /**
  111645. * Get the size of the texture.
  111646. * @returns the texture size.
  111647. */
  111648. getSize(): ISize;
  111649. /**
  111650. * Get the base size of the texture.
  111651. * It can be different from the size if the texture has been resized for POT for instance
  111652. * @returns the base size
  111653. */
  111654. getBaseSize(): ISize;
  111655. /**
  111656. * Update the sampling mode of the texture.
  111657. * Default is Trilinear mode.
  111658. *
  111659. * | Value | Type | Description |
  111660. * | ----- | ------------------ | ----------- |
  111661. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111662. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111663. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111664. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111665. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111666. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111667. * | 7 | NEAREST_LINEAR | |
  111668. * | 8 | NEAREST_NEAREST | |
  111669. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111670. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111671. * | 11 | LINEAR_LINEAR | |
  111672. * | 12 | LINEAR_NEAREST | |
  111673. *
  111674. * > _mag_: magnification filter (close to the viewer)
  111675. * > _min_: minification filter (far from the viewer)
  111676. * > _mip_: filter used between mip map levels
  111677. *@param samplingMode Define the new sampling mode of the texture
  111678. */
  111679. updateSamplingMode(samplingMode: number): void;
  111680. /**
  111681. * Scales the texture if is `canRescale()`
  111682. * @param ratio the resize factor we want to use to rescale
  111683. */
  111684. scale(ratio: number): void;
  111685. /**
  111686. * Get if the texture can rescale.
  111687. */
  111688. get canRescale(): boolean;
  111689. /** @hidden */
  111690. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111691. /** @hidden */
  111692. _rebuild(): void;
  111693. /**
  111694. * Triggers the load sequence in delayed load mode.
  111695. */
  111696. delayLoad(): void;
  111697. /**
  111698. * Clones the texture.
  111699. * @returns the cloned texture
  111700. */
  111701. clone(): Nullable<BaseTexture>;
  111702. /**
  111703. * Get the texture underlying type (INT, FLOAT...)
  111704. */
  111705. get textureType(): number;
  111706. /**
  111707. * Get the texture underlying format (RGB, RGBA...)
  111708. */
  111709. get textureFormat(): number;
  111710. /**
  111711. * Indicates that textures need to be re-calculated for all materials
  111712. */
  111713. protected _markAllSubMeshesAsTexturesDirty(): void;
  111714. /**
  111715. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111716. * This will returns an RGBA array buffer containing either in values (0-255) or
  111717. * float values (0-1) depending of the underlying buffer type.
  111718. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111719. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111720. * @param buffer defines a user defined buffer to fill with data (can be null)
  111721. * @returns The Array buffer containing the pixels data.
  111722. */
  111723. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111724. /**
  111725. * Release and destroy the underlying lower level texture aka internalTexture.
  111726. */
  111727. releaseInternalTexture(): void;
  111728. /** @hidden */
  111729. get _lodTextureHigh(): Nullable<BaseTexture>;
  111730. /** @hidden */
  111731. get _lodTextureMid(): Nullable<BaseTexture>;
  111732. /** @hidden */
  111733. get _lodTextureLow(): Nullable<BaseTexture>;
  111734. /**
  111735. * Dispose the texture and release its associated resources.
  111736. */
  111737. dispose(): void;
  111738. /**
  111739. * Serialize the texture into a JSON representation that can be parsed later on.
  111740. * @returns the JSON representation of the texture
  111741. */
  111742. serialize(): any;
  111743. /**
  111744. * Helper function to be called back once a list of texture contains only ready textures.
  111745. * @param textures Define the list of textures to wait for
  111746. * @param callback Define the callback triggered once the entire list will be ready
  111747. */
  111748. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111749. private static _isScene;
  111750. }
  111751. }
  111752. declare module BABYLON {
  111753. /**
  111754. * Options to be used when creating an effect.
  111755. */
  111756. export interface IEffectCreationOptions {
  111757. /**
  111758. * Atrributes that will be used in the shader.
  111759. */
  111760. attributes: string[];
  111761. /**
  111762. * Uniform varible names that will be set in the shader.
  111763. */
  111764. uniformsNames: string[];
  111765. /**
  111766. * Uniform buffer variable names that will be set in the shader.
  111767. */
  111768. uniformBuffersNames: string[];
  111769. /**
  111770. * Sampler texture variable names that will be set in the shader.
  111771. */
  111772. samplers: string[];
  111773. /**
  111774. * Define statements that will be set in the shader.
  111775. */
  111776. defines: any;
  111777. /**
  111778. * Possible fallbacks for this effect to improve performance when needed.
  111779. */
  111780. fallbacks: Nullable<IEffectFallbacks>;
  111781. /**
  111782. * Callback that will be called when the shader is compiled.
  111783. */
  111784. onCompiled: Nullable<(effect: Effect) => void>;
  111785. /**
  111786. * Callback that will be called if an error occurs during shader compilation.
  111787. */
  111788. onError: Nullable<(effect: Effect, errors: string) => void>;
  111789. /**
  111790. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111791. */
  111792. indexParameters?: any;
  111793. /**
  111794. * Max number of lights that can be used in the shader.
  111795. */
  111796. maxSimultaneousLights?: number;
  111797. /**
  111798. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111799. */
  111800. transformFeedbackVaryings?: Nullable<string[]>;
  111801. /**
  111802. * 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
  111803. */
  111804. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111805. /**
  111806. * Is this effect rendering to several color attachments ?
  111807. */
  111808. multiTarget?: boolean;
  111809. }
  111810. /**
  111811. * Effect containing vertex and fragment shader that can be executed on an object.
  111812. */
  111813. export class Effect implements IDisposable {
  111814. /**
  111815. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111816. */
  111817. static ShadersRepository: string;
  111818. /**
  111819. * Enable logging of the shader code when a compilation error occurs
  111820. */
  111821. static LogShaderCodeOnCompilationError: boolean;
  111822. /**
  111823. * Name of the effect.
  111824. */
  111825. name: any;
  111826. /**
  111827. * String container all the define statements that should be set on the shader.
  111828. */
  111829. defines: string;
  111830. /**
  111831. * Callback that will be called when the shader is compiled.
  111832. */
  111833. onCompiled: Nullable<(effect: Effect) => void>;
  111834. /**
  111835. * Callback that will be called if an error occurs during shader compilation.
  111836. */
  111837. onError: Nullable<(effect: Effect, errors: string) => void>;
  111838. /**
  111839. * Callback that will be called when effect is bound.
  111840. */
  111841. onBind: Nullable<(effect: Effect) => void>;
  111842. /**
  111843. * Unique ID of the effect.
  111844. */
  111845. uniqueId: number;
  111846. /**
  111847. * Observable that will be called when the shader is compiled.
  111848. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111849. */
  111850. onCompileObservable: Observable<Effect>;
  111851. /**
  111852. * Observable that will be called if an error occurs during shader compilation.
  111853. */
  111854. onErrorObservable: Observable<Effect>;
  111855. /** @hidden */
  111856. _onBindObservable: Nullable<Observable<Effect>>;
  111857. /**
  111858. * @hidden
  111859. * Specifies if the effect was previously ready
  111860. */
  111861. _wasPreviouslyReady: boolean;
  111862. /**
  111863. * Observable that will be called when effect is bound.
  111864. */
  111865. get onBindObservable(): Observable<Effect>;
  111866. /** @hidden */
  111867. _bonesComputationForcedToCPU: boolean;
  111868. /** @hidden */
  111869. _multiTarget: boolean;
  111870. private static _uniqueIdSeed;
  111871. private _engine;
  111872. private _uniformBuffersNames;
  111873. private _uniformBuffersNamesList;
  111874. private _uniformsNames;
  111875. private _samplerList;
  111876. private _samplers;
  111877. private _isReady;
  111878. private _compilationError;
  111879. private _allFallbacksProcessed;
  111880. private _attributesNames;
  111881. private _attributes;
  111882. private _attributeLocationByName;
  111883. private _uniforms;
  111884. /**
  111885. * Key for the effect.
  111886. * @hidden
  111887. */
  111888. _key: string;
  111889. private _indexParameters;
  111890. private _fallbacks;
  111891. private _vertexSourceCode;
  111892. private _fragmentSourceCode;
  111893. private _vertexSourceCodeOverride;
  111894. private _fragmentSourceCodeOverride;
  111895. private _transformFeedbackVaryings;
  111896. /**
  111897. * Compiled shader to webGL program.
  111898. * @hidden
  111899. */
  111900. _pipelineContext: Nullable<IPipelineContext>;
  111901. private _valueCache;
  111902. private static _baseCache;
  111903. /**
  111904. * Instantiates an effect.
  111905. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111906. * @param baseName Name of the effect.
  111907. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111908. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111909. * @param samplers List of sampler variables that will be passed to the shader.
  111910. * @param engine Engine to be used to render the effect
  111911. * @param defines Define statements to be added to the shader.
  111912. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111913. * @param onCompiled Callback that will be called when the shader is compiled.
  111914. * @param onError Callback that will be called if an error occurs during shader compilation.
  111915. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111916. */
  111917. 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);
  111918. private _useFinalCode;
  111919. /**
  111920. * Unique key for this effect
  111921. */
  111922. get key(): string;
  111923. /**
  111924. * If the effect has been compiled and prepared.
  111925. * @returns if the effect is compiled and prepared.
  111926. */
  111927. isReady(): boolean;
  111928. private _isReadyInternal;
  111929. /**
  111930. * The engine the effect was initialized with.
  111931. * @returns the engine.
  111932. */
  111933. getEngine(): Engine;
  111934. /**
  111935. * The pipeline context for this effect
  111936. * @returns the associated pipeline context
  111937. */
  111938. getPipelineContext(): Nullable<IPipelineContext>;
  111939. /**
  111940. * The set of names of attribute variables for the shader.
  111941. * @returns An array of attribute names.
  111942. */
  111943. getAttributesNames(): string[];
  111944. /**
  111945. * Returns the attribute at the given index.
  111946. * @param index The index of the attribute.
  111947. * @returns The location of the attribute.
  111948. */
  111949. getAttributeLocation(index: number): number;
  111950. /**
  111951. * Returns the attribute based on the name of the variable.
  111952. * @param name of the attribute to look up.
  111953. * @returns the attribute location.
  111954. */
  111955. getAttributeLocationByName(name: string): number;
  111956. /**
  111957. * The number of attributes.
  111958. * @returns the numnber of attributes.
  111959. */
  111960. getAttributesCount(): number;
  111961. /**
  111962. * Gets the index of a uniform variable.
  111963. * @param uniformName of the uniform to look up.
  111964. * @returns the index.
  111965. */
  111966. getUniformIndex(uniformName: string): number;
  111967. /**
  111968. * Returns the attribute based on the name of the variable.
  111969. * @param uniformName of the uniform to look up.
  111970. * @returns the location of the uniform.
  111971. */
  111972. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111973. /**
  111974. * Returns an array of sampler variable names
  111975. * @returns The array of sampler variable names.
  111976. */
  111977. getSamplers(): string[];
  111978. /**
  111979. * Returns an array of uniform variable names
  111980. * @returns The array of uniform variable names.
  111981. */
  111982. getUniformNames(): string[];
  111983. /**
  111984. * Returns an array of uniform buffer variable names
  111985. * @returns The array of uniform buffer variable names.
  111986. */
  111987. getUniformBuffersNames(): string[];
  111988. /**
  111989. * Returns the index parameters used to create the effect
  111990. * @returns The index parameters object
  111991. */
  111992. getIndexParameters(): any;
  111993. /**
  111994. * The error from the last compilation.
  111995. * @returns the error string.
  111996. */
  111997. getCompilationError(): string;
  111998. /**
  111999. * Gets a boolean indicating that all fallbacks were used during compilation
  112000. * @returns true if all fallbacks were used
  112001. */
  112002. allFallbacksProcessed(): boolean;
  112003. /**
  112004. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  112005. * @param func The callback to be used.
  112006. */
  112007. executeWhenCompiled(func: (effect: Effect) => void): void;
  112008. private _checkIsReady;
  112009. private _loadShader;
  112010. /**
  112011. * Gets the vertex shader source code of this effect
  112012. */
  112013. get vertexSourceCode(): string;
  112014. /**
  112015. * Gets the fragment shader source code of this effect
  112016. */
  112017. get fragmentSourceCode(): string;
  112018. /**
  112019. * Recompiles the webGL program
  112020. * @param vertexSourceCode The source code for the vertex shader.
  112021. * @param fragmentSourceCode The source code for the fragment shader.
  112022. * @param onCompiled Callback called when completed.
  112023. * @param onError Callback called on error.
  112024. * @hidden
  112025. */
  112026. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  112027. /**
  112028. * Prepares the effect
  112029. * @hidden
  112030. */
  112031. _prepareEffect(): void;
  112032. private _getShaderCodeAndErrorLine;
  112033. private _processCompilationErrors;
  112034. /**
  112035. * Checks if the effect is supported. (Must be called after compilation)
  112036. */
  112037. get isSupported(): boolean;
  112038. /**
  112039. * Binds a texture to the engine to be used as output of the shader.
  112040. * @param channel Name of the output variable.
  112041. * @param texture Texture to bind.
  112042. * @hidden
  112043. */
  112044. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  112045. /**
  112046. * Sets a texture on the engine to be used in the shader.
  112047. * @param channel Name of the sampler variable.
  112048. * @param texture Texture to set.
  112049. */
  112050. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  112051. /**
  112052. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  112053. * @param channel Name of the sampler variable.
  112054. * @param texture Texture to set.
  112055. */
  112056. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  112057. /**
  112058. * Sets an array of textures on the engine to be used in the shader.
  112059. * @param channel Name of the variable.
  112060. * @param textures Textures to set.
  112061. */
  112062. setTextureArray(channel: string, textures: BaseTexture[]): void;
  112063. /**
  112064. * 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)
  112065. * @param channel Name of the sampler variable.
  112066. * @param postProcess Post process to get the input texture from.
  112067. */
  112068. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  112069. /**
  112070. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  112071. * 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)
  112072. * @param channel Name of the sampler variable.
  112073. * @param postProcess Post process to get the output texture from.
  112074. */
  112075. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  112076. /** @hidden */
  112077. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  112078. /** @hidden */
  112079. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  112080. /** @hidden */
  112081. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  112082. /** @hidden */
  112083. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  112084. /**
  112085. * Binds a buffer to a uniform.
  112086. * @param buffer Buffer to bind.
  112087. * @param name Name of the uniform variable to bind to.
  112088. */
  112089. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  112090. /**
  112091. * Binds block to a uniform.
  112092. * @param blockName Name of the block to bind.
  112093. * @param index Index to bind.
  112094. */
  112095. bindUniformBlock(blockName: string, index: number): void;
  112096. /**
  112097. * Sets an interger value on a uniform variable.
  112098. * @param uniformName Name of the variable.
  112099. * @param value Value to be set.
  112100. * @returns this effect.
  112101. */
  112102. setInt(uniformName: string, value: number): Effect;
  112103. /**
  112104. * Sets an int array on a uniform variable.
  112105. * @param uniformName Name of the variable.
  112106. * @param array array to be set.
  112107. * @returns this effect.
  112108. */
  112109. setIntArray(uniformName: string, array: Int32Array): Effect;
  112110. /**
  112111. * 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)
  112112. * @param uniformName Name of the variable.
  112113. * @param array array to be set.
  112114. * @returns this effect.
  112115. */
  112116. setIntArray2(uniformName: string, array: Int32Array): Effect;
  112117. /**
  112118. * 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)
  112119. * @param uniformName Name of the variable.
  112120. * @param array array to be set.
  112121. * @returns this effect.
  112122. */
  112123. setIntArray3(uniformName: string, array: Int32Array): Effect;
  112124. /**
  112125. * 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)
  112126. * @param uniformName Name of the variable.
  112127. * @param array array to be set.
  112128. * @returns this effect.
  112129. */
  112130. setIntArray4(uniformName: string, array: Int32Array): Effect;
  112131. /**
  112132. * Sets an float array on a uniform variable.
  112133. * @param uniformName Name of the variable.
  112134. * @param array array to be set.
  112135. * @returns this effect.
  112136. */
  112137. setFloatArray(uniformName: string, array: Float32Array): Effect;
  112138. /**
  112139. * 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)
  112140. * @param uniformName Name of the variable.
  112141. * @param array array to be set.
  112142. * @returns this effect.
  112143. */
  112144. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  112145. /**
  112146. * 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)
  112147. * @param uniformName Name of the variable.
  112148. * @param array array to be set.
  112149. * @returns this effect.
  112150. */
  112151. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  112152. /**
  112153. * 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)
  112154. * @param uniformName Name of the variable.
  112155. * @param array array to be set.
  112156. * @returns this effect.
  112157. */
  112158. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  112159. /**
  112160. * Sets an array on a uniform variable.
  112161. * @param uniformName Name of the variable.
  112162. * @param array array to be set.
  112163. * @returns this effect.
  112164. */
  112165. setArray(uniformName: string, array: number[]): Effect;
  112166. /**
  112167. * 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)
  112168. * @param uniformName Name of the variable.
  112169. * @param array array to be set.
  112170. * @returns this effect.
  112171. */
  112172. setArray2(uniformName: string, array: number[]): Effect;
  112173. /**
  112174. * 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)
  112175. * @param uniformName Name of the variable.
  112176. * @param array array to be set.
  112177. * @returns this effect.
  112178. */
  112179. setArray3(uniformName: string, array: number[]): Effect;
  112180. /**
  112181. * 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)
  112182. * @param uniformName Name of the variable.
  112183. * @param array array to be set.
  112184. * @returns this effect.
  112185. */
  112186. setArray4(uniformName: string, array: number[]): Effect;
  112187. /**
  112188. * Sets matrices on a uniform variable.
  112189. * @param uniformName Name of the variable.
  112190. * @param matrices matrices to be set.
  112191. * @returns this effect.
  112192. */
  112193. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  112194. /**
  112195. * Sets matrix on a uniform variable.
  112196. * @param uniformName Name of the variable.
  112197. * @param matrix matrix to be set.
  112198. * @returns this effect.
  112199. */
  112200. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  112201. /**
  112202. * 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)
  112203. * @param uniformName Name of the variable.
  112204. * @param matrix matrix to be set.
  112205. * @returns this effect.
  112206. */
  112207. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  112208. /**
  112209. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  112210. * @param uniformName Name of the variable.
  112211. * @param matrix matrix to be set.
  112212. * @returns this effect.
  112213. */
  112214. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  112215. /**
  112216. * Sets a float on a uniform variable.
  112217. * @param uniformName Name of the variable.
  112218. * @param value value to be set.
  112219. * @returns this effect.
  112220. */
  112221. setFloat(uniformName: string, value: number): Effect;
  112222. /**
  112223. * Sets a boolean on a uniform variable.
  112224. * @param uniformName Name of the variable.
  112225. * @param bool value to be set.
  112226. * @returns this effect.
  112227. */
  112228. setBool(uniformName: string, bool: boolean): Effect;
  112229. /**
  112230. * Sets a Vector2 on a uniform variable.
  112231. * @param uniformName Name of the variable.
  112232. * @param vector2 vector2 to be set.
  112233. * @returns this effect.
  112234. */
  112235. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  112236. /**
  112237. * Sets a float2 on a uniform variable.
  112238. * @param uniformName Name of the variable.
  112239. * @param x First float in float2.
  112240. * @param y Second float in float2.
  112241. * @returns this effect.
  112242. */
  112243. setFloat2(uniformName: string, x: number, y: number): Effect;
  112244. /**
  112245. * Sets a Vector3 on a uniform variable.
  112246. * @param uniformName Name of the variable.
  112247. * @param vector3 Value to be set.
  112248. * @returns this effect.
  112249. */
  112250. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  112251. /**
  112252. * Sets a float3 on a uniform variable.
  112253. * @param uniformName Name of the variable.
  112254. * @param x First float in float3.
  112255. * @param y Second float in float3.
  112256. * @param z Third float in float3.
  112257. * @returns this effect.
  112258. */
  112259. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  112260. /**
  112261. * Sets a Vector4 on a uniform variable.
  112262. * @param uniformName Name of the variable.
  112263. * @param vector4 Value to be set.
  112264. * @returns this effect.
  112265. */
  112266. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  112267. /**
  112268. * Sets a float4 on a uniform variable.
  112269. * @param uniformName Name of the variable.
  112270. * @param x First float in float4.
  112271. * @param y Second float in float4.
  112272. * @param z Third float in float4.
  112273. * @param w Fourth float in float4.
  112274. * @returns this effect.
  112275. */
  112276. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  112277. /**
  112278. * Sets a Color3 on a uniform variable.
  112279. * @param uniformName Name of the variable.
  112280. * @param color3 Value to be set.
  112281. * @returns this effect.
  112282. */
  112283. setColor3(uniformName: string, color3: IColor3Like): Effect;
  112284. /**
  112285. * Sets a Color4 on a uniform variable.
  112286. * @param uniformName Name of the variable.
  112287. * @param color3 Value to be set.
  112288. * @param alpha Alpha value to be set.
  112289. * @returns this effect.
  112290. */
  112291. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  112292. /**
  112293. * Sets a Color4 on a uniform variable
  112294. * @param uniformName defines the name of the variable
  112295. * @param color4 defines the value to be set
  112296. * @returns this effect.
  112297. */
  112298. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  112299. /** Release all associated resources */
  112300. dispose(): void;
  112301. /**
  112302. * This function will add a new shader to the shader store
  112303. * @param name the name of the shader
  112304. * @param pixelShader optional pixel shader content
  112305. * @param vertexShader optional vertex shader content
  112306. */
  112307. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  112308. /**
  112309. * Store of each shader (The can be looked up using effect.key)
  112310. */
  112311. static ShadersStore: {
  112312. [key: string]: string;
  112313. };
  112314. /**
  112315. * Store of each included file for a shader (The can be looked up using effect.key)
  112316. */
  112317. static IncludesShadersStore: {
  112318. [key: string]: string;
  112319. };
  112320. /**
  112321. * Resets the cache of effects.
  112322. */
  112323. static ResetCache(): void;
  112324. }
  112325. }
  112326. declare module BABYLON {
  112327. /**
  112328. * Interface used to describe the capabilities of the engine relatively to the current browser
  112329. */
  112330. export interface EngineCapabilities {
  112331. /** Maximum textures units per fragment shader */
  112332. maxTexturesImageUnits: number;
  112333. /** Maximum texture units per vertex shader */
  112334. maxVertexTextureImageUnits: number;
  112335. /** Maximum textures units in the entire pipeline */
  112336. maxCombinedTexturesImageUnits: number;
  112337. /** Maximum texture size */
  112338. maxTextureSize: number;
  112339. /** Maximum texture samples */
  112340. maxSamples?: number;
  112341. /** Maximum cube texture size */
  112342. maxCubemapTextureSize: number;
  112343. /** Maximum render texture size */
  112344. maxRenderTextureSize: number;
  112345. /** Maximum number of vertex attributes */
  112346. maxVertexAttribs: number;
  112347. /** Maximum number of varyings */
  112348. maxVaryingVectors: number;
  112349. /** Maximum number of uniforms per vertex shader */
  112350. maxVertexUniformVectors: number;
  112351. /** Maximum number of uniforms per fragment shader */
  112352. maxFragmentUniformVectors: number;
  112353. /** Defines if standard derivates (dx/dy) are supported */
  112354. standardDerivatives: boolean;
  112355. /** Defines if s3tc texture compression is supported */
  112356. s3tc?: WEBGL_compressed_texture_s3tc;
  112357. /** Defines if pvrtc texture compression is supported */
  112358. pvrtc: any;
  112359. /** Defines if etc1 texture compression is supported */
  112360. etc1: any;
  112361. /** Defines if etc2 texture compression is supported */
  112362. etc2: any;
  112363. /** Defines if astc texture compression is supported */
  112364. astc: any;
  112365. /** Defines if float textures are supported */
  112366. textureFloat: boolean;
  112367. /** Defines if vertex array objects are supported */
  112368. vertexArrayObject: boolean;
  112369. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112370. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112371. /** Gets the maximum level of anisotropy supported */
  112372. maxAnisotropy: number;
  112373. /** Defines if instancing is supported */
  112374. instancedArrays: boolean;
  112375. /** Defines if 32 bits indices are supported */
  112376. uintIndices: boolean;
  112377. /** Defines if high precision shaders are supported */
  112378. highPrecisionShaderSupported: boolean;
  112379. /** Defines if depth reading in the fragment shader is supported */
  112380. fragmentDepthSupported: boolean;
  112381. /** Defines if float texture linear filtering is supported*/
  112382. textureFloatLinearFiltering: boolean;
  112383. /** Defines if rendering to float textures is supported */
  112384. textureFloatRender: boolean;
  112385. /** Defines if half float textures are supported*/
  112386. textureHalfFloat: boolean;
  112387. /** Defines if half float texture linear filtering is supported*/
  112388. textureHalfFloatLinearFiltering: boolean;
  112389. /** Defines if rendering to half float textures is supported */
  112390. textureHalfFloatRender: boolean;
  112391. /** Defines if textureLOD shader command is supported */
  112392. textureLOD: boolean;
  112393. /** Defines if draw buffers extension is supported */
  112394. drawBuffersExtension: boolean;
  112395. /** Defines if depth textures are supported */
  112396. depthTextureExtension: boolean;
  112397. /** Defines if float color buffer are supported */
  112398. colorBufferFloat: boolean;
  112399. /** Gets disjoint timer query extension (null if not supported) */
  112400. timerQuery?: EXT_disjoint_timer_query;
  112401. /** Defines if timestamp can be used with timer query */
  112402. canUseTimestampForTimerQuery: boolean;
  112403. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112404. multiview?: any;
  112405. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112406. oculusMultiview?: any;
  112407. /** Function used to let the system compiles shaders in background */
  112408. parallelShaderCompile?: {
  112409. COMPLETION_STATUS_KHR: number;
  112410. };
  112411. /** Max number of texture samples for MSAA */
  112412. maxMSAASamples: number;
  112413. /** Defines if the blend min max extension is supported */
  112414. blendMinMax: boolean;
  112415. }
  112416. }
  112417. declare module BABYLON {
  112418. /**
  112419. * @hidden
  112420. **/
  112421. export class DepthCullingState {
  112422. private _isDepthTestDirty;
  112423. private _isDepthMaskDirty;
  112424. private _isDepthFuncDirty;
  112425. private _isCullFaceDirty;
  112426. private _isCullDirty;
  112427. private _isZOffsetDirty;
  112428. private _isFrontFaceDirty;
  112429. private _depthTest;
  112430. private _depthMask;
  112431. private _depthFunc;
  112432. private _cull;
  112433. private _cullFace;
  112434. private _zOffset;
  112435. private _frontFace;
  112436. /**
  112437. * Initializes the state.
  112438. */
  112439. constructor();
  112440. get isDirty(): boolean;
  112441. get zOffset(): number;
  112442. set zOffset(value: number);
  112443. get cullFace(): Nullable<number>;
  112444. set cullFace(value: Nullable<number>);
  112445. get cull(): Nullable<boolean>;
  112446. set cull(value: Nullable<boolean>);
  112447. get depthFunc(): Nullable<number>;
  112448. set depthFunc(value: Nullable<number>);
  112449. get depthMask(): boolean;
  112450. set depthMask(value: boolean);
  112451. get depthTest(): boolean;
  112452. set depthTest(value: boolean);
  112453. get frontFace(): Nullable<number>;
  112454. set frontFace(value: Nullable<number>);
  112455. reset(): void;
  112456. apply(gl: WebGLRenderingContext): void;
  112457. }
  112458. }
  112459. declare module BABYLON {
  112460. /**
  112461. * @hidden
  112462. **/
  112463. export class StencilState {
  112464. /** 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 */
  112465. static readonly ALWAYS: number;
  112466. /** Passed to stencilOperation to specify that stencil value must be kept */
  112467. static readonly KEEP: number;
  112468. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112469. static readonly REPLACE: number;
  112470. private _isStencilTestDirty;
  112471. private _isStencilMaskDirty;
  112472. private _isStencilFuncDirty;
  112473. private _isStencilOpDirty;
  112474. private _stencilTest;
  112475. private _stencilMask;
  112476. private _stencilFunc;
  112477. private _stencilFuncRef;
  112478. private _stencilFuncMask;
  112479. private _stencilOpStencilFail;
  112480. private _stencilOpDepthFail;
  112481. private _stencilOpStencilDepthPass;
  112482. get isDirty(): boolean;
  112483. get stencilFunc(): number;
  112484. set stencilFunc(value: number);
  112485. get stencilFuncRef(): number;
  112486. set stencilFuncRef(value: number);
  112487. get stencilFuncMask(): number;
  112488. set stencilFuncMask(value: number);
  112489. get stencilOpStencilFail(): number;
  112490. set stencilOpStencilFail(value: number);
  112491. get stencilOpDepthFail(): number;
  112492. set stencilOpDepthFail(value: number);
  112493. get stencilOpStencilDepthPass(): number;
  112494. set stencilOpStencilDepthPass(value: number);
  112495. get stencilMask(): number;
  112496. set stencilMask(value: number);
  112497. get stencilTest(): boolean;
  112498. set stencilTest(value: boolean);
  112499. constructor();
  112500. reset(): void;
  112501. apply(gl: WebGLRenderingContext): void;
  112502. }
  112503. }
  112504. declare module BABYLON {
  112505. /**
  112506. * @hidden
  112507. **/
  112508. export class AlphaState {
  112509. private _isAlphaBlendDirty;
  112510. private _isBlendFunctionParametersDirty;
  112511. private _isBlendEquationParametersDirty;
  112512. private _isBlendConstantsDirty;
  112513. private _alphaBlend;
  112514. private _blendFunctionParameters;
  112515. private _blendEquationParameters;
  112516. private _blendConstants;
  112517. /**
  112518. * Initializes the state.
  112519. */
  112520. constructor();
  112521. get isDirty(): boolean;
  112522. get alphaBlend(): boolean;
  112523. set alphaBlend(value: boolean);
  112524. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112525. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112526. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112527. reset(): void;
  112528. apply(gl: WebGLRenderingContext): void;
  112529. }
  112530. }
  112531. declare module BABYLON {
  112532. /** @hidden */
  112533. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112534. attributeProcessor(attribute: string): string;
  112535. varyingProcessor(varying: string, isFragment: boolean): string;
  112536. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112537. }
  112538. }
  112539. declare module BABYLON {
  112540. /**
  112541. * Interface for attribute information associated with buffer instanciation
  112542. */
  112543. export interface InstancingAttributeInfo {
  112544. /**
  112545. * Name of the GLSL attribute
  112546. * if attribute index is not specified, this is used to retrieve the index from the effect
  112547. */
  112548. attributeName: string;
  112549. /**
  112550. * Index/offset of the attribute in the vertex shader
  112551. * if not specified, this will be computes from the name.
  112552. */
  112553. index?: number;
  112554. /**
  112555. * size of the attribute, 1, 2, 3 or 4
  112556. */
  112557. attributeSize: number;
  112558. /**
  112559. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112560. */
  112561. offset: number;
  112562. /**
  112563. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112564. * default to 1
  112565. */
  112566. divisor?: number;
  112567. /**
  112568. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112569. * default is FLOAT
  112570. */
  112571. attributeType?: number;
  112572. /**
  112573. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112574. */
  112575. normalized?: boolean;
  112576. }
  112577. }
  112578. declare module BABYLON {
  112579. interface ThinEngine {
  112580. /**
  112581. * Update a video texture
  112582. * @param texture defines the texture to update
  112583. * @param video defines the video element to use
  112584. * @param invertY defines if data must be stored with Y axis inverted
  112585. */
  112586. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112587. }
  112588. }
  112589. declare module BABYLON {
  112590. interface ThinEngine {
  112591. /**
  112592. * Creates a dynamic texture
  112593. * @param width defines the width of the texture
  112594. * @param height defines the height of the texture
  112595. * @param generateMipMaps defines if the engine should generate the mip levels
  112596. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112597. * @returns the dynamic texture inside an InternalTexture
  112598. */
  112599. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112600. /**
  112601. * Update the content of a dynamic texture
  112602. * @param texture defines the texture to update
  112603. * @param canvas defines the canvas containing the source
  112604. * @param invertY defines if data must be stored with Y axis inverted
  112605. * @param premulAlpha defines if alpha is stored as premultiplied
  112606. * @param format defines the format of the data
  112607. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112608. */
  112609. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112610. }
  112611. }
  112612. declare module BABYLON {
  112613. /**
  112614. * Settings for finer control over video usage
  112615. */
  112616. export interface VideoTextureSettings {
  112617. /**
  112618. * Applies `autoplay` to video, if specified
  112619. */
  112620. autoPlay?: boolean;
  112621. /**
  112622. * Applies `loop` to video, if specified
  112623. */
  112624. loop?: boolean;
  112625. /**
  112626. * Automatically updates internal texture from video at every frame in the render loop
  112627. */
  112628. autoUpdateTexture: boolean;
  112629. /**
  112630. * Image src displayed during the video loading or until the user interacts with the video.
  112631. */
  112632. poster?: string;
  112633. }
  112634. /**
  112635. * If you want to display a video in your scene, this is the special texture for that.
  112636. * This special texture works similar to other textures, with the exception of a few parameters.
  112637. * @see https://doc.babylonjs.com/how_to/video_texture
  112638. */
  112639. export class VideoTexture extends Texture {
  112640. /**
  112641. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112642. */
  112643. readonly autoUpdateTexture: boolean;
  112644. /**
  112645. * The video instance used by the texture internally
  112646. */
  112647. readonly video: HTMLVideoElement;
  112648. private _onUserActionRequestedObservable;
  112649. /**
  112650. * Event triggerd when a dom action is required by the user to play the video.
  112651. * This happens due to recent changes in browser policies preventing video to auto start.
  112652. */
  112653. get onUserActionRequestedObservable(): Observable<Texture>;
  112654. private _generateMipMaps;
  112655. private _stillImageCaptured;
  112656. private _displayingPosterTexture;
  112657. private _settings;
  112658. private _createInternalTextureOnEvent;
  112659. private _frameId;
  112660. private _currentSrc;
  112661. /**
  112662. * Creates a video texture.
  112663. * If you want to display a video in your scene, this is the special texture for that.
  112664. * This special texture works similar to other textures, with the exception of a few parameters.
  112665. * @see https://doc.babylonjs.com/how_to/video_texture
  112666. * @param name optional name, will detect from video source, if not defined
  112667. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112668. * @param scene is obviously the current scene.
  112669. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112670. * @param invertY is false by default but can be used to invert video on Y axis
  112671. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112672. * @param settings allows finer control over video usage
  112673. */
  112674. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112675. private _getName;
  112676. private _getVideo;
  112677. private _createInternalTexture;
  112678. private reset;
  112679. /**
  112680. * @hidden Internal method to initiate `update`.
  112681. */
  112682. _rebuild(): void;
  112683. /**
  112684. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112685. */
  112686. update(): void;
  112687. /**
  112688. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112689. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112690. */
  112691. updateTexture(isVisible: boolean): void;
  112692. protected _updateInternalTexture: () => void;
  112693. /**
  112694. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112695. * @param url New url.
  112696. */
  112697. updateURL(url: string): void;
  112698. /**
  112699. * Clones the texture.
  112700. * @returns the cloned texture
  112701. */
  112702. clone(): VideoTexture;
  112703. /**
  112704. * Dispose the texture and release its associated resources.
  112705. */
  112706. dispose(): void;
  112707. /**
  112708. * Creates a video texture straight from a stream.
  112709. * @param scene Define the scene the texture should be created in
  112710. * @param stream Define the stream the texture should be created from
  112711. * @returns The created video texture as a promise
  112712. */
  112713. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112714. /**
  112715. * Creates a video texture straight from your WebCam video feed.
  112716. * @param scene Define the scene the texture should be created in
  112717. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112718. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112719. * @returns The created video texture as a promise
  112720. */
  112721. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112722. minWidth: number;
  112723. maxWidth: number;
  112724. minHeight: number;
  112725. maxHeight: number;
  112726. deviceId: string;
  112727. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112728. /**
  112729. * Creates a video texture straight from your WebCam video feed.
  112730. * @param scene Define the scene the texture should be created in
  112731. * @param onReady Define a callback to triggered once the texture will be ready
  112732. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112733. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112734. */
  112735. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112736. minWidth: number;
  112737. maxWidth: number;
  112738. minHeight: number;
  112739. maxHeight: number;
  112740. deviceId: string;
  112741. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112742. }
  112743. }
  112744. declare module BABYLON {
  112745. /**
  112746. * Defines the interface used by objects working like Scene
  112747. * @hidden
  112748. */
  112749. export interface ISceneLike {
  112750. _addPendingData(data: any): void;
  112751. _removePendingData(data: any): void;
  112752. offlineProvider: IOfflineProvider;
  112753. }
  112754. /** Interface defining initialization parameters for Engine class */
  112755. export interface EngineOptions extends WebGLContextAttributes {
  112756. /**
  112757. * Defines if the engine should no exceed a specified device ratio
  112758. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112759. */
  112760. limitDeviceRatio?: number;
  112761. /**
  112762. * Defines if webvr should be enabled automatically
  112763. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112764. */
  112765. autoEnableWebVR?: boolean;
  112766. /**
  112767. * Defines if webgl2 should be turned off even if supported
  112768. * @see https://doc.babylonjs.com/features/webgl2
  112769. */
  112770. disableWebGL2Support?: boolean;
  112771. /**
  112772. * Defines if webaudio should be initialized as well
  112773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112774. */
  112775. audioEngine?: boolean;
  112776. /**
  112777. * Defines if animations should run using a deterministic lock step
  112778. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112779. */
  112780. deterministicLockstep?: boolean;
  112781. /** Defines the maximum steps to use with deterministic lock step mode */
  112782. lockstepMaxSteps?: number;
  112783. /** Defines the seconds between each deterministic lock step */
  112784. timeStep?: number;
  112785. /**
  112786. * Defines that engine should ignore context lost events
  112787. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112788. */
  112789. doNotHandleContextLost?: boolean;
  112790. /**
  112791. * Defines that engine should ignore modifying touch action attribute and style
  112792. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112793. */
  112794. doNotHandleTouchAction?: boolean;
  112795. /**
  112796. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112797. */
  112798. useHighPrecisionFloats?: boolean;
  112799. /**
  112800. * Make the canvas XR Compatible for XR sessions
  112801. */
  112802. xrCompatible?: boolean;
  112803. /**
  112804. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  112805. */
  112806. useHighPrecisionMatrix?: boolean;
  112807. }
  112808. /**
  112809. * The base engine class (root of all engines)
  112810. */
  112811. export class ThinEngine {
  112812. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112813. static ExceptionList: ({
  112814. key: string;
  112815. capture: string;
  112816. captureConstraint: number;
  112817. targets: string[];
  112818. } | {
  112819. key: string;
  112820. capture: null;
  112821. captureConstraint: null;
  112822. targets: string[];
  112823. })[];
  112824. /** @hidden */
  112825. static _TextureLoaders: IInternalTextureLoader[];
  112826. /**
  112827. * Returns the current npm package of the sdk
  112828. */
  112829. static get NpmPackage(): string;
  112830. /**
  112831. * Returns the current version of the framework
  112832. */
  112833. static get Version(): string;
  112834. /**
  112835. * Returns a string describing the current engine
  112836. */
  112837. get description(): string;
  112838. /**
  112839. * Gets or sets the epsilon value used by collision engine
  112840. */
  112841. static CollisionsEpsilon: number;
  112842. /**
  112843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112844. */
  112845. static get ShadersRepository(): string;
  112846. static set ShadersRepository(value: string);
  112847. /** @hidden */
  112848. _shaderProcessor: IShaderProcessor;
  112849. /**
  112850. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112851. */
  112852. forcePOTTextures: boolean;
  112853. /**
  112854. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112855. */
  112856. isFullscreen: boolean;
  112857. /**
  112858. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112859. */
  112860. cullBackFaces: boolean;
  112861. /**
  112862. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112863. */
  112864. renderEvenInBackground: boolean;
  112865. /**
  112866. * Gets or sets a boolean indicating that cache can be kept between frames
  112867. */
  112868. preventCacheWipeBetweenFrames: boolean;
  112869. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112870. validateShaderPrograms: boolean;
  112871. /**
  112872. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112873. * This can provide greater z depth for distant objects.
  112874. */
  112875. useReverseDepthBuffer: boolean;
  112876. /**
  112877. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112878. */
  112879. disableUniformBuffers: boolean;
  112880. /** @hidden */
  112881. _uniformBuffers: UniformBuffer[];
  112882. /**
  112883. * Gets a boolean indicating that the engine supports uniform buffers
  112884. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112885. */
  112886. get supportsUniformBuffers(): boolean;
  112887. /** @hidden */
  112888. _gl: WebGLRenderingContext;
  112889. /** @hidden */
  112890. _webGLVersion: number;
  112891. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112892. protected _windowIsBackground: boolean;
  112893. protected _creationOptions: EngineOptions;
  112894. protected _highPrecisionShadersAllowed: boolean;
  112895. /** @hidden */
  112896. get _shouldUseHighPrecisionShader(): boolean;
  112897. /**
  112898. * Gets a boolean indicating that only power of 2 textures are supported
  112899. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112900. */
  112901. get needPOTTextures(): boolean;
  112902. /** @hidden */
  112903. _badOS: boolean;
  112904. /** @hidden */
  112905. _badDesktopOS: boolean;
  112906. private _hardwareScalingLevel;
  112907. /** @hidden */
  112908. _caps: EngineCapabilities;
  112909. private _isStencilEnable;
  112910. private _glVersion;
  112911. private _glRenderer;
  112912. private _glVendor;
  112913. /** @hidden */
  112914. _videoTextureSupported: boolean;
  112915. protected _renderingQueueLaunched: boolean;
  112916. protected _activeRenderLoops: (() => void)[];
  112917. /**
  112918. * Observable signaled when a context lost event is raised
  112919. */
  112920. onContextLostObservable: Observable<ThinEngine>;
  112921. /**
  112922. * Observable signaled when a context restored event is raised
  112923. */
  112924. onContextRestoredObservable: Observable<ThinEngine>;
  112925. private _onContextLost;
  112926. private _onContextRestored;
  112927. protected _contextWasLost: boolean;
  112928. /** @hidden */
  112929. _doNotHandleContextLost: boolean;
  112930. /**
  112931. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112932. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112933. */
  112934. get doNotHandleContextLost(): boolean;
  112935. set doNotHandleContextLost(value: boolean);
  112936. /**
  112937. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112938. */
  112939. disableVertexArrayObjects: boolean;
  112940. /** @hidden */
  112941. protected _colorWrite: boolean;
  112942. /** @hidden */
  112943. protected _colorWriteChanged: boolean;
  112944. /** @hidden */
  112945. protected _depthCullingState: DepthCullingState;
  112946. /** @hidden */
  112947. protected _stencilState: StencilState;
  112948. /** @hidden */
  112949. _alphaState: AlphaState;
  112950. /** @hidden */
  112951. _alphaMode: number;
  112952. /** @hidden */
  112953. _alphaEquation: number;
  112954. /** @hidden */
  112955. _internalTexturesCache: InternalTexture[];
  112956. /** @hidden */
  112957. protected _activeChannel: number;
  112958. private _currentTextureChannel;
  112959. /** @hidden */
  112960. protected _boundTexturesCache: {
  112961. [key: string]: Nullable<InternalTexture>;
  112962. };
  112963. /** @hidden */
  112964. protected _currentEffect: Nullable<Effect>;
  112965. /** @hidden */
  112966. protected _currentProgram: Nullable<WebGLProgram>;
  112967. private _compiledEffects;
  112968. private _vertexAttribArraysEnabled;
  112969. /** @hidden */
  112970. protected _cachedViewport: Nullable<IViewportLike>;
  112971. private _cachedVertexArrayObject;
  112972. /** @hidden */
  112973. protected _cachedVertexBuffers: any;
  112974. /** @hidden */
  112975. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112976. /** @hidden */
  112977. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112978. /** @hidden */
  112979. _currentRenderTarget: Nullable<InternalTexture>;
  112980. private _uintIndicesCurrentlySet;
  112981. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112982. /** @hidden */
  112983. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112984. /** @hidden */
  112985. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112986. private _currentBufferPointers;
  112987. private _currentInstanceLocations;
  112988. private _currentInstanceBuffers;
  112989. private _textureUnits;
  112990. /** @hidden */
  112991. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112992. /** @hidden */
  112993. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112994. /** @hidden */
  112995. _boundRenderFunction: any;
  112996. private _vaoRecordInProgress;
  112997. private _mustWipeVertexAttributes;
  112998. private _emptyTexture;
  112999. private _emptyCubeTexture;
  113000. private _emptyTexture3D;
  113001. private _emptyTexture2DArray;
  113002. /** @hidden */
  113003. _frameHandler: number;
  113004. private _nextFreeTextureSlots;
  113005. private _maxSimultaneousTextures;
  113006. private _activeRequests;
  113007. /** @hidden */
  113008. _transformTextureUrl: Nullable<(url: string) => string>;
  113009. protected get _supportsHardwareTextureRescaling(): boolean;
  113010. private _framebufferDimensionsObject;
  113011. /**
  113012. * sets the object from which width and height will be taken from when getting render width and height
  113013. * Will fallback to the gl object
  113014. * @param dimensions the framebuffer width and height that will be used.
  113015. */
  113016. set framebufferDimensionsObject(dimensions: Nullable<{
  113017. framebufferWidth: number;
  113018. framebufferHeight: number;
  113019. }>);
  113020. /**
  113021. * Gets the current viewport
  113022. */
  113023. get currentViewport(): Nullable<IViewportLike>;
  113024. /**
  113025. * Gets the default empty texture
  113026. */
  113027. get emptyTexture(): InternalTexture;
  113028. /**
  113029. * Gets the default empty 3D texture
  113030. */
  113031. get emptyTexture3D(): InternalTexture;
  113032. /**
  113033. * Gets the default empty 2D array texture
  113034. */
  113035. get emptyTexture2DArray(): InternalTexture;
  113036. /**
  113037. * Gets the default empty cube texture
  113038. */
  113039. get emptyCubeTexture(): InternalTexture;
  113040. /**
  113041. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  113042. */
  113043. readonly premultipliedAlpha: boolean;
  113044. /**
  113045. * Observable event triggered before each texture is initialized
  113046. */
  113047. onBeforeTextureInitObservable: Observable<Texture>;
  113048. /**
  113049. * Creates a new engine
  113050. * @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
  113051. * @param antialias defines enable antialiasing (default: false)
  113052. * @param options defines further options to be sent to the getContext() function
  113053. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113054. */
  113055. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113056. private _rebuildInternalTextures;
  113057. private _rebuildEffects;
  113058. /**
  113059. * Gets a boolean indicating if all created effects are ready
  113060. * @returns true if all effects are ready
  113061. */
  113062. areAllEffectsReady(): boolean;
  113063. protected _rebuildBuffers(): void;
  113064. protected _initGLContext(): void;
  113065. /**
  113066. * Gets version of the current webGL context
  113067. */
  113068. get webGLVersion(): number;
  113069. /**
  113070. * Gets a string idenfifying the name of the class
  113071. * @returns "Engine" string
  113072. */
  113073. getClassName(): string;
  113074. /**
  113075. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  113076. */
  113077. get isStencilEnable(): boolean;
  113078. /** @hidden */
  113079. _prepareWorkingCanvas(): void;
  113080. /**
  113081. * Reset the texture cache to empty state
  113082. */
  113083. resetTextureCache(): void;
  113084. /**
  113085. * Gets an object containing information about the current webGL context
  113086. * @returns an object containing the vender, the renderer and the version of the current webGL context
  113087. */
  113088. getGlInfo(): {
  113089. vendor: string;
  113090. renderer: string;
  113091. version: string;
  113092. };
  113093. /**
  113094. * Defines the hardware scaling level.
  113095. * By default the hardware scaling level is computed from the window device ratio.
  113096. * 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.
  113097. * @param level defines the level to use
  113098. */
  113099. setHardwareScalingLevel(level: number): void;
  113100. /**
  113101. * Gets the current hardware scaling level.
  113102. * By default the hardware scaling level is computed from the window device ratio.
  113103. * 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.
  113104. * @returns a number indicating the current hardware scaling level
  113105. */
  113106. getHardwareScalingLevel(): number;
  113107. /**
  113108. * Gets the list of loaded textures
  113109. * @returns an array containing all loaded textures
  113110. */
  113111. getLoadedTexturesCache(): InternalTexture[];
  113112. /**
  113113. * Gets the object containing all engine capabilities
  113114. * @returns the EngineCapabilities object
  113115. */
  113116. getCaps(): EngineCapabilities;
  113117. /**
  113118. * stop executing a render loop function and remove it from the execution array
  113119. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  113120. */
  113121. stopRenderLoop(renderFunction?: () => void): void;
  113122. /** @hidden */
  113123. _renderLoop(): void;
  113124. /**
  113125. * Gets the HTML canvas attached with the current webGL context
  113126. * @returns a HTML canvas
  113127. */
  113128. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  113129. /**
  113130. * Gets host window
  113131. * @returns the host window object
  113132. */
  113133. getHostWindow(): Nullable<Window>;
  113134. /**
  113135. * Gets the current render width
  113136. * @param useScreen defines if screen size must be used (or the current render target if any)
  113137. * @returns a number defining the current render width
  113138. */
  113139. getRenderWidth(useScreen?: boolean): number;
  113140. /**
  113141. * Gets the current render height
  113142. * @param useScreen defines if screen size must be used (or the current render target if any)
  113143. * @returns a number defining the current render height
  113144. */
  113145. getRenderHeight(useScreen?: boolean): number;
  113146. /**
  113147. * Can be used to override the current requestAnimationFrame requester.
  113148. * @hidden
  113149. */
  113150. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113151. /**
  113152. * Register and execute a render loop. The engine can have more than one render function
  113153. * @param renderFunction defines the function to continuously execute
  113154. */
  113155. runRenderLoop(renderFunction: () => void): void;
  113156. /**
  113157. * Clear the current render buffer or the current render target (if any is set up)
  113158. * @param color defines the color to use
  113159. * @param backBuffer defines if the back buffer must be cleared
  113160. * @param depth defines if the depth buffer must be cleared
  113161. * @param stencil defines if the stencil buffer must be cleared
  113162. */
  113163. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113164. private _viewportCached;
  113165. /** @hidden */
  113166. _viewport(x: number, y: number, width: number, height: number): void;
  113167. /**
  113168. * Set the WebGL's viewport
  113169. * @param viewport defines the viewport element to be used
  113170. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113171. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113172. */
  113173. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113174. /**
  113175. * Begin a new frame
  113176. */
  113177. beginFrame(): void;
  113178. /**
  113179. * Enf the current frame
  113180. */
  113181. endFrame(): void;
  113182. /**
  113183. * Resize the view according to the canvas' size
  113184. */
  113185. resize(): void;
  113186. /**
  113187. * Force a specific size of the canvas
  113188. * @param width defines the new canvas' width
  113189. * @param height defines the new canvas' height
  113190. * @returns true if the size was changed
  113191. */
  113192. setSize(width: number, height: number): boolean;
  113193. /**
  113194. * Binds the frame buffer to the specified texture.
  113195. * @param texture The texture to render to or null for the default canvas
  113196. * @param faceIndex The face of the texture to render to in case of cube texture
  113197. * @param requiredWidth The width of the target to render to
  113198. * @param requiredHeight The height of the target to render to
  113199. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113200. * @param lodLevel defines the lod level to bind to the frame buffer
  113201. * @param layer defines the 2d array index to bind to frame buffer to
  113202. */
  113203. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  113204. /** @hidden */
  113205. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113206. /**
  113207. * Unbind the current render target texture from the webGL context
  113208. * @param texture defines the render target texture to unbind
  113209. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113210. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113211. */
  113212. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113213. /**
  113214. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  113215. */
  113216. flushFramebuffer(): void;
  113217. /**
  113218. * Unbind the current render target and bind the default framebuffer
  113219. */
  113220. restoreDefaultFramebuffer(): void;
  113221. /** @hidden */
  113222. protected _resetVertexBufferBinding(): void;
  113223. /**
  113224. * Creates a vertex buffer
  113225. * @param data the data for the vertex buffer
  113226. * @returns the new WebGL static buffer
  113227. */
  113228. createVertexBuffer(data: DataArray): DataBuffer;
  113229. private _createVertexBuffer;
  113230. /**
  113231. * Creates a dynamic vertex buffer
  113232. * @param data the data for the dynamic vertex buffer
  113233. * @returns the new WebGL dynamic buffer
  113234. */
  113235. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113236. protected _resetIndexBufferBinding(): void;
  113237. /**
  113238. * Creates a new index buffer
  113239. * @param indices defines the content of the index buffer
  113240. * @param updatable defines if the index buffer must be updatable
  113241. * @returns a new webGL buffer
  113242. */
  113243. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  113244. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  113245. /**
  113246. * Bind a webGL buffer to the webGL context
  113247. * @param buffer defines the buffer to bind
  113248. */
  113249. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  113250. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  113251. private bindBuffer;
  113252. /**
  113253. * update the bound buffer with the given data
  113254. * @param data defines the data to update
  113255. */
  113256. updateArrayBuffer(data: Float32Array): void;
  113257. private _vertexAttribPointer;
  113258. /** @hidden */
  113259. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  113260. private _bindVertexBuffersAttributes;
  113261. /**
  113262. * Records a vertex array object
  113263. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  113264. * @param vertexBuffers defines the list of vertex buffers to store
  113265. * @param indexBuffer defines the index buffer to store
  113266. * @param effect defines the effect to store
  113267. * @returns the new vertex array object
  113268. */
  113269. recordVertexArrayObject(vertexBuffers: {
  113270. [key: string]: VertexBuffer;
  113271. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113272. /**
  113273. * Bind a specific vertex array object
  113274. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  113275. * @param vertexArrayObject defines the vertex array object to bind
  113276. * @param indexBuffer defines the index buffer to bind
  113277. */
  113278. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  113279. /**
  113280. * Bind webGl buffers directly to the webGL context
  113281. * @param vertexBuffer defines the vertex buffer to bind
  113282. * @param indexBuffer defines the index buffer to bind
  113283. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113284. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113285. * @param effect defines the effect associated with the vertex buffer
  113286. */
  113287. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  113288. private _unbindVertexArrayObject;
  113289. /**
  113290. * Bind a list of vertex buffers to the webGL context
  113291. * @param vertexBuffers defines the list of vertex buffers to bind
  113292. * @param indexBuffer defines the index buffer to bind
  113293. * @param effect defines the effect associated with the vertex buffers
  113294. */
  113295. bindBuffers(vertexBuffers: {
  113296. [key: string]: Nullable<VertexBuffer>;
  113297. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  113298. /**
  113299. * Unbind all instance attributes
  113300. */
  113301. unbindInstanceAttributes(): void;
  113302. /**
  113303. * Release and free the memory of a vertex array object
  113304. * @param vao defines the vertex array object to delete
  113305. */
  113306. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  113307. /** @hidden */
  113308. _releaseBuffer(buffer: DataBuffer): boolean;
  113309. protected _deleteBuffer(buffer: DataBuffer): void;
  113310. /**
  113311. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  113312. * @param instancesBuffer defines the webGL buffer to update and bind
  113313. * @param data defines the data to store in the buffer
  113314. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  113315. */
  113316. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113317. /**
  113318. * Bind the content of a webGL buffer used with instantiation
  113319. * @param instancesBuffer defines the webGL buffer to bind
  113320. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113321. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113322. */
  113323. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113324. /**
  113325. * Disable the instance attribute corresponding to the name in parameter
  113326. * @param name defines the name of the attribute to disable
  113327. */
  113328. disableInstanceAttributeByName(name: string): void;
  113329. /**
  113330. * Disable the instance attribute corresponding to the location in parameter
  113331. * @param attributeLocation defines the attribute location of the attribute to disable
  113332. */
  113333. disableInstanceAttribute(attributeLocation: number): void;
  113334. /**
  113335. * Disable the attribute corresponding to the location in parameter
  113336. * @param attributeLocation defines the attribute location of the attribute to disable
  113337. */
  113338. disableAttributeByIndex(attributeLocation: number): void;
  113339. /**
  113340. * Send a draw order
  113341. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113342. * @param indexStart defines the starting index
  113343. * @param indexCount defines the number of index to draw
  113344. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113345. */
  113346. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113347. /**
  113348. * Draw a list of points
  113349. * @param verticesStart defines the index of first vertex to draw
  113350. * @param verticesCount defines the count of vertices to draw
  113351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113352. */
  113353. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113354. /**
  113355. * Draw a list of unindexed primitives
  113356. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113357. * @param verticesStart defines the index of first vertex to draw
  113358. * @param verticesCount defines the count of vertices to draw
  113359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113360. */
  113361. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113362. /**
  113363. * Draw a list of indexed primitives
  113364. * @param fillMode defines the primitive to use
  113365. * @param indexStart defines the starting index
  113366. * @param indexCount defines the number of index to draw
  113367. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113368. */
  113369. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113370. /**
  113371. * Draw a list of unindexed primitives
  113372. * @param fillMode defines the primitive to use
  113373. * @param verticesStart defines the index of first vertex to draw
  113374. * @param verticesCount defines the count of vertices to draw
  113375. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113376. */
  113377. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113378. private _drawMode;
  113379. /** @hidden */
  113380. protected _reportDrawCall(): void;
  113381. /** @hidden */
  113382. _releaseEffect(effect: Effect): void;
  113383. /** @hidden */
  113384. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113385. /**
  113386. * Create a new effect (used to store vertex/fragment shaders)
  113387. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113388. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113389. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113390. * @param samplers defines an array of string used to represent textures
  113391. * @param defines defines the string containing the defines to use to compile the shaders
  113392. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113393. * @param onCompiled defines a function to call when the effect creation is successful
  113394. * @param onError defines a function to call when the effect creation has failed
  113395. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113396. * @returns the new Effect
  113397. */
  113398. 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;
  113399. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113400. private _compileShader;
  113401. private _compileRawShader;
  113402. /** @hidden */
  113403. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113404. /**
  113405. * Directly creates a webGL program
  113406. * @param pipelineContext defines the pipeline context to attach to
  113407. * @param vertexCode defines the vertex shader code to use
  113408. * @param fragmentCode defines the fragment shader code to use
  113409. * @param context defines the webGL context to use (if not set, the current one will be used)
  113410. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113411. * @returns the new webGL program
  113412. */
  113413. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113414. /**
  113415. * Creates a webGL program
  113416. * @param pipelineContext defines the pipeline context to attach to
  113417. * @param vertexCode defines the vertex shader code to use
  113418. * @param fragmentCode defines the fragment shader code to use
  113419. * @param defines defines the string containing the defines to use to compile the shaders
  113420. * @param context defines the webGL context to use (if not set, the current one will be used)
  113421. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113422. * @returns the new webGL program
  113423. */
  113424. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113425. /**
  113426. * Creates a new pipeline context
  113427. * @returns the new pipeline
  113428. */
  113429. createPipelineContext(): IPipelineContext;
  113430. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113431. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113432. /** @hidden */
  113433. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113434. /** @hidden */
  113435. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113436. /** @hidden */
  113437. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113438. /**
  113439. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113440. * @param pipelineContext defines the pipeline context to use
  113441. * @param uniformsNames defines the list of uniform names
  113442. * @returns an array of webGL uniform locations
  113443. */
  113444. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113445. /**
  113446. * Gets the lsit of active attributes for a given webGL program
  113447. * @param pipelineContext defines the pipeline context to use
  113448. * @param attributesNames defines the list of attribute names to get
  113449. * @returns an array of indices indicating the offset of each attribute
  113450. */
  113451. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113452. /**
  113453. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113454. * @param effect defines the effect to activate
  113455. */
  113456. enableEffect(effect: Nullable<Effect>): void;
  113457. /**
  113458. * Set the value of an uniform to a number (int)
  113459. * @param uniform defines the webGL uniform location where to store the value
  113460. * @param value defines the int number to store
  113461. */
  113462. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113463. /**
  113464. * Set the value of an uniform to an array of int32
  113465. * @param uniform defines the webGL uniform location where to store the value
  113466. * @param array defines the array of int32 to store
  113467. */
  113468. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113469. /**
  113470. * Set the value of an uniform to an array of int32 (stored as vec2)
  113471. * @param uniform defines the webGL uniform location where to store the value
  113472. * @param array defines the array of int32 to store
  113473. */
  113474. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113475. /**
  113476. * Set the value of an uniform to an array of int32 (stored as vec3)
  113477. * @param uniform defines the webGL uniform location where to store the value
  113478. * @param array defines the array of int32 to store
  113479. */
  113480. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113481. /**
  113482. * Set the value of an uniform to an array of int32 (stored as vec4)
  113483. * @param uniform defines the webGL uniform location where to store the value
  113484. * @param array defines the array of int32 to store
  113485. */
  113486. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113487. /**
  113488. * Set the value of an uniform to an array of number
  113489. * @param uniform defines the webGL uniform location where to store the value
  113490. * @param array defines the array of number to store
  113491. */
  113492. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113493. /**
  113494. * Set the value of an uniform to an array of number (stored as vec2)
  113495. * @param uniform defines the webGL uniform location where to store the value
  113496. * @param array defines the array of number to store
  113497. */
  113498. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113499. /**
  113500. * Set the value of an uniform to an array of number (stored as vec3)
  113501. * @param uniform defines the webGL uniform location where to store the value
  113502. * @param array defines the array of number to store
  113503. */
  113504. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113505. /**
  113506. * Set the value of an uniform to an array of number (stored as vec4)
  113507. * @param uniform defines the webGL uniform location where to store the value
  113508. * @param array defines the array of number to store
  113509. */
  113510. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113511. /**
  113512. * Set the value of an uniform to an array of float32 (stored as matrices)
  113513. * @param uniform defines the webGL uniform location where to store the value
  113514. * @param matrices defines the array of float32 to store
  113515. */
  113516. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113517. /**
  113518. * Set the value of an uniform to a matrix (3x3)
  113519. * @param uniform defines the webGL uniform location where to store the value
  113520. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113521. */
  113522. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113523. /**
  113524. * Set the value of an uniform to a matrix (2x2)
  113525. * @param uniform defines the webGL uniform location where to store the value
  113526. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113527. */
  113528. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113529. /**
  113530. * Set the value of an uniform to a number (float)
  113531. * @param uniform defines the webGL uniform location where to store the value
  113532. * @param value defines the float number to store
  113533. */
  113534. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113535. /**
  113536. * Set the value of an uniform to a vec2
  113537. * @param uniform defines the webGL uniform location where to store the value
  113538. * @param x defines the 1st component of the value
  113539. * @param y defines the 2nd component of the value
  113540. */
  113541. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113542. /**
  113543. * Set the value of an uniform to a vec3
  113544. * @param uniform defines the webGL uniform location where to store the value
  113545. * @param x defines the 1st component of the value
  113546. * @param y defines the 2nd component of the value
  113547. * @param z defines the 3rd component of the value
  113548. */
  113549. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113550. /**
  113551. * Set the value of an uniform to a vec4
  113552. * @param uniform defines the webGL uniform location where to store the value
  113553. * @param x defines the 1st component of the value
  113554. * @param y defines the 2nd component of the value
  113555. * @param z defines the 3rd component of the value
  113556. * @param w defines the 4th component of the value
  113557. */
  113558. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113559. /**
  113560. * Apply all cached states (depth, culling, stencil and alpha)
  113561. */
  113562. applyStates(): void;
  113563. /**
  113564. * Enable or disable color writing
  113565. * @param enable defines the state to set
  113566. */
  113567. setColorWrite(enable: boolean): void;
  113568. /**
  113569. * Gets a boolean indicating if color writing is enabled
  113570. * @returns the current color writing state
  113571. */
  113572. getColorWrite(): boolean;
  113573. /**
  113574. * Gets the depth culling state manager
  113575. */
  113576. get depthCullingState(): DepthCullingState;
  113577. /**
  113578. * Gets the alpha state manager
  113579. */
  113580. get alphaState(): AlphaState;
  113581. /**
  113582. * Gets the stencil state manager
  113583. */
  113584. get stencilState(): StencilState;
  113585. /**
  113586. * Clears the list of texture accessible through engine.
  113587. * This can help preventing texture load conflict due to name collision.
  113588. */
  113589. clearInternalTexturesCache(): void;
  113590. /**
  113591. * Force the entire cache to be cleared
  113592. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113593. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113594. */
  113595. wipeCaches(bruteForce?: boolean): void;
  113596. /** @hidden */
  113597. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113598. min: number;
  113599. mag: number;
  113600. };
  113601. /** @hidden */
  113602. _createTexture(): WebGLTexture;
  113603. /**
  113604. * Usually called from Texture.ts.
  113605. * Passed information to create a WebGLTexture
  113606. * @param url defines a value which contains one of the following:
  113607. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113608. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113609. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113610. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113611. * @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)
  113612. * @param scene needed for loading to the correct scene
  113613. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113614. * @param onLoad optional callback to be called upon successful completion
  113615. * @param onError optional callback to be called upon failure
  113616. * @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
  113617. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113618. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113619. * @param forcedExtension defines the extension to use to pick the right loader
  113620. * @param mimeType defines an optional mime type
  113621. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113622. */
  113623. 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;
  113624. /**
  113625. * Loads an image as an HTMLImageElement.
  113626. * @param input url string, ArrayBuffer, or Blob to load
  113627. * @param onLoad callback called when the image successfully loads
  113628. * @param onError callback called when the image fails to load
  113629. * @param offlineProvider offline provider for caching
  113630. * @param mimeType optional mime type
  113631. * @returns the HTMLImageElement of the loaded image
  113632. * @hidden
  113633. */
  113634. 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>;
  113635. /**
  113636. * @hidden
  113637. */
  113638. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113639. private _unpackFlipYCached;
  113640. /**
  113641. * In case you are sharing the context with other applications, it might
  113642. * be interested to not cache the unpack flip y state to ensure a consistent
  113643. * value would be set.
  113644. */
  113645. enableUnpackFlipYCached: boolean;
  113646. /** @hidden */
  113647. _unpackFlipY(value: boolean): void;
  113648. /** @hidden */
  113649. _getUnpackAlignement(): number;
  113650. private _getTextureTarget;
  113651. /**
  113652. * Update the sampling mode of a given texture
  113653. * @param samplingMode defines the required sampling mode
  113654. * @param texture defines the texture to update
  113655. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113656. */
  113657. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113658. /**
  113659. * Update the sampling mode of a given texture
  113660. * @param texture defines the texture to update
  113661. * @param wrapU defines the texture wrap mode of the u coordinates
  113662. * @param wrapV defines the texture wrap mode of the v coordinates
  113663. * @param wrapR defines the texture wrap mode of the r coordinates
  113664. */
  113665. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113666. /** @hidden */
  113667. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113668. width: number;
  113669. height: number;
  113670. layers?: number;
  113671. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113672. /** @hidden */
  113673. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113674. /** @hidden */
  113675. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113676. /**
  113677. * Update a portion of an internal texture
  113678. * @param texture defines the texture to update
  113679. * @param imageData defines the data to store into the texture
  113680. * @param xOffset defines the x coordinates of the update rectangle
  113681. * @param yOffset defines the y coordinates of the update rectangle
  113682. * @param width defines the width of the update rectangle
  113683. * @param height defines the height of the update rectangle
  113684. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113685. * @param lod defines the lod level to update (0 by default)
  113686. */
  113687. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113688. /** @hidden */
  113689. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113690. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113691. private _prepareWebGLTexture;
  113692. /** @hidden */
  113693. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113694. private _getDepthStencilBuffer;
  113695. /** @hidden */
  113696. _releaseFramebufferObjects(texture: InternalTexture): void;
  113697. /** @hidden */
  113698. _releaseTexture(texture: InternalTexture): void;
  113699. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113700. protected _setProgram(program: WebGLProgram): void;
  113701. protected _boundUniforms: {
  113702. [key: number]: WebGLUniformLocation;
  113703. };
  113704. /**
  113705. * Binds an effect to the webGL context
  113706. * @param effect defines the effect to bind
  113707. */
  113708. bindSamplers(effect: Effect): void;
  113709. private _activateCurrentTexture;
  113710. /** @hidden */
  113711. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113712. /** @hidden */
  113713. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113714. /**
  113715. * Unbind all textures from the webGL context
  113716. */
  113717. unbindAllTextures(): void;
  113718. /**
  113719. * Sets a texture to the according uniform.
  113720. * @param channel The texture channel
  113721. * @param uniform The uniform to set
  113722. * @param texture The texture to apply
  113723. */
  113724. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113725. private _bindSamplerUniformToChannel;
  113726. private _getTextureWrapMode;
  113727. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113728. /**
  113729. * Sets an array of texture to the webGL context
  113730. * @param channel defines the channel where the texture array must be set
  113731. * @param uniform defines the associated uniform location
  113732. * @param textures defines the array of textures to bind
  113733. */
  113734. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113735. /** @hidden */
  113736. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113737. private _setTextureParameterFloat;
  113738. private _setTextureParameterInteger;
  113739. /**
  113740. * Unbind all vertex attributes from the webGL context
  113741. */
  113742. unbindAllAttributes(): void;
  113743. /**
  113744. * 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
  113745. */
  113746. releaseEffects(): void;
  113747. /**
  113748. * Dispose and release all associated resources
  113749. */
  113750. dispose(): void;
  113751. /**
  113752. * Attach a new callback raised when context lost event is fired
  113753. * @param callback defines the callback to call
  113754. */
  113755. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113756. /**
  113757. * Attach a new callback raised when context restored event is fired
  113758. * @param callback defines the callback to call
  113759. */
  113760. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113761. /**
  113762. * Get the current error code of the webGL context
  113763. * @returns the error code
  113764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113765. */
  113766. getError(): number;
  113767. private _canRenderToFloatFramebuffer;
  113768. private _canRenderToHalfFloatFramebuffer;
  113769. private _canRenderToFramebuffer;
  113770. /** @hidden */
  113771. _getWebGLTextureType(type: number): number;
  113772. /** @hidden */
  113773. _getInternalFormat(format: number): number;
  113774. /** @hidden */
  113775. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113776. /** @hidden */
  113777. _getRGBAMultiSampleBufferFormat(type: number): number;
  113778. /** @hidden */
  113779. _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;
  113780. /**
  113781. * Loads a file from a url
  113782. * @param url url to load
  113783. * @param onSuccess callback called when the file successfully loads
  113784. * @param onProgress callback called while file is loading (if the server supports this mode)
  113785. * @param offlineProvider defines the offline provider for caching
  113786. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113787. * @param onError callback called when the file fails to load
  113788. * @returns a file request object
  113789. * @hidden
  113790. */
  113791. 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;
  113792. /**
  113793. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113794. * @param x defines the x coordinate of the rectangle where pixels must be read
  113795. * @param y defines the y coordinate of the rectangle where pixels must be read
  113796. * @param width defines the width of the rectangle where pixels must be read
  113797. * @param height defines the height of the rectangle where pixels must be read
  113798. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113799. * @returns a Uint8Array containing RGBA colors
  113800. */
  113801. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113802. private static _isSupported;
  113803. /**
  113804. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113805. * @returns true if the engine can be created
  113806. * @ignorenaming
  113807. */
  113808. static isSupported(): boolean;
  113809. /**
  113810. * Find the next highest power of two.
  113811. * @param x Number to start search from.
  113812. * @return Next highest power of two.
  113813. */
  113814. static CeilingPOT(x: number): number;
  113815. /**
  113816. * Find the next lowest power of two.
  113817. * @param x Number to start search from.
  113818. * @return Next lowest power of two.
  113819. */
  113820. static FloorPOT(x: number): number;
  113821. /**
  113822. * Find the nearest power of two.
  113823. * @param x Number to start search from.
  113824. * @return Next nearest power of two.
  113825. */
  113826. static NearestPOT(x: number): number;
  113827. /**
  113828. * Get the closest exponent of two
  113829. * @param value defines the value to approximate
  113830. * @param max defines the maximum value to return
  113831. * @param mode defines how to define the closest value
  113832. * @returns closest exponent of two of the given value
  113833. */
  113834. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113835. /**
  113836. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113837. * @param func - the function to be called
  113838. * @param requester - the object that will request the next frame. Falls back to window.
  113839. * @returns frame number
  113840. */
  113841. static QueueNewFrame(func: () => void, requester?: any): number;
  113842. /**
  113843. * Gets host document
  113844. * @returns the host document object
  113845. */
  113846. getHostDocument(): Nullable<Document>;
  113847. }
  113848. }
  113849. declare module BABYLON {
  113850. /**
  113851. * Class representing spherical harmonics coefficients to the 3rd degree
  113852. */
  113853. export class SphericalHarmonics {
  113854. /**
  113855. * Defines whether or not the harmonics have been prescaled for rendering.
  113856. */
  113857. preScaled: boolean;
  113858. /**
  113859. * The l0,0 coefficients of the spherical harmonics
  113860. */
  113861. l00: Vector3;
  113862. /**
  113863. * The l1,-1 coefficients of the spherical harmonics
  113864. */
  113865. l1_1: Vector3;
  113866. /**
  113867. * The l1,0 coefficients of the spherical harmonics
  113868. */
  113869. l10: Vector3;
  113870. /**
  113871. * The l1,1 coefficients of the spherical harmonics
  113872. */
  113873. l11: Vector3;
  113874. /**
  113875. * The l2,-2 coefficients of the spherical harmonics
  113876. */
  113877. l2_2: Vector3;
  113878. /**
  113879. * The l2,-1 coefficients of the spherical harmonics
  113880. */
  113881. l2_1: Vector3;
  113882. /**
  113883. * The l2,0 coefficients of the spherical harmonics
  113884. */
  113885. l20: Vector3;
  113886. /**
  113887. * The l2,1 coefficients of the spherical harmonics
  113888. */
  113889. l21: Vector3;
  113890. /**
  113891. * The l2,2 coefficients of the spherical harmonics
  113892. */
  113893. l22: Vector3;
  113894. /**
  113895. * Adds a light to the spherical harmonics
  113896. * @param direction the direction of the light
  113897. * @param color the color of the light
  113898. * @param deltaSolidAngle the delta solid angle of the light
  113899. */
  113900. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113901. /**
  113902. * Scales the spherical harmonics by the given amount
  113903. * @param scale the amount to scale
  113904. */
  113905. scaleInPlace(scale: number): void;
  113906. /**
  113907. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113908. *
  113909. * ```
  113910. * E_lm = A_l * L_lm
  113911. * ```
  113912. *
  113913. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113914. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113915. * the scaling factors are given in equation 9.
  113916. */
  113917. convertIncidentRadianceToIrradiance(): void;
  113918. /**
  113919. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113920. *
  113921. * ```
  113922. * L = (1/pi) * E * rho
  113923. * ```
  113924. *
  113925. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113926. */
  113927. convertIrradianceToLambertianRadiance(): void;
  113928. /**
  113929. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113930. * required operations at run time.
  113931. *
  113932. * This is simply done by scaling back the SH with Ylm constants parameter.
  113933. * The trigonometric part being applied by the shader at run time.
  113934. */
  113935. preScaleForRendering(): void;
  113936. /**
  113937. * Constructs a spherical harmonics from an array.
  113938. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113939. * @returns the spherical harmonics
  113940. */
  113941. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113942. /**
  113943. * Gets the spherical harmonics from polynomial
  113944. * @param polynomial the spherical polynomial
  113945. * @returns the spherical harmonics
  113946. */
  113947. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113948. }
  113949. /**
  113950. * Class representing spherical polynomial coefficients to the 3rd degree
  113951. */
  113952. export class SphericalPolynomial {
  113953. private _harmonics;
  113954. /**
  113955. * The spherical harmonics used to create the polynomials.
  113956. */
  113957. get preScaledHarmonics(): SphericalHarmonics;
  113958. /**
  113959. * The x coefficients of the spherical polynomial
  113960. */
  113961. x: Vector3;
  113962. /**
  113963. * The y coefficients of the spherical polynomial
  113964. */
  113965. y: Vector3;
  113966. /**
  113967. * The z coefficients of the spherical polynomial
  113968. */
  113969. z: Vector3;
  113970. /**
  113971. * The xx coefficients of the spherical polynomial
  113972. */
  113973. xx: Vector3;
  113974. /**
  113975. * The yy coefficients of the spherical polynomial
  113976. */
  113977. yy: Vector3;
  113978. /**
  113979. * The zz coefficients of the spherical polynomial
  113980. */
  113981. zz: Vector3;
  113982. /**
  113983. * The xy coefficients of the spherical polynomial
  113984. */
  113985. xy: Vector3;
  113986. /**
  113987. * The yz coefficients of the spherical polynomial
  113988. */
  113989. yz: Vector3;
  113990. /**
  113991. * The zx coefficients of the spherical polynomial
  113992. */
  113993. zx: Vector3;
  113994. /**
  113995. * Adds an ambient color to the spherical polynomial
  113996. * @param color the color to add
  113997. */
  113998. addAmbient(color: Color3): void;
  113999. /**
  114000. * Scales the spherical polynomial by the given amount
  114001. * @param scale the amount to scale
  114002. */
  114003. scaleInPlace(scale: number): void;
  114004. /**
  114005. * Gets the spherical polynomial from harmonics
  114006. * @param harmonics the spherical harmonics
  114007. * @returns the spherical polynomial
  114008. */
  114009. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  114010. /**
  114011. * Constructs a spherical polynomial from an array.
  114012. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  114013. * @returns the spherical polynomial
  114014. */
  114015. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  114016. }
  114017. }
  114018. declare module BABYLON {
  114019. /**
  114020. * Defines the source of the internal texture
  114021. */
  114022. export enum InternalTextureSource {
  114023. /**
  114024. * The source of the texture data is unknown
  114025. */
  114026. Unknown = 0,
  114027. /**
  114028. * Texture data comes from an URL
  114029. */
  114030. Url = 1,
  114031. /**
  114032. * Texture data is only used for temporary storage
  114033. */
  114034. Temp = 2,
  114035. /**
  114036. * Texture data comes from raw data (ArrayBuffer)
  114037. */
  114038. Raw = 3,
  114039. /**
  114040. * Texture content is dynamic (video or dynamic texture)
  114041. */
  114042. Dynamic = 4,
  114043. /**
  114044. * Texture content is generated by rendering to it
  114045. */
  114046. RenderTarget = 5,
  114047. /**
  114048. * Texture content is part of a multi render target process
  114049. */
  114050. MultiRenderTarget = 6,
  114051. /**
  114052. * Texture data comes from a cube data file
  114053. */
  114054. Cube = 7,
  114055. /**
  114056. * Texture data comes from a raw cube data
  114057. */
  114058. CubeRaw = 8,
  114059. /**
  114060. * Texture data come from a prefiltered cube data file
  114061. */
  114062. CubePrefiltered = 9,
  114063. /**
  114064. * Texture content is raw 3D data
  114065. */
  114066. Raw3D = 10,
  114067. /**
  114068. * Texture content is raw 2D array data
  114069. */
  114070. Raw2DArray = 11,
  114071. /**
  114072. * Texture content is a depth texture
  114073. */
  114074. Depth = 12,
  114075. /**
  114076. * Texture data comes from a raw cube data encoded with RGBD
  114077. */
  114078. CubeRawRGBD = 13
  114079. }
  114080. /**
  114081. * Class used to store data associated with WebGL texture data for the engine
  114082. * This class should not be used directly
  114083. */
  114084. export class InternalTexture {
  114085. /** @hidden */
  114086. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  114087. /**
  114088. * Defines if the texture is ready
  114089. */
  114090. isReady: boolean;
  114091. /**
  114092. * Defines if the texture is a cube texture
  114093. */
  114094. isCube: boolean;
  114095. /**
  114096. * Defines if the texture contains 3D data
  114097. */
  114098. is3D: boolean;
  114099. /**
  114100. * Defines if the texture contains 2D array data
  114101. */
  114102. is2DArray: boolean;
  114103. /**
  114104. * Defines if the texture contains multiview data
  114105. */
  114106. isMultiview: boolean;
  114107. /**
  114108. * Gets the URL used to load this texture
  114109. */
  114110. url: string;
  114111. /**
  114112. * Gets the sampling mode of the texture
  114113. */
  114114. samplingMode: number;
  114115. /**
  114116. * Gets a boolean indicating if the texture needs mipmaps generation
  114117. */
  114118. generateMipMaps: boolean;
  114119. /**
  114120. * Gets the number of samples used by the texture (WebGL2+ only)
  114121. */
  114122. samples: number;
  114123. /**
  114124. * Gets the type of the texture (int, float...)
  114125. */
  114126. type: number;
  114127. /**
  114128. * Gets the format of the texture (RGB, RGBA...)
  114129. */
  114130. format: number;
  114131. /**
  114132. * Observable called when the texture is loaded
  114133. */
  114134. onLoadedObservable: Observable<InternalTexture>;
  114135. /**
  114136. * Gets the width of the texture
  114137. */
  114138. width: number;
  114139. /**
  114140. * Gets the height of the texture
  114141. */
  114142. height: number;
  114143. /**
  114144. * Gets the depth of the texture
  114145. */
  114146. depth: number;
  114147. /**
  114148. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  114149. */
  114150. baseWidth: number;
  114151. /**
  114152. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  114153. */
  114154. baseHeight: number;
  114155. /**
  114156. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  114157. */
  114158. baseDepth: number;
  114159. /**
  114160. * Gets a boolean indicating if the texture is inverted on Y axis
  114161. */
  114162. invertY: boolean;
  114163. /** @hidden */
  114164. _invertVScale: boolean;
  114165. /** @hidden */
  114166. _associatedChannel: number;
  114167. /** @hidden */
  114168. _source: InternalTextureSource;
  114169. /** @hidden */
  114170. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  114171. /** @hidden */
  114172. _bufferView: Nullable<ArrayBufferView>;
  114173. /** @hidden */
  114174. _bufferViewArray: Nullable<ArrayBufferView[]>;
  114175. /** @hidden */
  114176. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  114177. /** @hidden */
  114178. _size: number;
  114179. /** @hidden */
  114180. _extension: string;
  114181. /** @hidden */
  114182. _files: Nullable<string[]>;
  114183. /** @hidden */
  114184. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114185. /** @hidden */
  114186. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114187. /** @hidden */
  114188. _framebuffer: Nullable<WebGLFramebuffer>;
  114189. /** @hidden */
  114190. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  114191. /** @hidden */
  114192. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  114193. /** @hidden */
  114194. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  114195. /** @hidden */
  114196. _attachments: Nullable<number[]>;
  114197. /** @hidden */
  114198. _textureArray: Nullable<InternalTexture[]>;
  114199. /** @hidden */
  114200. _cachedCoordinatesMode: Nullable<number>;
  114201. /** @hidden */
  114202. _cachedWrapU: Nullable<number>;
  114203. /** @hidden */
  114204. _cachedWrapV: Nullable<number>;
  114205. /** @hidden */
  114206. _cachedWrapR: Nullable<number>;
  114207. /** @hidden */
  114208. _cachedAnisotropicFilteringLevel: Nullable<number>;
  114209. /** @hidden */
  114210. _isDisabled: boolean;
  114211. /** @hidden */
  114212. _compression: Nullable<string>;
  114213. /** @hidden */
  114214. _generateStencilBuffer: boolean;
  114215. /** @hidden */
  114216. _generateDepthBuffer: boolean;
  114217. /** @hidden */
  114218. _comparisonFunction: number;
  114219. /** @hidden */
  114220. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  114221. /** @hidden */
  114222. _lodGenerationScale: number;
  114223. /** @hidden */
  114224. _lodGenerationOffset: number;
  114225. /** @hidden */
  114226. _depthStencilTexture: Nullable<InternalTexture>;
  114227. /** @hidden */
  114228. _colorTextureArray: Nullable<WebGLTexture>;
  114229. /** @hidden */
  114230. _depthStencilTextureArray: Nullable<WebGLTexture>;
  114231. /** @hidden */
  114232. _lodTextureHigh: Nullable<BaseTexture>;
  114233. /** @hidden */
  114234. _lodTextureMid: Nullable<BaseTexture>;
  114235. /** @hidden */
  114236. _lodTextureLow: Nullable<BaseTexture>;
  114237. /** @hidden */
  114238. _isRGBD: boolean;
  114239. /** @hidden */
  114240. _linearSpecularLOD: boolean;
  114241. /** @hidden */
  114242. _irradianceTexture: Nullable<BaseTexture>;
  114243. /** @hidden */
  114244. _webGLTexture: Nullable<WebGLTexture>;
  114245. /** @hidden */
  114246. _references: number;
  114247. private _engine;
  114248. /**
  114249. * Gets the Engine the texture belongs to.
  114250. * @returns The babylon engine
  114251. */
  114252. getEngine(): ThinEngine;
  114253. /**
  114254. * Gets the data source type of the texture
  114255. */
  114256. get source(): InternalTextureSource;
  114257. /**
  114258. * Creates a new InternalTexture
  114259. * @param engine defines the engine to use
  114260. * @param source defines the type of data that will be used
  114261. * @param delayAllocation if the texture allocation should be delayed (default: false)
  114262. */
  114263. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  114264. /**
  114265. * Increments the number of references (ie. the number of Texture that point to it)
  114266. */
  114267. incrementReferences(): void;
  114268. /**
  114269. * Change the size of the texture (not the size of the content)
  114270. * @param width defines the new width
  114271. * @param height defines the new height
  114272. * @param depth defines the new depth (1 by default)
  114273. */
  114274. updateSize(width: int, height: int, depth?: int): void;
  114275. /** @hidden */
  114276. _rebuild(): void;
  114277. /** @hidden */
  114278. _swapAndDie(target: InternalTexture): void;
  114279. /**
  114280. * Dispose the current allocated resources
  114281. */
  114282. dispose(): void;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * Class used to work with sound analyzer using fast fourier transform (FFT)
  114288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114289. */
  114290. export class Analyser {
  114291. /**
  114292. * Gets or sets the smoothing
  114293. * @ignorenaming
  114294. */
  114295. SMOOTHING: number;
  114296. /**
  114297. * Gets or sets the FFT table size
  114298. * @ignorenaming
  114299. */
  114300. FFT_SIZE: number;
  114301. /**
  114302. * Gets or sets the bar graph amplitude
  114303. * @ignorenaming
  114304. */
  114305. BARGRAPHAMPLITUDE: number;
  114306. /**
  114307. * Gets or sets the position of the debug canvas
  114308. * @ignorenaming
  114309. */
  114310. DEBUGCANVASPOS: {
  114311. x: number;
  114312. y: number;
  114313. };
  114314. /**
  114315. * Gets or sets the debug canvas size
  114316. * @ignorenaming
  114317. */
  114318. DEBUGCANVASSIZE: {
  114319. width: number;
  114320. height: number;
  114321. };
  114322. private _byteFreqs;
  114323. private _byteTime;
  114324. private _floatFreqs;
  114325. private _webAudioAnalyser;
  114326. private _debugCanvas;
  114327. private _debugCanvasContext;
  114328. private _scene;
  114329. private _registerFunc;
  114330. private _audioEngine;
  114331. /**
  114332. * Creates a new analyser
  114333. * @param scene defines hosting scene
  114334. */
  114335. constructor(scene: Scene);
  114336. /**
  114337. * Get the number of data values you will have to play with for the visualization
  114338. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114339. * @returns a number
  114340. */
  114341. getFrequencyBinCount(): number;
  114342. /**
  114343. * Gets the current frequency data as a byte array
  114344. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114345. * @returns a Uint8Array
  114346. */
  114347. getByteFrequencyData(): Uint8Array;
  114348. /**
  114349. * Gets the current waveform as a byte array
  114350. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114351. * @returns a Uint8Array
  114352. */
  114353. getByteTimeDomainData(): Uint8Array;
  114354. /**
  114355. * Gets the current frequency data as a float array
  114356. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114357. * @returns a Float32Array
  114358. */
  114359. getFloatFrequencyData(): Float32Array;
  114360. /**
  114361. * Renders the debug canvas
  114362. */
  114363. drawDebugCanvas(): void;
  114364. /**
  114365. * Stops rendering the debug canvas and removes it
  114366. */
  114367. stopDebugCanvas(): void;
  114368. /**
  114369. * Connects two audio nodes
  114370. * @param inputAudioNode defines first node to connect
  114371. * @param outputAudioNode defines second node to connect
  114372. */
  114373. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114374. /**
  114375. * Releases all associated resources
  114376. */
  114377. dispose(): void;
  114378. }
  114379. }
  114380. declare module BABYLON {
  114381. /**
  114382. * This represents an audio engine and it is responsible
  114383. * to play, synchronize and analyse sounds throughout the application.
  114384. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114385. */
  114386. export interface IAudioEngine extends IDisposable {
  114387. /**
  114388. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114389. */
  114390. readonly canUseWebAudio: boolean;
  114391. /**
  114392. * Gets the current AudioContext if available.
  114393. */
  114394. readonly audioContext: Nullable<AudioContext>;
  114395. /**
  114396. * The master gain node defines the global audio volume of your audio engine.
  114397. */
  114398. readonly masterGain: GainNode;
  114399. /**
  114400. * Gets whether or not mp3 are supported by your browser.
  114401. */
  114402. readonly isMP3supported: boolean;
  114403. /**
  114404. * Gets whether or not ogg are supported by your browser.
  114405. */
  114406. readonly isOGGsupported: boolean;
  114407. /**
  114408. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114409. * @ignoreNaming
  114410. */
  114411. WarnedWebAudioUnsupported: boolean;
  114412. /**
  114413. * Defines if the audio engine relies on a custom unlocked button.
  114414. * In this case, the embedded button will not be displayed.
  114415. */
  114416. useCustomUnlockedButton: boolean;
  114417. /**
  114418. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114419. */
  114420. readonly unlocked: boolean;
  114421. /**
  114422. * Event raised when audio has been unlocked on the browser.
  114423. */
  114424. onAudioUnlockedObservable: Observable<AudioEngine>;
  114425. /**
  114426. * Event raised when audio has been locked on the browser.
  114427. */
  114428. onAudioLockedObservable: Observable<AudioEngine>;
  114429. /**
  114430. * Flags the audio engine in Locked state.
  114431. * This happens due to new browser policies preventing audio to autoplay.
  114432. */
  114433. lock(): void;
  114434. /**
  114435. * Unlocks the audio engine once a user action has been done on the dom.
  114436. * This is helpful to resume play once browser policies have been satisfied.
  114437. */
  114438. unlock(): void;
  114439. /**
  114440. * Gets the global volume sets on the master gain.
  114441. * @returns the global volume if set or -1 otherwise
  114442. */
  114443. getGlobalVolume(): number;
  114444. /**
  114445. * Sets the global volume of your experience (sets on the master gain).
  114446. * @param newVolume Defines the new global volume of the application
  114447. */
  114448. setGlobalVolume(newVolume: number): void;
  114449. /**
  114450. * Connect the audio engine to an audio analyser allowing some amazing
  114451. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114452. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114453. * @param analyser The analyser to connect to the engine
  114454. */
  114455. connectToAnalyser(analyser: Analyser): void;
  114456. }
  114457. /**
  114458. * This represents the default audio engine used in babylon.
  114459. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114460. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114461. */
  114462. export class AudioEngine implements IAudioEngine {
  114463. private _audioContext;
  114464. private _audioContextInitialized;
  114465. private _muteButton;
  114466. private _hostElement;
  114467. /**
  114468. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114469. */
  114470. canUseWebAudio: boolean;
  114471. /**
  114472. * The master gain node defines the global audio volume of your audio engine.
  114473. */
  114474. masterGain: GainNode;
  114475. /**
  114476. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114477. * @ignoreNaming
  114478. */
  114479. WarnedWebAudioUnsupported: boolean;
  114480. /**
  114481. * Gets whether or not mp3 are supported by your browser.
  114482. */
  114483. isMP3supported: boolean;
  114484. /**
  114485. * Gets whether or not ogg are supported by your browser.
  114486. */
  114487. isOGGsupported: boolean;
  114488. /**
  114489. * Gets whether audio has been unlocked on the device.
  114490. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114491. * a user interaction has happened.
  114492. */
  114493. unlocked: boolean;
  114494. /**
  114495. * Defines if the audio engine relies on a custom unlocked button.
  114496. * In this case, the embedded button will not be displayed.
  114497. */
  114498. useCustomUnlockedButton: boolean;
  114499. /**
  114500. * Event raised when audio has been unlocked on the browser.
  114501. */
  114502. onAudioUnlockedObservable: Observable<AudioEngine>;
  114503. /**
  114504. * Event raised when audio has been locked on the browser.
  114505. */
  114506. onAudioLockedObservable: Observable<AudioEngine>;
  114507. /**
  114508. * Gets the current AudioContext if available.
  114509. */
  114510. get audioContext(): Nullable<AudioContext>;
  114511. private _connectedAnalyser;
  114512. /**
  114513. * Instantiates a new audio engine.
  114514. *
  114515. * There should be only one per page as some browsers restrict the number
  114516. * of audio contexts you can create.
  114517. * @param hostElement defines the host element where to display the mute icon if necessary
  114518. */
  114519. constructor(hostElement?: Nullable<HTMLElement>);
  114520. /**
  114521. * Flags the audio engine in Locked state.
  114522. * This happens due to new browser policies preventing audio to autoplay.
  114523. */
  114524. lock(): void;
  114525. /**
  114526. * Unlocks the audio engine once a user action has been done on the dom.
  114527. * This is helpful to resume play once browser policies have been satisfied.
  114528. */
  114529. unlock(): void;
  114530. private _resumeAudioContext;
  114531. private _initializeAudioContext;
  114532. private _tryToRun;
  114533. private _triggerRunningState;
  114534. private _triggerSuspendedState;
  114535. private _displayMuteButton;
  114536. private _moveButtonToTopLeft;
  114537. private _onResize;
  114538. private _hideMuteButton;
  114539. /**
  114540. * Destroy and release the resources associated with the audio ccontext.
  114541. */
  114542. dispose(): void;
  114543. /**
  114544. * Gets the global volume sets on the master gain.
  114545. * @returns the global volume if set or -1 otherwise
  114546. */
  114547. getGlobalVolume(): number;
  114548. /**
  114549. * Sets the global volume of your experience (sets on the master gain).
  114550. * @param newVolume Defines the new global volume of the application
  114551. */
  114552. setGlobalVolume(newVolume: number): void;
  114553. /**
  114554. * Connect the audio engine to an audio analyser allowing some amazing
  114555. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114556. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114557. * @param analyser The analyser to connect to the engine
  114558. */
  114559. connectToAnalyser(analyser: Analyser): void;
  114560. }
  114561. }
  114562. declare module BABYLON {
  114563. /**
  114564. * Interface used to present a loading screen while loading a scene
  114565. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114566. */
  114567. export interface ILoadingScreen {
  114568. /**
  114569. * Function called to display the loading screen
  114570. */
  114571. displayLoadingUI: () => void;
  114572. /**
  114573. * Function called to hide the loading screen
  114574. */
  114575. hideLoadingUI: () => void;
  114576. /**
  114577. * Gets or sets the color to use for the background
  114578. */
  114579. loadingUIBackgroundColor: string;
  114580. /**
  114581. * Gets or sets the text to display while loading
  114582. */
  114583. loadingUIText: string;
  114584. }
  114585. /**
  114586. * Class used for the default loading screen
  114587. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114588. */
  114589. export class DefaultLoadingScreen implements ILoadingScreen {
  114590. private _renderingCanvas;
  114591. private _loadingText;
  114592. private _loadingDivBackgroundColor;
  114593. private _loadingDiv;
  114594. private _loadingTextDiv;
  114595. /** Gets or sets the logo url to use for the default loading screen */
  114596. static DefaultLogoUrl: string;
  114597. /** Gets or sets the spinner url to use for the default loading screen */
  114598. static DefaultSpinnerUrl: string;
  114599. /**
  114600. * Creates a new default loading screen
  114601. * @param _renderingCanvas defines the canvas used to render the scene
  114602. * @param _loadingText defines the default text to display
  114603. * @param _loadingDivBackgroundColor defines the default background color
  114604. */
  114605. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114606. /**
  114607. * Function called to display the loading screen
  114608. */
  114609. displayLoadingUI(): void;
  114610. /**
  114611. * Function called to hide the loading screen
  114612. */
  114613. hideLoadingUI(): void;
  114614. /**
  114615. * Gets or sets the text to display while loading
  114616. */
  114617. set loadingUIText(text: string);
  114618. get loadingUIText(): string;
  114619. /**
  114620. * Gets or sets the color to use for the background
  114621. */
  114622. get loadingUIBackgroundColor(): string;
  114623. set loadingUIBackgroundColor(color: string);
  114624. private _resizeLoadingUI;
  114625. }
  114626. }
  114627. declare module BABYLON {
  114628. /**
  114629. * Interface for any object that can request an animation frame
  114630. */
  114631. export interface ICustomAnimationFrameRequester {
  114632. /**
  114633. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114634. */
  114635. renderFunction?: Function;
  114636. /**
  114637. * Called to request the next frame to render to
  114638. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114639. */
  114640. requestAnimationFrame: Function;
  114641. /**
  114642. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114643. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114644. */
  114645. requestID?: number;
  114646. }
  114647. }
  114648. declare module BABYLON {
  114649. /**
  114650. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114651. */
  114652. export class PerformanceMonitor {
  114653. private _enabled;
  114654. private _rollingFrameTime;
  114655. private _lastFrameTimeMs;
  114656. /**
  114657. * constructor
  114658. * @param frameSampleSize The number of samples required to saturate the sliding window
  114659. */
  114660. constructor(frameSampleSize?: number);
  114661. /**
  114662. * Samples current frame
  114663. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114664. */
  114665. sampleFrame(timeMs?: number): void;
  114666. /**
  114667. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114668. */
  114669. get averageFrameTime(): number;
  114670. /**
  114671. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114672. */
  114673. get averageFrameTimeVariance(): number;
  114674. /**
  114675. * Returns the frame time of the most recent frame
  114676. */
  114677. get instantaneousFrameTime(): number;
  114678. /**
  114679. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114680. */
  114681. get averageFPS(): number;
  114682. /**
  114683. * Returns the average framerate in frames per second using the most recent frame time
  114684. */
  114685. get instantaneousFPS(): number;
  114686. /**
  114687. * Returns true if enough samples have been taken to completely fill the sliding window
  114688. */
  114689. get isSaturated(): boolean;
  114690. /**
  114691. * Enables contributions to the sliding window sample set
  114692. */
  114693. enable(): void;
  114694. /**
  114695. * Disables contributions to the sliding window sample set
  114696. * Samples will not be interpolated over the disabled period
  114697. */
  114698. disable(): void;
  114699. /**
  114700. * Returns true if sampling is enabled
  114701. */
  114702. get isEnabled(): boolean;
  114703. /**
  114704. * Resets performance monitor
  114705. */
  114706. reset(): void;
  114707. }
  114708. /**
  114709. * RollingAverage
  114710. *
  114711. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114712. */
  114713. export class RollingAverage {
  114714. /**
  114715. * Current average
  114716. */
  114717. average: number;
  114718. /**
  114719. * Current variance
  114720. */
  114721. variance: number;
  114722. protected _samples: Array<number>;
  114723. protected _sampleCount: number;
  114724. protected _pos: number;
  114725. protected _m2: number;
  114726. /**
  114727. * constructor
  114728. * @param length The number of samples required to saturate the sliding window
  114729. */
  114730. constructor(length: number);
  114731. /**
  114732. * Adds a sample to the sample set
  114733. * @param v The sample value
  114734. */
  114735. add(v: number): void;
  114736. /**
  114737. * Returns previously added values or null if outside of history or outside the sliding window domain
  114738. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114739. * @return Value previously recorded with add() or null if outside of range
  114740. */
  114741. history(i: number): number;
  114742. /**
  114743. * Returns true if enough samples have been taken to completely fill the sliding window
  114744. * @return true if sample-set saturated
  114745. */
  114746. isSaturated(): boolean;
  114747. /**
  114748. * Resets the rolling average (equivalent to 0 samples taken so far)
  114749. */
  114750. reset(): void;
  114751. /**
  114752. * Wraps a value around the sample range boundaries
  114753. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114754. * @return Wrapped position in sample range
  114755. */
  114756. protected _wrapPosition(i: number): number;
  114757. }
  114758. }
  114759. declare module BABYLON {
  114760. /**
  114761. * This class is used to track a performance counter which is number based.
  114762. * The user has access to many properties which give statistics of different nature.
  114763. *
  114764. * The implementer can track two kinds of Performance Counter: time and count.
  114765. * 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.
  114766. * 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.
  114767. */
  114768. export class PerfCounter {
  114769. /**
  114770. * Gets or sets a global boolean to turn on and off all the counters
  114771. */
  114772. static Enabled: boolean;
  114773. /**
  114774. * Returns the smallest value ever
  114775. */
  114776. get min(): number;
  114777. /**
  114778. * Returns the biggest value ever
  114779. */
  114780. get max(): number;
  114781. /**
  114782. * Returns the average value since the performance counter is running
  114783. */
  114784. get average(): number;
  114785. /**
  114786. * Returns the average value of the last second the counter was monitored
  114787. */
  114788. get lastSecAverage(): number;
  114789. /**
  114790. * Returns the current value
  114791. */
  114792. get current(): number;
  114793. /**
  114794. * Gets the accumulated total
  114795. */
  114796. get total(): number;
  114797. /**
  114798. * Gets the total value count
  114799. */
  114800. get count(): number;
  114801. /**
  114802. * Creates a new counter
  114803. */
  114804. constructor();
  114805. /**
  114806. * Call this method to start monitoring a new frame.
  114807. * 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.
  114808. */
  114809. fetchNewFrame(): void;
  114810. /**
  114811. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114812. * @param newCount the count value to add to the monitored count
  114813. * @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.
  114814. */
  114815. addCount(newCount: number, fetchResult: boolean): void;
  114816. /**
  114817. * Start monitoring this performance counter
  114818. */
  114819. beginMonitoring(): void;
  114820. /**
  114821. * Compute the time lapsed since the previous beginMonitoring() call.
  114822. * @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
  114823. */
  114824. endMonitoring(newFrame?: boolean): void;
  114825. private _fetchResult;
  114826. private _startMonitoringTime;
  114827. private _min;
  114828. private _max;
  114829. private _average;
  114830. private _current;
  114831. private _totalValueCount;
  114832. private _totalAccumulated;
  114833. private _lastSecAverage;
  114834. private _lastSecAccumulated;
  114835. private _lastSecTime;
  114836. private _lastSecValueCount;
  114837. }
  114838. }
  114839. declare module BABYLON {
  114840. interface ThinEngine {
  114841. /**
  114842. * Sets alpha constants used by some alpha blending modes
  114843. * @param r defines the red component
  114844. * @param g defines the green component
  114845. * @param b defines the blue component
  114846. * @param a defines the alpha component
  114847. */
  114848. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114849. /**
  114850. * Sets the current alpha mode
  114851. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114852. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114853. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114854. */
  114855. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114856. /**
  114857. * Gets the current alpha mode
  114858. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114859. * @returns the current alpha mode
  114860. */
  114861. getAlphaMode(): number;
  114862. /**
  114863. * Sets the current alpha equation
  114864. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114865. */
  114866. setAlphaEquation(equation: number): void;
  114867. /**
  114868. * Gets the current alpha equation.
  114869. * @returns the current alpha equation
  114870. */
  114871. getAlphaEquation(): number;
  114872. }
  114873. }
  114874. declare module BABYLON {
  114875. interface ThinEngine {
  114876. /** @hidden */
  114877. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114878. }
  114879. }
  114880. declare module BABYLON {
  114881. /**
  114882. * Defines the interface used by display changed events
  114883. */
  114884. export interface IDisplayChangedEventArgs {
  114885. /** Gets the vrDisplay object (if any) */
  114886. vrDisplay: Nullable<any>;
  114887. /** Gets a boolean indicating if webVR is supported */
  114888. vrSupported: boolean;
  114889. }
  114890. /**
  114891. * Defines the interface used by objects containing a viewport (like a camera)
  114892. */
  114893. interface IViewportOwnerLike {
  114894. /**
  114895. * Gets or sets the viewport
  114896. */
  114897. viewport: IViewportLike;
  114898. }
  114899. /**
  114900. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114901. */
  114902. export class Engine extends ThinEngine {
  114903. /** Defines that alpha blending is disabled */
  114904. static readonly ALPHA_DISABLE: number;
  114905. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114906. static readonly ALPHA_ADD: number;
  114907. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114908. static readonly ALPHA_COMBINE: number;
  114909. /** Defines that alpha blending to DEST - SRC * DEST */
  114910. static readonly ALPHA_SUBTRACT: number;
  114911. /** Defines that alpha blending to SRC * DEST */
  114912. static readonly ALPHA_MULTIPLY: number;
  114913. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114914. static readonly ALPHA_MAXIMIZED: number;
  114915. /** Defines that alpha blending to SRC + DEST */
  114916. static readonly ALPHA_ONEONE: number;
  114917. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114918. static readonly ALPHA_PREMULTIPLIED: number;
  114919. /**
  114920. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114921. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114922. */
  114923. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114924. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114925. static readonly ALPHA_INTERPOLATE: number;
  114926. /**
  114927. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114928. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114929. */
  114930. static readonly ALPHA_SCREENMODE: number;
  114931. /** Defines that the ressource is not delayed*/
  114932. static readonly DELAYLOADSTATE_NONE: number;
  114933. /** Defines that the ressource was successfully delay loaded */
  114934. static readonly DELAYLOADSTATE_LOADED: number;
  114935. /** Defines that the ressource is currently delay loading */
  114936. static readonly DELAYLOADSTATE_LOADING: number;
  114937. /** Defines that the ressource is delayed and has not started loading */
  114938. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114940. static readonly NEVER: number;
  114941. /** 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 */
  114942. static readonly ALWAYS: number;
  114943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114944. static readonly LESS: number;
  114945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114946. static readonly EQUAL: number;
  114947. /** 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 */
  114948. static readonly LEQUAL: number;
  114949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114950. static readonly GREATER: number;
  114951. /** 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 */
  114952. static readonly GEQUAL: number;
  114953. /** 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 */
  114954. static readonly NOTEQUAL: number;
  114955. /** Passed to stencilOperation to specify that stencil value must be kept */
  114956. static readonly KEEP: number;
  114957. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114958. static readonly REPLACE: number;
  114959. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114960. static readonly INCR: number;
  114961. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114962. static readonly DECR: number;
  114963. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114964. static readonly INVERT: number;
  114965. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114966. static readonly INCR_WRAP: number;
  114967. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114968. static readonly DECR_WRAP: number;
  114969. /** Texture is not repeating outside of 0..1 UVs */
  114970. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114971. /** Texture is repeating outside of 0..1 UVs */
  114972. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114973. /** Texture is repeating and mirrored */
  114974. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114975. /** ALPHA */
  114976. static readonly TEXTUREFORMAT_ALPHA: number;
  114977. /** LUMINANCE */
  114978. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114979. /** LUMINANCE_ALPHA */
  114980. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114981. /** RGB */
  114982. static readonly TEXTUREFORMAT_RGB: number;
  114983. /** RGBA */
  114984. static readonly TEXTUREFORMAT_RGBA: number;
  114985. /** RED */
  114986. static readonly TEXTUREFORMAT_RED: number;
  114987. /** RED (2nd reference) */
  114988. static readonly TEXTUREFORMAT_R: number;
  114989. /** RG */
  114990. static readonly TEXTUREFORMAT_RG: number;
  114991. /** RED_INTEGER */
  114992. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114993. /** RED_INTEGER (2nd reference) */
  114994. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114995. /** RG_INTEGER */
  114996. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114997. /** RGB_INTEGER */
  114998. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114999. /** RGBA_INTEGER */
  115000. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  115001. /** UNSIGNED_BYTE */
  115002. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  115003. /** UNSIGNED_BYTE (2nd reference) */
  115004. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  115005. /** FLOAT */
  115006. static readonly TEXTURETYPE_FLOAT: number;
  115007. /** HALF_FLOAT */
  115008. static readonly TEXTURETYPE_HALF_FLOAT: number;
  115009. /** BYTE */
  115010. static readonly TEXTURETYPE_BYTE: number;
  115011. /** SHORT */
  115012. static readonly TEXTURETYPE_SHORT: number;
  115013. /** UNSIGNED_SHORT */
  115014. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  115015. /** INT */
  115016. static readonly TEXTURETYPE_INT: number;
  115017. /** UNSIGNED_INT */
  115018. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  115019. /** UNSIGNED_SHORT_4_4_4_4 */
  115020. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  115021. /** UNSIGNED_SHORT_5_5_5_1 */
  115022. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  115023. /** UNSIGNED_SHORT_5_6_5 */
  115024. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  115025. /** UNSIGNED_INT_2_10_10_10_REV */
  115026. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  115027. /** UNSIGNED_INT_24_8 */
  115028. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  115029. /** UNSIGNED_INT_10F_11F_11F_REV */
  115030. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  115031. /** UNSIGNED_INT_5_9_9_9_REV */
  115032. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  115033. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  115034. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115035. /** nearest is mag = nearest and min = nearest and mip = linear */
  115036. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  115037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115038. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  115039. /** Trilinear is mag = linear and min = linear and mip = linear */
  115040. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  115041. /** nearest is mag = nearest and min = nearest and mip = linear */
  115042. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  115043. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115044. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  115045. /** Trilinear is mag = linear and min = linear and mip = linear */
  115046. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  115047. /** mag = nearest and min = nearest and mip = nearest */
  115048. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  115049. /** mag = nearest and min = linear and mip = nearest */
  115050. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  115051. /** mag = nearest and min = linear and mip = linear */
  115052. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  115053. /** mag = nearest and min = linear and mip = none */
  115054. static readonly TEXTURE_NEAREST_LINEAR: number;
  115055. /** mag = nearest and min = nearest and mip = none */
  115056. static readonly TEXTURE_NEAREST_NEAREST: number;
  115057. /** mag = linear and min = nearest and mip = nearest */
  115058. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  115059. /** mag = linear and min = nearest and mip = linear */
  115060. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  115061. /** mag = linear and min = linear and mip = none */
  115062. static readonly TEXTURE_LINEAR_LINEAR: number;
  115063. /** mag = linear and min = nearest and mip = none */
  115064. static readonly TEXTURE_LINEAR_NEAREST: number;
  115065. /** Explicit coordinates mode */
  115066. static readonly TEXTURE_EXPLICIT_MODE: number;
  115067. /** Spherical coordinates mode */
  115068. static readonly TEXTURE_SPHERICAL_MODE: number;
  115069. /** Planar coordinates mode */
  115070. static readonly TEXTURE_PLANAR_MODE: number;
  115071. /** Cubic coordinates mode */
  115072. static readonly TEXTURE_CUBIC_MODE: number;
  115073. /** Projection coordinates mode */
  115074. static readonly TEXTURE_PROJECTION_MODE: number;
  115075. /** Skybox coordinates mode */
  115076. static readonly TEXTURE_SKYBOX_MODE: number;
  115077. /** Inverse Cubic coordinates mode */
  115078. static readonly TEXTURE_INVCUBIC_MODE: number;
  115079. /** Equirectangular coordinates mode */
  115080. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  115081. /** Equirectangular Fixed coordinates mode */
  115082. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  115083. /** Equirectangular Fixed Mirrored coordinates mode */
  115084. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  115085. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  115086. static readonly SCALEMODE_FLOOR: number;
  115087. /** Defines that texture rescaling will look for the nearest power of 2 size */
  115088. static readonly SCALEMODE_NEAREST: number;
  115089. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  115090. static readonly SCALEMODE_CEILING: number;
  115091. /**
  115092. * Returns the current npm package of the sdk
  115093. */
  115094. static get NpmPackage(): string;
  115095. /**
  115096. * Returns the current version of the framework
  115097. */
  115098. static get Version(): string;
  115099. /** Gets the list of created engines */
  115100. static get Instances(): Engine[];
  115101. /**
  115102. * Gets the latest created engine
  115103. */
  115104. static get LastCreatedEngine(): Nullable<Engine>;
  115105. /**
  115106. * Gets the latest created scene
  115107. */
  115108. static get LastCreatedScene(): Nullable<Scene>;
  115109. /**
  115110. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  115111. * @param flag defines which part of the materials must be marked as dirty
  115112. * @param predicate defines a predicate used to filter which materials should be affected
  115113. */
  115114. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  115115. /**
  115116. * Method called to create the default loading screen.
  115117. * This can be overriden in your own app.
  115118. * @param canvas The rendering canvas element
  115119. * @returns The loading screen
  115120. */
  115121. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  115122. /**
  115123. * Method called to create the default rescale post process on each engine.
  115124. */
  115125. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  115126. /**
  115127. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  115128. **/
  115129. enableOfflineSupport: boolean;
  115130. /**
  115131. * 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)
  115132. **/
  115133. disableManifestCheck: boolean;
  115134. /**
  115135. * Gets the list of created scenes
  115136. */
  115137. scenes: Scene[];
  115138. /**
  115139. * Event raised when a new scene is created
  115140. */
  115141. onNewSceneAddedObservable: Observable<Scene>;
  115142. /**
  115143. * Gets the list of created postprocesses
  115144. */
  115145. postProcesses: PostProcess[];
  115146. /**
  115147. * Gets a boolean indicating if the pointer is currently locked
  115148. */
  115149. isPointerLock: boolean;
  115150. /**
  115151. * Observable event triggered each time the rendering canvas is resized
  115152. */
  115153. onResizeObservable: Observable<Engine>;
  115154. /**
  115155. * Observable event triggered each time the canvas loses focus
  115156. */
  115157. onCanvasBlurObservable: Observable<Engine>;
  115158. /**
  115159. * Observable event triggered each time the canvas gains focus
  115160. */
  115161. onCanvasFocusObservable: Observable<Engine>;
  115162. /**
  115163. * Observable event triggered each time the canvas receives pointerout event
  115164. */
  115165. onCanvasPointerOutObservable: Observable<PointerEvent>;
  115166. /**
  115167. * Observable raised when the engine begins a new frame
  115168. */
  115169. onBeginFrameObservable: Observable<Engine>;
  115170. /**
  115171. * If set, will be used to request the next animation frame for the render loop
  115172. */
  115173. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  115174. /**
  115175. * Observable raised when the engine ends the current frame
  115176. */
  115177. onEndFrameObservable: Observable<Engine>;
  115178. /**
  115179. * Observable raised when the engine is about to compile a shader
  115180. */
  115181. onBeforeShaderCompilationObservable: Observable<Engine>;
  115182. /**
  115183. * Observable raised when the engine has jsut compiled a shader
  115184. */
  115185. onAfterShaderCompilationObservable: Observable<Engine>;
  115186. /**
  115187. * Gets the audio engine
  115188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115189. * @ignorenaming
  115190. */
  115191. static audioEngine: IAudioEngine;
  115192. /**
  115193. * Default AudioEngine factory responsible of creating the Audio Engine.
  115194. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  115195. */
  115196. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  115197. /**
  115198. * Default offline support factory responsible of creating a tool used to store data locally.
  115199. * By default, this will create a Database object if the workload has been embedded.
  115200. */
  115201. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  115202. private _loadingScreen;
  115203. private _pointerLockRequested;
  115204. private _rescalePostProcess;
  115205. private _deterministicLockstep;
  115206. private _lockstepMaxSteps;
  115207. private _timeStep;
  115208. protected get _supportsHardwareTextureRescaling(): boolean;
  115209. private _fps;
  115210. private _deltaTime;
  115211. /** @hidden */
  115212. _drawCalls: PerfCounter;
  115213. /** 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 */
  115214. canvasTabIndex: number;
  115215. /**
  115216. * Turn this value on if you want to pause FPS computation when in background
  115217. */
  115218. disablePerformanceMonitorInBackground: boolean;
  115219. private _performanceMonitor;
  115220. /**
  115221. * Gets the performance monitor attached to this engine
  115222. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115223. */
  115224. get performanceMonitor(): PerformanceMonitor;
  115225. private _onFocus;
  115226. private _onBlur;
  115227. private _onCanvasPointerOut;
  115228. private _onCanvasBlur;
  115229. private _onCanvasFocus;
  115230. private _onFullscreenChange;
  115231. private _onPointerLockChange;
  115232. /**
  115233. * Gets the HTML element used to attach event listeners
  115234. * @returns a HTML element
  115235. */
  115236. getInputElement(): Nullable<HTMLElement>;
  115237. /**
  115238. * Creates a new engine
  115239. * @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
  115240. * @param antialias defines enable antialiasing (default: false)
  115241. * @param options defines further options to be sent to the getContext() function
  115242. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115243. */
  115244. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115245. /**
  115246. * Gets current aspect ratio
  115247. * @param viewportOwner defines the camera to use to get the aspect ratio
  115248. * @param useScreen defines if screen size must be used (or the current render target if any)
  115249. * @returns a number defining the aspect ratio
  115250. */
  115251. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  115252. /**
  115253. * Gets current screen aspect ratio
  115254. * @returns a number defining the aspect ratio
  115255. */
  115256. getScreenAspectRatio(): number;
  115257. /**
  115258. * Gets the client rect of the HTML canvas attached with the current webGL context
  115259. * @returns a client rectanglee
  115260. */
  115261. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  115262. /**
  115263. * Gets the client rect of the HTML element used for events
  115264. * @returns a client rectanglee
  115265. */
  115266. getInputElementClientRect(): Nullable<ClientRect>;
  115267. /**
  115268. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  115269. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115270. * @returns true if engine is in deterministic lock step mode
  115271. */
  115272. isDeterministicLockStep(): boolean;
  115273. /**
  115274. * Gets the max steps when engine is running in deterministic lock step
  115275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115276. * @returns the max steps
  115277. */
  115278. getLockstepMaxSteps(): number;
  115279. /**
  115280. * Returns the time in ms between steps when using deterministic lock step.
  115281. * @returns time step in (ms)
  115282. */
  115283. getTimeStep(): number;
  115284. /**
  115285. * Force the mipmap generation for the given render target texture
  115286. * @param texture defines the render target texture to use
  115287. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  115288. */
  115289. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  115290. /** States */
  115291. /**
  115292. * Set various states to the webGL context
  115293. * @param culling defines backface culling state
  115294. * @param zOffset defines the value to apply to zOffset (0 by default)
  115295. * @param force defines if states must be applied even if cache is up to date
  115296. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  115297. */
  115298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115299. /**
  115300. * Set the z offset to apply to current rendering
  115301. * @param value defines the offset to apply
  115302. */
  115303. setZOffset(value: number): void;
  115304. /**
  115305. * Gets the current value of the zOffset
  115306. * @returns the current zOffset state
  115307. */
  115308. getZOffset(): number;
  115309. /**
  115310. * Enable or disable depth buffering
  115311. * @param enable defines the state to set
  115312. */
  115313. setDepthBuffer(enable: boolean): void;
  115314. /**
  115315. * Gets a boolean indicating if depth writing is enabled
  115316. * @returns the current depth writing state
  115317. */
  115318. getDepthWrite(): boolean;
  115319. /**
  115320. * Enable or disable depth writing
  115321. * @param enable defines the state to set
  115322. */
  115323. setDepthWrite(enable: boolean): void;
  115324. /**
  115325. * Gets a boolean indicating if stencil buffer is enabled
  115326. * @returns the current stencil buffer state
  115327. */
  115328. getStencilBuffer(): boolean;
  115329. /**
  115330. * Enable or disable the stencil buffer
  115331. * @param enable defines if the stencil buffer must be enabled or disabled
  115332. */
  115333. setStencilBuffer(enable: boolean): void;
  115334. /**
  115335. * Gets the current stencil mask
  115336. * @returns a number defining the new stencil mask to use
  115337. */
  115338. getStencilMask(): number;
  115339. /**
  115340. * Sets the current stencil mask
  115341. * @param mask defines the new stencil mask to use
  115342. */
  115343. setStencilMask(mask: number): void;
  115344. /**
  115345. * Gets the current stencil function
  115346. * @returns a number defining the stencil function to use
  115347. */
  115348. getStencilFunction(): number;
  115349. /**
  115350. * Gets the current stencil reference value
  115351. * @returns a number defining the stencil reference value to use
  115352. */
  115353. getStencilFunctionReference(): number;
  115354. /**
  115355. * Gets the current stencil mask
  115356. * @returns a number defining the stencil mask to use
  115357. */
  115358. getStencilFunctionMask(): number;
  115359. /**
  115360. * Sets the current stencil function
  115361. * @param stencilFunc defines the new stencil function to use
  115362. */
  115363. setStencilFunction(stencilFunc: number): void;
  115364. /**
  115365. * Sets the current stencil reference
  115366. * @param reference defines the new stencil reference to use
  115367. */
  115368. setStencilFunctionReference(reference: number): void;
  115369. /**
  115370. * Sets the current stencil mask
  115371. * @param mask defines the new stencil mask to use
  115372. */
  115373. setStencilFunctionMask(mask: number): void;
  115374. /**
  115375. * Gets the current stencil operation when stencil fails
  115376. * @returns a number defining stencil operation to use when stencil fails
  115377. */
  115378. getStencilOperationFail(): number;
  115379. /**
  115380. * Gets the current stencil operation when depth fails
  115381. * @returns a number defining stencil operation to use when depth fails
  115382. */
  115383. getStencilOperationDepthFail(): number;
  115384. /**
  115385. * Gets the current stencil operation when stencil passes
  115386. * @returns a number defining stencil operation to use when stencil passes
  115387. */
  115388. getStencilOperationPass(): number;
  115389. /**
  115390. * Sets the stencil operation to use when stencil fails
  115391. * @param operation defines the stencil operation to use when stencil fails
  115392. */
  115393. setStencilOperationFail(operation: number): void;
  115394. /**
  115395. * Sets the stencil operation to use when depth fails
  115396. * @param operation defines the stencil operation to use when depth fails
  115397. */
  115398. setStencilOperationDepthFail(operation: number): void;
  115399. /**
  115400. * Sets the stencil operation to use when stencil passes
  115401. * @param operation defines the stencil operation to use when stencil passes
  115402. */
  115403. setStencilOperationPass(operation: number): void;
  115404. /**
  115405. * Sets a boolean indicating if the dithering state is enabled or disabled
  115406. * @param value defines the dithering state
  115407. */
  115408. setDitheringState(value: boolean): void;
  115409. /**
  115410. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115411. * @param value defines the rasterizer state
  115412. */
  115413. setRasterizerState(value: boolean): void;
  115414. /**
  115415. * Gets the current depth function
  115416. * @returns a number defining the depth function
  115417. */
  115418. getDepthFunction(): Nullable<number>;
  115419. /**
  115420. * Sets the current depth function
  115421. * @param depthFunc defines the function to use
  115422. */
  115423. setDepthFunction(depthFunc: number): void;
  115424. /**
  115425. * Sets the current depth function to GREATER
  115426. */
  115427. setDepthFunctionToGreater(): void;
  115428. /**
  115429. * Sets the current depth function to GEQUAL
  115430. */
  115431. setDepthFunctionToGreaterOrEqual(): void;
  115432. /**
  115433. * Sets the current depth function to LESS
  115434. */
  115435. setDepthFunctionToLess(): void;
  115436. /**
  115437. * Sets the current depth function to LEQUAL
  115438. */
  115439. setDepthFunctionToLessOrEqual(): void;
  115440. private _cachedStencilBuffer;
  115441. private _cachedStencilFunction;
  115442. private _cachedStencilMask;
  115443. private _cachedStencilOperationPass;
  115444. private _cachedStencilOperationFail;
  115445. private _cachedStencilOperationDepthFail;
  115446. private _cachedStencilReference;
  115447. /**
  115448. * Caches the the state of the stencil buffer
  115449. */
  115450. cacheStencilState(): void;
  115451. /**
  115452. * Restores the state of the stencil buffer
  115453. */
  115454. restoreStencilState(): void;
  115455. /**
  115456. * Directly set the WebGL Viewport
  115457. * @param x defines the x coordinate of the viewport (in screen space)
  115458. * @param y defines the y coordinate of the viewport (in screen space)
  115459. * @param width defines the width of the viewport (in screen space)
  115460. * @param height defines the height of the viewport (in screen space)
  115461. * @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
  115462. */
  115463. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115464. /**
  115465. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115466. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115467. * @param y defines the y-coordinate of the corner of the clear rectangle
  115468. * @param width defines the width of the clear rectangle
  115469. * @param height defines the height of the clear rectangle
  115470. * @param clearColor defines the clear color
  115471. */
  115472. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115473. /**
  115474. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115475. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115476. * @param y defines the y-coordinate of the corner of the clear rectangle
  115477. * @param width defines the width of the clear rectangle
  115478. * @param height defines the height of the clear rectangle
  115479. */
  115480. enableScissor(x: number, y: number, width: number, height: number): void;
  115481. /**
  115482. * Disable previously set scissor test rectangle
  115483. */
  115484. disableScissor(): void;
  115485. protected _reportDrawCall(): void;
  115486. /**
  115487. * Initializes a webVR display and starts listening to display change events
  115488. * The onVRDisplayChangedObservable will be notified upon these changes
  115489. * @returns The onVRDisplayChangedObservable
  115490. */
  115491. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115492. /** @hidden */
  115493. _prepareVRComponent(): void;
  115494. /** @hidden */
  115495. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115496. /** @hidden */
  115497. _submitVRFrame(): void;
  115498. /**
  115499. * Call this function to leave webVR mode
  115500. * Will do nothing if webVR is not supported or if there is no webVR device
  115501. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115502. */
  115503. disableVR(): void;
  115504. /**
  115505. * Gets a boolean indicating that the system is in VR mode and is presenting
  115506. * @returns true if VR mode is engaged
  115507. */
  115508. isVRPresenting(): boolean;
  115509. /** @hidden */
  115510. _requestVRFrame(): void;
  115511. /** @hidden */
  115512. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115513. /**
  115514. * Gets the source code of the vertex shader associated with a specific webGL program
  115515. * @param program defines the program to use
  115516. * @returns a string containing the source code of the vertex shader associated with the program
  115517. */
  115518. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115519. /**
  115520. * Gets the source code of the fragment shader associated with a specific webGL program
  115521. * @param program defines the program to use
  115522. * @returns a string containing the source code of the fragment shader associated with the program
  115523. */
  115524. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115525. /**
  115526. * Sets a depth stencil texture from a render target to the according uniform.
  115527. * @param channel The texture channel
  115528. * @param uniform The uniform to set
  115529. * @param texture The render target texture containing the depth stencil texture to apply
  115530. */
  115531. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115532. /**
  115533. * Sets a texture to the webGL context from a postprocess
  115534. * @param channel defines the channel to use
  115535. * @param postProcess defines the source postprocess
  115536. */
  115537. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115538. /**
  115539. * Binds the output of the passed in post process to the texture channel specified
  115540. * @param channel The channel the texture should be bound to
  115541. * @param postProcess The post process which's output should be bound
  115542. */
  115543. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115544. protected _rebuildBuffers(): void;
  115545. /** @hidden */
  115546. _renderFrame(): void;
  115547. _renderLoop(): void;
  115548. /** @hidden */
  115549. _renderViews(): boolean;
  115550. /**
  115551. * Toggle full screen mode
  115552. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115553. */
  115554. switchFullscreen(requestPointerLock: boolean): void;
  115555. /**
  115556. * Enters full screen mode
  115557. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115558. */
  115559. enterFullscreen(requestPointerLock: boolean): void;
  115560. /**
  115561. * Exits full screen mode
  115562. */
  115563. exitFullscreen(): void;
  115564. /**
  115565. * Enters Pointerlock mode
  115566. */
  115567. enterPointerlock(): void;
  115568. /**
  115569. * Exits Pointerlock mode
  115570. */
  115571. exitPointerlock(): void;
  115572. /**
  115573. * Begin a new frame
  115574. */
  115575. beginFrame(): void;
  115576. /**
  115577. * Enf the current frame
  115578. */
  115579. endFrame(): void;
  115580. resize(): void;
  115581. /**
  115582. * Force a specific size of the canvas
  115583. * @param width defines the new canvas' width
  115584. * @param height defines the new canvas' height
  115585. * @returns true if the size was changed
  115586. */
  115587. setSize(width: number, height: number): boolean;
  115588. /**
  115589. * Updates a dynamic vertex buffer.
  115590. * @param vertexBuffer the vertex buffer to update
  115591. * @param data the data used to update the vertex buffer
  115592. * @param byteOffset the byte offset of the data
  115593. * @param byteLength the byte length of the data
  115594. */
  115595. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115596. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115597. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115598. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115599. _releaseTexture(texture: InternalTexture): void;
  115600. /**
  115601. * @hidden
  115602. * Rescales a texture
  115603. * @param source input texutre
  115604. * @param destination destination texture
  115605. * @param scene scene to use to render the resize
  115606. * @param internalFormat format to use when resizing
  115607. * @param onComplete callback to be called when resize has completed
  115608. */
  115609. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115610. /**
  115611. * Gets the current framerate
  115612. * @returns a number representing the framerate
  115613. */
  115614. getFps(): number;
  115615. /**
  115616. * Gets the time spent between current and previous frame
  115617. * @returns a number representing the delta time in ms
  115618. */
  115619. getDeltaTime(): number;
  115620. private _measureFps;
  115621. /** @hidden */
  115622. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115623. /**
  115624. * Update a dynamic index buffer
  115625. * @param indexBuffer defines the target index buffer
  115626. * @param indices defines the data to update
  115627. * @param offset defines the offset in the target index buffer where update should start
  115628. */
  115629. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115630. /**
  115631. * Updates the sample count of a render target texture
  115632. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115633. * @param texture defines the texture to update
  115634. * @param samples defines the sample count to set
  115635. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115636. */
  115637. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115638. /**
  115639. * Updates a depth texture Comparison Mode and Function.
  115640. * If the comparison Function is equal to 0, the mode will be set to none.
  115641. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115642. * @param texture The texture to set the comparison function for
  115643. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115644. */
  115645. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115646. /**
  115647. * Creates a webGL buffer to use with instanciation
  115648. * @param capacity defines the size of the buffer
  115649. * @returns the webGL buffer
  115650. */
  115651. createInstancesBuffer(capacity: number): DataBuffer;
  115652. /**
  115653. * Delete a webGL buffer used with instanciation
  115654. * @param buffer defines the webGL buffer to delete
  115655. */
  115656. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115657. private _clientWaitAsync;
  115658. /** @hidden */
  115659. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115660. dispose(): void;
  115661. private _disableTouchAction;
  115662. /**
  115663. * Display the loading screen
  115664. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115665. */
  115666. displayLoadingUI(): void;
  115667. /**
  115668. * Hide the loading screen
  115669. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115670. */
  115671. hideLoadingUI(): void;
  115672. /**
  115673. * Gets the current loading screen object
  115674. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115675. */
  115676. get loadingScreen(): ILoadingScreen;
  115677. /**
  115678. * Sets the current loading screen object
  115679. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115680. */
  115681. set loadingScreen(loadingScreen: ILoadingScreen);
  115682. /**
  115683. * Sets the current loading screen text
  115684. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115685. */
  115686. set loadingUIText(text: string);
  115687. /**
  115688. * Sets the current loading screen background color
  115689. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115690. */
  115691. set loadingUIBackgroundColor(color: string);
  115692. /** Pointerlock and fullscreen */
  115693. /**
  115694. * Ask the browser to promote the current element to pointerlock mode
  115695. * @param element defines the DOM element to promote
  115696. */
  115697. static _RequestPointerlock(element: HTMLElement): void;
  115698. /**
  115699. * Asks the browser to exit pointerlock mode
  115700. */
  115701. static _ExitPointerlock(): void;
  115702. /**
  115703. * Ask the browser to promote the current element to fullscreen rendering mode
  115704. * @param element defines the DOM element to promote
  115705. */
  115706. static _RequestFullscreen(element: HTMLElement): void;
  115707. /**
  115708. * Asks the browser to exit fullscreen mode
  115709. */
  115710. static _ExitFullscreen(): void;
  115711. }
  115712. }
  115713. declare module BABYLON {
  115714. /**
  115715. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115716. * during the life time of the application.
  115717. */
  115718. export class EngineStore {
  115719. /** Gets the list of created engines */
  115720. static Instances: Engine[];
  115721. /** @hidden */
  115722. static _LastCreatedScene: Nullable<Scene>;
  115723. /**
  115724. * Gets the latest created engine
  115725. */
  115726. static get LastCreatedEngine(): Nullable<Engine>;
  115727. /**
  115728. * Gets the latest created scene
  115729. */
  115730. static get LastCreatedScene(): Nullable<Scene>;
  115731. /**
  115732. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115733. * @ignorenaming
  115734. */
  115735. static UseFallbackTexture: boolean;
  115736. /**
  115737. * Texture content used if a texture cannot loaded
  115738. * @ignorenaming
  115739. */
  115740. static FallbackTexture: string;
  115741. }
  115742. }
  115743. declare module BABYLON {
  115744. /**
  115745. * Helper class that provides a small promise polyfill
  115746. */
  115747. export class PromisePolyfill {
  115748. /**
  115749. * Static function used to check if the polyfill is required
  115750. * If this is the case then the function will inject the polyfill to window.Promise
  115751. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115752. */
  115753. static Apply(force?: boolean): void;
  115754. }
  115755. }
  115756. declare module BABYLON {
  115757. /**
  115758. * Interface for screenshot methods with describe argument called `size` as object with options
  115759. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115760. */
  115761. export interface IScreenshotSize {
  115762. /**
  115763. * number in pixels for canvas height
  115764. */
  115765. height?: number;
  115766. /**
  115767. * multiplier allowing render at a higher or lower resolution
  115768. * If value is defined then height and width will be ignored and taken from camera
  115769. */
  115770. precision?: number;
  115771. /**
  115772. * number in pixels for canvas width
  115773. */
  115774. width?: number;
  115775. }
  115776. }
  115777. declare module BABYLON {
  115778. interface IColor4Like {
  115779. r: float;
  115780. g: float;
  115781. b: float;
  115782. a: float;
  115783. }
  115784. /**
  115785. * Class containing a set of static utilities functions
  115786. */
  115787. export class Tools {
  115788. /**
  115789. * Gets or sets the base URL to use to load assets
  115790. */
  115791. static get BaseUrl(): string;
  115792. static set BaseUrl(value: string);
  115793. /**
  115794. * Enable/Disable Custom HTTP Request Headers globally.
  115795. * default = false
  115796. * @see CustomRequestHeaders
  115797. */
  115798. static UseCustomRequestHeaders: boolean;
  115799. /**
  115800. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115801. * i.e. when loading files, where the server/service expects an Authorization header
  115802. */
  115803. static CustomRequestHeaders: {
  115804. [key: string]: string;
  115805. };
  115806. /**
  115807. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115808. */
  115809. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115810. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115811. /**
  115812. * Default behaviour for cors in the application.
  115813. * It can be a string if the expected behavior is identical in the entire app.
  115814. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115815. */
  115816. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115817. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115818. /**
  115819. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115820. * @ignorenaming
  115821. */
  115822. static get UseFallbackTexture(): boolean;
  115823. static set UseFallbackTexture(value: boolean);
  115824. /**
  115825. * Use this object to register external classes like custom textures or material
  115826. * to allow the laoders to instantiate them
  115827. */
  115828. static get RegisteredExternalClasses(): {
  115829. [key: string]: Object;
  115830. };
  115831. static set RegisteredExternalClasses(classes: {
  115832. [key: string]: Object;
  115833. });
  115834. /**
  115835. * Texture content used if a texture cannot loaded
  115836. * @ignorenaming
  115837. */
  115838. static get fallbackTexture(): string;
  115839. static set fallbackTexture(value: string);
  115840. /**
  115841. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115842. * @param u defines the coordinate on X axis
  115843. * @param v defines the coordinate on Y axis
  115844. * @param width defines the width of the source data
  115845. * @param height defines the height of the source data
  115846. * @param pixels defines the source byte array
  115847. * @param color defines the output color
  115848. */
  115849. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115850. /**
  115851. * Interpolates between a and b via alpha
  115852. * @param a The lower value (returned when alpha = 0)
  115853. * @param b The upper value (returned when alpha = 1)
  115854. * @param alpha The interpolation-factor
  115855. * @return The mixed value
  115856. */
  115857. static Mix(a: number, b: number, alpha: number): number;
  115858. /**
  115859. * Tries to instantiate a new object from a given class name
  115860. * @param className defines the class name to instantiate
  115861. * @returns the new object or null if the system was not able to do the instantiation
  115862. */
  115863. static Instantiate(className: string): any;
  115864. /**
  115865. * Provides a slice function that will work even on IE
  115866. * @param data defines the array to slice
  115867. * @param start defines the start of the data (optional)
  115868. * @param end defines the end of the data (optional)
  115869. * @returns the new sliced array
  115870. */
  115871. static Slice<T>(data: T, start?: number, end?: number): T;
  115872. /**
  115873. * Polyfill for setImmediate
  115874. * @param action defines the action to execute after the current execution block
  115875. */
  115876. static SetImmediate(action: () => void): void;
  115877. /**
  115878. * Function indicating if a number is an exponent of 2
  115879. * @param value defines the value to test
  115880. * @returns true if the value is an exponent of 2
  115881. */
  115882. static IsExponentOfTwo(value: number): boolean;
  115883. private static _tmpFloatArray;
  115884. /**
  115885. * Returns the nearest 32-bit single precision float representation of a Number
  115886. * @param value A Number. If the parameter is of a different type, it will get converted
  115887. * to a number or to NaN if it cannot be converted
  115888. * @returns number
  115889. */
  115890. static FloatRound(value: number): number;
  115891. /**
  115892. * Extracts the filename from a path
  115893. * @param path defines the path to use
  115894. * @returns the filename
  115895. */
  115896. static GetFilename(path: string): string;
  115897. /**
  115898. * Extracts the "folder" part of a path (everything before the filename).
  115899. * @param uri The URI to extract the info from
  115900. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115901. * @returns The "folder" part of the path
  115902. */
  115903. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115904. /**
  115905. * Extracts text content from a DOM element hierarchy
  115906. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115907. */
  115908. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115909. /**
  115910. * Convert an angle in radians to degrees
  115911. * @param angle defines the angle to convert
  115912. * @returns the angle in degrees
  115913. */
  115914. static ToDegrees(angle: number): number;
  115915. /**
  115916. * Convert an angle in degrees to radians
  115917. * @param angle defines the angle to convert
  115918. * @returns the angle in radians
  115919. */
  115920. static ToRadians(angle: number): number;
  115921. /**
  115922. * Returns an array if obj is not an array
  115923. * @param obj defines the object to evaluate as an array
  115924. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115925. * @returns either obj directly if obj is an array or a new array containing obj
  115926. */
  115927. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115928. /**
  115929. * Gets the pointer prefix to use
  115930. * @param engine defines the engine we are finding the prefix for
  115931. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115932. */
  115933. static GetPointerPrefix(engine: Engine): string;
  115934. /**
  115935. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115936. * @param url define the url we are trying
  115937. * @param element define the dom element where to configure the cors policy
  115938. */
  115939. static SetCorsBehavior(url: string | string[], element: {
  115940. crossOrigin: string | null;
  115941. }): void;
  115942. /**
  115943. * Removes unwanted characters from an url
  115944. * @param url defines the url to clean
  115945. * @returns the cleaned url
  115946. */
  115947. static CleanUrl(url: string): string;
  115948. /**
  115949. * Gets or sets a function used to pre-process url before using them to load assets
  115950. */
  115951. static get PreprocessUrl(): (url: string) => string;
  115952. static set PreprocessUrl(processor: (url: string) => string);
  115953. /**
  115954. * Loads an image as an HTMLImageElement.
  115955. * @param input url string, ArrayBuffer, or Blob to load
  115956. * @param onLoad callback called when the image successfully loads
  115957. * @param onError callback called when the image fails to load
  115958. * @param offlineProvider offline provider for caching
  115959. * @param mimeType optional mime type
  115960. * @returns the HTMLImageElement of the loaded image
  115961. */
  115962. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115963. /**
  115964. * Loads a file from a url
  115965. * @param url url string, ArrayBuffer, or Blob to load
  115966. * @param onSuccess callback called when the file successfully loads
  115967. * @param onProgress callback called while file is loading (if the server supports this mode)
  115968. * @param offlineProvider defines the offline provider for caching
  115969. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115970. * @param onError callback called when the file fails to load
  115971. * @returns a file request object
  115972. */
  115973. 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;
  115974. /**
  115975. * Loads a file from a url
  115976. * @param url the file url to load
  115977. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115978. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115979. */
  115980. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115981. /**
  115982. * Load a script (identified by an url). When the url returns, the
  115983. * content of this file is added into a new script element, attached to the DOM (body element)
  115984. * @param scriptUrl defines the url of the script to laod
  115985. * @param onSuccess defines the callback called when the script is loaded
  115986. * @param onError defines the callback to call if an error occurs
  115987. * @param scriptId defines the id of the script element
  115988. */
  115989. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115990. /**
  115991. * Load an asynchronous script (identified by an url). When the url returns, the
  115992. * content of this file is added into a new script element, attached to the DOM (body element)
  115993. * @param scriptUrl defines the url of the script to laod
  115994. * @param scriptId defines the id of the script element
  115995. * @returns a promise request object
  115996. */
  115997. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115998. /**
  115999. * Loads a file from a blob
  116000. * @param fileToLoad defines the blob to use
  116001. * @param callback defines the callback to call when data is loaded
  116002. * @param progressCallback defines the callback to call during loading process
  116003. * @returns a file request object
  116004. */
  116005. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  116006. /**
  116007. * Reads a file from a File object
  116008. * @param file defines the file to load
  116009. * @param onSuccess defines the callback to call when data is loaded
  116010. * @param onProgress defines the callback to call during loading process
  116011. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116012. * @param onError defines the callback to call when an error occurs
  116013. * @returns a file request object
  116014. */
  116015. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  116016. /**
  116017. * Creates a data url from a given string content
  116018. * @param content defines the content to convert
  116019. * @returns the new data url link
  116020. */
  116021. static FileAsURL(content: string): string;
  116022. /**
  116023. * Format the given number to a specific decimal format
  116024. * @param value defines the number to format
  116025. * @param decimals defines the number of decimals to use
  116026. * @returns the formatted string
  116027. */
  116028. static Format(value: number, decimals?: number): string;
  116029. /**
  116030. * Tries to copy an object by duplicating every property
  116031. * @param source defines the source object
  116032. * @param destination defines the target object
  116033. * @param doNotCopyList defines a list of properties to avoid
  116034. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  116035. */
  116036. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  116037. /**
  116038. * Gets a boolean indicating if the given object has no own property
  116039. * @param obj defines the object to test
  116040. * @returns true if object has no own property
  116041. */
  116042. static IsEmpty(obj: any): boolean;
  116043. /**
  116044. * Function used to register events at window level
  116045. * @param windowElement defines the Window object to use
  116046. * @param events defines the events to register
  116047. */
  116048. static RegisterTopRootEvents(windowElement: Window, events: {
  116049. name: string;
  116050. handler: Nullable<(e: FocusEvent) => any>;
  116051. }[]): void;
  116052. /**
  116053. * Function used to unregister events from window level
  116054. * @param windowElement defines the Window object to use
  116055. * @param events defines the events to unregister
  116056. */
  116057. static UnregisterTopRootEvents(windowElement: Window, events: {
  116058. name: string;
  116059. handler: Nullable<(e: FocusEvent) => any>;
  116060. }[]): void;
  116061. /**
  116062. * @ignore
  116063. */
  116064. static _ScreenshotCanvas: HTMLCanvasElement;
  116065. /**
  116066. * Dumps the current bound framebuffer
  116067. * @param width defines the rendering width
  116068. * @param height defines the rendering height
  116069. * @param engine defines the hosting engine
  116070. * @param successCallback defines the callback triggered once the data are available
  116071. * @param mimeType defines the mime type of the result
  116072. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  116073. */
  116074. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  116075. /**
  116076. * Converts the canvas data to blob.
  116077. * This acts as a polyfill for browsers not supporting the to blob function.
  116078. * @param canvas Defines the canvas to extract the data from
  116079. * @param successCallback Defines the callback triggered once the data are available
  116080. * @param mimeType Defines the mime type of the result
  116081. */
  116082. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  116083. /**
  116084. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  116085. * @param successCallback defines the callback triggered once the data are available
  116086. * @param mimeType defines the mime type of the result
  116087. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  116088. */
  116089. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  116090. /**
  116091. * Downloads a blob in the browser
  116092. * @param blob defines the blob to download
  116093. * @param fileName defines the name of the downloaded file
  116094. */
  116095. static Download(blob: Blob, fileName: string): void;
  116096. /**
  116097. * Captures a screenshot of the current rendering
  116098. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116099. * @param engine defines the rendering engine
  116100. * @param camera defines the source camera
  116101. * @param size This parameter can be set to a single number or to an object with the
  116102. * following (optional) properties: precision, width, height. If a single number is passed,
  116103. * it will be used for both width and height. If an object is passed, the screenshot size
  116104. * will be derived from the parameters. The precision property is a multiplier allowing
  116105. * rendering at a higher or lower resolution
  116106. * @param successCallback defines the callback receives a single parameter which contains the
  116107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116108. * src parameter of an <img> to display it
  116109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116110. * Check your browser for supported MIME types
  116111. */
  116112. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  116113. /**
  116114. * Captures a screenshot of the current rendering
  116115. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116116. * @param engine defines the rendering engine
  116117. * @param camera defines the source camera
  116118. * @param size This parameter can be set to a single number or to an object with the
  116119. * following (optional) properties: precision, width, height. If a single number is passed,
  116120. * it will be used for both width and height. If an object is passed, the screenshot size
  116121. * will be derived from the parameters. The precision property is a multiplier allowing
  116122. * rendering at a higher or lower resolution
  116123. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116124. * Check your browser for supported MIME types
  116125. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116126. * to the src parameter of an <img> to display it
  116127. */
  116128. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  116129. /**
  116130. * Generates an image screenshot from the specified camera.
  116131. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116132. * @param engine The engine to use for rendering
  116133. * @param camera The camera to use for rendering
  116134. * @param size This parameter can be set to a single number or to an object with the
  116135. * following (optional) properties: precision, width, height. If a single number is passed,
  116136. * it will be used for both width and height. If an object is passed, the screenshot size
  116137. * will be derived from the parameters. The precision property is a multiplier allowing
  116138. * rendering at a higher or lower resolution
  116139. * @param successCallback The callback receives a single parameter which contains the
  116140. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116141. * src parameter of an <img> to display it
  116142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116143. * Check your browser for supported MIME types
  116144. * @param samples Texture samples (default: 1)
  116145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116146. * @param fileName A name for for the downloaded file.
  116147. */
  116148. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116149. /**
  116150. * Generates an image screenshot from the specified camera.
  116151. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116152. * @param engine The engine to use for rendering
  116153. * @param camera The camera to use for rendering
  116154. * @param size This parameter can be set to a single number or to an object with the
  116155. * following (optional) properties: precision, width, height. If a single number is passed,
  116156. * it will be used for both width and height. If an object is passed, the screenshot size
  116157. * will be derived from the parameters. The precision property is a multiplier allowing
  116158. * rendering at a higher or lower resolution
  116159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116160. * Check your browser for supported MIME types
  116161. * @param samples Texture samples (default: 1)
  116162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116163. * @param fileName A name for for the downloaded file.
  116164. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116165. * to the src parameter of an <img> to display it
  116166. */
  116167. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  116168. /**
  116169. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116170. * Be aware Math.random() could cause collisions, but:
  116171. * "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"
  116172. * @returns a pseudo random id
  116173. */
  116174. static RandomId(): string;
  116175. /**
  116176. * Test if the given uri is a base64 string
  116177. * @param uri The uri to test
  116178. * @return True if the uri is a base64 string or false otherwise
  116179. */
  116180. static IsBase64(uri: string): boolean;
  116181. /**
  116182. * Decode the given base64 uri.
  116183. * @param uri The uri to decode
  116184. * @return The decoded base64 data.
  116185. */
  116186. static DecodeBase64(uri: string): ArrayBuffer;
  116187. /**
  116188. * Gets the absolute url.
  116189. * @param url the input url
  116190. * @return the absolute url
  116191. */
  116192. static GetAbsoluteUrl(url: string): string;
  116193. /**
  116194. * No log
  116195. */
  116196. static readonly NoneLogLevel: number;
  116197. /**
  116198. * Only message logs
  116199. */
  116200. static readonly MessageLogLevel: number;
  116201. /**
  116202. * Only warning logs
  116203. */
  116204. static readonly WarningLogLevel: number;
  116205. /**
  116206. * Only error logs
  116207. */
  116208. static readonly ErrorLogLevel: number;
  116209. /**
  116210. * All logs
  116211. */
  116212. static readonly AllLogLevel: number;
  116213. /**
  116214. * Gets a value indicating the number of loading errors
  116215. * @ignorenaming
  116216. */
  116217. static get errorsCount(): number;
  116218. /**
  116219. * Callback called when a new log is added
  116220. */
  116221. static OnNewCacheEntry: (entry: string) => void;
  116222. /**
  116223. * Log a message to the console
  116224. * @param message defines the message to log
  116225. */
  116226. static Log(message: string): void;
  116227. /**
  116228. * Write a warning message to the console
  116229. * @param message defines the message to log
  116230. */
  116231. static Warn(message: string): void;
  116232. /**
  116233. * Write an error message to the console
  116234. * @param message defines the message to log
  116235. */
  116236. static Error(message: string): void;
  116237. /**
  116238. * Gets current log cache (list of logs)
  116239. */
  116240. static get LogCache(): string;
  116241. /**
  116242. * Clears the log cache
  116243. */
  116244. static ClearLogCache(): void;
  116245. /**
  116246. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  116247. */
  116248. static set LogLevels(level: number);
  116249. /**
  116250. * Checks if the window object exists
  116251. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  116252. */
  116253. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  116254. /**
  116255. * No performance log
  116256. */
  116257. static readonly PerformanceNoneLogLevel: number;
  116258. /**
  116259. * Use user marks to log performance
  116260. */
  116261. static readonly PerformanceUserMarkLogLevel: number;
  116262. /**
  116263. * Log performance to the console
  116264. */
  116265. static readonly PerformanceConsoleLogLevel: number;
  116266. private static _performance;
  116267. /**
  116268. * Sets the current performance log level
  116269. */
  116270. static set PerformanceLogLevel(level: number);
  116271. private static _StartPerformanceCounterDisabled;
  116272. private static _EndPerformanceCounterDisabled;
  116273. private static _StartUserMark;
  116274. private static _EndUserMark;
  116275. private static _StartPerformanceConsole;
  116276. private static _EndPerformanceConsole;
  116277. /**
  116278. * Starts a performance counter
  116279. */
  116280. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  116281. /**
  116282. * Ends a specific performance coutner
  116283. */
  116284. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  116285. /**
  116286. * Gets either window.performance.now() if supported or Date.now() else
  116287. */
  116288. static get Now(): number;
  116289. /**
  116290. * This method will return the name of the class used to create the instance of the given object.
  116291. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  116292. * @param object the object to get the class name from
  116293. * @param isType defines if the object is actually a type
  116294. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  116295. */
  116296. static GetClassName(object: any, isType?: boolean): string;
  116297. /**
  116298. * Gets the first element of an array satisfying a given predicate
  116299. * @param array defines the array to browse
  116300. * @param predicate defines the predicate to use
  116301. * @returns null if not found or the element
  116302. */
  116303. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  116304. /**
  116305. * This method will return the name of the full name of the class, including its owning module (if any).
  116306. * 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).
  116307. * @param object the object to get the class name from
  116308. * @param isType defines if the object is actually a type
  116309. * @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.
  116310. * @ignorenaming
  116311. */
  116312. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  116313. /**
  116314. * Returns a promise that resolves after the given amount of time.
  116315. * @param delay Number of milliseconds to delay
  116316. * @returns Promise that resolves after the given amount of time
  116317. */
  116318. static DelayAsync(delay: number): Promise<void>;
  116319. /**
  116320. * Utility function to detect if the current user agent is Safari
  116321. * @returns whether or not the current user agent is safari
  116322. */
  116323. static IsSafari(): boolean;
  116324. }
  116325. /**
  116326. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116327. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116328. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116329. * @param name The name of the class, case should be preserved
  116330. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116331. */
  116332. export function className(name: string, module?: string): (target: Object) => void;
  116333. /**
  116334. * An implementation of a loop for asynchronous functions.
  116335. */
  116336. export class AsyncLoop {
  116337. /**
  116338. * Defines the number of iterations for the loop
  116339. */
  116340. iterations: number;
  116341. /**
  116342. * Defines the current index of the loop.
  116343. */
  116344. index: number;
  116345. private _done;
  116346. private _fn;
  116347. private _successCallback;
  116348. /**
  116349. * Constructor.
  116350. * @param iterations the number of iterations.
  116351. * @param func the function to run each iteration
  116352. * @param successCallback the callback that will be called upon succesful execution
  116353. * @param offset starting offset.
  116354. */
  116355. constructor(
  116356. /**
  116357. * Defines the number of iterations for the loop
  116358. */
  116359. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116360. /**
  116361. * Execute the next iteration. Must be called after the last iteration was finished.
  116362. */
  116363. executeNext(): void;
  116364. /**
  116365. * Break the loop and run the success callback.
  116366. */
  116367. breakLoop(): void;
  116368. /**
  116369. * Create and run an async loop.
  116370. * @param iterations the number of iterations.
  116371. * @param fn the function to run each iteration
  116372. * @param successCallback the callback that will be called upon succesful execution
  116373. * @param offset starting offset.
  116374. * @returns the created async loop object
  116375. */
  116376. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116377. /**
  116378. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116379. * @param iterations total number of iterations
  116380. * @param syncedIterations number of synchronous iterations in each async iteration.
  116381. * @param fn the function to call each iteration.
  116382. * @param callback a success call back that will be called when iterating stops.
  116383. * @param breakFunction a break condition (optional)
  116384. * @param timeout timeout settings for the setTimeout function. default - 0.
  116385. * @returns the created async loop object
  116386. */
  116387. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116388. }
  116389. }
  116390. declare module BABYLON {
  116391. /**
  116392. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116393. * The underlying implementation relies on an associative array to ensure the best performances.
  116394. * The value can be anything including 'null' but except 'undefined'
  116395. */
  116396. export class StringDictionary<T> {
  116397. /**
  116398. * This will clear this dictionary and copy the content from the 'source' one.
  116399. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116400. * @param source the dictionary to take the content from and copy to this dictionary
  116401. */
  116402. copyFrom(source: StringDictionary<T>): void;
  116403. /**
  116404. * Get a value based from its key
  116405. * @param key the given key to get the matching value from
  116406. * @return the value if found, otherwise undefined is returned
  116407. */
  116408. get(key: string): T | undefined;
  116409. /**
  116410. * Get a value from its key or add it if it doesn't exist.
  116411. * This method will ensure you that a given key/data will be present in the dictionary.
  116412. * @param key the given key to get the matching value from
  116413. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116414. * The factory will only be invoked if there's no data for the given key.
  116415. * @return the value corresponding to the key.
  116416. */
  116417. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116418. /**
  116419. * Get a value from its key if present in the dictionary otherwise add it
  116420. * @param key the key to get the value from
  116421. * @param val if there's no such key/value pair in the dictionary add it with this value
  116422. * @return the value corresponding to the key
  116423. */
  116424. getOrAdd(key: string, val: T): T;
  116425. /**
  116426. * Check if there's a given key in the dictionary
  116427. * @param key the key to check for
  116428. * @return true if the key is present, false otherwise
  116429. */
  116430. contains(key: string): boolean;
  116431. /**
  116432. * Add a new key and its corresponding value
  116433. * @param key the key to add
  116434. * @param value the value corresponding to the key
  116435. * @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
  116436. */
  116437. add(key: string, value: T): boolean;
  116438. /**
  116439. * Update a specific value associated to a key
  116440. * @param key defines the key to use
  116441. * @param value defines the value to store
  116442. * @returns true if the value was updated (or false if the key was not found)
  116443. */
  116444. set(key: string, value: T): boolean;
  116445. /**
  116446. * Get the element of the given key and remove it from the dictionary
  116447. * @param key defines the key to search
  116448. * @returns the value associated with the key or null if not found
  116449. */
  116450. getAndRemove(key: string): Nullable<T>;
  116451. /**
  116452. * Remove a key/value from the dictionary.
  116453. * @param key the key to remove
  116454. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116455. */
  116456. remove(key: string): boolean;
  116457. /**
  116458. * Clear the whole content of the dictionary
  116459. */
  116460. clear(): void;
  116461. /**
  116462. * Gets the current count
  116463. */
  116464. get count(): number;
  116465. /**
  116466. * Execute a callback on each key/val of the dictionary.
  116467. * Note that you can remove any element in this dictionary in the callback implementation
  116468. * @param callback the callback to execute on a given key/value pair
  116469. */
  116470. forEach(callback: (key: string, val: T) => void): void;
  116471. /**
  116472. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116473. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116474. * Note that you can remove any element in this dictionary in the callback implementation
  116475. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116476. * @returns the first item
  116477. */
  116478. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116479. private _count;
  116480. private _data;
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /** @hidden */
  116485. export interface ICollisionCoordinator {
  116486. createCollider(): Collider;
  116487. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116488. init(scene: Scene): void;
  116489. }
  116490. /** @hidden */
  116491. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116492. private _scene;
  116493. private _scaledPosition;
  116494. private _scaledVelocity;
  116495. private _finalPosition;
  116496. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116497. createCollider(): Collider;
  116498. init(scene: Scene): void;
  116499. private _collideWithWorld;
  116500. }
  116501. }
  116502. declare module BABYLON {
  116503. /**
  116504. * Class used to manage all inputs for the scene.
  116505. */
  116506. export class InputManager {
  116507. /** The distance in pixel that you have to move to prevent some events */
  116508. static DragMovementThreshold: number;
  116509. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116510. static LongPressDelay: number;
  116511. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116512. static DoubleClickDelay: number;
  116513. /** If you need to check double click without raising a single click at first click, enable this flag */
  116514. static ExclusiveDoubleClickMode: boolean;
  116515. private _wheelEventName;
  116516. private _onPointerMove;
  116517. private _onPointerDown;
  116518. private _onPointerUp;
  116519. private _initClickEvent;
  116520. private _initActionManager;
  116521. private _delayedSimpleClick;
  116522. private _delayedSimpleClickTimeout;
  116523. private _previousDelayedSimpleClickTimeout;
  116524. private _meshPickProceed;
  116525. private _previousButtonPressed;
  116526. private _currentPickResult;
  116527. private _previousPickResult;
  116528. private _totalPointersPressed;
  116529. private _doubleClickOccured;
  116530. private _pointerOverMesh;
  116531. private _pickedDownMesh;
  116532. private _pickedUpMesh;
  116533. private _pointerX;
  116534. private _pointerY;
  116535. private _unTranslatedPointerX;
  116536. private _unTranslatedPointerY;
  116537. private _startingPointerPosition;
  116538. private _previousStartingPointerPosition;
  116539. private _startingPointerTime;
  116540. private _previousStartingPointerTime;
  116541. private _pointerCaptures;
  116542. private _onKeyDown;
  116543. private _onKeyUp;
  116544. private _onCanvasFocusObserver;
  116545. private _onCanvasBlurObserver;
  116546. private _scene;
  116547. /**
  116548. * Creates a new InputManager
  116549. * @param scene defines the hosting scene
  116550. */
  116551. constructor(scene: Scene);
  116552. /**
  116553. * Gets the mesh that is currently under the pointer
  116554. */
  116555. get meshUnderPointer(): Nullable<AbstractMesh>;
  116556. /**
  116557. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116558. */
  116559. get unTranslatedPointer(): Vector2;
  116560. /**
  116561. * Gets or sets the current on-screen X position of the pointer
  116562. */
  116563. get pointerX(): number;
  116564. set pointerX(value: number);
  116565. /**
  116566. * Gets or sets the current on-screen Y position of the pointer
  116567. */
  116568. get pointerY(): number;
  116569. set pointerY(value: number);
  116570. private _updatePointerPosition;
  116571. private _processPointerMove;
  116572. private _setRayOnPointerInfo;
  116573. private _checkPrePointerObservable;
  116574. /**
  116575. * Use this method to simulate a pointer move on a mesh
  116576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116579. */
  116580. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116581. /**
  116582. * Use this method to simulate a pointer down on a mesh
  116583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116586. */
  116587. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116588. private _processPointerDown;
  116589. /** @hidden */
  116590. _isPointerSwiping(): boolean;
  116591. /**
  116592. * Use this method to simulate a pointer up on a mesh
  116593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116596. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116597. */
  116598. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116599. private _processPointerUp;
  116600. /**
  116601. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116602. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116603. * @returns true if the pointer was captured
  116604. */
  116605. isPointerCaptured(pointerId?: number): boolean;
  116606. /**
  116607. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116608. * @param attachUp defines if you want to attach events to pointerup
  116609. * @param attachDown defines if you want to attach events to pointerdown
  116610. * @param attachMove defines if you want to attach events to pointermove
  116611. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116612. */
  116613. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116614. /**
  116615. * Detaches all event handlers
  116616. */
  116617. detachControl(): void;
  116618. /**
  116619. * Force the value of meshUnderPointer
  116620. * @param mesh defines the mesh to use
  116621. */
  116622. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116623. /**
  116624. * Gets the mesh under the pointer
  116625. * @returns a Mesh or null if no mesh is under the pointer
  116626. */
  116627. getPointerOverMesh(): Nullable<AbstractMesh>;
  116628. }
  116629. }
  116630. declare module BABYLON {
  116631. /**
  116632. * This class defines the direct association between an animation and a target
  116633. */
  116634. export class TargetedAnimation {
  116635. /**
  116636. * Animation to perform
  116637. */
  116638. animation: Animation;
  116639. /**
  116640. * Target to animate
  116641. */
  116642. target: any;
  116643. /**
  116644. * Returns the string "TargetedAnimation"
  116645. * @returns "TargetedAnimation"
  116646. */
  116647. getClassName(): string;
  116648. /**
  116649. * Serialize the object
  116650. * @returns the JSON object representing the current entity
  116651. */
  116652. serialize(): any;
  116653. }
  116654. /**
  116655. * Use this class to create coordinated animations on multiple targets
  116656. */
  116657. export class AnimationGroup implements IDisposable {
  116658. /** The name of the animation group */
  116659. name: string;
  116660. private _scene;
  116661. private _targetedAnimations;
  116662. private _animatables;
  116663. private _from;
  116664. private _to;
  116665. private _isStarted;
  116666. private _isPaused;
  116667. private _speedRatio;
  116668. private _loopAnimation;
  116669. private _isAdditive;
  116670. /**
  116671. * Gets or sets the unique id of the node
  116672. */
  116673. uniqueId: number;
  116674. /**
  116675. * This observable will notify when one animation have ended
  116676. */
  116677. onAnimationEndObservable: Observable<TargetedAnimation>;
  116678. /**
  116679. * Observer raised when one animation loops
  116680. */
  116681. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116682. /**
  116683. * Observer raised when all animations have looped
  116684. */
  116685. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116686. /**
  116687. * This observable will notify when all animations have ended.
  116688. */
  116689. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116690. /**
  116691. * This observable will notify when all animations have paused.
  116692. */
  116693. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116694. /**
  116695. * This observable will notify when all animations are playing.
  116696. */
  116697. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116698. /**
  116699. * Gets the first frame
  116700. */
  116701. get from(): number;
  116702. /**
  116703. * Gets the last frame
  116704. */
  116705. get to(): number;
  116706. /**
  116707. * Define if the animations are started
  116708. */
  116709. get isStarted(): boolean;
  116710. /**
  116711. * Gets a value indicating that the current group is playing
  116712. */
  116713. get isPlaying(): boolean;
  116714. /**
  116715. * Gets or sets the speed ratio to use for all animations
  116716. */
  116717. get speedRatio(): number;
  116718. /**
  116719. * Gets or sets the speed ratio to use for all animations
  116720. */
  116721. set speedRatio(value: number);
  116722. /**
  116723. * Gets or sets if all animations should loop or not
  116724. */
  116725. get loopAnimation(): boolean;
  116726. set loopAnimation(value: boolean);
  116727. /**
  116728. * Gets or sets if all animations should be evaluated additively
  116729. */
  116730. get isAdditive(): boolean;
  116731. set isAdditive(value: boolean);
  116732. /**
  116733. * Gets the targeted animations for this animation group
  116734. */
  116735. get targetedAnimations(): Array<TargetedAnimation>;
  116736. /**
  116737. * returning the list of animatables controlled by this animation group.
  116738. */
  116739. get animatables(): Array<Animatable>;
  116740. /**
  116741. * Gets the list of target animations
  116742. */
  116743. get children(): TargetedAnimation[];
  116744. /**
  116745. * Instantiates a new Animation Group.
  116746. * This helps managing several animations at once.
  116747. * @see https://doc.babylonjs.com/how_to/group
  116748. * @param name Defines the name of the group
  116749. * @param scene Defines the scene the group belongs to
  116750. */
  116751. constructor(
  116752. /** The name of the animation group */
  116753. name: string, scene?: Nullable<Scene>);
  116754. /**
  116755. * Add an animation (with its target) in the group
  116756. * @param animation defines the animation we want to add
  116757. * @param target defines the target of the animation
  116758. * @returns the TargetedAnimation object
  116759. */
  116760. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116761. /**
  116762. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116763. * It can add constant keys at begin or end
  116764. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116765. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116766. * @returns the animation group
  116767. */
  116768. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116769. private _animationLoopCount;
  116770. private _animationLoopFlags;
  116771. private _processLoop;
  116772. /**
  116773. * Start all animations on given targets
  116774. * @param loop defines if animations must loop
  116775. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116776. * @param from defines the from key (optional)
  116777. * @param to defines the to key (optional)
  116778. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116779. * @returns the current animation group
  116780. */
  116781. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116782. /**
  116783. * Pause all animations
  116784. * @returns the animation group
  116785. */
  116786. pause(): AnimationGroup;
  116787. /**
  116788. * Play all animations to initial state
  116789. * This function will start() the animations if they were not started or will restart() them if they were paused
  116790. * @param loop defines if animations must loop
  116791. * @returns the animation group
  116792. */
  116793. play(loop?: boolean): AnimationGroup;
  116794. /**
  116795. * Reset all animations to initial state
  116796. * @returns the animation group
  116797. */
  116798. reset(): AnimationGroup;
  116799. /**
  116800. * Restart animations from key 0
  116801. * @returns the animation group
  116802. */
  116803. restart(): AnimationGroup;
  116804. /**
  116805. * Stop all animations
  116806. * @returns the animation group
  116807. */
  116808. stop(): AnimationGroup;
  116809. /**
  116810. * Set animation weight for all animatables
  116811. * @param weight defines the weight to use
  116812. * @return the animationGroup
  116813. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116814. */
  116815. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116816. /**
  116817. * Synchronize and normalize all animatables with a source animatable
  116818. * @param root defines the root animatable to synchronize with
  116819. * @return the animationGroup
  116820. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116821. */
  116822. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116823. /**
  116824. * Goes to a specific frame in this animation group
  116825. * @param frame the frame number to go to
  116826. * @return the animationGroup
  116827. */
  116828. goToFrame(frame: number): AnimationGroup;
  116829. /**
  116830. * Dispose all associated resources
  116831. */
  116832. dispose(): void;
  116833. private _checkAnimationGroupEnded;
  116834. /**
  116835. * Clone the current animation group and returns a copy
  116836. * @param newName defines the name of the new group
  116837. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116838. * @returns the new aniamtion group
  116839. */
  116840. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116841. /**
  116842. * Serializes the animationGroup to an object
  116843. * @returns Serialized object
  116844. */
  116845. serialize(): any;
  116846. /**
  116847. * Returns a new AnimationGroup object parsed from the source provided.
  116848. * @param parsedAnimationGroup defines the source
  116849. * @param scene defines the scene that will receive the animationGroup
  116850. * @returns a new AnimationGroup
  116851. */
  116852. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116853. /**
  116854. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116855. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116856. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116857. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116858. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116859. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116860. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116861. */
  116862. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116863. /**
  116864. * Returns the string "AnimationGroup"
  116865. * @returns "AnimationGroup"
  116866. */
  116867. getClassName(): string;
  116868. /**
  116869. * Creates a detailled string about the object
  116870. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116871. * @returns a string representing the object
  116872. */
  116873. toString(fullDetails?: boolean): string;
  116874. }
  116875. }
  116876. declare module BABYLON {
  116877. /**
  116878. * Define an interface for all classes that will hold resources
  116879. */
  116880. export interface IDisposable {
  116881. /**
  116882. * Releases all held resources
  116883. */
  116884. dispose(): void;
  116885. }
  116886. /** Interface defining initialization parameters for Scene class */
  116887. export interface SceneOptions {
  116888. /**
  116889. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116890. * It will improve performance when the number of geometries becomes important.
  116891. */
  116892. useGeometryUniqueIdsMap?: boolean;
  116893. /**
  116894. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116895. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116896. */
  116897. useMaterialMeshMap?: boolean;
  116898. /**
  116899. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116900. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116901. */
  116902. useClonedMeshMap?: boolean;
  116903. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116904. virtual?: boolean;
  116905. }
  116906. /**
  116907. * Represents a scene to be rendered by the engine.
  116908. * @see https://doc.babylonjs.com/features/scene
  116909. */
  116910. export class Scene extends AbstractScene implements IAnimatable {
  116911. /** The fog is deactivated */
  116912. static readonly FOGMODE_NONE: number;
  116913. /** The fog density is following an exponential function */
  116914. static readonly FOGMODE_EXP: number;
  116915. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116916. static readonly FOGMODE_EXP2: number;
  116917. /** The fog density is following a linear function. */
  116918. static readonly FOGMODE_LINEAR: number;
  116919. /**
  116920. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116922. */
  116923. static MinDeltaTime: number;
  116924. /**
  116925. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116927. */
  116928. static MaxDeltaTime: number;
  116929. /**
  116930. * Factory used to create the default material.
  116931. * @param name The name of the material to create
  116932. * @param scene The scene to create the material for
  116933. * @returns The default material
  116934. */
  116935. static DefaultMaterialFactory(scene: Scene): Material;
  116936. /**
  116937. * Factory used to create the a collision coordinator.
  116938. * @returns The collision coordinator
  116939. */
  116940. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116941. /** @hidden */
  116942. _inputManager: InputManager;
  116943. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116944. cameraToUseForPointers: Nullable<Camera>;
  116945. /** @hidden */
  116946. readonly _isScene: boolean;
  116947. /** @hidden */
  116948. _blockEntityCollection: boolean;
  116949. /**
  116950. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116951. */
  116952. autoClear: boolean;
  116953. /**
  116954. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116955. */
  116956. autoClearDepthAndStencil: boolean;
  116957. /**
  116958. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116959. */
  116960. clearColor: Color4;
  116961. /**
  116962. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116963. */
  116964. ambientColor: Color3;
  116965. /**
  116966. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116967. * It should only be one of the following (if not the default embedded one):
  116968. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116969. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116970. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116971. * The material properties need to be setup according to the type of texture in use.
  116972. */
  116973. environmentBRDFTexture: BaseTexture;
  116974. /** @hidden */
  116975. protected _environmentTexture: Nullable<BaseTexture>;
  116976. /**
  116977. * Texture used in all pbr material as the reflection texture.
  116978. * As in the majority of the scene they are the same (exception for multi room and so on),
  116979. * this is easier to reference from here than from all the materials.
  116980. */
  116981. get environmentTexture(): Nullable<BaseTexture>;
  116982. /**
  116983. * Texture used in all pbr material as the reflection texture.
  116984. * As in the majority of the scene they are the same (exception for multi room and so on),
  116985. * this is easier to set here than in all the materials.
  116986. */
  116987. set environmentTexture(value: Nullable<BaseTexture>);
  116988. /** @hidden */
  116989. protected _environmentIntensity: number;
  116990. /**
  116991. * Intensity of the environment in all pbr material.
  116992. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116993. * As in the majority of the scene they are the same (exception for multi room and so on),
  116994. * this is easier to reference from here than from all the materials.
  116995. */
  116996. get environmentIntensity(): number;
  116997. /**
  116998. * Intensity of the environment in all pbr material.
  116999. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  117000. * As in the majority of the scene they are the same (exception for multi room and so on),
  117001. * this is easier to set here than in all the materials.
  117002. */
  117003. set environmentIntensity(value: number);
  117004. /** @hidden */
  117005. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117006. /**
  117007. * Default image processing configuration used either in the rendering
  117008. * Forward main pass or through the imageProcessingPostProcess if present.
  117009. * As in the majority of the scene they are the same (exception for multi camera),
  117010. * this is easier to reference from here than from all the materials and post process.
  117011. *
  117012. * No setter as we it is a shared configuration, you can set the values instead.
  117013. */
  117014. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  117015. private _forceWireframe;
  117016. /**
  117017. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  117018. */
  117019. set forceWireframe(value: boolean);
  117020. get forceWireframe(): boolean;
  117021. private _skipFrustumClipping;
  117022. /**
  117023. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  117024. */
  117025. set skipFrustumClipping(value: boolean);
  117026. get skipFrustumClipping(): boolean;
  117027. private _forcePointsCloud;
  117028. /**
  117029. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  117030. */
  117031. set forcePointsCloud(value: boolean);
  117032. get forcePointsCloud(): boolean;
  117033. /**
  117034. * Gets or sets the active clipplane 1
  117035. */
  117036. clipPlane: Nullable<Plane>;
  117037. /**
  117038. * Gets or sets the active clipplane 2
  117039. */
  117040. clipPlane2: Nullable<Plane>;
  117041. /**
  117042. * Gets or sets the active clipplane 3
  117043. */
  117044. clipPlane3: Nullable<Plane>;
  117045. /**
  117046. * Gets or sets the active clipplane 4
  117047. */
  117048. clipPlane4: Nullable<Plane>;
  117049. /**
  117050. * Gets or sets the active clipplane 5
  117051. */
  117052. clipPlane5: Nullable<Plane>;
  117053. /**
  117054. * Gets or sets the active clipplane 6
  117055. */
  117056. clipPlane6: Nullable<Plane>;
  117057. /**
  117058. * Gets or sets a boolean indicating if animations are enabled
  117059. */
  117060. animationsEnabled: boolean;
  117061. private _animationPropertiesOverride;
  117062. /**
  117063. * Gets or sets the animation properties override
  117064. */
  117065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117067. /**
  117068. * Gets or sets a boolean indicating if a constant deltatime has to be used
  117069. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  117070. */
  117071. useConstantAnimationDeltaTime: boolean;
  117072. /**
  117073. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  117074. * Please note that it requires to run a ray cast through the scene on every frame
  117075. */
  117076. constantlyUpdateMeshUnderPointer: boolean;
  117077. /**
  117078. * Defines the HTML cursor to use when hovering over interactive elements
  117079. */
  117080. hoverCursor: string;
  117081. /**
  117082. * Defines the HTML default cursor to use (empty by default)
  117083. */
  117084. defaultCursor: string;
  117085. /**
  117086. * Defines whether cursors are handled by the scene.
  117087. */
  117088. doNotHandleCursors: boolean;
  117089. /**
  117090. * This is used to call preventDefault() on pointer down
  117091. * in order to block unwanted artifacts like system double clicks
  117092. */
  117093. preventDefaultOnPointerDown: boolean;
  117094. /**
  117095. * This is used to call preventDefault() on pointer up
  117096. * in order to block unwanted artifacts like system double clicks
  117097. */
  117098. preventDefaultOnPointerUp: boolean;
  117099. /**
  117100. * Gets or sets user defined metadata
  117101. */
  117102. metadata: any;
  117103. /**
  117104. * For internal use only. Please do not use.
  117105. */
  117106. reservedDataStore: any;
  117107. /**
  117108. * Gets the name of the plugin used to load this scene (null by default)
  117109. */
  117110. loadingPluginName: string;
  117111. /**
  117112. * Use this array to add regular expressions used to disable offline support for specific urls
  117113. */
  117114. disableOfflineSupportExceptionRules: RegExp[];
  117115. /**
  117116. * An event triggered when the scene is disposed.
  117117. */
  117118. onDisposeObservable: Observable<Scene>;
  117119. private _onDisposeObserver;
  117120. /** Sets a function to be executed when this scene is disposed. */
  117121. set onDispose(callback: () => void);
  117122. /**
  117123. * An event triggered before rendering the scene (right after animations and physics)
  117124. */
  117125. onBeforeRenderObservable: Observable<Scene>;
  117126. private _onBeforeRenderObserver;
  117127. /** Sets a function to be executed before rendering this scene */
  117128. set beforeRender(callback: Nullable<() => void>);
  117129. /**
  117130. * An event triggered after rendering the scene
  117131. */
  117132. onAfterRenderObservable: Observable<Scene>;
  117133. /**
  117134. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  117135. */
  117136. onAfterRenderCameraObservable: Observable<Camera>;
  117137. private _onAfterRenderObserver;
  117138. /** Sets a function to be executed after rendering this scene */
  117139. set afterRender(callback: Nullable<() => void>);
  117140. /**
  117141. * An event triggered before animating the scene
  117142. */
  117143. onBeforeAnimationsObservable: Observable<Scene>;
  117144. /**
  117145. * An event triggered after animations processing
  117146. */
  117147. onAfterAnimationsObservable: Observable<Scene>;
  117148. /**
  117149. * An event triggered before draw calls are ready to be sent
  117150. */
  117151. onBeforeDrawPhaseObservable: Observable<Scene>;
  117152. /**
  117153. * An event triggered after draw calls have been sent
  117154. */
  117155. onAfterDrawPhaseObservable: Observable<Scene>;
  117156. /**
  117157. * An event triggered when the scene is ready
  117158. */
  117159. onReadyObservable: Observable<Scene>;
  117160. /**
  117161. * An event triggered before rendering a camera
  117162. */
  117163. onBeforeCameraRenderObservable: Observable<Camera>;
  117164. private _onBeforeCameraRenderObserver;
  117165. /** Sets a function to be executed before rendering a camera*/
  117166. set beforeCameraRender(callback: () => void);
  117167. /**
  117168. * An event triggered after rendering a camera
  117169. */
  117170. onAfterCameraRenderObservable: Observable<Camera>;
  117171. private _onAfterCameraRenderObserver;
  117172. /** Sets a function to be executed after rendering a camera*/
  117173. set afterCameraRender(callback: () => void);
  117174. /**
  117175. * An event triggered when active meshes evaluation is about to start
  117176. */
  117177. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  117178. /**
  117179. * An event triggered when active meshes evaluation is done
  117180. */
  117181. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  117182. /**
  117183. * An event triggered when particles rendering is about to start
  117184. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117185. */
  117186. onBeforeParticlesRenderingObservable: Observable<Scene>;
  117187. /**
  117188. * An event triggered when particles rendering is done
  117189. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117190. */
  117191. onAfterParticlesRenderingObservable: Observable<Scene>;
  117192. /**
  117193. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  117194. */
  117195. onDataLoadedObservable: Observable<Scene>;
  117196. /**
  117197. * An event triggered when a camera is created
  117198. */
  117199. onNewCameraAddedObservable: Observable<Camera>;
  117200. /**
  117201. * An event triggered when a camera is removed
  117202. */
  117203. onCameraRemovedObservable: Observable<Camera>;
  117204. /**
  117205. * An event triggered when a light is created
  117206. */
  117207. onNewLightAddedObservable: Observable<Light>;
  117208. /**
  117209. * An event triggered when a light is removed
  117210. */
  117211. onLightRemovedObservable: Observable<Light>;
  117212. /**
  117213. * An event triggered when a geometry is created
  117214. */
  117215. onNewGeometryAddedObservable: Observable<Geometry>;
  117216. /**
  117217. * An event triggered when a geometry is removed
  117218. */
  117219. onGeometryRemovedObservable: Observable<Geometry>;
  117220. /**
  117221. * An event triggered when a transform node is created
  117222. */
  117223. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  117224. /**
  117225. * An event triggered when a transform node is removed
  117226. */
  117227. onTransformNodeRemovedObservable: Observable<TransformNode>;
  117228. /**
  117229. * An event triggered when a mesh is created
  117230. */
  117231. onNewMeshAddedObservable: Observable<AbstractMesh>;
  117232. /**
  117233. * An event triggered when a mesh is removed
  117234. */
  117235. onMeshRemovedObservable: Observable<AbstractMesh>;
  117236. /**
  117237. * An event triggered when a skeleton is created
  117238. */
  117239. onNewSkeletonAddedObservable: Observable<Skeleton>;
  117240. /**
  117241. * An event triggered when a skeleton is removed
  117242. */
  117243. onSkeletonRemovedObservable: Observable<Skeleton>;
  117244. /**
  117245. * An event triggered when a material is created
  117246. */
  117247. onNewMaterialAddedObservable: Observable<Material>;
  117248. /**
  117249. * An event triggered when a material is removed
  117250. */
  117251. onMaterialRemovedObservable: Observable<Material>;
  117252. /**
  117253. * An event triggered when a texture is created
  117254. */
  117255. onNewTextureAddedObservable: Observable<BaseTexture>;
  117256. /**
  117257. * An event triggered when a texture is removed
  117258. */
  117259. onTextureRemovedObservable: Observable<BaseTexture>;
  117260. /**
  117261. * An event triggered when render targets are about to be rendered
  117262. * Can happen multiple times per frame.
  117263. */
  117264. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  117265. /**
  117266. * An event triggered when render targets were rendered.
  117267. * Can happen multiple times per frame.
  117268. */
  117269. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  117270. /**
  117271. * An event triggered before calculating deterministic simulation step
  117272. */
  117273. onBeforeStepObservable: Observable<Scene>;
  117274. /**
  117275. * An event triggered after calculating deterministic simulation step
  117276. */
  117277. onAfterStepObservable: Observable<Scene>;
  117278. /**
  117279. * An event triggered when the activeCamera property is updated
  117280. */
  117281. onActiveCameraChanged: Observable<Scene>;
  117282. /**
  117283. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  117284. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  117285. * 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)
  117286. */
  117287. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  117288. /**
  117289. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  117290. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  117291. * 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)
  117292. */
  117293. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  117294. /**
  117295. * This Observable will when a mesh has been imported into the scene.
  117296. */
  117297. onMeshImportedObservable: Observable<AbstractMesh>;
  117298. /**
  117299. * This Observable will when an animation file has been imported into the scene.
  117300. */
  117301. onAnimationFileImportedObservable: Observable<Scene>;
  117302. /**
  117303. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  117304. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  117305. */
  117306. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  117307. /** @hidden */
  117308. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  117309. /**
  117310. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  117311. */
  117312. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  117313. /**
  117314. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  117315. */
  117316. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117317. /**
  117318. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117319. */
  117320. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117321. /** Callback called when a pointer move is detected */
  117322. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117323. /** Callback called when a pointer down is detected */
  117324. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117325. /** Callback called when a pointer up is detected */
  117326. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117327. /** Callback called when a pointer pick is detected */
  117328. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117329. /**
  117330. * 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).
  117331. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117332. */
  117333. onPrePointerObservable: Observable<PointerInfoPre>;
  117334. /**
  117335. * Observable event triggered each time an input event is received from the rendering canvas
  117336. */
  117337. onPointerObservable: Observable<PointerInfo>;
  117338. /**
  117339. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117340. */
  117341. get unTranslatedPointer(): Vector2;
  117342. /**
  117343. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117344. */
  117345. static get DragMovementThreshold(): number;
  117346. static set DragMovementThreshold(value: number);
  117347. /**
  117348. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117349. */
  117350. static get LongPressDelay(): number;
  117351. static set LongPressDelay(value: number);
  117352. /**
  117353. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117354. */
  117355. static get DoubleClickDelay(): number;
  117356. static set DoubleClickDelay(value: number);
  117357. /** If you need to check double click without raising a single click at first click, enable this flag */
  117358. static get ExclusiveDoubleClickMode(): boolean;
  117359. static set ExclusiveDoubleClickMode(value: boolean);
  117360. /** @hidden */
  117361. _mirroredCameraPosition: Nullable<Vector3>;
  117362. /**
  117363. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117364. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117365. */
  117366. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117367. /**
  117368. * Observable event triggered each time an keyboard event is received from the hosting window
  117369. */
  117370. onKeyboardObservable: Observable<KeyboardInfo>;
  117371. private _useRightHandedSystem;
  117372. /**
  117373. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117374. */
  117375. set useRightHandedSystem(value: boolean);
  117376. get useRightHandedSystem(): boolean;
  117377. private _timeAccumulator;
  117378. private _currentStepId;
  117379. private _currentInternalStep;
  117380. /**
  117381. * Sets the step Id used by deterministic lock step
  117382. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117383. * @param newStepId defines the step Id
  117384. */
  117385. setStepId(newStepId: number): void;
  117386. /**
  117387. * Gets the step Id used by deterministic lock step
  117388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117389. * @returns the step Id
  117390. */
  117391. getStepId(): number;
  117392. /**
  117393. * Gets the internal step used by deterministic lock step
  117394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117395. * @returns the internal step
  117396. */
  117397. getInternalStep(): number;
  117398. private _fogEnabled;
  117399. /**
  117400. * Gets or sets a boolean indicating if fog is enabled on this scene
  117401. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117402. * (Default is true)
  117403. */
  117404. set fogEnabled(value: boolean);
  117405. get fogEnabled(): boolean;
  117406. private _fogMode;
  117407. /**
  117408. * Gets or sets the fog mode to use
  117409. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117410. * | mode | value |
  117411. * | --- | --- |
  117412. * | FOGMODE_NONE | 0 |
  117413. * | FOGMODE_EXP | 1 |
  117414. * | FOGMODE_EXP2 | 2 |
  117415. * | FOGMODE_LINEAR | 3 |
  117416. */
  117417. set fogMode(value: number);
  117418. get fogMode(): number;
  117419. /**
  117420. * Gets or sets the fog color to use
  117421. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117422. * (Default is Color3(0.2, 0.2, 0.3))
  117423. */
  117424. fogColor: Color3;
  117425. /**
  117426. * Gets or sets the fog density to use
  117427. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117428. * (Default is 0.1)
  117429. */
  117430. fogDensity: number;
  117431. /**
  117432. * Gets or sets the fog start distance to use
  117433. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117434. * (Default is 0)
  117435. */
  117436. fogStart: number;
  117437. /**
  117438. * Gets or sets the fog end distance to use
  117439. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117440. * (Default is 1000)
  117441. */
  117442. fogEnd: number;
  117443. /**
  117444. * Flag indicating that the frame buffer binding is handled by another component
  117445. */
  117446. prePass: boolean;
  117447. private _shadowsEnabled;
  117448. /**
  117449. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117450. */
  117451. set shadowsEnabled(value: boolean);
  117452. get shadowsEnabled(): boolean;
  117453. private _lightsEnabled;
  117454. /**
  117455. * Gets or sets a boolean indicating if lights are enabled on this scene
  117456. */
  117457. set lightsEnabled(value: boolean);
  117458. get lightsEnabled(): boolean;
  117459. /** All of the active cameras added to this scene. */
  117460. activeCameras: Camera[];
  117461. /** @hidden */
  117462. _activeCamera: Nullable<Camera>;
  117463. /** Gets or sets the current active camera */
  117464. get activeCamera(): Nullable<Camera>;
  117465. set activeCamera(value: Nullable<Camera>);
  117466. private _defaultMaterial;
  117467. /** The default material used on meshes when no material is affected */
  117468. get defaultMaterial(): Material;
  117469. /** The default material used on meshes when no material is affected */
  117470. set defaultMaterial(value: Material);
  117471. private _texturesEnabled;
  117472. /**
  117473. * Gets or sets a boolean indicating if textures are enabled on this scene
  117474. */
  117475. set texturesEnabled(value: boolean);
  117476. get texturesEnabled(): boolean;
  117477. /**
  117478. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117479. */
  117480. physicsEnabled: boolean;
  117481. /**
  117482. * Gets or sets a boolean indicating if particles are enabled on this scene
  117483. */
  117484. particlesEnabled: boolean;
  117485. /**
  117486. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117487. */
  117488. spritesEnabled: boolean;
  117489. private _skeletonsEnabled;
  117490. /**
  117491. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117492. */
  117493. set skeletonsEnabled(value: boolean);
  117494. get skeletonsEnabled(): boolean;
  117495. /**
  117496. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117497. */
  117498. lensFlaresEnabled: boolean;
  117499. /**
  117500. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117501. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117502. */
  117503. collisionsEnabled: boolean;
  117504. private _collisionCoordinator;
  117505. /** @hidden */
  117506. get collisionCoordinator(): ICollisionCoordinator;
  117507. /**
  117508. * Defines the gravity applied to this scene (used only for collisions)
  117509. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117510. */
  117511. gravity: Vector3;
  117512. /**
  117513. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117514. */
  117515. postProcessesEnabled: boolean;
  117516. /**
  117517. * The list of postprocesses added to the scene
  117518. */
  117519. postProcesses: PostProcess[];
  117520. /**
  117521. * Gets the current postprocess manager
  117522. */
  117523. postProcessManager: PostProcessManager;
  117524. /**
  117525. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117526. */
  117527. renderTargetsEnabled: boolean;
  117528. /**
  117529. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117530. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117531. */
  117532. dumpNextRenderTargets: boolean;
  117533. /**
  117534. * The list of user defined render targets added to the scene
  117535. */
  117536. customRenderTargets: RenderTargetTexture[];
  117537. /**
  117538. * Defines if texture loading must be delayed
  117539. * If true, textures will only be loaded when they need to be rendered
  117540. */
  117541. useDelayedTextureLoading: boolean;
  117542. /**
  117543. * Gets the list of meshes imported to the scene through SceneLoader
  117544. */
  117545. importedMeshesFiles: String[];
  117546. /**
  117547. * Gets or sets a boolean indicating if probes are enabled on this scene
  117548. */
  117549. probesEnabled: boolean;
  117550. /**
  117551. * Gets or sets the current offline provider to use to store scene data
  117552. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117553. */
  117554. offlineProvider: IOfflineProvider;
  117555. /**
  117556. * Gets or sets the action manager associated with the scene
  117557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117558. */
  117559. actionManager: AbstractActionManager;
  117560. private _meshesForIntersections;
  117561. /**
  117562. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117563. */
  117564. proceduralTexturesEnabled: boolean;
  117565. private _engine;
  117566. private _totalVertices;
  117567. /** @hidden */
  117568. _activeIndices: PerfCounter;
  117569. /** @hidden */
  117570. _activeParticles: PerfCounter;
  117571. /** @hidden */
  117572. _activeBones: PerfCounter;
  117573. private _animationRatio;
  117574. /** @hidden */
  117575. _animationTimeLast: number;
  117576. /** @hidden */
  117577. _animationTime: number;
  117578. /**
  117579. * Gets or sets a general scale for animation speed
  117580. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117581. */
  117582. animationTimeScale: number;
  117583. /** @hidden */
  117584. _cachedMaterial: Nullable<Material>;
  117585. /** @hidden */
  117586. _cachedEffect: Nullable<Effect>;
  117587. /** @hidden */
  117588. _cachedVisibility: Nullable<number>;
  117589. private _renderId;
  117590. private _frameId;
  117591. private _executeWhenReadyTimeoutId;
  117592. private _intermediateRendering;
  117593. private _viewUpdateFlag;
  117594. private _projectionUpdateFlag;
  117595. /** @hidden */
  117596. _toBeDisposed: Nullable<IDisposable>[];
  117597. private _activeRequests;
  117598. /** @hidden */
  117599. _pendingData: any[];
  117600. private _isDisposed;
  117601. /**
  117602. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117603. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117604. */
  117605. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117606. private _activeMeshes;
  117607. private _processedMaterials;
  117608. private _renderTargets;
  117609. /** @hidden */
  117610. _activeParticleSystems: SmartArray<IParticleSystem>;
  117611. private _activeSkeletons;
  117612. private _softwareSkinnedMeshes;
  117613. private _renderingManager;
  117614. /** @hidden */
  117615. _activeAnimatables: Animatable[];
  117616. private _transformMatrix;
  117617. private _sceneUbo;
  117618. /** @hidden */
  117619. _viewMatrix: Matrix;
  117620. private _projectionMatrix;
  117621. /** @hidden */
  117622. _forcedViewPosition: Nullable<Vector3>;
  117623. /** @hidden */
  117624. _frustumPlanes: Plane[];
  117625. /**
  117626. * Gets the list of frustum planes (built from the active camera)
  117627. */
  117628. get frustumPlanes(): Plane[];
  117629. /**
  117630. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117631. * This is useful if there are more lights that the maximum simulteanous authorized
  117632. */
  117633. requireLightSorting: boolean;
  117634. /** @hidden */
  117635. readonly useMaterialMeshMap: boolean;
  117636. /** @hidden */
  117637. readonly useClonedMeshMap: boolean;
  117638. private _externalData;
  117639. private _uid;
  117640. /**
  117641. * @hidden
  117642. * Backing store of defined scene components.
  117643. */
  117644. _components: ISceneComponent[];
  117645. /**
  117646. * @hidden
  117647. * Backing store of defined scene components.
  117648. */
  117649. _serializableComponents: ISceneSerializableComponent[];
  117650. /**
  117651. * List of components to register on the next registration step.
  117652. */
  117653. private _transientComponents;
  117654. /**
  117655. * Registers the transient components if needed.
  117656. */
  117657. private _registerTransientComponents;
  117658. /**
  117659. * @hidden
  117660. * Add a component to the scene.
  117661. * Note that the ccomponent could be registered on th next frame if this is called after
  117662. * the register component stage.
  117663. * @param component Defines the component to add to the scene
  117664. */
  117665. _addComponent(component: ISceneComponent): void;
  117666. /**
  117667. * @hidden
  117668. * Gets a component from the scene.
  117669. * @param name defines the name of the component to retrieve
  117670. * @returns the component or null if not present
  117671. */
  117672. _getComponent(name: string): Nullable<ISceneComponent>;
  117673. /**
  117674. * @hidden
  117675. * Defines the actions happening before camera updates.
  117676. */
  117677. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117678. /**
  117679. * @hidden
  117680. * Defines the actions happening before clear the canvas.
  117681. */
  117682. _beforeClearStage: Stage<SimpleStageAction>;
  117683. /**
  117684. * @hidden
  117685. * Defines the actions when collecting render targets for the frame.
  117686. */
  117687. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117688. /**
  117689. * @hidden
  117690. * Defines the actions happening for one camera in the frame.
  117691. */
  117692. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117693. /**
  117694. * @hidden
  117695. * Defines the actions happening during the per mesh ready checks.
  117696. */
  117697. _isReadyForMeshStage: Stage<MeshStageAction>;
  117698. /**
  117699. * @hidden
  117700. * Defines the actions happening before evaluate active mesh checks.
  117701. */
  117702. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117703. /**
  117704. * @hidden
  117705. * Defines the actions happening during the evaluate sub mesh checks.
  117706. */
  117707. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117708. /**
  117709. * @hidden
  117710. * Defines the actions happening during the active mesh stage.
  117711. */
  117712. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117713. /**
  117714. * @hidden
  117715. * Defines the actions happening during the per camera render target step.
  117716. */
  117717. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117718. /**
  117719. * @hidden
  117720. * Defines the actions happening just before the active camera is drawing.
  117721. */
  117722. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117723. /**
  117724. * @hidden
  117725. * Defines the actions happening just before a render target is drawing.
  117726. */
  117727. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117728. /**
  117729. * @hidden
  117730. * Defines the actions happening just before a rendering group is drawing.
  117731. */
  117732. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117733. /**
  117734. * @hidden
  117735. * Defines the actions happening just before a mesh is drawing.
  117736. */
  117737. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117738. /**
  117739. * @hidden
  117740. * Defines the actions happening just after a mesh has been drawn.
  117741. */
  117742. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117743. /**
  117744. * @hidden
  117745. * Defines the actions happening just after a rendering group has been drawn.
  117746. */
  117747. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117748. /**
  117749. * @hidden
  117750. * Defines the actions happening just after the active camera has been drawn.
  117751. */
  117752. _afterCameraDrawStage: Stage<CameraStageAction>;
  117753. /**
  117754. * @hidden
  117755. * Defines the actions happening just after a render target has been drawn.
  117756. */
  117757. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117758. /**
  117759. * @hidden
  117760. * Defines the actions happening just after rendering all cameras and computing intersections.
  117761. */
  117762. _afterRenderStage: Stage<SimpleStageAction>;
  117763. /**
  117764. * @hidden
  117765. * Defines the actions happening when a pointer move event happens.
  117766. */
  117767. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117768. /**
  117769. * @hidden
  117770. * Defines the actions happening when a pointer down event happens.
  117771. */
  117772. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117773. /**
  117774. * @hidden
  117775. * Defines the actions happening when a pointer up event happens.
  117776. */
  117777. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117778. /**
  117779. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117780. */
  117781. private geometriesByUniqueId;
  117782. /**
  117783. * Creates a new Scene
  117784. * @param engine defines the engine to use to render this scene
  117785. * @param options defines the scene options
  117786. */
  117787. constructor(engine: Engine, options?: SceneOptions);
  117788. /**
  117789. * Gets a string idenfifying the name of the class
  117790. * @returns "Scene" string
  117791. */
  117792. getClassName(): string;
  117793. private _defaultMeshCandidates;
  117794. /**
  117795. * @hidden
  117796. */
  117797. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117798. private _defaultSubMeshCandidates;
  117799. /**
  117800. * @hidden
  117801. */
  117802. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117803. /**
  117804. * Sets the default candidate providers for the scene.
  117805. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117806. * and getCollidingSubMeshCandidates to their default function
  117807. */
  117808. setDefaultCandidateProviders(): void;
  117809. /**
  117810. * Gets the mesh that is currently under the pointer
  117811. */
  117812. get meshUnderPointer(): Nullable<AbstractMesh>;
  117813. /**
  117814. * Gets or sets the current on-screen X position of the pointer
  117815. */
  117816. get pointerX(): number;
  117817. set pointerX(value: number);
  117818. /**
  117819. * Gets or sets the current on-screen Y position of the pointer
  117820. */
  117821. get pointerY(): number;
  117822. set pointerY(value: number);
  117823. /**
  117824. * Gets the cached material (ie. the latest rendered one)
  117825. * @returns the cached material
  117826. */
  117827. getCachedMaterial(): Nullable<Material>;
  117828. /**
  117829. * Gets the cached effect (ie. the latest rendered one)
  117830. * @returns the cached effect
  117831. */
  117832. getCachedEffect(): Nullable<Effect>;
  117833. /**
  117834. * Gets the cached visibility state (ie. the latest rendered one)
  117835. * @returns the cached visibility state
  117836. */
  117837. getCachedVisibility(): Nullable<number>;
  117838. /**
  117839. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117840. * @param material defines the current material
  117841. * @param effect defines the current effect
  117842. * @param visibility defines the current visibility state
  117843. * @returns true if one parameter is not cached
  117844. */
  117845. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117846. /**
  117847. * Gets the engine associated with the scene
  117848. * @returns an Engine
  117849. */
  117850. getEngine(): Engine;
  117851. /**
  117852. * Gets the total number of vertices rendered per frame
  117853. * @returns the total number of vertices rendered per frame
  117854. */
  117855. getTotalVertices(): number;
  117856. /**
  117857. * Gets the performance counter for total vertices
  117858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117859. */
  117860. get totalVerticesPerfCounter(): PerfCounter;
  117861. /**
  117862. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117863. * @returns the total number of active indices rendered per frame
  117864. */
  117865. getActiveIndices(): number;
  117866. /**
  117867. * Gets the performance counter for active indices
  117868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117869. */
  117870. get totalActiveIndicesPerfCounter(): PerfCounter;
  117871. /**
  117872. * Gets the total number of active particles rendered per frame
  117873. * @returns the total number of active particles rendered per frame
  117874. */
  117875. getActiveParticles(): number;
  117876. /**
  117877. * Gets the performance counter for active particles
  117878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117879. */
  117880. get activeParticlesPerfCounter(): PerfCounter;
  117881. /**
  117882. * Gets the total number of active bones rendered per frame
  117883. * @returns the total number of active bones rendered per frame
  117884. */
  117885. getActiveBones(): number;
  117886. /**
  117887. * Gets the performance counter for active bones
  117888. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117889. */
  117890. get activeBonesPerfCounter(): PerfCounter;
  117891. /**
  117892. * Gets the array of active meshes
  117893. * @returns an array of AbstractMesh
  117894. */
  117895. getActiveMeshes(): SmartArray<AbstractMesh>;
  117896. /**
  117897. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117898. * @returns a number
  117899. */
  117900. getAnimationRatio(): number;
  117901. /**
  117902. * Gets an unique Id for the current render phase
  117903. * @returns a number
  117904. */
  117905. getRenderId(): number;
  117906. /**
  117907. * Gets an unique Id for the current frame
  117908. * @returns a number
  117909. */
  117910. getFrameId(): number;
  117911. /** Call this function if you want to manually increment the render Id*/
  117912. incrementRenderId(): void;
  117913. private _createUbo;
  117914. /**
  117915. * Use this method to simulate a pointer move on a mesh
  117916. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117917. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117918. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117919. * @returns the current scene
  117920. */
  117921. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117922. /**
  117923. * Use this method to simulate a pointer down on a mesh
  117924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117927. * @returns the current scene
  117928. */
  117929. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117930. /**
  117931. * Use this method to simulate a pointer up on a mesh
  117932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117935. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117936. * @returns the current scene
  117937. */
  117938. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117939. /**
  117940. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117941. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117942. * @returns true if the pointer was captured
  117943. */
  117944. isPointerCaptured(pointerId?: number): boolean;
  117945. /**
  117946. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117947. * @param attachUp defines if you want to attach events to pointerup
  117948. * @param attachDown defines if you want to attach events to pointerdown
  117949. * @param attachMove defines if you want to attach events to pointermove
  117950. */
  117951. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117952. /** Detaches all event handlers*/
  117953. detachControl(): void;
  117954. /**
  117955. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117956. * Delay loaded resources are not taking in account
  117957. * @return true if all required resources are ready
  117958. */
  117959. isReady(): boolean;
  117960. /** Resets all cached information relative to material (including effect and visibility) */
  117961. resetCachedMaterial(): void;
  117962. /**
  117963. * Registers a function to be called before every frame render
  117964. * @param func defines the function to register
  117965. */
  117966. registerBeforeRender(func: () => void): void;
  117967. /**
  117968. * Unregisters a function called before every frame render
  117969. * @param func defines the function to unregister
  117970. */
  117971. unregisterBeforeRender(func: () => void): void;
  117972. /**
  117973. * Registers a function to be called after every frame render
  117974. * @param func defines the function to register
  117975. */
  117976. registerAfterRender(func: () => void): void;
  117977. /**
  117978. * Unregisters a function called after every frame render
  117979. * @param func defines the function to unregister
  117980. */
  117981. unregisterAfterRender(func: () => void): void;
  117982. private _executeOnceBeforeRender;
  117983. /**
  117984. * The provided function will run before render once and will be disposed afterwards.
  117985. * A timeout delay can be provided so that the function will be executed in N ms.
  117986. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117987. * @param func The function to be executed.
  117988. * @param timeout optional delay in ms
  117989. */
  117990. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117991. /** @hidden */
  117992. _addPendingData(data: any): void;
  117993. /** @hidden */
  117994. _removePendingData(data: any): void;
  117995. /**
  117996. * Returns the number of items waiting to be loaded
  117997. * @returns the number of items waiting to be loaded
  117998. */
  117999. getWaitingItemsCount(): number;
  118000. /**
  118001. * Returns a boolean indicating if the scene is still loading data
  118002. */
  118003. get isLoading(): boolean;
  118004. /**
  118005. * Registers a function to be executed when the scene is ready
  118006. * @param {Function} func - the function to be executed
  118007. */
  118008. executeWhenReady(func: () => void): void;
  118009. /**
  118010. * Returns a promise that resolves when the scene is ready
  118011. * @returns A promise that resolves when the scene is ready
  118012. */
  118013. whenReadyAsync(): Promise<void>;
  118014. /** @hidden */
  118015. _checkIsReady(): void;
  118016. /**
  118017. * Gets all animatable attached to the scene
  118018. */
  118019. get animatables(): Animatable[];
  118020. /**
  118021. * Resets the last animation time frame.
  118022. * Useful to override when animations start running when loading a scene for the first time.
  118023. */
  118024. resetLastAnimationTimeFrame(): void;
  118025. /**
  118026. * Gets the current view matrix
  118027. * @returns a Matrix
  118028. */
  118029. getViewMatrix(): Matrix;
  118030. /**
  118031. * Gets the current projection matrix
  118032. * @returns a Matrix
  118033. */
  118034. getProjectionMatrix(): Matrix;
  118035. /**
  118036. * Gets the current transform matrix
  118037. * @returns a Matrix made of View * Projection
  118038. */
  118039. getTransformMatrix(): Matrix;
  118040. /**
  118041. * Sets the current transform matrix
  118042. * @param viewL defines the View matrix to use
  118043. * @param projectionL defines the Projection matrix to use
  118044. * @param viewR defines the right View matrix to use (if provided)
  118045. * @param projectionR defines the right Projection matrix to use (if provided)
  118046. */
  118047. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  118048. /**
  118049. * Gets the uniform buffer used to store scene data
  118050. * @returns a UniformBuffer
  118051. */
  118052. getSceneUniformBuffer(): UniformBuffer;
  118053. /**
  118054. * Gets an unique (relatively to the current scene) Id
  118055. * @returns an unique number for the scene
  118056. */
  118057. getUniqueId(): number;
  118058. /**
  118059. * Add a mesh to the list of scene's meshes
  118060. * @param newMesh defines the mesh to add
  118061. * @param recursive if all child meshes should also be added to the scene
  118062. */
  118063. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  118064. /**
  118065. * Remove a mesh for the list of scene's meshes
  118066. * @param toRemove defines the mesh to remove
  118067. * @param recursive if all child meshes should also be removed from the scene
  118068. * @returns the index where the mesh was in the mesh list
  118069. */
  118070. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  118071. /**
  118072. * Add a transform node to the list of scene's transform nodes
  118073. * @param newTransformNode defines the transform node to add
  118074. */
  118075. addTransformNode(newTransformNode: TransformNode): void;
  118076. /**
  118077. * Remove a transform node for the list of scene's transform nodes
  118078. * @param toRemove defines the transform node to remove
  118079. * @returns the index where the transform node was in the transform node list
  118080. */
  118081. removeTransformNode(toRemove: TransformNode): number;
  118082. /**
  118083. * Remove a skeleton for the list of scene's skeletons
  118084. * @param toRemove defines the skeleton to remove
  118085. * @returns the index where the skeleton was in the skeleton list
  118086. */
  118087. removeSkeleton(toRemove: Skeleton): number;
  118088. /**
  118089. * Remove a morph target for the list of scene's morph targets
  118090. * @param toRemove defines the morph target to remove
  118091. * @returns the index where the morph target was in the morph target list
  118092. */
  118093. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  118094. /**
  118095. * Remove a light for the list of scene's lights
  118096. * @param toRemove defines the light to remove
  118097. * @returns the index where the light was in the light list
  118098. */
  118099. removeLight(toRemove: Light): number;
  118100. /**
  118101. * Remove a camera for the list of scene's cameras
  118102. * @param toRemove defines the camera to remove
  118103. * @returns the index where the camera was in the camera list
  118104. */
  118105. removeCamera(toRemove: Camera): number;
  118106. /**
  118107. * Remove a particle system for the list of scene's particle systems
  118108. * @param toRemove defines the particle system to remove
  118109. * @returns the index where the particle system was in the particle system list
  118110. */
  118111. removeParticleSystem(toRemove: IParticleSystem): number;
  118112. /**
  118113. * Remove a animation for the list of scene's animations
  118114. * @param toRemove defines the animation to remove
  118115. * @returns the index where the animation was in the animation list
  118116. */
  118117. removeAnimation(toRemove: Animation): number;
  118118. /**
  118119. * Will stop the animation of the given target
  118120. * @param target - the target
  118121. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  118122. * @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)
  118123. */
  118124. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  118125. /**
  118126. * Removes the given animation group from this scene.
  118127. * @param toRemove The animation group to remove
  118128. * @returns The index of the removed animation group
  118129. */
  118130. removeAnimationGroup(toRemove: AnimationGroup): number;
  118131. /**
  118132. * Removes the given multi-material from this scene.
  118133. * @param toRemove The multi-material to remove
  118134. * @returns The index of the removed multi-material
  118135. */
  118136. removeMultiMaterial(toRemove: MultiMaterial): number;
  118137. /**
  118138. * Removes the given material from this scene.
  118139. * @param toRemove The material to remove
  118140. * @returns The index of the removed material
  118141. */
  118142. removeMaterial(toRemove: Material): number;
  118143. /**
  118144. * Removes the given action manager from this scene.
  118145. * @param toRemove The action manager to remove
  118146. * @returns The index of the removed action manager
  118147. */
  118148. removeActionManager(toRemove: AbstractActionManager): number;
  118149. /**
  118150. * Removes the given texture from this scene.
  118151. * @param toRemove The texture to remove
  118152. * @returns The index of the removed texture
  118153. */
  118154. removeTexture(toRemove: BaseTexture): number;
  118155. /**
  118156. * Adds the given light to this scene
  118157. * @param newLight The light to add
  118158. */
  118159. addLight(newLight: Light): void;
  118160. /**
  118161. * Sorts the list list based on light priorities
  118162. */
  118163. sortLightsByPriority(): void;
  118164. /**
  118165. * Adds the given camera to this scene
  118166. * @param newCamera The camera to add
  118167. */
  118168. addCamera(newCamera: Camera): void;
  118169. /**
  118170. * Adds the given skeleton to this scene
  118171. * @param newSkeleton The skeleton to add
  118172. */
  118173. addSkeleton(newSkeleton: Skeleton): void;
  118174. /**
  118175. * Adds the given particle system to this scene
  118176. * @param newParticleSystem The particle system to add
  118177. */
  118178. addParticleSystem(newParticleSystem: IParticleSystem): void;
  118179. /**
  118180. * Adds the given animation to this scene
  118181. * @param newAnimation The animation to add
  118182. */
  118183. addAnimation(newAnimation: Animation): void;
  118184. /**
  118185. * Adds the given animation group to this scene.
  118186. * @param newAnimationGroup The animation group to add
  118187. */
  118188. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  118189. /**
  118190. * Adds the given multi-material to this scene
  118191. * @param newMultiMaterial The multi-material to add
  118192. */
  118193. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  118194. /**
  118195. * Adds the given material to this scene
  118196. * @param newMaterial The material to add
  118197. */
  118198. addMaterial(newMaterial: Material): void;
  118199. /**
  118200. * Adds the given morph target to this scene
  118201. * @param newMorphTargetManager The morph target to add
  118202. */
  118203. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  118204. /**
  118205. * Adds the given geometry to this scene
  118206. * @param newGeometry The geometry to add
  118207. */
  118208. addGeometry(newGeometry: Geometry): void;
  118209. /**
  118210. * Adds the given action manager to this scene
  118211. * @param newActionManager The action manager to add
  118212. */
  118213. addActionManager(newActionManager: AbstractActionManager): void;
  118214. /**
  118215. * Adds the given texture to this scene.
  118216. * @param newTexture The texture to add
  118217. */
  118218. addTexture(newTexture: BaseTexture): void;
  118219. /**
  118220. * Switch active camera
  118221. * @param newCamera defines the new active camera
  118222. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  118223. */
  118224. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  118225. /**
  118226. * sets the active camera of the scene using its ID
  118227. * @param id defines the camera's ID
  118228. * @return the new active camera or null if none found.
  118229. */
  118230. setActiveCameraByID(id: string): Nullable<Camera>;
  118231. /**
  118232. * sets the active camera of the scene using its name
  118233. * @param name defines the camera's name
  118234. * @returns the new active camera or null if none found.
  118235. */
  118236. setActiveCameraByName(name: string): Nullable<Camera>;
  118237. /**
  118238. * get an animation group using its name
  118239. * @param name defines the material's name
  118240. * @return the animation group or null if none found.
  118241. */
  118242. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  118243. /**
  118244. * Get a material using its unique id
  118245. * @param uniqueId defines the material's unique id
  118246. * @return the material or null if none found.
  118247. */
  118248. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  118249. /**
  118250. * get a material using its id
  118251. * @param id defines the material's ID
  118252. * @return the material or null if none found.
  118253. */
  118254. getMaterialByID(id: string): Nullable<Material>;
  118255. /**
  118256. * Gets a the last added material using a given id
  118257. * @param id defines the material's ID
  118258. * @return the last material with the given id or null if none found.
  118259. */
  118260. getLastMaterialByID(id: string): Nullable<Material>;
  118261. /**
  118262. * Gets a material using its name
  118263. * @param name defines the material's name
  118264. * @return the material or null if none found.
  118265. */
  118266. getMaterialByName(name: string): Nullable<Material>;
  118267. /**
  118268. * Get a texture using its unique id
  118269. * @param uniqueId defines the texture's unique id
  118270. * @return the texture or null if none found.
  118271. */
  118272. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  118273. /**
  118274. * Gets a camera using its id
  118275. * @param id defines the id to look for
  118276. * @returns the camera or null if not found
  118277. */
  118278. getCameraByID(id: string): Nullable<Camera>;
  118279. /**
  118280. * Gets a camera using its unique id
  118281. * @param uniqueId defines the unique id to look for
  118282. * @returns the camera or null if not found
  118283. */
  118284. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  118285. /**
  118286. * Gets a camera using its name
  118287. * @param name defines the camera's name
  118288. * @return the camera or null if none found.
  118289. */
  118290. getCameraByName(name: string): Nullable<Camera>;
  118291. /**
  118292. * Gets a bone using its id
  118293. * @param id defines the bone's id
  118294. * @return the bone or null if not found
  118295. */
  118296. getBoneByID(id: string): Nullable<Bone>;
  118297. /**
  118298. * Gets a bone using its id
  118299. * @param name defines the bone's name
  118300. * @return the bone or null if not found
  118301. */
  118302. getBoneByName(name: string): Nullable<Bone>;
  118303. /**
  118304. * Gets a light node using its name
  118305. * @param name defines the the light's name
  118306. * @return the light or null if none found.
  118307. */
  118308. getLightByName(name: string): Nullable<Light>;
  118309. /**
  118310. * Gets a light node using its id
  118311. * @param id defines the light's id
  118312. * @return the light or null if none found.
  118313. */
  118314. getLightByID(id: string): Nullable<Light>;
  118315. /**
  118316. * Gets a light node using its scene-generated unique ID
  118317. * @param uniqueId defines the light's unique id
  118318. * @return the light or null if none found.
  118319. */
  118320. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118321. /**
  118322. * Gets a particle system by id
  118323. * @param id defines the particle system id
  118324. * @return the corresponding system or null if none found
  118325. */
  118326. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118327. /**
  118328. * Gets a geometry using its ID
  118329. * @param id defines the geometry's id
  118330. * @return the geometry or null if none found.
  118331. */
  118332. getGeometryByID(id: string): Nullable<Geometry>;
  118333. private _getGeometryByUniqueID;
  118334. /**
  118335. * Add a new geometry to this scene
  118336. * @param geometry defines the geometry to be added to the scene.
  118337. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118338. * @return a boolean defining if the geometry was added or not
  118339. */
  118340. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118341. /**
  118342. * Removes an existing geometry
  118343. * @param geometry defines the geometry to be removed from the scene
  118344. * @return a boolean defining if the geometry was removed or not
  118345. */
  118346. removeGeometry(geometry: Geometry): boolean;
  118347. /**
  118348. * Gets the list of geometries attached to the scene
  118349. * @returns an array of Geometry
  118350. */
  118351. getGeometries(): Geometry[];
  118352. /**
  118353. * Gets the first added mesh found of a given ID
  118354. * @param id defines the id to search for
  118355. * @return the mesh found or null if not found at all
  118356. */
  118357. getMeshByID(id: string): Nullable<AbstractMesh>;
  118358. /**
  118359. * Gets a list of meshes using their id
  118360. * @param id defines the id to search for
  118361. * @returns a list of meshes
  118362. */
  118363. getMeshesByID(id: string): Array<AbstractMesh>;
  118364. /**
  118365. * Gets the first added transform node found of a given ID
  118366. * @param id defines the id to search for
  118367. * @return the found transform node or null if not found at all.
  118368. */
  118369. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118370. /**
  118371. * Gets a transform node with its auto-generated unique id
  118372. * @param uniqueId efines the unique id to search for
  118373. * @return the found transform node or null if not found at all.
  118374. */
  118375. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118376. /**
  118377. * Gets a list of transform nodes using their id
  118378. * @param id defines the id to search for
  118379. * @returns a list of transform nodes
  118380. */
  118381. getTransformNodesByID(id: string): Array<TransformNode>;
  118382. /**
  118383. * Gets a mesh with its auto-generated unique id
  118384. * @param uniqueId defines the unique id to search for
  118385. * @return the found mesh or null if not found at all.
  118386. */
  118387. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118388. /**
  118389. * Gets a the last added mesh using a given id
  118390. * @param id defines the id to search for
  118391. * @return the found mesh or null if not found at all.
  118392. */
  118393. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118394. /**
  118395. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118396. * @param id defines the id to search for
  118397. * @return the found node or null if not found at all
  118398. */
  118399. getLastEntryByID(id: string): Nullable<Node>;
  118400. /**
  118401. * Gets a node (Mesh, Camera, Light) using a given id
  118402. * @param id defines the id to search for
  118403. * @return the found node or null if not found at all
  118404. */
  118405. getNodeByID(id: string): Nullable<Node>;
  118406. /**
  118407. * Gets a node (Mesh, Camera, Light) using a given name
  118408. * @param name defines the name to search for
  118409. * @return the found node or null if not found at all.
  118410. */
  118411. getNodeByName(name: string): Nullable<Node>;
  118412. /**
  118413. * Gets a mesh using a given name
  118414. * @param name defines the name to search for
  118415. * @return the found mesh or null if not found at all.
  118416. */
  118417. getMeshByName(name: string): Nullable<AbstractMesh>;
  118418. /**
  118419. * Gets a transform node using a given name
  118420. * @param name defines the name to search for
  118421. * @return the found transform node or null if not found at all.
  118422. */
  118423. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118424. /**
  118425. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118426. * @param id defines the id to search for
  118427. * @return the found skeleton or null if not found at all.
  118428. */
  118429. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118430. /**
  118431. * Gets a skeleton using a given auto generated unique id
  118432. * @param uniqueId defines the unique id to search for
  118433. * @return the found skeleton or null if not found at all.
  118434. */
  118435. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118436. /**
  118437. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118438. * @param id defines the id to search for
  118439. * @return the found skeleton or null if not found at all.
  118440. */
  118441. getSkeletonById(id: string): Nullable<Skeleton>;
  118442. /**
  118443. * Gets a skeleton using a given name
  118444. * @param name defines the name to search for
  118445. * @return the found skeleton or null if not found at all.
  118446. */
  118447. getSkeletonByName(name: string): Nullable<Skeleton>;
  118448. /**
  118449. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118450. * @param id defines the id to search for
  118451. * @return the found morph target manager or null if not found at all.
  118452. */
  118453. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118454. /**
  118455. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118456. * @param id defines the id to search for
  118457. * @return the found morph target or null if not found at all.
  118458. */
  118459. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118460. /**
  118461. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118462. * @param name defines the name to search for
  118463. * @return the found morph target or null if not found at all.
  118464. */
  118465. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118466. /**
  118467. * Gets a boolean indicating if the given mesh is active
  118468. * @param mesh defines the mesh to look for
  118469. * @returns true if the mesh is in the active list
  118470. */
  118471. isActiveMesh(mesh: AbstractMesh): boolean;
  118472. /**
  118473. * Return a unique id as a string which can serve as an identifier for the scene
  118474. */
  118475. get uid(): string;
  118476. /**
  118477. * Add an externaly attached data from its key.
  118478. * This method call will fail and return false, if such key already exists.
  118479. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118480. * @param key the unique key that identifies the data
  118481. * @param data the data object to associate to the key for this Engine instance
  118482. * @return true if no such key were already present and the data was added successfully, false otherwise
  118483. */
  118484. addExternalData<T>(key: string, data: T): boolean;
  118485. /**
  118486. * Get an externaly attached data from its key
  118487. * @param key the unique key that identifies the data
  118488. * @return the associated data, if present (can be null), or undefined if not present
  118489. */
  118490. getExternalData<T>(key: string): Nullable<T>;
  118491. /**
  118492. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118493. * @param key the unique key that identifies the data
  118494. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118495. * @return the associated data, can be null if the factory returned null.
  118496. */
  118497. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118498. /**
  118499. * Remove an externaly attached data from the Engine instance
  118500. * @param key the unique key that identifies the data
  118501. * @return true if the data was successfully removed, false if it doesn't exist
  118502. */
  118503. removeExternalData(key: string): boolean;
  118504. private _evaluateSubMesh;
  118505. /**
  118506. * Clear the processed materials smart array preventing retention point in material dispose.
  118507. */
  118508. freeProcessedMaterials(): void;
  118509. private _preventFreeActiveMeshesAndRenderingGroups;
  118510. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118511. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118512. * when disposing several meshes in a row or a hierarchy of meshes.
  118513. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118514. */
  118515. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118516. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118517. /**
  118518. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118519. */
  118520. freeActiveMeshes(): void;
  118521. /**
  118522. * Clear the info related to rendering groups preventing retention points during dispose.
  118523. */
  118524. freeRenderingGroups(): void;
  118525. /** @hidden */
  118526. _isInIntermediateRendering(): boolean;
  118527. /**
  118528. * Lambda returning the list of potentially active meshes.
  118529. */
  118530. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118531. /**
  118532. * Lambda returning the list of potentially active sub meshes.
  118533. */
  118534. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118535. /**
  118536. * Lambda returning the list of potentially intersecting sub meshes.
  118537. */
  118538. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118539. /**
  118540. * Lambda returning the list of potentially colliding sub meshes.
  118541. */
  118542. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118543. private _activeMeshesFrozen;
  118544. private _skipEvaluateActiveMeshesCompletely;
  118545. /**
  118546. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118547. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118548. * @returns the current scene
  118549. */
  118550. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118551. /**
  118552. * Use this function to restart evaluating active meshes on every frame
  118553. * @returns the current scene
  118554. */
  118555. unfreezeActiveMeshes(): Scene;
  118556. private _evaluateActiveMeshes;
  118557. private _activeMesh;
  118558. /**
  118559. * Update the transform matrix to update from the current active camera
  118560. * @param force defines a boolean used to force the update even if cache is up to date
  118561. */
  118562. updateTransformMatrix(force?: boolean): void;
  118563. private _bindFrameBuffer;
  118564. /** @hidden */
  118565. _allowPostProcessClearColor: boolean;
  118566. /** @hidden */
  118567. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118568. private _processSubCameras;
  118569. private _checkIntersections;
  118570. /** @hidden */
  118571. _advancePhysicsEngineStep(step: number): void;
  118572. /**
  118573. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118574. */
  118575. getDeterministicFrameTime: () => number;
  118576. /** @hidden */
  118577. _animate(): void;
  118578. /** Execute all animations (for a frame) */
  118579. animate(): void;
  118580. /**
  118581. * Render the scene
  118582. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118583. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118584. */
  118585. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118586. /**
  118587. * Freeze all materials
  118588. * A frozen material will not be updatable but should be faster to render
  118589. */
  118590. freezeMaterials(): void;
  118591. /**
  118592. * Unfreeze all materials
  118593. * A frozen material will not be updatable but should be faster to render
  118594. */
  118595. unfreezeMaterials(): void;
  118596. /**
  118597. * Releases all held ressources
  118598. */
  118599. dispose(): void;
  118600. /**
  118601. * Gets if the scene is already disposed
  118602. */
  118603. get isDisposed(): boolean;
  118604. /**
  118605. * Call this function to reduce memory footprint of the scene.
  118606. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118607. */
  118608. clearCachedVertexData(): void;
  118609. /**
  118610. * This function will remove the local cached buffer data from texture.
  118611. * It will save memory but will prevent the texture from being rebuilt
  118612. */
  118613. cleanCachedTextureBuffer(): void;
  118614. /**
  118615. * Get the world extend vectors with an optional filter
  118616. *
  118617. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118618. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118619. */
  118620. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118621. min: Vector3;
  118622. max: Vector3;
  118623. };
  118624. /**
  118625. * Creates a ray that can be used to pick in the scene
  118626. * @param x defines the x coordinate of the origin (on-screen)
  118627. * @param y defines the y coordinate of the origin (on-screen)
  118628. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118629. * @param camera defines the camera to use for the picking
  118630. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118631. * @returns a Ray
  118632. */
  118633. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118634. /**
  118635. * Creates a ray that can be used to pick in the scene
  118636. * @param x defines the x coordinate of the origin (on-screen)
  118637. * @param y defines the y coordinate of the origin (on-screen)
  118638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118639. * @param result defines the ray where to store the picking ray
  118640. * @param camera defines the camera to use for the picking
  118641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118642. * @returns the current scene
  118643. */
  118644. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118645. /**
  118646. * Creates a ray that can be used to pick in the scene
  118647. * @param x defines the x coordinate of the origin (on-screen)
  118648. * @param y defines the y coordinate of the origin (on-screen)
  118649. * @param camera defines the camera to use for the picking
  118650. * @returns a Ray
  118651. */
  118652. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118653. /**
  118654. * Creates a ray that can be used to pick in the scene
  118655. * @param x defines the x coordinate of the origin (on-screen)
  118656. * @param y defines the y coordinate of the origin (on-screen)
  118657. * @param result defines the ray where to store the picking ray
  118658. * @param camera defines the camera to use for the picking
  118659. * @returns the current scene
  118660. */
  118661. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118662. /** Launch a ray to try to pick a mesh in the scene
  118663. * @param x position on screen
  118664. * @param y position on screen
  118665. * @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
  118666. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118667. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118669. * @returns a PickingInfo
  118670. */
  118671. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118672. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118673. * @param x position on screen
  118674. * @param y position on screen
  118675. * @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
  118676. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118677. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118678. * @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)
  118679. */
  118680. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118681. /** Use the given ray to pick a mesh in the scene
  118682. * @param ray The ray to use to pick meshes
  118683. * @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
  118684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118686. * @returns a PickingInfo
  118687. */
  118688. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118689. /**
  118690. * Launch a ray to try to pick a mesh in the scene
  118691. * @param x X position on screen
  118692. * @param y Y position on screen
  118693. * @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
  118694. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118696. * @returns an array of PickingInfo
  118697. */
  118698. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118699. /**
  118700. * Launch a ray to try to pick a mesh in the scene
  118701. * @param ray Ray to use
  118702. * @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
  118703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118704. * @returns an array of PickingInfo
  118705. */
  118706. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118707. /**
  118708. * Force the value of meshUnderPointer
  118709. * @param mesh defines the mesh to use
  118710. */
  118711. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118712. /**
  118713. * Gets the mesh under the pointer
  118714. * @returns a Mesh or null if no mesh is under the pointer
  118715. */
  118716. getPointerOverMesh(): Nullable<AbstractMesh>;
  118717. /** @hidden */
  118718. _rebuildGeometries(): void;
  118719. /** @hidden */
  118720. _rebuildTextures(): void;
  118721. private _getByTags;
  118722. /**
  118723. * Get a list of meshes by tags
  118724. * @param tagsQuery defines the tags query to use
  118725. * @param forEach defines a predicate used to filter results
  118726. * @returns an array of Mesh
  118727. */
  118728. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118729. /**
  118730. * Get a list of cameras by tags
  118731. * @param tagsQuery defines the tags query to use
  118732. * @param forEach defines a predicate used to filter results
  118733. * @returns an array of Camera
  118734. */
  118735. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118736. /**
  118737. * Get a list of lights by tags
  118738. * @param tagsQuery defines the tags query to use
  118739. * @param forEach defines a predicate used to filter results
  118740. * @returns an array of Light
  118741. */
  118742. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118743. /**
  118744. * Get a list of materials by tags
  118745. * @param tagsQuery defines the tags query to use
  118746. * @param forEach defines a predicate used to filter results
  118747. * @returns an array of Material
  118748. */
  118749. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118750. /**
  118751. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118752. * This allowed control for front to back rendering or reversly depending of the special needs.
  118753. *
  118754. * @param renderingGroupId The rendering group id corresponding to its index
  118755. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118756. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118757. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118758. */
  118759. 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;
  118760. /**
  118761. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118762. *
  118763. * @param renderingGroupId The rendering group id corresponding to its index
  118764. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118765. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118766. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118767. */
  118768. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118769. /**
  118770. * Gets the current auto clear configuration for one rendering group of the rendering
  118771. * manager.
  118772. * @param index the rendering group index to get the information for
  118773. * @returns The auto clear setup for the requested rendering group
  118774. */
  118775. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118776. private _blockMaterialDirtyMechanism;
  118777. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118778. get blockMaterialDirtyMechanism(): boolean;
  118779. set blockMaterialDirtyMechanism(value: boolean);
  118780. /**
  118781. * Will flag all materials as dirty to trigger new shader compilation
  118782. * @param flag defines the flag used to specify which material part must be marked as dirty
  118783. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118784. */
  118785. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118786. /** @hidden */
  118787. _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;
  118788. /** @hidden */
  118789. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118790. /** @hidden */
  118791. _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;
  118792. /** @hidden */
  118793. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118794. /** @hidden */
  118795. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118796. /** @hidden */
  118797. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118798. }
  118799. }
  118800. declare module BABYLON {
  118801. /**
  118802. * Set of assets to keep when moving a scene into an asset container.
  118803. */
  118804. export class KeepAssets extends AbstractScene {
  118805. }
  118806. /**
  118807. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118808. */
  118809. export class InstantiatedEntries {
  118810. /**
  118811. * List of new root nodes (eg. nodes with no parent)
  118812. */
  118813. rootNodes: TransformNode[];
  118814. /**
  118815. * List of new skeletons
  118816. */
  118817. skeletons: Skeleton[];
  118818. /**
  118819. * List of new animation groups
  118820. */
  118821. animationGroups: AnimationGroup[];
  118822. }
  118823. /**
  118824. * Container with a set of assets that can be added or removed from a scene.
  118825. */
  118826. export class AssetContainer extends AbstractScene {
  118827. private _wasAddedToScene;
  118828. /**
  118829. * The scene the AssetContainer belongs to.
  118830. */
  118831. scene: Scene;
  118832. /**
  118833. * Instantiates an AssetContainer.
  118834. * @param scene The scene the AssetContainer belongs to.
  118835. */
  118836. constructor(scene: Scene);
  118837. /**
  118838. * Instantiate or clone all meshes and add the new ones to the scene.
  118839. * Skeletons and animation groups will all be cloned
  118840. * @param nameFunction defines an optional function used to get new names for clones
  118841. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118842. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118843. */
  118844. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118845. /**
  118846. * Adds all the assets from the container to the scene.
  118847. */
  118848. addAllToScene(): void;
  118849. /**
  118850. * Removes all the assets in the container from the scene
  118851. */
  118852. removeAllFromScene(): void;
  118853. /**
  118854. * Disposes all the assets in the container
  118855. */
  118856. dispose(): void;
  118857. private _moveAssets;
  118858. /**
  118859. * Removes all the assets contained in the scene and adds them to the container.
  118860. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118861. */
  118862. moveAllFromScene(keepAssets?: KeepAssets): void;
  118863. /**
  118864. * 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.
  118865. * @returns the root mesh
  118866. */
  118867. createRootMesh(): Mesh;
  118868. /**
  118869. * Merge animations (direct and animation groups) from this asset container into a scene
  118870. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118871. * @param animatables set of animatables to retarget to a node from the scene
  118872. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118873. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118874. */
  118875. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118876. }
  118877. }
  118878. declare module BABYLON {
  118879. /**
  118880. * Defines how the parser contract is defined.
  118881. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118882. */
  118883. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118884. /**
  118885. * Defines how the individual parser contract is defined.
  118886. * These parser can parse an individual asset
  118887. */
  118888. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118889. /**
  118890. * Base class of the scene acting as a container for the different elements composing a scene.
  118891. * This class is dynamically extended by the different components of the scene increasing
  118892. * flexibility and reducing coupling
  118893. */
  118894. export abstract class AbstractScene {
  118895. /**
  118896. * Stores the list of available parsers in the application.
  118897. */
  118898. private static _BabylonFileParsers;
  118899. /**
  118900. * Stores the list of available individual parsers in the application.
  118901. */
  118902. private static _IndividualBabylonFileParsers;
  118903. /**
  118904. * Adds a parser in the list of available ones
  118905. * @param name Defines the name of the parser
  118906. * @param parser Defines the parser to add
  118907. */
  118908. static AddParser(name: string, parser: BabylonFileParser): void;
  118909. /**
  118910. * Gets a general parser from the list of avaialble ones
  118911. * @param name Defines the name of the parser
  118912. * @returns the requested parser or null
  118913. */
  118914. static GetParser(name: string): Nullable<BabylonFileParser>;
  118915. /**
  118916. * Adds n individual parser in the list of available ones
  118917. * @param name Defines the name of the parser
  118918. * @param parser Defines the parser to add
  118919. */
  118920. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118921. /**
  118922. * Gets an individual parser from the list of avaialble ones
  118923. * @param name Defines the name of the parser
  118924. * @returns the requested parser or null
  118925. */
  118926. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118927. /**
  118928. * Parser json data and populate both a scene and its associated container object
  118929. * @param jsonData Defines the data to parse
  118930. * @param scene Defines the scene to parse the data for
  118931. * @param container Defines the container attached to the parsing sequence
  118932. * @param rootUrl Defines the root url of the data
  118933. */
  118934. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118935. /**
  118936. * Gets the list of root nodes (ie. nodes with no parent)
  118937. */
  118938. rootNodes: Node[];
  118939. /** All of the cameras added to this scene
  118940. * @see https://doc.babylonjs.com/babylon101/cameras
  118941. */
  118942. cameras: Camera[];
  118943. /**
  118944. * All of the lights added to this scene
  118945. * @see https://doc.babylonjs.com/babylon101/lights
  118946. */
  118947. lights: Light[];
  118948. /**
  118949. * All of the (abstract) meshes added to this scene
  118950. */
  118951. meshes: AbstractMesh[];
  118952. /**
  118953. * The list of skeletons added to the scene
  118954. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118955. */
  118956. skeletons: Skeleton[];
  118957. /**
  118958. * All of the particle systems added to this scene
  118959. * @see https://doc.babylonjs.com/babylon101/particles
  118960. */
  118961. particleSystems: IParticleSystem[];
  118962. /**
  118963. * Gets a list of Animations associated with the scene
  118964. */
  118965. animations: Animation[];
  118966. /**
  118967. * All of the animation groups added to this scene
  118968. * @see https://doc.babylonjs.com/how_to/group
  118969. */
  118970. animationGroups: AnimationGroup[];
  118971. /**
  118972. * All of the multi-materials added to this scene
  118973. * @see https://doc.babylonjs.com/how_to/multi_materials
  118974. */
  118975. multiMaterials: MultiMaterial[];
  118976. /**
  118977. * All of the materials added to this scene
  118978. * In the context of a Scene, it is not supposed to be modified manually.
  118979. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118980. * Note also that the order of the Material within the array is not significant and might change.
  118981. * @see https://doc.babylonjs.com/babylon101/materials
  118982. */
  118983. materials: Material[];
  118984. /**
  118985. * The list of morph target managers added to the scene
  118986. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118987. */
  118988. morphTargetManagers: MorphTargetManager[];
  118989. /**
  118990. * The list of geometries used in the scene.
  118991. */
  118992. geometries: Geometry[];
  118993. /**
  118994. * All of the tranform nodes added to this scene
  118995. * In the context of a Scene, it is not supposed to be modified manually.
  118996. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118997. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118998. * @see https://doc.babylonjs.com/how_to/transformnode
  118999. */
  119000. transformNodes: TransformNode[];
  119001. /**
  119002. * ActionManagers available on the scene.
  119003. */
  119004. actionManagers: AbstractActionManager[];
  119005. /**
  119006. * Textures to keep.
  119007. */
  119008. textures: BaseTexture[];
  119009. /**
  119010. * Environment texture for the scene
  119011. */
  119012. environmentTexture: Nullable<BaseTexture>;
  119013. /**
  119014. * @returns all meshes, lights, cameras, transformNodes and bones
  119015. */
  119016. getNodes(): Array<Node>;
  119017. }
  119018. }
  119019. declare module BABYLON {
  119020. /**
  119021. * Interface used to define options for Sound class
  119022. */
  119023. export interface ISoundOptions {
  119024. /**
  119025. * Does the sound autoplay once loaded.
  119026. */
  119027. autoplay?: boolean;
  119028. /**
  119029. * Does the sound loop after it finishes playing once.
  119030. */
  119031. loop?: boolean;
  119032. /**
  119033. * Sound's volume
  119034. */
  119035. volume?: number;
  119036. /**
  119037. * Is it a spatial sound?
  119038. */
  119039. spatialSound?: boolean;
  119040. /**
  119041. * Maximum distance to hear that sound
  119042. */
  119043. maxDistance?: number;
  119044. /**
  119045. * Uses user defined attenuation function
  119046. */
  119047. useCustomAttenuation?: boolean;
  119048. /**
  119049. * Define the roll off factor of spatial sounds.
  119050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119051. */
  119052. rolloffFactor?: number;
  119053. /**
  119054. * Define the reference distance the sound should be heard perfectly.
  119055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119056. */
  119057. refDistance?: number;
  119058. /**
  119059. * Define the distance attenuation model the sound will follow.
  119060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119061. */
  119062. distanceModel?: string;
  119063. /**
  119064. * Defines the playback speed (1 by default)
  119065. */
  119066. playbackRate?: number;
  119067. /**
  119068. * Defines if the sound is from a streaming source
  119069. */
  119070. streaming?: boolean;
  119071. /**
  119072. * Defines an optional length (in seconds) inside the sound file
  119073. */
  119074. length?: number;
  119075. /**
  119076. * Defines an optional offset (in seconds) inside the sound file
  119077. */
  119078. offset?: number;
  119079. /**
  119080. * If true, URLs will not be required to state the audio file codec to use.
  119081. */
  119082. skipCodecCheck?: boolean;
  119083. }
  119084. /**
  119085. * Defines a sound that can be played in the application.
  119086. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  119087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119088. */
  119089. export class Sound {
  119090. /**
  119091. * The name of the sound in the scene.
  119092. */
  119093. name: string;
  119094. /**
  119095. * Does the sound autoplay once loaded.
  119096. */
  119097. autoplay: boolean;
  119098. /**
  119099. * Does the sound loop after it finishes playing once.
  119100. */
  119101. loop: boolean;
  119102. /**
  119103. * Does the sound use a custom attenuation curve to simulate the falloff
  119104. * happening when the source gets further away from the camera.
  119105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  119106. */
  119107. useCustomAttenuation: boolean;
  119108. /**
  119109. * The sound track id this sound belongs to.
  119110. */
  119111. soundTrackId: number;
  119112. /**
  119113. * Is this sound currently played.
  119114. */
  119115. isPlaying: boolean;
  119116. /**
  119117. * Is this sound currently paused.
  119118. */
  119119. isPaused: boolean;
  119120. /**
  119121. * Does this sound enables spatial sound.
  119122. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119123. */
  119124. spatialSound: boolean;
  119125. /**
  119126. * Define the reference distance the sound should be heard perfectly.
  119127. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119128. */
  119129. refDistance: number;
  119130. /**
  119131. * Define the roll off factor of spatial sounds.
  119132. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119133. */
  119134. rolloffFactor: number;
  119135. /**
  119136. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  119137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119138. */
  119139. maxDistance: number;
  119140. /**
  119141. * Define the distance attenuation model the sound will follow.
  119142. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119143. */
  119144. distanceModel: string;
  119145. /**
  119146. * @hidden
  119147. * Back Compat
  119148. **/
  119149. onended: () => any;
  119150. /**
  119151. * Gets or sets an object used to store user defined information for the sound.
  119152. */
  119153. metadata: any;
  119154. /**
  119155. * Observable event when the current playing sound finishes.
  119156. */
  119157. onEndedObservable: Observable<Sound>;
  119158. private _panningModel;
  119159. private _playbackRate;
  119160. private _streaming;
  119161. private _startTime;
  119162. private _startOffset;
  119163. private _position;
  119164. /** @hidden */
  119165. _positionInEmitterSpace: boolean;
  119166. private _localDirection;
  119167. private _volume;
  119168. private _isReadyToPlay;
  119169. private _isDirectional;
  119170. private _readyToPlayCallback;
  119171. private _audioBuffer;
  119172. private _soundSource;
  119173. private _streamingSource;
  119174. private _soundPanner;
  119175. private _soundGain;
  119176. private _inputAudioNode;
  119177. private _outputAudioNode;
  119178. private _coneInnerAngle;
  119179. private _coneOuterAngle;
  119180. private _coneOuterGain;
  119181. private _scene;
  119182. private _connectedTransformNode;
  119183. private _customAttenuationFunction;
  119184. private _registerFunc;
  119185. private _isOutputConnected;
  119186. private _htmlAudioElement;
  119187. private _urlType;
  119188. private _length?;
  119189. private _offset?;
  119190. /** @hidden */
  119191. static _SceneComponentInitialization: (scene: Scene) => void;
  119192. /**
  119193. * Create a sound and attach it to a scene
  119194. * @param name Name of your sound
  119195. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  119196. * @param scene defines the scene the sound belongs to
  119197. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  119198. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  119199. */
  119200. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  119201. /**
  119202. * Release the sound and its associated resources
  119203. */
  119204. dispose(): void;
  119205. /**
  119206. * Gets if the sounds is ready to be played or not.
  119207. * @returns true if ready, otherwise false
  119208. */
  119209. isReady(): boolean;
  119210. private _soundLoaded;
  119211. /**
  119212. * Sets the data of the sound from an audiobuffer
  119213. * @param audioBuffer The audioBuffer containing the data
  119214. */
  119215. setAudioBuffer(audioBuffer: AudioBuffer): void;
  119216. /**
  119217. * Updates the current sounds options such as maxdistance, loop...
  119218. * @param options A JSON object containing values named as the object properties
  119219. */
  119220. updateOptions(options: ISoundOptions): void;
  119221. private _createSpatialParameters;
  119222. private _updateSpatialParameters;
  119223. /**
  119224. * Switch the panning model to HRTF:
  119225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119227. */
  119228. switchPanningModelToHRTF(): void;
  119229. /**
  119230. * Switch the panning model to Equal Power:
  119231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119233. */
  119234. switchPanningModelToEqualPower(): void;
  119235. private _switchPanningModel;
  119236. /**
  119237. * Connect this sound to a sound track audio node like gain...
  119238. * @param soundTrackAudioNode the sound track audio node to connect to
  119239. */
  119240. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  119241. /**
  119242. * Transform this sound into a directional source
  119243. * @param coneInnerAngle Size of the inner cone in degree
  119244. * @param coneOuterAngle Size of the outer cone in degree
  119245. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  119246. */
  119247. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  119248. /**
  119249. * Gets or sets the inner angle for the directional cone.
  119250. */
  119251. get directionalConeInnerAngle(): number;
  119252. /**
  119253. * Gets or sets the inner angle for the directional cone.
  119254. */
  119255. set directionalConeInnerAngle(value: number);
  119256. /**
  119257. * Gets or sets the outer angle for the directional cone.
  119258. */
  119259. get directionalConeOuterAngle(): number;
  119260. /**
  119261. * Gets or sets the outer angle for the directional cone.
  119262. */
  119263. set directionalConeOuterAngle(value: number);
  119264. /**
  119265. * Sets the position of the emitter if spatial sound is enabled
  119266. * @param newPosition Defines the new posisiton
  119267. */
  119268. setPosition(newPosition: Vector3): void;
  119269. /**
  119270. * Sets the local direction of the emitter if spatial sound is enabled
  119271. * @param newLocalDirection Defines the new local direction
  119272. */
  119273. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  119274. private _updateDirection;
  119275. /** @hidden */
  119276. updateDistanceFromListener(): void;
  119277. /**
  119278. * Sets a new custom attenuation function for the sound.
  119279. * @param callback Defines the function used for the attenuation
  119280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  119281. */
  119282. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  119283. /**
  119284. * Play the sound
  119285. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  119286. * @param offset (optional) Start the sound at a specific time in seconds
  119287. * @param length (optional) Sound duration (in seconds)
  119288. */
  119289. play(time?: number, offset?: number, length?: number): void;
  119290. private _onended;
  119291. /**
  119292. * Stop the sound
  119293. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  119294. */
  119295. stop(time?: number): void;
  119296. /**
  119297. * Put the sound in pause
  119298. */
  119299. pause(): void;
  119300. /**
  119301. * Sets a dedicated volume for this sounds
  119302. * @param newVolume Define the new volume of the sound
  119303. * @param time Define time for gradual change to new volume
  119304. */
  119305. setVolume(newVolume: number, time?: number): void;
  119306. /**
  119307. * Set the sound play back rate
  119308. * @param newPlaybackRate Define the playback rate the sound should be played at
  119309. */
  119310. setPlaybackRate(newPlaybackRate: number): void;
  119311. /**
  119312. * Gets the volume of the sound.
  119313. * @returns the volume of the sound
  119314. */
  119315. getVolume(): number;
  119316. /**
  119317. * Attach the sound to a dedicated mesh
  119318. * @param transformNode The transform node to connect the sound with
  119319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119320. */
  119321. attachToMesh(transformNode: TransformNode): void;
  119322. /**
  119323. * Detach the sound from the previously attached mesh
  119324. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119325. */
  119326. detachFromMesh(): void;
  119327. private _onRegisterAfterWorldMatrixUpdate;
  119328. /**
  119329. * Clone the current sound in the scene.
  119330. * @returns the new sound clone
  119331. */
  119332. clone(): Nullable<Sound>;
  119333. /**
  119334. * Gets the current underlying audio buffer containing the data
  119335. * @returns the audio buffer
  119336. */
  119337. getAudioBuffer(): Nullable<AudioBuffer>;
  119338. /**
  119339. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119340. * @returns the source node
  119341. */
  119342. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119343. /**
  119344. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119345. * @returns the gain node
  119346. */
  119347. getSoundGain(): Nullable<GainNode>;
  119348. /**
  119349. * Serializes the Sound in a JSON representation
  119350. * @returns the JSON representation of the sound
  119351. */
  119352. serialize(): any;
  119353. /**
  119354. * Parse a JSON representation of a sound to innstantiate in a given scene
  119355. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119356. * @param scene Define the scene the new parsed sound should be created in
  119357. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119358. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119359. * @returns the newly parsed sound
  119360. */
  119361. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * This defines an action helpful to play a defined sound on a triggered action.
  119367. */
  119368. export class PlaySoundAction extends Action {
  119369. private _sound;
  119370. /**
  119371. * Instantiate the action
  119372. * @param triggerOptions defines the trigger options
  119373. * @param sound defines the sound to play
  119374. * @param condition defines the trigger related conditions
  119375. */
  119376. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119377. /** @hidden */
  119378. _prepare(): void;
  119379. /**
  119380. * Execute the action and play the sound.
  119381. */
  119382. execute(): void;
  119383. /**
  119384. * Serializes the actions and its related information.
  119385. * @param parent defines the object to serialize in
  119386. * @returns the serialized object
  119387. */
  119388. serialize(parent: any): any;
  119389. }
  119390. /**
  119391. * This defines an action helpful to stop a defined sound on a triggered action.
  119392. */
  119393. export class StopSoundAction extends Action {
  119394. private _sound;
  119395. /**
  119396. * Instantiate the action
  119397. * @param triggerOptions defines the trigger options
  119398. * @param sound defines the sound to stop
  119399. * @param condition defines the trigger related conditions
  119400. */
  119401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119402. /** @hidden */
  119403. _prepare(): void;
  119404. /**
  119405. * Execute the action and stop the sound.
  119406. */
  119407. execute(): void;
  119408. /**
  119409. * Serializes the actions and its related information.
  119410. * @param parent defines the object to serialize in
  119411. * @returns the serialized object
  119412. */
  119413. serialize(parent: any): any;
  119414. }
  119415. }
  119416. declare module BABYLON {
  119417. /**
  119418. * This defines an action responsible to change the value of a property
  119419. * by interpolating between its current value and the newly set one once triggered.
  119420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119421. */
  119422. export class InterpolateValueAction extends Action {
  119423. /**
  119424. * Defines the path of the property where the value should be interpolated
  119425. */
  119426. propertyPath: string;
  119427. /**
  119428. * Defines the target value at the end of the interpolation.
  119429. */
  119430. value: any;
  119431. /**
  119432. * Defines the time it will take for the property to interpolate to the value.
  119433. */
  119434. duration: number;
  119435. /**
  119436. * Defines if the other scene animations should be stopped when the action has been triggered
  119437. */
  119438. stopOtherAnimations?: boolean;
  119439. /**
  119440. * Defines a callback raised once the interpolation animation has been done.
  119441. */
  119442. onInterpolationDone?: () => void;
  119443. /**
  119444. * Observable triggered once the interpolation animation has been done.
  119445. */
  119446. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119447. private _target;
  119448. private _effectiveTarget;
  119449. private _property;
  119450. /**
  119451. * Instantiate the action
  119452. * @param triggerOptions defines the trigger options
  119453. * @param target defines the object containing the value to interpolate
  119454. * @param propertyPath defines the path to the property in the target object
  119455. * @param value defines the target value at the end of the interpolation
  119456. * @param duration deines the time it will take for the property to interpolate to the value.
  119457. * @param condition defines the trigger related conditions
  119458. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119459. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119460. */
  119461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119462. /** @hidden */
  119463. _prepare(): void;
  119464. /**
  119465. * Execute the action starts the value interpolation.
  119466. */
  119467. execute(): void;
  119468. /**
  119469. * Serializes the actions and its related information.
  119470. * @param parent defines the object to serialize in
  119471. * @returns the serialized object
  119472. */
  119473. serialize(parent: any): any;
  119474. }
  119475. }
  119476. declare module BABYLON {
  119477. /**
  119478. * Options allowed during the creation of a sound track.
  119479. */
  119480. export interface ISoundTrackOptions {
  119481. /**
  119482. * The volume the sound track should take during creation
  119483. */
  119484. volume?: number;
  119485. /**
  119486. * Define if the sound track is the main sound track of the scene
  119487. */
  119488. mainTrack?: boolean;
  119489. }
  119490. /**
  119491. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119492. * It will be also used in a future release to apply effects on a specific track.
  119493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119494. */
  119495. export class SoundTrack {
  119496. /**
  119497. * The unique identifier of the sound track in the scene.
  119498. */
  119499. id: number;
  119500. /**
  119501. * The list of sounds included in the sound track.
  119502. */
  119503. soundCollection: Array<Sound>;
  119504. private _outputAudioNode;
  119505. private _scene;
  119506. private _connectedAnalyser;
  119507. private _options;
  119508. private _isInitialized;
  119509. /**
  119510. * Creates a new sound track.
  119511. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119512. * @param scene Define the scene the sound track belongs to
  119513. * @param options
  119514. */
  119515. constructor(scene: Scene, options?: ISoundTrackOptions);
  119516. private _initializeSoundTrackAudioGraph;
  119517. /**
  119518. * Release the sound track and its associated resources
  119519. */
  119520. dispose(): void;
  119521. /**
  119522. * Adds a sound to this sound track
  119523. * @param sound define the cound to add
  119524. * @ignoreNaming
  119525. */
  119526. AddSound(sound: Sound): void;
  119527. /**
  119528. * Removes a sound to this sound track
  119529. * @param sound define the cound to remove
  119530. * @ignoreNaming
  119531. */
  119532. RemoveSound(sound: Sound): void;
  119533. /**
  119534. * Set a global volume for the full sound track.
  119535. * @param newVolume Define the new volume of the sound track
  119536. */
  119537. setVolume(newVolume: number): void;
  119538. /**
  119539. * Switch the panning model to HRTF:
  119540. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119542. */
  119543. switchPanningModelToHRTF(): void;
  119544. /**
  119545. * Switch the panning model to Equal Power:
  119546. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119548. */
  119549. switchPanningModelToEqualPower(): void;
  119550. /**
  119551. * Connect the sound track to an audio analyser allowing some amazing
  119552. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119554. * @param analyser The analyser to connect to the engine
  119555. */
  119556. connectToAnalyser(analyser: Analyser): void;
  119557. }
  119558. }
  119559. declare module BABYLON {
  119560. interface AbstractScene {
  119561. /**
  119562. * The list of sounds used in the scene.
  119563. */
  119564. sounds: Nullable<Array<Sound>>;
  119565. }
  119566. interface Scene {
  119567. /**
  119568. * @hidden
  119569. * Backing field
  119570. */
  119571. _mainSoundTrack: SoundTrack;
  119572. /**
  119573. * The main sound track played by the scene.
  119574. * It cotains your primary collection of sounds.
  119575. */
  119576. mainSoundTrack: SoundTrack;
  119577. /**
  119578. * The list of sound tracks added to the scene
  119579. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119580. */
  119581. soundTracks: Nullable<Array<SoundTrack>>;
  119582. /**
  119583. * Gets a sound using a given name
  119584. * @param name defines the name to search for
  119585. * @return the found sound or null if not found at all.
  119586. */
  119587. getSoundByName(name: string): Nullable<Sound>;
  119588. /**
  119589. * Gets or sets if audio support is enabled
  119590. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119591. */
  119592. audioEnabled: boolean;
  119593. /**
  119594. * Gets or sets if audio will be output to headphones
  119595. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119596. */
  119597. headphone: boolean;
  119598. /**
  119599. * Gets or sets custom audio listener position provider
  119600. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119601. */
  119602. audioListenerPositionProvider: Nullable<() => Vector3>;
  119603. /**
  119604. * Gets or sets a refresh rate when using 3D audio positioning
  119605. */
  119606. audioPositioningRefreshRate: number;
  119607. }
  119608. /**
  119609. * Defines the sound scene component responsible to manage any sounds
  119610. * in a given scene.
  119611. */
  119612. export class AudioSceneComponent implements ISceneSerializableComponent {
  119613. /**
  119614. * The component name helpfull to identify the component in the list of scene components.
  119615. */
  119616. readonly name: string;
  119617. /**
  119618. * The scene the component belongs to.
  119619. */
  119620. scene: Scene;
  119621. private _audioEnabled;
  119622. /**
  119623. * Gets whether audio is enabled or not.
  119624. * Please use related enable/disable method to switch state.
  119625. */
  119626. get audioEnabled(): boolean;
  119627. private _headphone;
  119628. /**
  119629. * Gets whether audio is outputing to headphone or not.
  119630. * Please use the according Switch methods to change output.
  119631. */
  119632. get headphone(): boolean;
  119633. /**
  119634. * Gets or sets a refresh rate when using 3D audio positioning
  119635. */
  119636. audioPositioningRefreshRate: number;
  119637. private _audioListenerPositionProvider;
  119638. /**
  119639. * Gets the current audio listener position provider
  119640. */
  119641. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119642. /**
  119643. * Sets a custom listener position for all sounds in the scene
  119644. * By default, this is the position of the first active camera
  119645. */
  119646. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119647. /**
  119648. * Creates a new instance of the component for the given scene
  119649. * @param scene Defines the scene to register the component in
  119650. */
  119651. constructor(scene: Scene);
  119652. /**
  119653. * Registers the component in a given scene
  119654. */
  119655. register(): void;
  119656. /**
  119657. * Rebuilds the elements related to this component in case of
  119658. * context lost for instance.
  119659. */
  119660. rebuild(): void;
  119661. /**
  119662. * Serializes the component data to the specified json object
  119663. * @param serializationObject The object to serialize to
  119664. */
  119665. serialize(serializationObject: any): void;
  119666. /**
  119667. * Adds all the elements from the container to the scene
  119668. * @param container the container holding the elements
  119669. */
  119670. addFromContainer(container: AbstractScene): void;
  119671. /**
  119672. * Removes all the elements in the container from the scene
  119673. * @param container contains the elements to remove
  119674. * @param dispose if the removed element should be disposed (default: false)
  119675. */
  119676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119677. /**
  119678. * Disposes the component and the associated ressources.
  119679. */
  119680. dispose(): void;
  119681. /**
  119682. * Disables audio in the associated scene.
  119683. */
  119684. disableAudio(): void;
  119685. /**
  119686. * Enables audio in the associated scene.
  119687. */
  119688. enableAudio(): void;
  119689. /**
  119690. * Switch audio to headphone output.
  119691. */
  119692. switchAudioModeForHeadphones(): void;
  119693. /**
  119694. * Switch audio to normal speakers.
  119695. */
  119696. switchAudioModeForNormalSpeakers(): void;
  119697. private _cachedCameraDirection;
  119698. private _cachedCameraPosition;
  119699. private _lastCheck;
  119700. private _afterRender;
  119701. }
  119702. }
  119703. declare module BABYLON {
  119704. /**
  119705. * Wraps one or more Sound objects and selects one with random weight for playback.
  119706. */
  119707. export class WeightedSound {
  119708. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119709. loop: boolean;
  119710. private _coneInnerAngle;
  119711. private _coneOuterAngle;
  119712. private _volume;
  119713. /** A Sound is currently playing. */
  119714. isPlaying: boolean;
  119715. /** A Sound is currently paused. */
  119716. isPaused: boolean;
  119717. private _sounds;
  119718. private _weights;
  119719. private _currentIndex?;
  119720. /**
  119721. * Creates a new WeightedSound from the list of sounds given.
  119722. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119723. * @param sounds Array of Sounds that will be selected from.
  119724. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119725. */
  119726. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119727. /**
  119728. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119729. */
  119730. get directionalConeInnerAngle(): number;
  119731. /**
  119732. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119733. */
  119734. set directionalConeInnerAngle(value: number);
  119735. /**
  119736. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119737. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119738. */
  119739. get directionalConeOuterAngle(): number;
  119740. /**
  119741. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119742. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119743. */
  119744. set directionalConeOuterAngle(value: number);
  119745. /**
  119746. * Playback volume.
  119747. */
  119748. get volume(): number;
  119749. /**
  119750. * Playback volume.
  119751. */
  119752. set volume(value: number);
  119753. private _onended;
  119754. /**
  119755. * Suspend playback
  119756. */
  119757. pause(): void;
  119758. /**
  119759. * Stop playback
  119760. */
  119761. stop(): void;
  119762. /**
  119763. * Start playback.
  119764. * @param startOffset Position the clip head at a specific time in seconds.
  119765. */
  119766. play(startOffset?: number): void;
  119767. }
  119768. }
  119769. declare module BABYLON {
  119770. /**
  119771. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119772. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119773. */
  119774. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119775. /**
  119776. * Gets the name of the behavior.
  119777. */
  119778. get name(): string;
  119779. /**
  119780. * The easing function used by animations
  119781. */
  119782. static EasingFunction: BackEase;
  119783. /**
  119784. * The easing mode used by animations
  119785. */
  119786. static EasingMode: number;
  119787. /**
  119788. * The duration of the animation, in milliseconds
  119789. */
  119790. transitionDuration: number;
  119791. /**
  119792. * Length of the distance animated by the transition when lower radius is reached
  119793. */
  119794. lowerRadiusTransitionRange: number;
  119795. /**
  119796. * Length of the distance animated by the transition when upper radius is reached
  119797. */
  119798. upperRadiusTransitionRange: number;
  119799. private _autoTransitionRange;
  119800. /**
  119801. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119802. */
  119803. get autoTransitionRange(): boolean;
  119804. /**
  119805. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119806. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119807. */
  119808. set autoTransitionRange(value: boolean);
  119809. private _attachedCamera;
  119810. private _onAfterCheckInputsObserver;
  119811. private _onMeshTargetChangedObserver;
  119812. /**
  119813. * Initializes the behavior.
  119814. */
  119815. init(): void;
  119816. /**
  119817. * Attaches the behavior to its arc rotate camera.
  119818. * @param camera Defines the camera to attach the behavior to
  119819. */
  119820. attach(camera: ArcRotateCamera): void;
  119821. /**
  119822. * Detaches the behavior from its current arc rotate camera.
  119823. */
  119824. detach(): void;
  119825. private _radiusIsAnimating;
  119826. private _radiusBounceTransition;
  119827. private _animatables;
  119828. private _cachedWheelPrecision;
  119829. /**
  119830. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119831. * @param radiusLimit The limit to check against.
  119832. * @return Bool to indicate if at limit.
  119833. */
  119834. private _isRadiusAtLimit;
  119835. /**
  119836. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119837. * @param radiusDelta The delta by which to animate to. Can be negative.
  119838. */
  119839. private _applyBoundRadiusAnimation;
  119840. /**
  119841. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119842. */
  119843. protected _clearAnimationLocks(): void;
  119844. /**
  119845. * Stops and removes all animations that have been applied to the camera
  119846. */
  119847. stopAllAnimations(): void;
  119848. }
  119849. }
  119850. declare module BABYLON {
  119851. /**
  119852. * 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.
  119853. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119854. */
  119855. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119856. /**
  119857. * Gets the name of the behavior.
  119858. */
  119859. get name(): string;
  119860. private _mode;
  119861. private _radiusScale;
  119862. private _positionScale;
  119863. private _defaultElevation;
  119864. private _elevationReturnTime;
  119865. private _elevationReturnWaitTime;
  119866. private _zoomStopsAnimation;
  119867. private _framingTime;
  119868. /**
  119869. * The easing function used by animations
  119870. */
  119871. static EasingFunction: ExponentialEase;
  119872. /**
  119873. * The easing mode used by animations
  119874. */
  119875. static EasingMode: number;
  119876. /**
  119877. * Sets the current mode used by the behavior
  119878. */
  119879. set mode(mode: number);
  119880. /**
  119881. * Gets current mode used by the behavior.
  119882. */
  119883. get mode(): number;
  119884. /**
  119885. * Sets the scale applied to the radius (1 by default)
  119886. */
  119887. set radiusScale(radius: number);
  119888. /**
  119889. * Gets the scale applied to the radius
  119890. */
  119891. get radiusScale(): number;
  119892. /**
  119893. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119894. */
  119895. set positionScale(scale: number);
  119896. /**
  119897. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119898. */
  119899. get positionScale(): number;
  119900. /**
  119901. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119902. * behaviour is triggered, in radians.
  119903. */
  119904. set defaultElevation(elevation: number);
  119905. /**
  119906. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119907. * behaviour is triggered, in radians.
  119908. */
  119909. get defaultElevation(): number;
  119910. /**
  119911. * Sets the time (in milliseconds) taken to return to the default beta position.
  119912. * Negative value indicates camera should not return to default.
  119913. */
  119914. set elevationReturnTime(speed: number);
  119915. /**
  119916. * Gets the time (in milliseconds) taken to return to the default beta position.
  119917. * Negative value indicates camera should not return to default.
  119918. */
  119919. get elevationReturnTime(): number;
  119920. /**
  119921. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119922. */
  119923. set elevationReturnWaitTime(time: number);
  119924. /**
  119925. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119926. */
  119927. get elevationReturnWaitTime(): number;
  119928. /**
  119929. * Sets the flag that indicates if user zooming should stop animation.
  119930. */
  119931. set zoomStopsAnimation(flag: boolean);
  119932. /**
  119933. * Gets the flag that indicates if user zooming should stop animation.
  119934. */
  119935. get zoomStopsAnimation(): boolean;
  119936. /**
  119937. * Sets the transition time when framing the mesh, in milliseconds
  119938. */
  119939. set framingTime(time: number);
  119940. /**
  119941. * Gets the transition time when framing the mesh, in milliseconds
  119942. */
  119943. get framingTime(): number;
  119944. /**
  119945. * Define if the behavior should automatically change the configured
  119946. * camera limits and sensibilities.
  119947. */
  119948. autoCorrectCameraLimitsAndSensibility: boolean;
  119949. private _onPrePointerObservableObserver;
  119950. private _onAfterCheckInputsObserver;
  119951. private _onMeshTargetChangedObserver;
  119952. private _attachedCamera;
  119953. private _isPointerDown;
  119954. private _lastInteractionTime;
  119955. /**
  119956. * Initializes the behavior.
  119957. */
  119958. init(): void;
  119959. /**
  119960. * Attaches the behavior to its arc rotate camera.
  119961. * @param camera Defines the camera to attach the behavior to
  119962. */
  119963. attach(camera: ArcRotateCamera): void;
  119964. /**
  119965. * Detaches the behavior from its current arc rotate camera.
  119966. */
  119967. detach(): void;
  119968. private _animatables;
  119969. private _betaIsAnimating;
  119970. private _betaTransition;
  119971. private _radiusTransition;
  119972. private _vectorTransition;
  119973. /**
  119974. * Targets the given mesh and updates zoom level accordingly.
  119975. * @param mesh The mesh to target.
  119976. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119977. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119978. */
  119979. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119980. /**
  119981. * Targets the given mesh with its children and updates zoom level accordingly.
  119982. * @param mesh The mesh to target.
  119983. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119984. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119985. */
  119986. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119987. /**
  119988. * Targets the given meshes with their children and updates zoom level accordingly.
  119989. * @param meshes The mesh to target.
  119990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119992. */
  119993. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119994. /**
  119995. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119996. * @param minimumWorld Determines the smaller position of the bounding box extend
  119997. * @param maximumWorld Determines the bigger position of the bounding box extend
  119998. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119999. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120000. */
  120001. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120002. /**
  120003. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  120004. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  120005. * frustum width.
  120006. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  120007. * to fully enclose the mesh in the viewing frustum.
  120008. */
  120009. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  120010. /**
  120011. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  120012. * is automatically returned to its default position (expected to be above ground plane).
  120013. */
  120014. private _maintainCameraAboveGround;
  120015. /**
  120016. * Returns the frustum slope based on the canvas ratio and camera FOV
  120017. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  120018. */
  120019. private _getFrustumSlope;
  120020. /**
  120021. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  120022. */
  120023. private _clearAnimationLocks;
  120024. /**
  120025. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120026. */
  120027. private _applyUserInteraction;
  120028. /**
  120029. * Stops and removes all animations that have been applied to the camera
  120030. */
  120031. stopAllAnimations(): void;
  120032. /**
  120033. * Gets a value indicating if the user is moving the camera
  120034. */
  120035. get isUserIsMoving(): boolean;
  120036. /**
  120037. * The camera can move all the way towards the mesh.
  120038. */
  120039. static IgnoreBoundsSizeMode: number;
  120040. /**
  120041. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  120042. */
  120043. static FitFrustumSidesMode: number;
  120044. }
  120045. }
  120046. declare module BABYLON {
  120047. /**
  120048. * Base class for Camera Pointer Inputs.
  120049. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  120050. * for example usage.
  120051. */
  120052. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  120053. /**
  120054. * Defines the camera the input is attached to.
  120055. */
  120056. abstract camera: Camera;
  120057. /**
  120058. * Whether keyboard modifier keys are pressed at time of last mouse event.
  120059. */
  120060. protected _altKey: boolean;
  120061. protected _ctrlKey: boolean;
  120062. protected _metaKey: boolean;
  120063. protected _shiftKey: boolean;
  120064. /**
  120065. * Which mouse buttons were pressed at time of last mouse event.
  120066. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  120067. */
  120068. protected _buttonsPressed: number;
  120069. /**
  120070. * Defines the buttons associated with the input to handle camera move.
  120071. */
  120072. buttons: number[];
  120073. /**
  120074. * Attach the input controls to a specific dom element to get the input from.
  120075. * @param element Defines the element the controls should be listened from
  120076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120077. */
  120078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120079. /**
  120080. * Detach the current controls from the specified dom element.
  120081. * @param element Defines the element to stop listening the inputs from
  120082. */
  120083. detachControl(element: Nullable<HTMLElement>): void;
  120084. /**
  120085. * Gets the class name of the current input.
  120086. * @returns the class name
  120087. */
  120088. getClassName(): string;
  120089. /**
  120090. * Get the friendly name associated with the input class.
  120091. * @returns the input friendly name
  120092. */
  120093. getSimpleName(): string;
  120094. /**
  120095. * Called on pointer POINTERDOUBLETAP event.
  120096. * Override this method to provide functionality on POINTERDOUBLETAP event.
  120097. */
  120098. protected onDoubleTap(type: string): void;
  120099. /**
  120100. * Called on pointer POINTERMOVE event if only a single touch is active.
  120101. * Override this method to provide functionality.
  120102. */
  120103. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120104. /**
  120105. * Called on pointer POINTERMOVE event if multiple touches are active.
  120106. * Override this method to provide functionality.
  120107. */
  120108. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120109. /**
  120110. * Called on JS contextmenu event.
  120111. * Override this method to provide functionality.
  120112. */
  120113. protected onContextMenu(evt: PointerEvent): void;
  120114. /**
  120115. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120116. * press.
  120117. * Override this method to provide functionality.
  120118. */
  120119. protected onButtonDown(evt: PointerEvent): void;
  120120. /**
  120121. * Called each time a new POINTERUP event occurs. Ie, for each button
  120122. * release.
  120123. * Override this method to provide functionality.
  120124. */
  120125. protected onButtonUp(evt: PointerEvent): void;
  120126. /**
  120127. * Called when window becomes inactive.
  120128. * Override this method to provide functionality.
  120129. */
  120130. protected onLostFocus(): void;
  120131. private _pointerInput;
  120132. private _observer;
  120133. private _onLostFocus;
  120134. private pointA;
  120135. private pointB;
  120136. }
  120137. }
  120138. declare module BABYLON {
  120139. /**
  120140. * Manage the pointers inputs to control an arc rotate camera.
  120141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120142. */
  120143. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  120144. /**
  120145. * Defines the camera the input is attached to.
  120146. */
  120147. camera: ArcRotateCamera;
  120148. /**
  120149. * Gets the class name of the current input.
  120150. * @returns the class name
  120151. */
  120152. getClassName(): string;
  120153. /**
  120154. * Defines the buttons associated with the input to handle camera move.
  120155. */
  120156. buttons: number[];
  120157. /**
  120158. * Defines the pointer angular sensibility along the X axis or how fast is
  120159. * the camera rotating.
  120160. */
  120161. angularSensibilityX: number;
  120162. /**
  120163. * Defines the pointer angular sensibility along the Y axis or how fast is
  120164. * the camera rotating.
  120165. */
  120166. angularSensibilityY: number;
  120167. /**
  120168. * Defines the pointer pinch precision or how fast is the camera zooming.
  120169. */
  120170. pinchPrecision: number;
  120171. /**
  120172. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120173. * from 0.
  120174. * It defines the percentage of current camera.radius to use as delta when
  120175. * pinch zoom is used.
  120176. */
  120177. pinchDeltaPercentage: number;
  120178. /**
  120179. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120180. * that any object in the plane at the camera's target point will scale
  120181. * perfectly with finger motion.
  120182. * Overrides pinchDeltaPercentage and pinchPrecision.
  120183. */
  120184. useNaturalPinchZoom: boolean;
  120185. /**
  120186. * Defines the pointer panning sensibility or how fast is the camera moving.
  120187. */
  120188. panningSensibility: number;
  120189. /**
  120190. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  120191. */
  120192. multiTouchPanning: boolean;
  120193. /**
  120194. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  120195. * zoom (pinch) through multitouch.
  120196. */
  120197. multiTouchPanAndZoom: boolean;
  120198. /**
  120199. * Revers pinch action direction.
  120200. */
  120201. pinchInwards: boolean;
  120202. private _isPanClick;
  120203. private _twoFingerActivityCount;
  120204. private _isPinching;
  120205. /**
  120206. * Called on pointer POINTERMOVE event if only a single touch is active.
  120207. */
  120208. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120209. /**
  120210. * Called on pointer POINTERDOUBLETAP event.
  120211. */
  120212. protected onDoubleTap(type: string): void;
  120213. /**
  120214. * Called on pointer POINTERMOVE event if multiple touches are active.
  120215. */
  120216. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120217. /**
  120218. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120219. * press.
  120220. */
  120221. protected onButtonDown(evt: PointerEvent): void;
  120222. /**
  120223. * Called each time a new POINTERUP event occurs. Ie, for each button
  120224. * release.
  120225. */
  120226. protected onButtonUp(evt: PointerEvent): void;
  120227. /**
  120228. * Called when window becomes inactive.
  120229. */
  120230. protected onLostFocus(): void;
  120231. }
  120232. }
  120233. declare module BABYLON {
  120234. /**
  120235. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  120236. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120237. */
  120238. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  120239. /**
  120240. * Defines the camera the input is attached to.
  120241. */
  120242. camera: ArcRotateCamera;
  120243. /**
  120244. * Defines the list of key codes associated with the up action (increase alpha)
  120245. */
  120246. keysUp: number[];
  120247. /**
  120248. * Defines the list of key codes associated with the down action (decrease alpha)
  120249. */
  120250. keysDown: number[];
  120251. /**
  120252. * Defines the list of key codes associated with the left action (increase beta)
  120253. */
  120254. keysLeft: number[];
  120255. /**
  120256. * Defines the list of key codes associated with the right action (decrease beta)
  120257. */
  120258. keysRight: number[];
  120259. /**
  120260. * Defines the list of key codes associated with the reset action.
  120261. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  120262. */
  120263. keysReset: number[];
  120264. /**
  120265. * Defines the panning sensibility of the inputs.
  120266. * (How fast is the camera panning)
  120267. */
  120268. panningSensibility: number;
  120269. /**
  120270. * Defines the zooming sensibility of the inputs.
  120271. * (How fast is the camera zooming)
  120272. */
  120273. zoomingSensibility: number;
  120274. /**
  120275. * Defines whether maintaining the alt key down switch the movement mode from
  120276. * orientation to zoom.
  120277. */
  120278. useAltToZoom: boolean;
  120279. /**
  120280. * Rotation speed of the camera
  120281. */
  120282. angularSpeed: number;
  120283. private _keys;
  120284. private _ctrlPressed;
  120285. private _altPressed;
  120286. private _onCanvasBlurObserver;
  120287. private _onKeyboardObserver;
  120288. private _engine;
  120289. private _scene;
  120290. /**
  120291. * Attach the input controls to a specific dom element to get the input from.
  120292. * @param element Defines the element the controls should be listened from
  120293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120294. */
  120295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120296. /**
  120297. * Detach the current controls from the specified dom element.
  120298. * @param element Defines the element to stop listening the inputs from
  120299. */
  120300. detachControl(element: Nullable<HTMLElement>): void;
  120301. /**
  120302. * Update the current camera state depending on the inputs that have been used this frame.
  120303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120304. */
  120305. checkInputs(): void;
  120306. /**
  120307. * Gets the class name of the current intput.
  120308. * @returns the class name
  120309. */
  120310. getClassName(): string;
  120311. /**
  120312. * Get the friendly name associated with the input class.
  120313. * @returns the input friendly name
  120314. */
  120315. getSimpleName(): string;
  120316. }
  120317. }
  120318. declare module BABYLON {
  120319. /**
  120320. * Manage the mouse wheel inputs to control an arc rotate camera.
  120321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120322. */
  120323. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120324. /**
  120325. * Defines the camera the input is attached to.
  120326. */
  120327. camera: ArcRotateCamera;
  120328. /**
  120329. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120330. */
  120331. wheelPrecision: number;
  120332. /**
  120333. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120334. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120335. */
  120336. wheelDeltaPercentage: number;
  120337. private _wheel;
  120338. private _observer;
  120339. private computeDeltaFromMouseWheelLegacyEvent;
  120340. /**
  120341. * Attach the input controls to a specific dom element to get the input from.
  120342. * @param element Defines the element the controls should be listened from
  120343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120344. */
  120345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120346. /**
  120347. * Detach the current controls from the specified dom element.
  120348. * @param element Defines the element to stop listening the inputs from
  120349. */
  120350. detachControl(element: Nullable<HTMLElement>): void;
  120351. /**
  120352. * Gets the class name of the current intput.
  120353. * @returns the class name
  120354. */
  120355. getClassName(): string;
  120356. /**
  120357. * Get the friendly name associated with the input class.
  120358. * @returns the input friendly name
  120359. */
  120360. getSimpleName(): string;
  120361. }
  120362. }
  120363. declare module BABYLON {
  120364. /**
  120365. * Default Inputs manager for the ArcRotateCamera.
  120366. * It groups all the default supported inputs for ease of use.
  120367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120368. */
  120369. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120370. /**
  120371. * Instantiates a new ArcRotateCameraInputsManager.
  120372. * @param camera Defines the camera the inputs belong to
  120373. */
  120374. constructor(camera: ArcRotateCamera);
  120375. /**
  120376. * Add mouse wheel input support to the input manager.
  120377. * @returns the current input manager
  120378. */
  120379. addMouseWheel(): ArcRotateCameraInputsManager;
  120380. /**
  120381. * Add pointers input support to the input manager.
  120382. * @returns the current input manager
  120383. */
  120384. addPointers(): ArcRotateCameraInputsManager;
  120385. /**
  120386. * Add keyboard input support to the input manager.
  120387. * @returns the current input manager
  120388. */
  120389. addKeyboard(): ArcRotateCameraInputsManager;
  120390. }
  120391. }
  120392. declare module BABYLON {
  120393. /**
  120394. * This represents an orbital type of camera.
  120395. *
  120396. * 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.
  120397. * 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.
  120398. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120399. */
  120400. export class ArcRotateCamera extends TargetCamera {
  120401. /**
  120402. * Defines the rotation angle of the camera along the longitudinal axis.
  120403. */
  120404. alpha: number;
  120405. /**
  120406. * Defines the rotation angle of the camera along the latitudinal axis.
  120407. */
  120408. beta: number;
  120409. /**
  120410. * Defines the radius of the camera from it s target point.
  120411. */
  120412. radius: number;
  120413. protected _target: Vector3;
  120414. protected _targetHost: Nullable<AbstractMesh>;
  120415. /**
  120416. * Defines the target point of the camera.
  120417. * The camera looks towards it form the radius distance.
  120418. */
  120419. get target(): Vector3;
  120420. set target(value: Vector3);
  120421. /**
  120422. * Define the current local position of the camera in the scene
  120423. */
  120424. get position(): Vector3;
  120425. set position(newPosition: Vector3);
  120426. protected _upVector: Vector3;
  120427. protected _upToYMatrix: Matrix;
  120428. protected _YToUpMatrix: Matrix;
  120429. /**
  120430. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120431. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120432. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120433. */
  120434. set upVector(vec: Vector3);
  120435. get upVector(): Vector3;
  120436. /**
  120437. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120438. */
  120439. setMatUp(): void;
  120440. /**
  120441. * Current inertia value on the longitudinal axis.
  120442. * The bigger this number the longer it will take for the camera to stop.
  120443. */
  120444. inertialAlphaOffset: number;
  120445. /**
  120446. * Current inertia value on the latitudinal axis.
  120447. * The bigger this number the longer it will take for the camera to stop.
  120448. */
  120449. inertialBetaOffset: number;
  120450. /**
  120451. * Current inertia value on the radius axis.
  120452. * The bigger this number the longer it will take for the camera to stop.
  120453. */
  120454. inertialRadiusOffset: number;
  120455. /**
  120456. * Minimum allowed angle on the longitudinal axis.
  120457. * This can help limiting how the Camera is able to move in the scene.
  120458. */
  120459. lowerAlphaLimit: Nullable<number>;
  120460. /**
  120461. * Maximum allowed angle on the longitudinal axis.
  120462. * This can help limiting how the Camera is able to move in the scene.
  120463. */
  120464. upperAlphaLimit: Nullable<number>;
  120465. /**
  120466. * Minimum allowed angle on the latitudinal axis.
  120467. * This can help limiting how the Camera is able to move in the scene.
  120468. */
  120469. lowerBetaLimit: number;
  120470. /**
  120471. * Maximum allowed angle on the latitudinal axis.
  120472. * This can help limiting how the Camera is able to move in the scene.
  120473. */
  120474. upperBetaLimit: number;
  120475. /**
  120476. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120477. * This can help limiting how the Camera is able to move in the scene.
  120478. */
  120479. lowerRadiusLimit: Nullable<number>;
  120480. /**
  120481. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120482. * This can help limiting how the Camera is able to move in the scene.
  120483. */
  120484. upperRadiusLimit: Nullable<number>;
  120485. /**
  120486. * Defines the current inertia value used during panning of the camera along the X axis.
  120487. */
  120488. inertialPanningX: number;
  120489. /**
  120490. * Defines the current inertia value used during panning of the camera along the Y axis.
  120491. */
  120492. inertialPanningY: number;
  120493. /**
  120494. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120495. * Basically if your fingers moves away from more than this distance you will be considered
  120496. * in pinch mode.
  120497. */
  120498. pinchToPanMaxDistance: number;
  120499. /**
  120500. * Defines the maximum distance the camera can pan.
  120501. * This could help keeping the cammera always in your scene.
  120502. */
  120503. panningDistanceLimit: Nullable<number>;
  120504. /**
  120505. * Defines the target of the camera before paning.
  120506. */
  120507. panningOriginTarget: Vector3;
  120508. /**
  120509. * Defines the value of the inertia used during panning.
  120510. * 0 would mean stop inertia and one would mean no decelleration at all.
  120511. */
  120512. panningInertia: number;
  120513. /**
  120514. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120515. */
  120516. get angularSensibilityX(): number;
  120517. set angularSensibilityX(value: number);
  120518. /**
  120519. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120520. */
  120521. get angularSensibilityY(): number;
  120522. set angularSensibilityY(value: number);
  120523. /**
  120524. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120525. */
  120526. get pinchPrecision(): number;
  120527. set pinchPrecision(value: number);
  120528. /**
  120529. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120530. * It will be used instead of pinchDeltaPrecision if different from 0.
  120531. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120532. */
  120533. get pinchDeltaPercentage(): number;
  120534. set pinchDeltaPercentage(value: number);
  120535. /**
  120536. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120537. * and pinch delta percentage.
  120538. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120539. * that any object in the plane at the camera's target point will scale
  120540. * perfectly with finger motion.
  120541. */
  120542. get useNaturalPinchZoom(): boolean;
  120543. set useNaturalPinchZoom(value: boolean);
  120544. /**
  120545. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120546. */
  120547. get panningSensibility(): number;
  120548. set panningSensibility(value: number);
  120549. /**
  120550. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120551. */
  120552. get keysUp(): number[];
  120553. set keysUp(value: number[]);
  120554. /**
  120555. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120556. */
  120557. get keysDown(): number[];
  120558. set keysDown(value: number[]);
  120559. /**
  120560. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120561. */
  120562. get keysLeft(): number[];
  120563. set keysLeft(value: number[]);
  120564. /**
  120565. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120566. */
  120567. get keysRight(): number[];
  120568. set keysRight(value: number[]);
  120569. /**
  120570. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120571. */
  120572. get wheelPrecision(): number;
  120573. set wheelPrecision(value: number);
  120574. /**
  120575. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120576. * It will be used instead of pinchDeltaPrecision if different from 0.
  120577. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120578. */
  120579. get wheelDeltaPercentage(): number;
  120580. set wheelDeltaPercentage(value: number);
  120581. /**
  120582. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120583. */
  120584. zoomOnFactor: number;
  120585. /**
  120586. * Defines a screen offset for the camera position.
  120587. */
  120588. targetScreenOffset: Vector2;
  120589. /**
  120590. * Allows the camera to be completely reversed.
  120591. * If false the camera can not arrive upside down.
  120592. */
  120593. allowUpsideDown: boolean;
  120594. /**
  120595. * Define if double tap/click is used to restore the previously saved state of the camera.
  120596. */
  120597. useInputToRestoreState: boolean;
  120598. /** @hidden */
  120599. _viewMatrix: Matrix;
  120600. /** @hidden */
  120601. _useCtrlForPanning: boolean;
  120602. /** @hidden */
  120603. _panningMouseButton: number;
  120604. /**
  120605. * Defines the input associated to the camera.
  120606. */
  120607. inputs: ArcRotateCameraInputsManager;
  120608. /** @hidden */
  120609. _reset: () => void;
  120610. /**
  120611. * Defines the allowed panning axis.
  120612. */
  120613. panningAxis: Vector3;
  120614. protected _localDirection: Vector3;
  120615. protected _transformedDirection: Vector3;
  120616. private _bouncingBehavior;
  120617. /**
  120618. * Gets the bouncing behavior of the camera if it has been enabled.
  120619. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120620. */
  120621. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120622. /**
  120623. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120624. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120625. */
  120626. get useBouncingBehavior(): boolean;
  120627. set useBouncingBehavior(value: boolean);
  120628. private _framingBehavior;
  120629. /**
  120630. * Gets the framing behavior of the camera if it has been enabled.
  120631. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120632. */
  120633. get framingBehavior(): Nullable<FramingBehavior>;
  120634. /**
  120635. * Defines if the framing behavior of the camera is enabled on the camera.
  120636. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120637. */
  120638. get useFramingBehavior(): boolean;
  120639. set useFramingBehavior(value: boolean);
  120640. private _autoRotationBehavior;
  120641. /**
  120642. * Gets the auto rotation behavior of the camera if it has been enabled.
  120643. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120644. */
  120645. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120646. /**
  120647. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120648. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120649. */
  120650. get useAutoRotationBehavior(): boolean;
  120651. set useAutoRotationBehavior(value: boolean);
  120652. /**
  120653. * Observable triggered when the mesh target has been changed on the camera.
  120654. */
  120655. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120656. /**
  120657. * Event raised when the camera is colliding with a mesh.
  120658. */
  120659. onCollide: (collidedMesh: AbstractMesh) => void;
  120660. /**
  120661. * Defines whether the camera should check collision with the objects oh the scene.
  120662. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120663. */
  120664. checkCollisions: boolean;
  120665. /**
  120666. * Defines the collision radius of the camera.
  120667. * This simulates a sphere around the camera.
  120668. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120669. */
  120670. collisionRadius: Vector3;
  120671. protected _collider: Collider;
  120672. protected _previousPosition: Vector3;
  120673. protected _collisionVelocity: Vector3;
  120674. protected _newPosition: Vector3;
  120675. protected _previousAlpha: number;
  120676. protected _previousBeta: number;
  120677. protected _previousRadius: number;
  120678. protected _collisionTriggered: boolean;
  120679. protected _targetBoundingCenter: Nullable<Vector3>;
  120680. private _computationVector;
  120681. /**
  120682. * Instantiates a new ArcRotateCamera in a given scene
  120683. * @param name Defines the name of the camera
  120684. * @param alpha Defines the camera rotation along the logitudinal axis
  120685. * @param beta Defines the camera rotation along the latitudinal axis
  120686. * @param radius Defines the camera distance from its target
  120687. * @param target Defines the camera target
  120688. * @param scene Defines the scene the camera belongs to
  120689. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120690. */
  120691. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120692. /** @hidden */
  120693. _initCache(): void;
  120694. /** @hidden */
  120695. _updateCache(ignoreParentClass?: boolean): void;
  120696. protected _getTargetPosition(): Vector3;
  120697. private _storedAlpha;
  120698. private _storedBeta;
  120699. private _storedRadius;
  120700. private _storedTarget;
  120701. private _storedTargetScreenOffset;
  120702. /**
  120703. * Stores the current state of the camera (alpha, beta, radius and target)
  120704. * @returns the camera itself
  120705. */
  120706. storeState(): Camera;
  120707. /**
  120708. * @hidden
  120709. * Restored camera state. You must call storeState() first
  120710. */
  120711. _restoreStateValues(): boolean;
  120712. /** @hidden */
  120713. _isSynchronizedViewMatrix(): boolean;
  120714. /**
  120715. * Attached controls to the current camera.
  120716. * @param element Defines the element the controls should be listened from
  120717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120718. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120719. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120720. */
  120721. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120722. /**
  120723. * Detach the current controls from the camera.
  120724. * The camera will stop reacting to inputs.
  120725. * @param element Defines the element to stop listening the inputs from
  120726. */
  120727. detachControl(element: HTMLElement): void;
  120728. /** @hidden */
  120729. _checkInputs(): void;
  120730. protected _checkLimits(): void;
  120731. /**
  120732. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120733. */
  120734. rebuildAnglesAndRadius(): void;
  120735. /**
  120736. * Use a position to define the current camera related information like alpha, beta and radius
  120737. * @param position Defines the position to set the camera at
  120738. */
  120739. setPosition(position: Vector3): void;
  120740. /**
  120741. * Defines the target the camera should look at.
  120742. * This will automatically adapt alpha beta and radius to fit within the new target.
  120743. * @param target Defines the new target as a Vector or a mesh
  120744. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120745. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120746. */
  120747. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120748. /** @hidden */
  120749. _getViewMatrix(): Matrix;
  120750. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120751. /**
  120752. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120753. * @param meshes Defines the mesh to zoom on
  120754. * @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)
  120755. */
  120756. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120757. /**
  120758. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120759. * The target will be changed but the radius
  120760. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120761. * @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)
  120762. */
  120763. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120764. min: Vector3;
  120765. max: Vector3;
  120766. distance: number;
  120767. }, doNotUpdateMaxZ?: boolean): void;
  120768. /**
  120769. * @override
  120770. * Override Camera.createRigCamera
  120771. */
  120772. createRigCamera(name: string, cameraIndex: number): Camera;
  120773. /**
  120774. * @hidden
  120775. * @override
  120776. * Override Camera._updateRigCameras
  120777. */
  120778. _updateRigCameras(): void;
  120779. /**
  120780. * Destroy the camera and release the current resources hold by it.
  120781. */
  120782. dispose(): void;
  120783. /**
  120784. * Gets the current object class name.
  120785. * @return the class name
  120786. */
  120787. getClassName(): string;
  120788. }
  120789. }
  120790. declare module BABYLON {
  120791. /**
  120792. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120793. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120794. */
  120795. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120796. /**
  120797. * Gets the name of the behavior.
  120798. */
  120799. get name(): string;
  120800. private _zoomStopsAnimation;
  120801. private _idleRotationSpeed;
  120802. private _idleRotationWaitTime;
  120803. private _idleRotationSpinupTime;
  120804. /**
  120805. * Sets the flag that indicates if user zooming should stop animation.
  120806. */
  120807. set zoomStopsAnimation(flag: boolean);
  120808. /**
  120809. * Gets the flag that indicates if user zooming should stop animation.
  120810. */
  120811. get zoomStopsAnimation(): boolean;
  120812. /**
  120813. * Sets the default speed at which the camera rotates around the model.
  120814. */
  120815. set idleRotationSpeed(speed: number);
  120816. /**
  120817. * Gets the default speed at which the camera rotates around the model.
  120818. */
  120819. get idleRotationSpeed(): number;
  120820. /**
  120821. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120822. */
  120823. set idleRotationWaitTime(time: number);
  120824. /**
  120825. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120826. */
  120827. get idleRotationWaitTime(): number;
  120828. /**
  120829. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120830. */
  120831. set idleRotationSpinupTime(time: number);
  120832. /**
  120833. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120834. */
  120835. get idleRotationSpinupTime(): number;
  120836. /**
  120837. * Gets a value indicating if the camera is currently rotating because of this behavior
  120838. */
  120839. get rotationInProgress(): boolean;
  120840. private _onPrePointerObservableObserver;
  120841. private _onAfterCheckInputsObserver;
  120842. private _attachedCamera;
  120843. private _isPointerDown;
  120844. private _lastFrameTime;
  120845. private _lastInteractionTime;
  120846. private _cameraRotationSpeed;
  120847. /**
  120848. * Initializes the behavior.
  120849. */
  120850. init(): void;
  120851. /**
  120852. * Attaches the behavior to its arc rotate camera.
  120853. * @param camera Defines the camera to attach the behavior to
  120854. */
  120855. attach(camera: ArcRotateCamera): void;
  120856. /**
  120857. * Detaches the behavior from its current arc rotate camera.
  120858. */
  120859. detach(): void;
  120860. /**
  120861. * Returns true if user is scrolling.
  120862. * @return true if user is scrolling.
  120863. */
  120864. private _userIsZooming;
  120865. private _lastFrameRadius;
  120866. private _shouldAnimationStopForInteraction;
  120867. /**
  120868. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120869. */
  120870. private _applyUserInteraction;
  120871. private _userIsMoving;
  120872. }
  120873. }
  120874. declare module BABYLON {
  120875. /**
  120876. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120877. */
  120878. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120879. private ui;
  120880. /**
  120881. * The name of the behavior
  120882. */
  120883. name: string;
  120884. /**
  120885. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120886. */
  120887. distanceAwayFromFace: number;
  120888. /**
  120889. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120890. */
  120891. distanceAwayFromBottomOfFace: number;
  120892. private _faceVectors;
  120893. private _target;
  120894. private _scene;
  120895. private _onRenderObserver;
  120896. private _tmpMatrix;
  120897. private _tmpVector;
  120898. /**
  120899. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120900. * @param ui The transform node that should be attched to the mesh
  120901. */
  120902. constructor(ui: TransformNode);
  120903. /**
  120904. * Initializes the behavior
  120905. */
  120906. init(): void;
  120907. private _closestFace;
  120908. private _zeroVector;
  120909. private _lookAtTmpMatrix;
  120910. private _lookAtToRef;
  120911. /**
  120912. * Attaches the AttachToBoxBehavior to the passed in mesh
  120913. * @param target The mesh that the specified node will be attached to
  120914. */
  120915. attach(target: Mesh): void;
  120916. /**
  120917. * Detaches the behavior from the mesh
  120918. */
  120919. detach(): void;
  120920. }
  120921. }
  120922. declare module BABYLON {
  120923. /**
  120924. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120925. */
  120926. export class FadeInOutBehavior implements Behavior<Mesh> {
  120927. /**
  120928. * Time in milliseconds to delay before fading in (Default: 0)
  120929. */
  120930. delay: number;
  120931. /**
  120932. * Time in milliseconds for the mesh to fade in (Default: 300)
  120933. */
  120934. fadeInTime: number;
  120935. private _millisecondsPerFrame;
  120936. private _hovered;
  120937. private _hoverValue;
  120938. private _ownerNode;
  120939. /**
  120940. * Instatiates the FadeInOutBehavior
  120941. */
  120942. constructor();
  120943. /**
  120944. * The name of the behavior
  120945. */
  120946. get name(): string;
  120947. /**
  120948. * Initializes the behavior
  120949. */
  120950. init(): void;
  120951. /**
  120952. * Attaches the fade behavior on the passed in mesh
  120953. * @param ownerNode The mesh that will be faded in/out once attached
  120954. */
  120955. attach(ownerNode: Mesh): void;
  120956. /**
  120957. * Detaches the behavior from the mesh
  120958. */
  120959. detach(): void;
  120960. /**
  120961. * Triggers the mesh to begin fading in or out
  120962. * @param value if the object should fade in or out (true to fade in)
  120963. */
  120964. fadeIn(value: boolean): void;
  120965. private _update;
  120966. private _setAllVisibility;
  120967. }
  120968. }
  120969. declare module BABYLON {
  120970. /**
  120971. * Class containing a set of static utilities functions for managing Pivots
  120972. * @hidden
  120973. */
  120974. export class PivotTools {
  120975. private static _PivotCached;
  120976. private static _OldPivotPoint;
  120977. private static _PivotTranslation;
  120978. private static _PivotTmpVector;
  120979. /** @hidden */
  120980. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120981. /** @hidden */
  120982. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120983. }
  120984. }
  120985. declare module BABYLON {
  120986. /**
  120987. * Class containing static functions to help procedurally build meshes
  120988. */
  120989. export class PlaneBuilder {
  120990. /**
  120991. * Creates a plane mesh
  120992. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120993. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120994. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120998. * @param name defines the name of the mesh
  120999. * @param options defines the options used to create the mesh
  121000. * @param scene defines the hosting scene
  121001. * @returns the plane mesh
  121002. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121003. */
  121004. static CreatePlane(name: string, options: {
  121005. size?: number;
  121006. width?: number;
  121007. height?: number;
  121008. sideOrientation?: number;
  121009. frontUVs?: Vector4;
  121010. backUVs?: Vector4;
  121011. updatable?: boolean;
  121012. sourcePlane?: Plane;
  121013. }, scene?: Nullable<Scene>): Mesh;
  121014. }
  121015. }
  121016. declare module BABYLON {
  121017. /**
  121018. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  121019. */
  121020. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  121021. private static _AnyMouseID;
  121022. /**
  121023. * Abstract mesh the behavior is set on
  121024. */
  121025. attachedNode: AbstractMesh;
  121026. private _dragPlane;
  121027. private _scene;
  121028. private _pointerObserver;
  121029. private _beforeRenderObserver;
  121030. private static _planeScene;
  121031. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  121032. /**
  121033. * 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)
  121034. */
  121035. maxDragAngle: number;
  121036. /**
  121037. * @hidden
  121038. */
  121039. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  121040. /**
  121041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121042. */
  121043. currentDraggingPointerID: number;
  121044. /**
  121045. * The last position where the pointer hit the drag plane in world space
  121046. */
  121047. lastDragPosition: Vector3;
  121048. /**
  121049. * If the behavior is currently in a dragging state
  121050. */
  121051. dragging: boolean;
  121052. /**
  121053. * 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)
  121054. */
  121055. dragDeltaRatio: number;
  121056. /**
  121057. * If the drag plane orientation should be updated during the dragging (Default: true)
  121058. */
  121059. updateDragPlane: boolean;
  121060. private _debugMode;
  121061. private _moving;
  121062. /**
  121063. * Fires each time the attached mesh is dragged with the pointer
  121064. * * delta between last drag position and current drag position in world space
  121065. * * dragDistance along the drag axis
  121066. * * dragPlaneNormal normal of the current drag plane used during the drag
  121067. * * dragPlanePoint in world space where the drag intersects the drag plane
  121068. */
  121069. onDragObservable: Observable<{
  121070. delta: Vector3;
  121071. dragPlanePoint: Vector3;
  121072. dragPlaneNormal: Vector3;
  121073. dragDistance: number;
  121074. pointerId: number;
  121075. }>;
  121076. /**
  121077. * Fires each time a drag begins (eg. mouse down on mesh)
  121078. */
  121079. onDragStartObservable: Observable<{
  121080. dragPlanePoint: Vector3;
  121081. pointerId: number;
  121082. }>;
  121083. /**
  121084. * Fires each time a drag ends (eg. mouse release after drag)
  121085. */
  121086. onDragEndObservable: Observable<{
  121087. dragPlanePoint: Vector3;
  121088. pointerId: number;
  121089. }>;
  121090. /**
  121091. * If the attached mesh should be moved when dragged
  121092. */
  121093. moveAttached: boolean;
  121094. /**
  121095. * If the drag behavior will react to drag events (Default: true)
  121096. */
  121097. enabled: boolean;
  121098. /**
  121099. * If pointer events should start and release the drag (Default: true)
  121100. */
  121101. startAndReleaseDragOnPointerEvents: boolean;
  121102. /**
  121103. * If camera controls should be detached during the drag
  121104. */
  121105. detachCameraControls: boolean;
  121106. /**
  121107. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  121108. */
  121109. useObjectOrientationForDragging: boolean;
  121110. private _options;
  121111. /**
  121112. * Gets the options used by the behavior
  121113. */
  121114. get options(): {
  121115. dragAxis?: Vector3;
  121116. dragPlaneNormal?: Vector3;
  121117. };
  121118. /**
  121119. * Sets the options used by the behavior
  121120. */
  121121. set options(options: {
  121122. dragAxis?: Vector3;
  121123. dragPlaneNormal?: Vector3;
  121124. });
  121125. /**
  121126. * Creates a pointer drag behavior that can be attached to a mesh
  121127. * @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)
  121128. */
  121129. constructor(options?: {
  121130. dragAxis?: Vector3;
  121131. dragPlaneNormal?: Vector3;
  121132. });
  121133. /**
  121134. * Predicate to determine if it is valid to move the object to a new position when it is moved
  121135. */
  121136. validateDrag: (targetPosition: Vector3) => boolean;
  121137. /**
  121138. * The name of the behavior
  121139. */
  121140. get name(): string;
  121141. /**
  121142. * Initializes the behavior
  121143. */
  121144. init(): void;
  121145. private _tmpVector;
  121146. private _alternatePickedPoint;
  121147. private _worldDragAxis;
  121148. private _targetPosition;
  121149. private _attachedElement;
  121150. /**
  121151. * Attaches the drag behavior the passed in mesh
  121152. * @param ownerNode The mesh that will be dragged around once attached
  121153. * @param predicate Predicate to use for pick filtering
  121154. */
  121155. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  121156. /**
  121157. * Force relase the drag action by code.
  121158. */
  121159. releaseDrag(): void;
  121160. private _startDragRay;
  121161. private _lastPointerRay;
  121162. /**
  121163. * Simulates the start of a pointer drag event on the behavior
  121164. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  121165. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  121166. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  121167. */
  121168. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  121169. private _startDrag;
  121170. private _dragDelta;
  121171. private _moveDrag;
  121172. private _pickWithRayOnDragPlane;
  121173. private _pointA;
  121174. private _pointB;
  121175. private _pointC;
  121176. private _lineA;
  121177. private _lineB;
  121178. private _localAxis;
  121179. private _lookAt;
  121180. private _updateDragPlanePosition;
  121181. /**
  121182. * Detaches the behavior from the mesh
  121183. */
  121184. detach(): void;
  121185. }
  121186. }
  121187. declare module BABYLON {
  121188. /**
  121189. * A behavior that when attached to a mesh will allow the mesh to be scaled
  121190. */
  121191. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  121192. private _dragBehaviorA;
  121193. private _dragBehaviorB;
  121194. private _startDistance;
  121195. private _initialScale;
  121196. private _targetScale;
  121197. private _ownerNode;
  121198. private _sceneRenderObserver;
  121199. /**
  121200. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  121201. */
  121202. constructor();
  121203. /**
  121204. * The name of the behavior
  121205. */
  121206. get name(): string;
  121207. /**
  121208. * Initializes the behavior
  121209. */
  121210. init(): void;
  121211. private _getCurrentDistance;
  121212. /**
  121213. * Attaches the scale behavior the passed in mesh
  121214. * @param ownerNode The mesh that will be scaled around once attached
  121215. */
  121216. attach(ownerNode: Mesh): void;
  121217. /**
  121218. * Detaches the behavior from the mesh
  121219. */
  121220. detach(): void;
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. /**
  121225. * 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
  121226. */
  121227. export class SixDofDragBehavior implements Behavior<Mesh> {
  121228. private static _virtualScene;
  121229. private _ownerNode;
  121230. private _sceneRenderObserver;
  121231. private _scene;
  121232. private _targetPosition;
  121233. private _virtualOriginMesh;
  121234. private _virtualDragMesh;
  121235. private _pointerObserver;
  121236. private _moving;
  121237. private _startingOrientation;
  121238. private _attachedElement;
  121239. /**
  121240. * 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)
  121241. */
  121242. private zDragFactor;
  121243. /**
  121244. * If the object should rotate to face the drag origin
  121245. */
  121246. rotateDraggedObject: boolean;
  121247. /**
  121248. * If the behavior is currently in a dragging state
  121249. */
  121250. dragging: boolean;
  121251. /**
  121252. * 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)
  121253. */
  121254. dragDeltaRatio: number;
  121255. /**
  121256. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121257. */
  121258. currentDraggingPointerID: number;
  121259. /**
  121260. * If camera controls should be detached during the drag
  121261. */
  121262. detachCameraControls: boolean;
  121263. /**
  121264. * Fires each time a drag starts
  121265. */
  121266. onDragStartObservable: Observable<{}>;
  121267. /**
  121268. * Fires each time a drag ends (eg. mouse release after drag)
  121269. */
  121270. onDragEndObservable: Observable<{}>;
  121271. /**
  121272. * 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
  121273. */
  121274. constructor();
  121275. /**
  121276. * The name of the behavior
  121277. */
  121278. get name(): string;
  121279. /**
  121280. * Initializes the behavior
  121281. */
  121282. init(): void;
  121283. /**
  121284. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  121285. */
  121286. private get _pointerCamera();
  121287. /**
  121288. * Attaches the scale behavior the passed in mesh
  121289. * @param ownerNode The mesh that will be scaled around once attached
  121290. */
  121291. attach(ownerNode: Mesh): void;
  121292. /**
  121293. * Detaches the behavior from the mesh
  121294. */
  121295. detach(): void;
  121296. }
  121297. }
  121298. declare module BABYLON {
  121299. /**
  121300. * Class used to apply inverse kinematics to bones
  121301. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  121302. */
  121303. export class BoneIKController {
  121304. private static _tmpVecs;
  121305. private static _tmpQuat;
  121306. private static _tmpMats;
  121307. /**
  121308. * Gets or sets the target mesh
  121309. */
  121310. targetMesh: AbstractMesh;
  121311. /** Gets or sets the mesh used as pole */
  121312. poleTargetMesh: AbstractMesh;
  121313. /**
  121314. * Gets or sets the bone used as pole
  121315. */
  121316. poleTargetBone: Nullable<Bone>;
  121317. /**
  121318. * Gets or sets the target position
  121319. */
  121320. targetPosition: Vector3;
  121321. /**
  121322. * Gets or sets the pole target position
  121323. */
  121324. poleTargetPosition: Vector3;
  121325. /**
  121326. * Gets or sets the pole target local offset
  121327. */
  121328. poleTargetLocalOffset: Vector3;
  121329. /**
  121330. * Gets or sets the pole angle
  121331. */
  121332. poleAngle: number;
  121333. /**
  121334. * Gets or sets the mesh associated with the controller
  121335. */
  121336. mesh: AbstractMesh;
  121337. /**
  121338. * 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)
  121339. */
  121340. slerpAmount: number;
  121341. private _bone1Quat;
  121342. private _bone1Mat;
  121343. private _bone2Ang;
  121344. private _bone1;
  121345. private _bone2;
  121346. private _bone1Length;
  121347. private _bone2Length;
  121348. private _maxAngle;
  121349. private _maxReach;
  121350. private _rightHandedSystem;
  121351. private _bendAxis;
  121352. private _slerping;
  121353. private _adjustRoll;
  121354. /**
  121355. * Gets or sets maximum allowed angle
  121356. */
  121357. get maxAngle(): number;
  121358. set maxAngle(value: number);
  121359. /**
  121360. * Creates a new BoneIKController
  121361. * @param mesh defines the mesh to control
  121362. * @param bone defines the bone to control
  121363. * @param options defines options to set up the controller
  121364. */
  121365. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121366. targetMesh?: AbstractMesh;
  121367. poleTargetMesh?: AbstractMesh;
  121368. poleTargetBone?: Bone;
  121369. poleTargetLocalOffset?: Vector3;
  121370. poleAngle?: number;
  121371. bendAxis?: Vector3;
  121372. maxAngle?: number;
  121373. slerpAmount?: number;
  121374. });
  121375. private _setMaxAngle;
  121376. /**
  121377. * Force the controller to update the bones
  121378. */
  121379. update(): void;
  121380. }
  121381. }
  121382. declare module BABYLON {
  121383. /**
  121384. * Class used to make a bone look toward a point in space
  121385. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121386. */
  121387. export class BoneLookController {
  121388. private static _tmpVecs;
  121389. private static _tmpQuat;
  121390. private static _tmpMats;
  121391. /**
  121392. * The target Vector3 that the bone will look at
  121393. */
  121394. target: Vector3;
  121395. /**
  121396. * The mesh that the bone is attached to
  121397. */
  121398. mesh: AbstractMesh;
  121399. /**
  121400. * The bone that will be looking to the target
  121401. */
  121402. bone: Bone;
  121403. /**
  121404. * The up axis of the coordinate system that is used when the bone is rotated
  121405. */
  121406. upAxis: Vector3;
  121407. /**
  121408. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121409. */
  121410. upAxisSpace: Space;
  121411. /**
  121412. * Used to make an adjustment to the yaw of the bone
  121413. */
  121414. adjustYaw: number;
  121415. /**
  121416. * Used to make an adjustment to the pitch of the bone
  121417. */
  121418. adjustPitch: number;
  121419. /**
  121420. * Used to make an adjustment to the roll of the bone
  121421. */
  121422. adjustRoll: number;
  121423. /**
  121424. * 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)
  121425. */
  121426. slerpAmount: number;
  121427. private _minYaw;
  121428. private _maxYaw;
  121429. private _minPitch;
  121430. private _maxPitch;
  121431. private _minYawSin;
  121432. private _minYawCos;
  121433. private _maxYawSin;
  121434. private _maxYawCos;
  121435. private _midYawConstraint;
  121436. private _minPitchTan;
  121437. private _maxPitchTan;
  121438. private _boneQuat;
  121439. private _slerping;
  121440. private _transformYawPitch;
  121441. private _transformYawPitchInv;
  121442. private _firstFrameSkipped;
  121443. private _yawRange;
  121444. private _fowardAxis;
  121445. /**
  121446. * Gets or sets the minimum yaw angle that the bone can look to
  121447. */
  121448. get minYaw(): number;
  121449. set minYaw(value: number);
  121450. /**
  121451. * Gets or sets the maximum yaw angle that the bone can look to
  121452. */
  121453. get maxYaw(): number;
  121454. set maxYaw(value: number);
  121455. /**
  121456. * Gets or sets the minimum pitch angle that the bone can look to
  121457. */
  121458. get minPitch(): number;
  121459. set minPitch(value: number);
  121460. /**
  121461. * Gets or sets the maximum pitch angle that the bone can look to
  121462. */
  121463. get maxPitch(): number;
  121464. set maxPitch(value: number);
  121465. /**
  121466. * Create a BoneLookController
  121467. * @param mesh the mesh that the bone belongs to
  121468. * @param bone the bone that will be looking to the target
  121469. * @param target the target Vector3 to look at
  121470. * @param options optional settings:
  121471. * * maxYaw: the maximum angle the bone will yaw to
  121472. * * minYaw: the minimum angle the bone will yaw to
  121473. * * maxPitch: the maximum angle the bone will pitch to
  121474. * * minPitch: the minimum angle the bone will yaw to
  121475. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121476. * * upAxis: the up axis of the coordinate system
  121477. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121478. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121479. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121480. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121481. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121482. * * adjustRoll: used to make an adjustment to the roll of the bone
  121483. **/
  121484. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121485. maxYaw?: number;
  121486. minYaw?: number;
  121487. maxPitch?: number;
  121488. minPitch?: number;
  121489. slerpAmount?: number;
  121490. upAxis?: Vector3;
  121491. upAxisSpace?: Space;
  121492. yawAxis?: Vector3;
  121493. pitchAxis?: Vector3;
  121494. adjustYaw?: number;
  121495. adjustPitch?: number;
  121496. adjustRoll?: number;
  121497. });
  121498. /**
  121499. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121500. */
  121501. update(): void;
  121502. private _getAngleDiff;
  121503. private _getAngleBetween;
  121504. private _isAngleBetween;
  121505. }
  121506. }
  121507. declare module BABYLON {
  121508. /**
  121509. * Manage the gamepad inputs to control an arc rotate camera.
  121510. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121511. */
  121512. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121513. /**
  121514. * Defines the camera the input is attached to.
  121515. */
  121516. camera: ArcRotateCamera;
  121517. /**
  121518. * Defines the gamepad the input is gathering event from.
  121519. */
  121520. gamepad: Nullable<Gamepad>;
  121521. /**
  121522. * Defines the gamepad rotation sensiblity.
  121523. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121524. */
  121525. gamepadRotationSensibility: number;
  121526. /**
  121527. * Defines the gamepad move sensiblity.
  121528. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121529. */
  121530. gamepadMoveSensibility: number;
  121531. private _yAxisScale;
  121532. /**
  121533. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121534. */
  121535. get invertYAxis(): boolean;
  121536. set invertYAxis(value: boolean);
  121537. private _onGamepadConnectedObserver;
  121538. private _onGamepadDisconnectedObserver;
  121539. /**
  121540. * Attach the input controls to a specific dom element to get the input from.
  121541. * @param element Defines the element the controls should be listened from
  121542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121543. */
  121544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121545. /**
  121546. * Detach the current controls from the specified dom element.
  121547. * @param element Defines the element to stop listening the inputs from
  121548. */
  121549. detachControl(element: Nullable<HTMLElement>): void;
  121550. /**
  121551. * Update the current camera state depending on the inputs that have been used this frame.
  121552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121553. */
  121554. checkInputs(): void;
  121555. /**
  121556. * Gets the class name of the current intput.
  121557. * @returns the class name
  121558. */
  121559. getClassName(): string;
  121560. /**
  121561. * Get the friendly name associated with the input class.
  121562. * @returns the input friendly name
  121563. */
  121564. getSimpleName(): string;
  121565. }
  121566. }
  121567. declare module BABYLON {
  121568. interface ArcRotateCameraInputsManager {
  121569. /**
  121570. * Add orientation input support to the input manager.
  121571. * @returns the current input manager
  121572. */
  121573. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121574. }
  121575. /**
  121576. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121577. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121578. */
  121579. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121580. /**
  121581. * Defines the camera the input is attached to.
  121582. */
  121583. camera: ArcRotateCamera;
  121584. /**
  121585. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121586. */
  121587. alphaCorrection: number;
  121588. /**
  121589. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121590. */
  121591. gammaCorrection: number;
  121592. private _alpha;
  121593. private _gamma;
  121594. private _dirty;
  121595. private _deviceOrientationHandler;
  121596. /**
  121597. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121598. */
  121599. constructor();
  121600. /**
  121601. * Attach the input controls to a specific dom element to get the input from.
  121602. * @param element Defines the element the controls should be listened from
  121603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121604. */
  121605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121606. /** @hidden */
  121607. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121608. /**
  121609. * Update the current camera state depending on the inputs that have been used this frame.
  121610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121611. */
  121612. checkInputs(): void;
  121613. /**
  121614. * Detach the current controls from the specified dom element.
  121615. * @param element Defines the element to stop listening the inputs from
  121616. */
  121617. detachControl(element: Nullable<HTMLElement>): void;
  121618. /**
  121619. * Gets the class name of the current intput.
  121620. * @returns the class name
  121621. */
  121622. getClassName(): string;
  121623. /**
  121624. * Get the friendly name associated with the input class.
  121625. * @returns the input friendly name
  121626. */
  121627. getSimpleName(): string;
  121628. }
  121629. }
  121630. declare module BABYLON {
  121631. /**
  121632. * Listen to mouse events to control the camera.
  121633. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121634. */
  121635. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121636. /**
  121637. * Defines the camera the input is attached to.
  121638. */
  121639. camera: FlyCamera;
  121640. /**
  121641. * Defines if touch is enabled. (Default is true.)
  121642. */
  121643. touchEnabled: boolean;
  121644. /**
  121645. * Defines the buttons associated with the input to handle camera rotation.
  121646. */
  121647. buttons: number[];
  121648. /**
  121649. * Assign buttons for Yaw control.
  121650. */
  121651. buttonsYaw: number[];
  121652. /**
  121653. * Assign buttons for Pitch control.
  121654. */
  121655. buttonsPitch: number[];
  121656. /**
  121657. * Assign buttons for Roll control.
  121658. */
  121659. buttonsRoll: number[];
  121660. /**
  121661. * Detect if any button is being pressed while mouse is moved.
  121662. * -1 = Mouse locked.
  121663. * 0 = Left button.
  121664. * 1 = Middle Button.
  121665. * 2 = Right Button.
  121666. */
  121667. activeButton: number;
  121668. /**
  121669. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121670. * Higher values reduce its sensitivity.
  121671. */
  121672. angularSensibility: number;
  121673. private _mousemoveCallback;
  121674. private _observer;
  121675. private _rollObserver;
  121676. private previousPosition;
  121677. private noPreventDefault;
  121678. private element;
  121679. /**
  121680. * Listen to mouse events to control the camera.
  121681. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121683. */
  121684. constructor(touchEnabled?: boolean);
  121685. /**
  121686. * Attach the mouse control to the HTML DOM element.
  121687. * @param element Defines the element that listens to the input events.
  121688. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121689. */
  121690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121691. /**
  121692. * Detach the current controls from the specified dom element.
  121693. * @param element Defines the element to stop listening the inputs from
  121694. */
  121695. detachControl(element: Nullable<HTMLElement>): void;
  121696. /**
  121697. * Gets the class name of the current input.
  121698. * @returns the class name.
  121699. */
  121700. getClassName(): string;
  121701. /**
  121702. * Get the friendly name associated with the input class.
  121703. * @returns the input's friendly name.
  121704. */
  121705. getSimpleName(): string;
  121706. private _pointerInput;
  121707. private _onMouseMove;
  121708. /**
  121709. * Rotate camera by mouse offset.
  121710. */
  121711. private rotateCamera;
  121712. }
  121713. }
  121714. declare module BABYLON {
  121715. /**
  121716. * Default Inputs manager for the FlyCamera.
  121717. * It groups all the default supported inputs for ease of use.
  121718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121719. */
  121720. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121721. /**
  121722. * Instantiates a new FlyCameraInputsManager.
  121723. * @param camera Defines the camera the inputs belong to.
  121724. */
  121725. constructor(camera: FlyCamera);
  121726. /**
  121727. * Add keyboard input support to the input manager.
  121728. * @returns the new FlyCameraKeyboardMoveInput().
  121729. */
  121730. addKeyboard(): FlyCameraInputsManager;
  121731. /**
  121732. * Add mouse input support to the input manager.
  121733. * @param touchEnabled Enable touch screen support.
  121734. * @returns the new FlyCameraMouseInput().
  121735. */
  121736. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121737. }
  121738. }
  121739. declare module BABYLON {
  121740. /**
  121741. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121742. * such as in a 3D Space Shooter or a Flight Simulator.
  121743. */
  121744. export class FlyCamera extends TargetCamera {
  121745. /**
  121746. * Define the collision ellipsoid of the camera.
  121747. * This is helpful for simulating a camera body, like a player's body.
  121748. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121749. */
  121750. ellipsoid: Vector3;
  121751. /**
  121752. * Define an offset for the position of the ellipsoid around the camera.
  121753. * This can be helpful if the camera is attached away from the player's body center,
  121754. * such as at its head.
  121755. */
  121756. ellipsoidOffset: Vector3;
  121757. /**
  121758. * Enable or disable collisions of the camera with the rest of the scene objects.
  121759. */
  121760. checkCollisions: boolean;
  121761. /**
  121762. * Enable or disable gravity on the camera.
  121763. */
  121764. applyGravity: boolean;
  121765. /**
  121766. * Define the current direction the camera is moving to.
  121767. */
  121768. cameraDirection: Vector3;
  121769. /**
  121770. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121771. * This overrides and empties cameraRotation.
  121772. */
  121773. rotationQuaternion: Quaternion;
  121774. /**
  121775. * Track Roll to maintain the wanted Rolling when looking around.
  121776. */
  121777. _trackRoll: number;
  121778. /**
  121779. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121780. */
  121781. rollCorrect: number;
  121782. /**
  121783. * Mimic a banked turn, Rolling the camera when Yawing.
  121784. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121785. */
  121786. bankedTurn: boolean;
  121787. /**
  121788. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121789. */
  121790. bankedTurnLimit: number;
  121791. /**
  121792. * Value of 0 disables the banked Roll.
  121793. * Value of 1 is equal to the Yaw angle in radians.
  121794. */
  121795. bankedTurnMultiplier: number;
  121796. /**
  121797. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121798. */
  121799. inputs: FlyCameraInputsManager;
  121800. /**
  121801. * Gets the input sensibility for mouse input.
  121802. * Higher values reduce sensitivity.
  121803. */
  121804. get angularSensibility(): number;
  121805. /**
  121806. * Sets the input sensibility for a mouse input.
  121807. * Higher values reduce sensitivity.
  121808. */
  121809. set angularSensibility(value: number);
  121810. /**
  121811. * Get the keys for camera movement forward.
  121812. */
  121813. get keysForward(): number[];
  121814. /**
  121815. * Set the keys for camera movement forward.
  121816. */
  121817. set keysForward(value: number[]);
  121818. /**
  121819. * Get the keys for camera movement backward.
  121820. */
  121821. get keysBackward(): number[];
  121822. set keysBackward(value: number[]);
  121823. /**
  121824. * Get the keys for camera movement up.
  121825. */
  121826. get keysUp(): number[];
  121827. /**
  121828. * Set the keys for camera movement up.
  121829. */
  121830. set keysUp(value: number[]);
  121831. /**
  121832. * Get the keys for camera movement down.
  121833. */
  121834. get keysDown(): number[];
  121835. /**
  121836. * Set the keys for camera movement down.
  121837. */
  121838. set keysDown(value: number[]);
  121839. /**
  121840. * Get the keys for camera movement left.
  121841. */
  121842. get keysLeft(): number[];
  121843. /**
  121844. * Set the keys for camera movement left.
  121845. */
  121846. set keysLeft(value: number[]);
  121847. /**
  121848. * Set the keys for camera movement right.
  121849. */
  121850. get keysRight(): number[];
  121851. /**
  121852. * Set the keys for camera movement right.
  121853. */
  121854. set keysRight(value: number[]);
  121855. /**
  121856. * Event raised when the camera collides with a mesh in the scene.
  121857. */
  121858. onCollide: (collidedMesh: AbstractMesh) => void;
  121859. private _collider;
  121860. private _needMoveForGravity;
  121861. private _oldPosition;
  121862. private _diffPosition;
  121863. private _newPosition;
  121864. /** @hidden */
  121865. _localDirection: Vector3;
  121866. /** @hidden */
  121867. _transformedDirection: Vector3;
  121868. /**
  121869. * Instantiates a FlyCamera.
  121870. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121871. * such as in a 3D Space Shooter or a Flight Simulator.
  121872. * @param name Define the name of the camera in the scene.
  121873. * @param position Define the starting position of the camera in the scene.
  121874. * @param scene Define the scene the camera belongs to.
  121875. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121876. */
  121877. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121878. /**
  121879. * Attach a control to the HTML DOM element.
  121880. * @param element Defines the element that listens to the input events.
  121881. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121882. */
  121883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121884. /**
  121885. * Detach a control from the HTML DOM element.
  121886. * The camera will stop reacting to that input.
  121887. * @param element Defines the element that listens to the input events.
  121888. */
  121889. detachControl(element: HTMLElement): void;
  121890. private _collisionMask;
  121891. /**
  121892. * Get the mask that the camera ignores in collision events.
  121893. */
  121894. get collisionMask(): number;
  121895. /**
  121896. * Set the mask that the camera ignores in collision events.
  121897. */
  121898. set collisionMask(mask: number);
  121899. /** @hidden */
  121900. _collideWithWorld(displacement: Vector3): void;
  121901. /** @hidden */
  121902. private _onCollisionPositionChange;
  121903. /** @hidden */
  121904. _checkInputs(): void;
  121905. /** @hidden */
  121906. _decideIfNeedsToMove(): boolean;
  121907. /** @hidden */
  121908. _updatePosition(): void;
  121909. /**
  121910. * Restore the Roll to its target value at the rate specified.
  121911. * @param rate - Higher means slower restoring.
  121912. * @hidden
  121913. */
  121914. restoreRoll(rate: number): void;
  121915. /**
  121916. * Destroy the camera and release the current resources held by it.
  121917. */
  121918. dispose(): void;
  121919. /**
  121920. * Get the current object class name.
  121921. * @returns the class name.
  121922. */
  121923. getClassName(): string;
  121924. }
  121925. }
  121926. declare module BABYLON {
  121927. /**
  121928. * Listen to keyboard events to control the camera.
  121929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121930. */
  121931. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121932. /**
  121933. * Defines the camera the input is attached to.
  121934. */
  121935. camera: FlyCamera;
  121936. /**
  121937. * The list of keyboard keys used to control the forward move of the camera.
  121938. */
  121939. keysForward: number[];
  121940. /**
  121941. * The list of keyboard keys used to control the backward move of the camera.
  121942. */
  121943. keysBackward: number[];
  121944. /**
  121945. * The list of keyboard keys used to control the forward move of the camera.
  121946. */
  121947. keysUp: number[];
  121948. /**
  121949. * The list of keyboard keys used to control the backward move of the camera.
  121950. */
  121951. keysDown: number[];
  121952. /**
  121953. * The list of keyboard keys used to control the right strafe move of the camera.
  121954. */
  121955. keysRight: number[];
  121956. /**
  121957. * The list of keyboard keys used to control the left strafe move of the camera.
  121958. */
  121959. keysLeft: number[];
  121960. private _keys;
  121961. private _onCanvasBlurObserver;
  121962. private _onKeyboardObserver;
  121963. private _engine;
  121964. private _scene;
  121965. /**
  121966. * Attach the input controls to a specific dom element to get the input from.
  121967. * @param element Defines the element the controls should be listened from
  121968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121969. */
  121970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121971. /**
  121972. * Detach the current controls from the specified dom element.
  121973. * @param element Defines the element to stop listening the inputs from
  121974. */
  121975. detachControl(element: Nullable<HTMLElement>): void;
  121976. /**
  121977. * Gets the class name of the current intput.
  121978. * @returns the class name
  121979. */
  121980. getClassName(): string;
  121981. /** @hidden */
  121982. _onLostFocus(e: FocusEvent): void;
  121983. /**
  121984. * Get the friendly name associated with the input class.
  121985. * @returns the input friendly name
  121986. */
  121987. getSimpleName(): string;
  121988. /**
  121989. * Update the current camera state depending on the inputs that have been used this frame.
  121990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121991. */
  121992. checkInputs(): void;
  121993. }
  121994. }
  121995. declare module BABYLON {
  121996. /**
  121997. * Manage the mouse wheel inputs to control a follow camera.
  121998. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121999. */
  122000. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  122001. /**
  122002. * Defines the camera the input is attached to.
  122003. */
  122004. camera: FollowCamera;
  122005. /**
  122006. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  122007. */
  122008. axisControlRadius: boolean;
  122009. /**
  122010. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  122011. */
  122012. axisControlHeight: boolean;
  122013. /**
  122014. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  122015. */
  122016. axisControlRotation: boolean;
  122017. /**
  122018. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  122019. * relation to mouseWheel events.
  122020. */
  122021. wheelPrecision: number;
  122022. /**
  122023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122025. */
  122026. wheelDeltaPercentage: number;
  122027. private _wheel;
  122028. private _observer;
  122029. /**
  122030. * Attach the input controls to a specific dom element to get the input from.
  122031. * @param element Defines the element the controls should be listened from
  122032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122033. */
  122034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122035. /**
  122036. * Detach the current controls from the specified dom element.
  122037. * @param element Defines the element to stop listening the inputs from
  122038. */
  122039. detachControl(element: Nullable<HTMLElement>): void;
  122040. /**
  122041. * Gets the class name of the current intput.
  122042. * @returns the class name
  122043. */
  122044. getClassName(): string;
  122045. /**
  122046. * Get the friendly name associated with the input class.
  122047. * @returns the input friendly name
  122048. */
  122049. getSimpleName(): string;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. /**
  122054. * Manage the pointers inputs to control an follow camera.
  122055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122056. */
  122057. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  122058. /**
  122059. * Defines the camera the input is attached to.
  122060. */
  122061. camera: FollowCamera;
  122062. /**
  122063. * Gets the class name of the current input.
  122064. * @returns the class name
  122065. */
  122066. getClassName(): string;
  122067. /**
  122068. * Defines the pointer angular sensibility along the X axis or how fast is
  122069. * the camera rotating.
  122070. * A negative number will reverse the axis direction.
  122071. */
  122072. angularSensibilityX: number;
  122073. /**
  122074. * Defines the pointer angular sensibility along the Y axis or how fast is
  122075. * the camera rotating.
  122076. * A negative number will reverse the axis direction.
  122077. */
  122078. angularSensibilityY: number;
  122079. /**
  122080. * Defines the pointer pinch precision or how fast is the camera zooming.
  122081. * A negative number will reverse the axis direction.
  122082. */
  122083. pinchPrecision: number;
  122084. /**
  122085. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122086. * from 0.
  122087. * It defines the percentage of current camera.radius to use as delta when
  122088. * pinch zoom is used.
  122089. */
  122090. pinchDeltaPercentage: number;
  122091. /**
  122092. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  122093. */
  122094. axisXControlRadius: boolean;
  122095. /**
  122096. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  122097. */
  122098. axisXControlHeight: boolean;
  122099. /**
  122100. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  122101. */
  122102. axisXControlRotation: boolean;
  122103. /**
  122104. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  122105. */
  122106. axisYControlRadius: boolean;
  122107. /**
  122108. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  122109. */
  122110. axisYControlHeight: boolean;
  122111. /**
  122112. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  122113. */
  122114. axisYControlRotation: boolean;
  122115. /**
  122116. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  122117. */
  122118. axisPinchControlRadius: boolean;
  122119. /**
  122120. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  122121. */
  122122. axisPinchControlHeight: boolean;
  122123. /**
  122124. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  122125. */
  122126. axisPinchControlRotation: boolean;
  122127. /**
  122128. * Log error messages if basic misconfiguration has occurred.
  122129. */
  122130. warningEnable: boolean;
  122131. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122132. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122133. private _warningCounter;
  122134. private _warning;
  122135. }
  122136. }
  122137. declare module BABYLON {
  122138. /**
  122139. * Default Inputs manager for the FollowCamera.
  122140. * It groups all the default supported inputs for ease of use.
  122141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122142. */
  122143. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  122144. /**
  122145. * Instantiates a new FollowCameraInputsManager.
  122146. * @param camera Defines the camera the inputs belong to
  122147. */
  122148. constructor(camera: FollowCamera);
  122149. /**
  122150. * Add keyboard input support to the input manager.
  122151. * @returns the current input manager
  122152. */
  122153. addKeyboard(): FollowCameraInputsManager;
  122154. /**
  122155. * Add mouse wheel input support to the input manager.
  122156. * @returns the current input manager
  122157. */
  122158. addMouseWheel(): FollowCameraInputsManager;
  122159. /**
  122160. * Add pointers input support to the input manager.
  122161. * @returns the current input manager
  122162. */
  122163. addPointers(): FollowCameraInputsManager;
  122164. /**
  122165. * Add orientation input support to the input manager.
  122166. * @returns the current input manager
  122167. */
  122168. addVRDeviceOrientation(): FollowCameraInputsManager;
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  122174. * an arc rotate version arcFollowCamera are available.
  122175. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122176. */
  122177. export class FollowCamera extends TargetCamera {
  122178. /**
  122179. * Distance the follow camera should follow an object at
  122180. */
  122181. radius: number;
  122182. /**
  122183. * Minimum allowed distance of the camera to the axis of rotation
  122184. * (The camera can not get closer).
  122185. * This can help limiting how the Camera is able to move in the scene.
  122186. */
  122187. lowerRadiusLimit: Nullable<number>;
  122188. /**
  122189. * Maximum allowed distance of the camera to the axis of rotation
  122190. * (The camera can not get further).
  122191. * This can help limiting how the Camera is able to move in the scene.
  122192. */
  122193. upperRadiusLimit: Nullable<number>;
  122194. /**
  122195. * Define a rotation offset between the camera and the object it follows
  122196. */
  122197. rotationOffset: number;
  122198. /**
  122199. * Minimum allowed angle to camera position relative to target object.
  122200. * This can help limiting how the Camera is able to move in the scene.
  122201. */
  122202. lowerRotationOffsetLimit: Nullable<number>;
  122203. /**
  122204. * Maximum allowed angle to camera position relative to target object.
  122205. * This can help limiting how the Camera is able to move in the scene.
  122206. */
  122207. upperRotationOffsetLimit: Nullable<number>;
  122208. /**
  122209. * Define a height offset between the camera and the object it follows.
  122210. * It can help following an object from the top (like a car chaing a plane)
  122211. */
  122212. heightOffset: number;
  122213. /**
  122214. * Minimum allowed height of camera position relative to target object.
  122215. * This can help limiting how the Camera is able to move in the scene.
  122216. */
  122217. lowerHeightOffsetLimit: Nullable<number>;
  122218. /**
  122219. * Maximum allowed height of camera position relative to target object.
  122220. * This can help limiting how the Camera is able to move in the scene.
  122221. */
  122222. upperHeightOffsetLimit: Nullable<number>;
  122223. /**
  122224. * Define how fast the camera can accelerate to follow it s target.
  122225. */
  122226. cameraAcceleration: number;
  122227. /**
  122228. * Define the speed limit of the camera following an object.
  122229. */
  122230. maxCameraSpeed: number;
  122231. /**
  122232. * Define the target of the camera.
  122233. */
  122234. lockedTarget: Nullable<AbstractMesh>;
  122235. /**
  122236. * Defines the input associated with the camera.
  122237. */
  122238. inputs: FollowCameraInputsManager;
  122239. /**
  122240. * Instantiates the follow camera.
  122241. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122242. * @param name Define the name of the camera in the scene
  122243. * @param position Define the position of the camera
  122244. * @param scene Define the scene the camera belong to
  122245. * @param lockedTarget Define the target of the camera
  122246. */
  122247. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  122248. private _follow;
  122249. /**
  122250. * Attached controls to the current camera.
  122251. * @param element Defines the element the controls should be listened from
  122252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122253. */
  122254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122255. /**
  122256. * Detach the current controls from the camera.
  122257. * The camera will stop reacting to inputs.
  122258. * @param element Defines the element to stop listening the inputs from
  122259. */
  122260. detachControl(element: HTMLElement): void;
  122261. /** @hidden */
  122262. _checkInputs(): void;
  122263. private _checkLimits;
  122264. /**
  122265. * Gets the camera class name.
  122266. * @returns the class name
  122267. */
  122268. getClassName(): string;
  122269. }
  122270. /**
  122271. * Arc Rotate version of the follow camera.
  122272. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  122273. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122274. */
  122275. export class ArcFollowCamera extends TargetCamera {
  122276. /** The longitudinal angle of the camera */
  122277. alpha: number;
  122278. /** The latitudinal angle of the camera */
  122279. beta: number;
  122280. /** The radius of the camera from its target */
  122281. radius: number;
  122282. /** Define the camera target (the mesh it should follow) */
  122283. target: Nullable<AbstractMesh>;
  122284. private _cartesianCoordinates;
  122285. /**
  122286. * Instantiates a new ArcFollowCamera
  122287. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122288. * @param name Define the name of the camera
  122289. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  122290. * @param beta Define the rotation angle of the camera around the elevation axis
  122291. * @param radius Define the radius of the camera from its target point
  122292. * @param target Define the target of the camera
  122293. * @param scene Define the scene the camera belongs to
  122294. */
  122295. constructor(name: string,
  122296. /** The longitudinal angle of the camera */
  122297. alpha: number,
  122298. /** The latitudinal angle of the camera */
  122299. beta: number,
  122300. /** The radius of the camera from its target */
  122301. radius: number,
  122302. /** Define the camera target (the mesh it should follow) */
  122303. target: Nullable<AbstractMesh>, scene: Scene);
  122304. private _follow;
  122305. /** @hidden */
  122306. _checkInputs(): void;
  122307. /**
  122308. * Returns the class name of the object.
  122309. * It is mostly used internally for serialization purposes.
  122310. */
  122311. getClassName(): string;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * Manage the keyboard inputs to control the movement of a follow camera.
  122317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122318. */
  122319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122320. /**
  122321. * Defines the camera the input is attached to.
  122322. */
  122323. camera: FollowCamera;
  122324. /**
  122325. * Defines the list of key codes associated with the up action (increase heightOffset)
  122326. */
  122327. keysHeightOffsetIncr: number[];
  122328. /**
  122329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122330. */
  122331. keysHeightOffsetDecr: number[];
  122332. /**
  122333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122334. */
  122335. keysHeightOffsetModifierAlt: boolean;
  122336. /**
  122337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122338. */
  122339. keysHeightOffsetModifierCtrl: boolean;
  122340. /**
  122341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122342. */
  122343. keysHeightOffsetModifierShift: boolean;
  122344. /**
  122345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122346. */
  122347. keysRotationOffsetIncr: number[];
  122348. /**
  122349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122350. */
  122351. keysRotationOffsetDecr: number[];
  122352. /**
  122353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122354. */
  122355. keysRotationOffsetModifierAlt: boolean;
  122356. /**
  122357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122358. */
  122359. keysRotationOffsetModifierCtrl: boolean;
  122360. /**
  122361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122362. */
  122363. keysRotationOffsetModifierShift: boolean;
  122364. /**
  122365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122366. */
  122367. keysRadiusIncr: number[];
  122368. /**
  122369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122370. */
  122371. keysRadiusDecr: number[];
  122372. /**
  122373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122374. */
  122375. keysRadiusModifierAlt: boolean;
  122376. /**
  122377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122378. */
  122379. keysRadiusModifierCtrl: boolean;
  122380. /**
  122381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122382. */
  122383. keysRadiusModifierShift: boolean;
  122384. /**
  122385. * Defines the rate of change of heightOffset.
  122386. */
  122387. heightSensibility: number;
  122388. /**
  122389. * Defines the rate of change of rotationOffset.
  122390. */
  122391. rotationSensibility: number;
  122392. /**
  122393. * Defines the rate of change of radius.
  122394. */
  122395. radiusSensibility: number;
  122396. private _keys;
  122397. private _ctrlPressed;
  122398. private _altPressed;
  122399. private _shiftPressed;
  122400. private _onCanvasBlurObserver;
  122401. private _onKeyboardObserver;
  122402. private _engine;
  122403. private _scene;
  122404. /**
  122405. * Attach the input controls to a specific dom element to get the input from.
  122406. * @param element Defines the element the controls should be listened from
  122407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122408. */
  122409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122410. /**
  122411. * Detach the current controls from the specified dom element.
  122412. * @param element Defines the element to stop listening the inputs from
  122413. */
  122414. detachControl(element: Nullable<HTMLElement>): void;
  122415. /**
  122416. * Update the current camera state depending on the inputs that have been used this frame.
  122417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122418. */
  122419. checkInputs(): void;
  122420. /**
  122421. * Gets the class name of the current input.
  122422. * @returns the class name
  122423. */
  122424. getClassName(): string;
  122425. /**
  122426. * Get the friendly name associated with the input class.
  122427. * @returns the input friendly name
  122428. */
  122429. getSimpleName(): string;
  122430. /**
  122431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122432. * allow modification of the heightOffset value.
  122433. */
  122434. private _modifierHeightOffset;
  122435. /**
  122436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122437. * allow modification of the rotationOffset value.
  122438. */
  122439. private _modifierRotationOffset;
  122440. /**
  122441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122442. * allow modification of the radius value.
  122443. */
  122444. private _modifierRadius;
  122445. }
  122446. }
  122447. declare module BABYLON {
  122448. interface FreeCameraInputsManager {
  122449. /**
  122450. * @hidden
  122451. */
  122452. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122453. /**
  122454. * Add orientation input support to the input manager.
  122455. * @returns the current input manager
  122456. */
  122457. addDeviceOrientation(): FreeCameraInputsManager;
  122458. }
  122459. /**
  122460. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122461. * Screen rotation is taken into account.
  122462. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122463. */
  122464. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122465. private _camera;
  122466. private _screenOrientationAngle;
  122467. private _constantTranform;
  122468. private _screenQuaternion;
  122469. private _alpha;
  122470. private _beta;
  122471. private _gamma;
  122472. /**
  122473. * Can be used to detect if a device orientation sensor is available on a device
  122474. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122475. * @returns a promise that will resolve on orientation change
  122476. */
  122477. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122478. /**
  122479. * @hidden
  122480. */
  122481. _onDeviceOrientationChangedObservable: Observable<void>;
  122482. /**
  122483. * Instantiates a new input
  122484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122485. */
  122486. constructor();
  122487. /**
  122488. * Define the camera controlled by the input.
  122489. */
  122490. get camera(): FreeCamera;
  122491. set camera(camera: FreeCamera);
  122492. /**
  122493. * Attach the input controls to a specific dom element to get the input from.
  122494. * @param element Defines the element the controls should be listened from
  122495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122496. */
  122497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122498. private _orientationChanged;
  122499. private _deviceOrientation;
  122500. /**
  122501. * Detach the current controls from the specified dom element.
  122502. * @param element Defines the element to stop listening the inputs from
  122503. */
  122504. detachControl(element: Nullable<HTMLElement>): void;
  122505. /**
  122506. * Update the current camera state depending on the inputs that have been used this frame.
  122507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122508. */
  122509. checkInputs(): void;
  122510. /**
  122511. * Gets the class name of the current intput.
  122512. * @returns the class name
  122513. */
  122514. getClassName(): string;
  122515. /**
  122516. * Get the friendly name associated with the input class.
  122517. * @returns the input friendly name
  122518. */
  122519. getSimpleName(): string;
  122520. }
  122521. }
  122522. declare module BABYLON {
  122523. /**
  122524. * Manage the gamepad inputs to control a free camera.
  122525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122526. */
  122527. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122528. /**
  122529. * Define the camera the input is attached to.
  122530. */
  122531. camera: FreeCamera;
  122532. /**
  122533. * Define the Gamepad controlling the input
  122534. */
  122535. gamepad: Nullable<Gamepad>;
  122536. /**
  122537. * Defines the gamepad rotation sensiblity.
  122538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122539. */
  122540. gamepadAngularSensibility: number;
  122541. /**
  122542. * Defines the gamepad move sensiblity.
  122543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122544. */
  122545. gamepadMoveSensibility: number;
  122546. private _yAxisScale;
  122547. /**
  122548. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122549. */
  122550. get invertYAxis(): boolean;
  122551. set invertYAxis(value: boolean);
  122552. private _onGamepadConnectedObserver;
  122553. private _onGamepadDisconnectedObserver;
  122554. private _cameraTransform;
  122555. private _deltaTransform;
  122556. private _vector3;
  122557. private _vector2;
  122558. /**
  122559. * Attach the input controls to a specific dom element to get the input from.
  122560. * @param element Defines the element the controls should be listened from
  122561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122562. */
  122563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122564. /**
  122565. * Detach the current controls from the specified dom element.
  122566. * @param element Defines the element to stop listening the inputs from
  122567. */
  122568. detachControl(element: Nullable<HTMLElement>): void;
  122569. /**
  122570. * Update the current camera state depending on the inputs that have been used this frame.
  122571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122572. */
  122573. checkInputs(): void;
  122574. /**
  122575. * Gets the class name of the current intput.
  122576. * @returns the class name
  122577. */
  122578. getClassName(): string;
  122579. /**
  122580. * Get the friendly name associated with the input class.
  122581. * @returns the input friendly name
  122582. */
  122583. getSimpleName(): string;
  122584. }
  122585. }
  122586. declare module BABYLON {
  122587. /**
  122588. * Defines the potential axis of a Joystick
  122589. */
  122590. export enum JoystickAxis {
  122591. /** X axis */
  122592. X = 0,
  122593. /** Y axis */
  122594. Y = 1,
  122595. /** Z axis */
  122596. Z = 2
  122597. }
  122598. /**
  122599. * Represents the different customization options available
  122600. * for VirtualJoystick
  122601. */
  122602. interface VirtualJoystickCustomizations {
  122603. /**
  122604. * Size of the joystick's puck
  122605. */
  122606. puckSize: number;
  122607. /**
  122608. * Size of the joystick's container
  122609. */
  122610. containerSize: number;
  122611. /**
  122612. * Color of the joystick && puck
  122613. */
  122614. color: string;
  122615. /**
  122616. * Image URL for the joystick's puck
  122617. */
  122618. puckImage?: string;
  122619. /**
  122620. * Image URL for the joystick's container
  122621. */
  122622. containerImage?: string;
  122623. /**
  122624. * Defines the unmoving position of the joystick container
  122625. */
  122626. position?: {
  122627. x: number;
  122628. y: number;
  122629. };
  122630. /**
  122631. * Defines whether or not the joystick container is always visible
  122632. */
  122633. alwaysVisible: boolean;
  122634. /**
  122635. * Defines whether or not to limit the movement of the puck to the joystick's container
  122636. */
  122637. limitToContainer: boolean;
  122638. }
  122639. /**
  122640. * Class used to define virtual joystick (used in touch mode)
  122641. */
  122642. export class VirtualJoystick {
  122643. /**
  122644. * Gets or sets a boolean indicating that left and right values must be inverted
  122645. */
  122646. reverseLeftRight: boolean;
  122647. /**
  122648. * Gets or sets a boolean indicating that up and down values must be inverted
  122649. */
  122650. reverseUpDown: boolean;
  122651. /**
  122652. * Gets the offset value for the position (ie. the change of the position value)
  122653. */
  122654. deltaPosition: Vector3;
  122655. /**
  122656. * Gets a boolean indicating if the virtual joystick was pressed
  122657. */
  122658. pressed: boolean;
  122659. /**
  122660. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122661. */
  122662. static Canvas: Nullable<HTMLCanvasElement>;
  122663. /**
  122664. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122665. */
  122666. limitToContainer: boolean;
  122667. private static _globalJoystickIndex;
  122668. private static _alwaysVisibleSticks;
  122669. private static vjCanvasContext;
  122670. private static vjCanvasWidth;
  122671. private static vjCanvasHeight;
  122672. private static halfWidth;
  122673. private static _GetDefaultOptions;
  122674. private _action;
  122675. private _axisTargetedByLeftAndRight;
  122676. private _axisTargetedByUpAndDown;
  122677. private _joystickSensibility;
  122678. private _inversedSensibility;
  122679. private _joystickPointerID;
  122680. private _joystickColor;
  122681. private _joystickPointerPos;
  122682. private _joystickPreviousPointerPos;
  122683. private _joystickPointerStartPos;
  122684. private _deltaJoystickVector;
  122685. private _leftJoystick;
  122686. private _touches;
  122687. private _joystickPosition;
  122688. private _alwaysVisible;
  122689. private _puckImage;
  122690. private _containerImage;
  122691. private _joystickPuckSize;
  122692. private _joystickContainerSize;
  122693. private _clearPuckSize;
  122694. private _clearContainerSize;
  122695. private _clearPuckSizeOffset;
  122696. private _clearContainerSizeOffset;
  122697. private _onPointerDownHandlerRef;
  122698. private _onPointerMoveHandlerRef;
  122699. private _onPointerUpHandlerRef;
  122700. private _onResize;
  122701. /**
  122702. * Creates a new virtual joystick
  122703. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122704. * @param customizations Defines the options we want to customize the VirtualJoystick
  122705. */
  122706. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122707. /**
  122708. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122709. * @param newJoystickSensibility defines the new sensibility
  122710. */
  122711. setJoystickSensibility(newJoystickSensibility: number): void;
  122712. private _onPointerDown;
  122713. private _onPointerMove;
  122714. private _onPointerUp;
  122715. /**
  122716. * Change the color of the virtual joystick
  122717. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122718. */
  122719. setJoystickColor(newColor: string): void;
  122720. /**
  122721. * Size of the joystick's container
  122722. */
  122723. set containerSize(newSize: number);
  122724. get containerSize(): number;
  122725. /**
  122726. * Size of the joystick's puck
  122727. */
  122728. set puckSize(newSize: number);
  122729. get puckSize(): number;
  122730. /**
  122731. * Clears the set position of the joystick
  122732. */
  122733. clearPosition(): void;
  122734. /**
  122735. * Defines whether or not the joystick container is always visible
  122736. */
  122737. set alwaysVisible(value: boolean);
  122738. get alwaysVisible(): boolean;
  122739. /**
  122740. * Sets the constant position of the Joystick container
  122741. * @param x X axis coordinate
  122742. * @param y Y axis coordinate
  122743. */
  122744. setPosition(x: number, y: number): void;
  122745. /**
  122746. * Defines a callback to call when the joystick is touched
  122747. * @param action defines the callback
  122748. */
  122749. setActionOnTouch(action: () => any): void;
  122750. /**
  122751. * Defines which axis you'd like to control for left & right
  122752. * @param axis defines the axis to use
  122753. */
  122754. setAxisForLeftRight(axis: JoystickAxis): void;
  122755. /**
  122756. * Defines which axis you'd like to control for up & down
  122757. * @param axis defines the axis to use
  122758. */
  122759. setAxisForUpDown(axis: JoystickAxis): void;
  122760. /**
  122761. * Clears the canvas from the previous puck / container draw
  122762. */
  122763. private _clearPreviousDraw;
  122764. /**
  122765. * Loads `urlPath` to be used for the container's image
  122766. * @param urlPath defines the urlPath of an image to use
  122767. */
  122768. setContainerImage(urlPath: string): void;
  122769. /**
  122770. * Loads `urlPath` to be used for the puck's image
  122771. * @param urlPath defines the urlPath of an image to use
  122772. */
  122773. setPuckImage(urlPath: string): void;
  122774. /**
  122775. * Draws the Virtual Joystick's container
  122776. */
  122777. private _drawContainer;
  122778. /**
  122779. * Draws the Virtual Joystick's puck
  122780. */
  122781. private _drawPuck;
  122782. private _drawVirtualJoystick;
  122783. /**
  122784. * Release internal HTML canvas
  122785. */
  122786. releaseCanvas(): void;
  122787. }
  122788. }
  122789. declare module BABYLON {
  122790. interface FreeCameraInputsManager {
  122791. /**
  122792. * Add virtual joystick input support to the input manager.
  122793. * @returns the current input manager
  122794. */
  122795. addVirtualJoystick(): FreeCameraInputsManager;
  122796. }
  122797. /**
  122798. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122800. */
  122801. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122802. /**
  122803. * Defines the camera the input is attached to.
  122804. */
  122805. camera: FreeCamera;
  122806. private _leftjoystick;
  122807. private _rightjoystick;
  122808. /**
  122809. * Gets the left stick of the virtual joystick.
  122810. * @returns The virtual Joystick
  122811. */
  122812. getLeftJoystick(): VirtualJoystick;
  122813. /**
  122814. * Gets the right stick of the virtual joystick.
  122815. * @returns The virtual Joystick
  122816. */
  122817. getRightJoystick(): VirtualJoystick;
  122818. /**
  122819. * Update the current camera state depending on the inputs that have been used this frame.
  122820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122821. */
  122822. checkInputs(): void;
  122823. /**
  122824. * Attach the input controls to a specific dom element to get the input from.
  122825. * @param element Defines the element the controls should be listened from
  122826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122827. */
  122828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122829. /**
  122830. * Detach the current controls from the specified dom element.
  122831. * @param element Defines the element to stop listening the inputs from
  122832. */
  122833. detachControl(element: Nullable<HTMLElement>): void;
  122834. /**
  122835. * Gets the class name of the current intput.
  122836. * @returns the class name
  122837. */
  122838. getClassName(): string;
  122839. /**
  122840. * Get the friendly name associated with the input class.
  122841. * @returns the input friendly name
  122842. */
  122843. getSimpleName(): string;
  122844. }
  122845. }
  122846. declare module BABYLON {
  122847. /**
  122848. * This represents a FPS type of camera controlled by touch.
  122849. * This is like a universal camera minus the Gamepad controls.
  122850. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122851. */
  122852. export class TouchCamera extends FreeCamera {
  122853. /**
  122854. * Defines the touch sensibility for rotation.
  122855. * The higher the faster.
  122856. */
  122857. get touchAngularSensibility(): number;
  122858. set touchAngularSensibility(value: number);
  122859. /**
  122860. * Defines the touch sensibility for move.
  122861. * The higher the faster.
  122862. */
  122863. get touchMoveSensibility(): number;
  122864. set touchMoveSensibility(value: number);
  122865. /**
  122866. * Instantiates a new touch camera.
  122867. * This represents a FPS type of camera controlled by touch.
  122868. * This is like a universal camera minus the Gamepad controls.
  122869. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122870. * @param name Define the name of the camera in the scene
  122871. * @param position Define the start position of the camera in the scene
  122872. * @param scene Define the scene the camera belongs to
  122873. */
  122874. constructor(name: string, position: Vector3, scene: Scene);
  122875. /**
  122876. * Gets the current object class name.
  122877. * @return the class name
  122878. */
  122879. getClassName(): string;
  122880. /** @hidden */
  122881. _setupInputs(): void;
  122882. }
  122883. }
  122884. declare module BABYLON {
  122885. /**
  122886. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122887. * being tilted forward or back and left or right.
  122888. */
  122889. export class DeviceOrientationCamera extends FreeCamera {
  122890. private _initialQuaternion;
  122891. private _quaternionCache;
  122892. private _tmpDragQuaternion;
  122893. private _disablePointerInputWhenUsingDeviceOrientation;
  122894. /**
  122895. * Creates a new device orientation camera
  122896. * @param name The name of the camera
  122897. * @param position The start position camera
  122898. * @param scene The scene the camera belongs to
  122899. */
  122900. constructor(name: string, position: Vector3, scene: Scene);
  122901. /**
  122902. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122903. */
  122904. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122905. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122906. private _dragFactor;
  122907. /**
  122908. * Enabled turning on the y axis when the orientation sensor is active
  122909. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122910. */
  122911. enableHorizontalDragging(dragFactor?: number): void;
  122912. /**
  122913. * Gets the current instance class name ("DeviceOrientationCamera").
  122914. * This helps avoiding instanceof at run time.
  122915. * @returns the class name
  122916. */
  122917. getClassName(): string;
  122918. /**
  122919. * @hidden
  122920. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122921. */
  122922. _checkInputs(): void;
  122923. /**
  122924. * Reset the camera to its default orientation on the specified axis only.
  122925. * @param axis The axis to reset
  122926. */
  122927. resetToCurrentRotation(axis?: Axis): void;
  122928. }
  122929. }
  122930. declare module BABYLON {
  122931. /**
  122932. * Defines supported buttons for XBox360 compatible gamepads
  122933. */
  122934. export enum Xbox360Button {
  122935. /** A */
  122936. A = 0,
  122937. /** B */
  122938. B = 1,
  122939. /** X */
  122940. X = 2,
  122941. /** Y */
  122942. Y = 3,
  122943. /** Left button */
  122944. LB = 4,
  122945. /** Right button */
  122946. RB = 5,
  122947. /** Back */
  122948. Back = 8,
  122949. /** Start */
  122950. Start = 9,
  122951. /** Left stick */
  122952. LeftStick = 10,
  122953. /** Right stick */
  122954. RightStick = 11
  122955. }
  122956. /** Defines values for XBox360 DPad */
  122957. export enum Xbox360Dpad {
  122958. /** Up */
  122959. Up = 12,
  122960. /** Down */
  122961. Down = 13,
  122962. /** Left */
  122963. Left = 14,
  122964. /** Right */
  122965. Right = 15
  122966. }
  122967. /**
  122968. * Defines a XBox360 gamepad
  122969. */
  122970. export class Xbox360Pad extends Gamepad {
  122971. private _leftTrigger;
  122972. private _rightTrigger;
  122973. private _onlefttriggerchanged;
  122974. private _onrighttriggerchanged;
  122975. private _onbuttondown;
  122976. private _onbuttonup;
  122977. private _ondpaddown;
  122978. private _ondpadup;
  122979. /** Observable raised when a button is pressed */
  122980. onButtonDownObservable: Observable<Xbox360Button>;
  122981. /** Observable raised when a button is released */
  122982. onButtonUpObservable: Observable<Xbox360Button>;
  122983. /** Observable raised when a pad is pressed */
  122984. onPadDownObservable: Observable<Xbox360Dpad>;
  122985. /** Observable raised when a pad is released */
  122986. onPadUpObservable: Observable<Xbox360Dpad>;
  122987. private _buttonA;
  122988. private _buttonB;
  122989. private _buttonX;
  122990. private _buttonY;
  122991. private _buttonBack;
  122992. private _buttonStart;
  122993. private _buttonLB;
  122994. private _buttonRB;
  122995. private _buttonLeftStick;
  122996. private _buttonRightStick;
  122997. private _dPadUp;
  122998. private _dPadDown;
  122999. private _dPadLeft;
  123000. private _dPadRight;
  123001. private _isXboxOnePad;
  123002. /**
  123003. * Creates a new XBox360 gamepad object
  123004. * @param id defines the id of this gamepad
  123005. * @param index defines its index
  123006. * @param gamepad defines the internal HTML gamepad object
  123007. * @param xboxOne defines if it is a XBox One gamepad
  123008. */
  123009. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  123010. /**
  123011. * Defines the callback to call when left trigger is pressed
  123012. * @param callback defines the callback to use
  123013. */
  123014. onlefttriggerchanged(callback: (value: number) => void): void;
  123015. /**
  123016. * Defines the callback to call when right trigger is pressed
  123017. * @param callback defines the callback to use
  123018. */
  123019. onrighttriggerchanged(callback: (value: number) => void): void;
  123020. /**
  123021. * Gets the left trigger value
  123022. */
  123023. get leftTrigger(): number;
  123024. /**
  123025. * Sets the left trigger value
  123026. */
  123027. set leftTrigger(newValue: number);
  123028. /**
  123029. * Gets the right trigger value
  123030. */
  123031. get rightTrigger(): number;
  123032. /**
  123033. * Sets the right trigger value
  123034. */
  123035. set rightTrigger(newValue: number);
  123036. /**
  123037. * Defines the callback to call when a button is pressed
  123038. * @param callback defines the callback to use
  123039. */
  123040. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  123041. /**
  123042. * Defines the callback to call when a button is released
  123043. * @param callback defines the callback to use
  123044. */
  123045. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  123046. /**
  123047. * Defines the callback to call when a pad is pressed
  123048. * @param callback defines the callback to use
  123049. */
  123050. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  123051. /**
  123052. * Defines the callback to call when a pad is released
  123053. * @param callback defines the callback to use
  123054. */
  123055. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  123056. private _setButtonValue;
  123057. private _setDPadValue;
  123058. /**
  123059. * Gets the value of the `A` button
  123060. */
  123061. get buttonA(): number;
  123062. /**
  123063. * Sets the value of the `A` button
  123064. */
  123065. set buttonA(value: number);
  123066. /**
  123067. * Gets the value of the `B` button
  123068. */
  123069. get buttonB(): number;
  123070. /**
  123071. * Sets the value of the `B` button
  123072. */
  123073. set buttonB(value: number);
  123074. /**
  123075. * Gets the value of the `X` button
  123076. */
  123077. get buttonX(): number;
  123078. /**
  123079. * Sets the value of the `X` button
  123080. */
  123081. set buttonX(value: number);
  123082. /**
  123083. * Gets the value of the `Y` button
  123084. */
  123085. get buttonY(): number;
  123086. /**
  123087. * Sets the value of the `Y` button
  123088. */
  123089. set buttonY(value: number);
  123090. /**
  123091. * Gets the value of the `Start` button
  123092. */
  123093. get buttonStart(): number;
  123094. /**
  123095. * Sets the value of the `Start` button
  123096. */
  123097. set buttonStart(value: number);
  123098. /**
  123099. * Gets the value of the `Back` button
  123100. */
  123101. get buttonBack(): number;
  123102. /**
  123103. * Sets the value of the `Back` button
  123104. */
  123105. set buttonBack(value: number);
  123106. /**
  123107. * Gets the value of the `Left` button
  123108. */
  123109. get buttonLB(): number;
  123110. /**
  123111. * Sets the value of the `Left` button
  123112. */
  123113. set buttonLB(value: number);
  123114. /**
  123115. * Gets the value of the `Right` button
  123116. */
  123117. get buttonRB(): number;
  123118. /**
  123119. * Sets the value of the `Right` button
  123120. */
  123121. set buttonRB(value: number);
  123122. /**
  123123. * Gets the value of the Left joystick
  123124. */
  123125. get buttonLeftStick(): number;
  123126. /**
  123127. * Sets the value of the Left joystick
  123128. */
  123129. set buttonLeftStick(value: number);
  123130. /**
  123131. * Gets the value of the Right joystick
  123132. */
  123133. get buttonRightStick(): number;
  123134. /**
  123135. * Sets the value of the Right joystick
  123136. */
  123137. set buttonRightStick(value: number);
  123138. /**
  123139. * Gets the value of D-pad up
  123140. */
  123141. get dPadUp(): number;
  123142. /**
  123143. * Sets the value of D-pad up
  123144. */
  123145. set dPadUp(value: number);
  123146. /**
  123147. * Gets the value of D-pad down
  123148. */
  123149. get dPadDown(): number;
  123150. /**
  123151. * Sets the value of D-pad down
  123152. */
  123153. set dPadDown(value: number);
  123154. /**
  123155. * Gets the value of D-pad left
  123156. */
  123157. get dPadLeft(): number;
  123158. /**
  123159. * Sets the value of D-pad left
  123160. */
  123161. set dPadLeft(value: number);
  123162. /**
  123163. * Gets the value of D-pad right
  123164. */
  123165. get dPadRight(): number;
  123166. /**
  123167. * Sets the value of D-pad right
  123168. */
  123169. set dPadRight(value: number);
  123170. /**
  123171. * Force the gamepad to synchronize with device values
  123172. */
  123173. update(): void;
  123174. /**
  123175. * Disposes the gamepad
  123176. */
  123177. dispose(): void;
  123178. }
  123179. }
  123180. declare module BABYLON {
  123181. /**
  123182. * Defines supported buttons for DualShock compatible gamepads
  123183. */
  123184. export enum DualShockButton {
  123185. /** Cross */
  123186. Cross = 0,
  123187. /** Circle */
  123188. Circle = 1,
  123189. /** Square */
  123190. Square = 2,
  123191. /** Triangle */
  123192. Triangle = 3,
  123193. /** L1 */
  123194. L1 = 4,
  123195. /** R1 */
  123196. R1 = 5,
  123197. /** Share */
  123198. Share = 8,
  123199. /** Options */
  123200. Options = 9,
  123201. /** Left stick */
  123202. LeftStick = 10,
  123203. /** Right stick */
  123204. RightStick = 11
  123205. }
  123206. /** Defines values for DualShock DPad */
  123207. export enum DualShockDpad {
  123208. /** Up */
  123209. Up = 12,
  123210. /** Down */
  123211. Down = 13,
  123212. /** Left */
  123213. Left = 14,
  123214. /** Right */
  123215. Right = 15
  123216. }
  123217. /**
  123218. * Defines a DualShock gamepad
  123219. */
  123220. export class DualShockPad extends Gamepad {
  123221. private _leftTrigger;
  123222. private _rightTrigger;
  123223. private _onlefttriggerchanged;
  123224. private _onrighttriggerchanged;
  123225. private _onbuttondown;
  123226. private _onbuttonup;
  123227. private _ondpaddown;
  123228. private _ondpadup;
  123229. /** Observable raised when a button is pressed */
  123230. onButtonDownObservable: Observable<DualShockButton>;
  123231. /** Observable raised when a button is released */
  123232. onButtonUpObservable: Observable<DualShockButton>;
  123233. /** Observable raised when a pad is pressed */
  123234. onPadDownObservable: Observable<DualShockDpad>;
  123235. /** Observable raised when a pad is released */
  123236. onPadUpObservable: Observable<DualShockDpad>;
  123237. private _buttonCross;
  123238. private _buttonCircle;
  123239. private _buttonSquare;
  123240. private _buttonTriangle;
  123241. private _buttonShare;
  123242. private _buttonOptions;
  123243. private _buttonL1;
  123244. private _buttonR1;
  123245. private _buttonLeftStick;
  123246. private _buttonRightStick;
  123247. private _dPadUp;
  123248. private _dPadDown;
  123249. private _dPadLeft;
  123250. private _dPadRight;
  123251. /**
  123252. * Creates a new DualShock gamepad object
  123253. * @param id defines the id of this gamepad
  123254. * @param index defines its index
  123255. * @param gamepad defines the internal HTML gamepad object
  123256. */
  123257. constructor(id: string, index: number, gamepad: any);
  123258. /**
  123259. * Defines the callback to call when left trigger is pressed
  123260. * @param callback defines the callback to use
  123261. */
  123262. onlefttriggerchanged(callback: (value: number) => void): void;
  123263. /**
  123264. * Defines the callback to call when right trigger is pressed
  123265. * @param callback defines the callback to use
  123266. */
  123267. onrighttriggerchanged(callback: (value: number) => void): void;
  123268. /**
  123269. * Gets the left trigger value
  123270. */
  123271. get leftTrigger(): number;
  123272. /**
  123273. * Sets the left trigger value
  123274. */
  123275. set leftTrigger(newValue: number);
  123276. /**
  123277. * Gets the right trigger value
  123278. */
  123279. get rightTrigger(): number;
  123280. /**
  123281. * Sets the right trigger value
  123282. */
  123283. set rightTrigger(newValue: number);
  123284. /**
  123285. * Defines the callback to call when a button is pressed
  123286. * @param callback defines the callback to use
  123287. */
  123288. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  123289. /**
  123290. * Defines the callback to call when a button is released
  123291. * @param callback defines the callback to use
  123292. */
  123293. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  123294. /**
  123295. * Defines the callback to call when a pad is pressed
  123296. * @param callback defines the callback to use
  123297. */
  123298. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  123299. /**
  123300. * Defines the callback to call when a pad is released
  123301. * @param callback defines the callback to use
  123302. */
  123303. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  123304. private _setButtonValue;
  123305. private _setDPadValue;
  123306. /**
  123307. * Gets the value of the `Cross` button
  123308. */
  123309. get buttonCross(): number;
  123310. /**
  123311. * Sets the value of the `Cross` button
  123312. */
  123313. set buttonCross(value: number);
  123314. /**
  123315. * Gets the value of the `Circle` button
  123316. */
  123317. get buttonCircle(): number;
  123318. /**
  123319. * Sets the value of the `Circle` button
  123320. */
  123321. set buttonCircle(value: number);
  123322. /**
  123323. * Gets the value of the `Square` button
  123324. */
  123325. get buttonSquare(): number;
  123326. /**
  123327. * Sets the value of the `Square` button
  123328. */
  123329. set buttonSquare(value: number);
  123330. /**
  123331. * Gets the value of the `Triangle` button
  123332. */
  123333. get buttonTriangle(): number;
  123334. /**
  123335. * Sets the value of the `Triangle` button
  123336. */
  123337. set buttonTriangle(value: number);
  123338. /**
  123339. * Gets the value of the `Options` button
  123340. */
  123341. get buttonOptions(): number;
  123342. /**
  123343. * Sets the value of the `Options` button
  123344. */
  123345. set buttonOptions(value: number);
  123346. /**
  123347. * Gets the value of the `Share` button
  123348. */
  123349. get buttonShare(): number;
  123350. /**
  123351. * Sets the value of the `Share` button
  123352. */
  123353. set buttonShare(value: number);
  123354. /**
  123355. * Gets the value of the `L1` button
  123356. */
  123357. get buttonL1(): number;
  123358. /**
  123359. * Sets the value of the `L1` button
  123360. */
  123361. set buttonL1(value: number);
  123362. /**
  123363. * Gets the value of the `R1` button
  123364. */
  123365. get buttonR1(): number;
  123366. /**
  123367. * Sets the value of the `R1` button
  123368. */
  123369. set buttonR1(value: number);
  123370. /**
  123371. * Gets the value of the Left joystick
  123372. */
  123373. get buttonLeftStick(): number;
  123374. /**
  123375. * Sets the value of the Left joystick
  123376. */
  123377. set buttonLeftStick(value: number);
  123378. /**
  123379. * Gets the value of the Right joystick
  123380. */
  123381. get buttonRightStick(): number;
  123382. /**
  123383. * Sets the value of the Right joystick
  123384. */
  123385. set buttonRightStick(value: number);
  123386. /**
  123387. * Gets the value of D-pad up
  123388. */
  123389. get dPadUp(): number;
  123390. /**
  123391. * Sets the value of D-pad up
  123392. */
  123393. set dPadUp(value: number);
  123394. /**
  123395. * Gets the value of D-pad down
  123396. */
  123397. get dPadDown(): number;
  123398. /**
  123399. * Sets the value of D-pad down
  123400. */
  123401. set dPadDown(value: number);
  123402. /**
  123403. * Gets the value of D-pad left
  123404. */
  123405. get dPadLeft(): number;
  123406. /**
  123407. * Sets the value of D-pad left
  123408. */
  123409. set dPadLeft(value: number);
  123410. /**
  123411. * Gets the value of D-pad right
  123412. */
  123413. get dPadRight(): number;
  123414. /**
  123415. * Sets the value of D-pad right
  123416. */
  123417. set dPadRight(value: number);
  123418. /**
  123419. * Force the gamepad to synchronize with device values
  123420. */
  123421. update(): void;
  123422. /**
  123423. * Disposes the gamepad
  123424. */
  123425. dispose(): void;
  123426. }
  123427. }
  123428. declare module BABYLON {
  123429. /**
  123430. * Manager for handling gamepads
  123431. */
  123432. export class GamepadManager {
  123433. private _scene?;
  123434. private _babylonGamepads;
  123435. private _oneGamepadConnected;
  123436. /** @hidden */
  123437. _isMonitoring: boolean;
  123438. private _gamepadEventSupported;
  123439. private _gamepadSupport?;
  123440. /**
  123441. * observable to be triggered when the gamepad controller has been connected
  123442. */
  123443. onGamepadConnectedObservable: Observable<Gamepad>;
  123444. /**
  123445. * observable to be triggered when the gamepad controller has been disconnected
  123446. */
  123447. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123448. private _onGamepadConnectedEvent;
  123449. private _onGamepadDisconnectedEvent;
  123450. /**
  123451. * Initializes the gamepad manager
  123452. * @param _scene BabylonJS scene
  123453. */
  123454. constructor(_scene?: Scene | undefined);
  123455. /**
  123456. * The gamepads in the game pad manager
  123457. */
  123458. get gamepads(): Gamepad[];
  123459. /**
  123460. * Get the gamepad controllers based on type
  123461. * @param type The type of gamepad controller
  123462. * @returns Nullable gamepad
  123463. */
  123464. getGamepadByType(type?: number): Nullable<Gamepad>;
  123465. /**
  123466. * Disposes the gamepad manager
  123467. */
  123468. dispose(): void;
  123469. private _addNewGamepad;
  123470. private _startMonitoringGamepads;
  123471. private _stopMonitoringGamepads;
  123472. /** @hidden */
  123473. _checkGamepadsStatus(): void;
  123474. private _updateGamepadObjects;
  123475. }
  123476. }
  123477. declare module BABYLON {
  123478. interface Scene {
  123479. /** @hidden */
  123480. _gamepadManager: Nullable<GamepadManager>;
  123481. /**
  123482. * Gets the gamepad manager associated with the scene
  123483. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123484. */
  123485. gamepadManager: GamepadManager;
  123486. }
  123487. /**
  123488. * Interface representing a free camera inputs manager
  123489. */
  123490. interface FreeCameraInputsManager {
  123491. /**
  123492. * Adds gamepad input support to the FreeCameraInputsManager.
  123493. * @returns the FreeCameraInputsManager
  123494. */
  123495. addGamepad(): FreeCameraInputsManager;
  123496. }
  123497. /**
  123498. * Interface representing an arc rotate camera inputs manager
  123499. */
  123500. interface ArcRotateCameraInputsManager {
  123501. /**
  123502. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123503. * @returns the camera inputs manager
  123504. */
  123505. addGamepad(): ArcRotateCameraInputsManager;
  123506. }
  123507. /**
  123508. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123509. */
  123510. export class GamepadSystemSceneComponent implements ISceneComponent {
  123511. /**
  123512. * The component name helpfull to identify the component in the list of scene components.
  123513. */
  123514. readonly name: string;
  123515. /**
  123516. * The scene the component belongs to.
  123517. */
  123518. scene: Scene;
  123519. /**
  123520. * Creates a new instance of the component for the given scene
  123521. * @param scene Defines the scene to register the component in
  123522. */
  123523. constructor(scene: Scene);
  123524. /**
  123525. * Registers the component in a given scene
  123526. */
  123527. register(): void;
  123528. /**
  123529. * Rebuilds the elements related to this component in case of
  123530. * context lost for instance.
  123531. */
  123532. rebuild(): void;
  123533. /**
  123534. * Disposes the component and the associated ressources
  123535. */
  123536. dispose(): void;
  123537. private _beforeCameraUpdate;
  123538. }
  123539. }
  123540. declare module BABYLON {
  123541. /**
  123542. * 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,
  123543. * which still works and will still be found in many Playgrounds.
  123544. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123545. */
  123546. export class UniversalCamera extends TouchCamera {
  123547. /**
  123548. * Defines the gamepad rotation sensiblity.
  123549. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123550. */
  123551. get gamepadAngularSensibility(): number;
  123552. set gamepadAngularSensibility(value: number);
  123553. /**
  123554. * Defines the gamepad move sensiblity.
  123555. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123556. */
  123557. get gamepadMoveSensibility(): number;
  123558. set gamepadMoveSensibility(value: number);
  123559. /**
  123560. * 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,
  123561. * which still works and will still be found in many Playgrounds.
  123562. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123563. * @param name Define the name of the camera in the scene
  123564. * @param position Define the start position of the camera in the scene
  123565. * @param scene Define the scene the camera belongs to
  123566. */
  123567. constructor(name: string, position: Vector3, scene: Scene);
  123568. /**
  123569. * Gets the current object class name.
  123570. * @return the class name
  123571. */
  123572. getClassName(): string;
  123573. }
  123574. }
  123575. declare module BABYLON {
  123576. /**
  123577. * This represents a FPS type of camera. This is only here for back compat purpose.
  123578. * Please use the UniversalCamera instead as both are identical.
  123579. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123580. */
  123581. export class GamepadCamera extends UniversalCamera {
  123582. /**
  123583. * Instantiates a new Gamepad Camera
  123584. * This represents a FPS type of camera. This is only here for back compat purpose.
  123585. * Please use the UniversalCamera instead as both are identical.
  123586. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123587. * @param name Define the name of the camera in the scene
  123588. * @param position Define the start position of the camera in the scene
  123589. * @param scene Define the scene the camera belongs to
  123590. */
  123591. constructor(name: string, position: Vector3, scene: Scene);
  123592. /**
  123593. * Gets the current object class name.
  123594. * @return the class name
  123595. */
  123596. getClassName(): string;
  123597. }
  123598. }
  123599. declare module BABYLON {
  123600. /** @hidden */
  123601. export var passPixelShader: {
  123602. name: string;
  123603. shader: string;
  123604. };
  123605. }
  123606. declare module BABYLON {
  123607. /** @hidden */
  123608. export var passCubePixelShader: {
  123609. name: string;
  123610. shader: string;
  123611. };
  123612. }
  123613. declare module BABYLON {
  123614. /**
  123615. * PassPostProcess which produces an output the same as it's input
  123616. */
  123617. export class PassPostProcess extends PostProcess {
  123618. /**
  123619. * Creates the PassPostProcess
  123620. * @param name The name of the effect.
  123621. * @param options The required width/height ratio to downsize to before computing the render pass.
  123622. * @param camera The camera to apply the render pass to.
  123623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123624. * @param engine The engine which the post process will be applied. (default: current engine)
  123625. * @param reusable If the post process can be reused on the same frame. (default: false)
  123626. * @param textureType The type of texture to be used when performing the post processing.
  123627. * @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)
  123628. */
  123629. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123630. }
  123631. /**
  123632. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123633. */
  123634. export class PassCubePostProcess extends PostProcess {
  123635. private _face;
  123636. /**
  123637. * Gets or sets the cube face to display.
  123638. * * 0 is +X
  123639. * * 1 is -X
  123640. * * 2 is +Y
  123641. * * 3 is -Y
  123642. * * 4 is +Z
  123643. * * 5 is -Z
  123644. */
  123645. get face(): number;
  123646. set face(value: number);
  123647. /**
  123648. * Creates the PassCubePostProcess
  123649. * @param name The name of the effect.
  123650. * @param options The required width/height ratio to downsize to before computing the render pass.
  123651. * @param camera The camera to apply the render pass to.
  123652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123653. * @param engine The engine which the post process will be applied. (default: current engine)
  123654. * @param reusable If the post process can be reused on the same frame. (default: false)
  123655. * @param textureType The type of texture to be used when performing the post processing.
  123656. * @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)
  123657. */
  123658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123659. }
  123660. }
  123661. declare module BABYLON {
  123662. /** @hidden */
  123663. export var anaglyphPixelShader: {
  123664. name: string;
  123665. shader: string;
  123666. };
  123667. }
  123668. declare module BABYLON {
  123669. /**
  123670. * Postprocess used to generate anaglyphic rendering
  123671. */
  123672. export class AnaglyphPostProcess extends PostProcess {
  123673. private _passedProcess;
  123674. /**
  123675. * Creates a new AnaglyphPostProcess
  123676. * @param name defines postprocess name
  123677. * @param options defines creation options or target ratio scale
  123678. * @param rigCameras defines cameras using this postprocess
  123679. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123680. * @param engine defines hosting engine
  123681. * @param reusable defines if the postprocess will be reused multiple times per frame
  123682. */
  123683. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123684. }
  123685. }
  123686. declare module BABYLON {
  123687. /**
  123688. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123689. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123690. */
  123691. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123692. /**
  123693. * Creates a new AnaglyphArcRotateCamera
  123694. * @param name defines camera name
  123695. * @param alpha defines alpha angle (in radians)
  123696. * @param beta defines beta angle (in radians)
  123697. * @param radius defines radius
  123698. * @param target defines camera target
  123699. * @param interaxialDistance defines distance between each color axis
  123700. * @param scene defines the hosting scene
  123701. */
  123702. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123703. /**
  123704. * Gets camera class name
  123705. * @returns AnaglyphArcRotateCamera
  123706. */
  123707. getClassName(): string;
  123708. }
  123709. }
  123710. declare module BABYLON {
  123711. /**
  123712. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123713. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123714. */
  123715. export class AnaglyphFreeCamera extends FreeCamera {
  123716. /**
  123717. * Creates a new AnaglyphFreeCamera
  123718. * @param name defines camera name
  123719. * @param position defines initial position
  123720. * @param interaxialDistance defines distance between each color axis
  123721. * @param scene defines the hosting scene
  123722. */
  123723. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123724. /**
  123725. * Gets camera class name
  123726. * @returns AnaglyphFreeCamera
  123727. */
  123728. getClassName(): string;
  123729. }
  123730. }
  123731. declare module BABYLON {
  123732. /**
  123733. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123734. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123735. */
  123736. export class AnaglyphGamepadCamera extends GamepadCamera {
  123737. /**
  123738. * Creates a new AnaglyphGamepadCamera
  123739. * @param name defines camera name
  123740. * @param position defines initial position
  123741. * @param interaxialDistance defines distance between each color axis
  123742. * @param scene defines the hosting scene
  123743. */
  123744. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123745. /**
  123746. * Gets camera class name
  123747. * @returns AnaglyphGamepadCamera
  123748. */
  123749. getClassName(): string;
  123750. }
  123751. }
  123752. declare module BABYLON {
  123753. /**
  123754. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123755. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123756. */
  123757. export class AnaglyphUniversalCamera extends UniversalCamera {
  123758. /**
  123759. * Creates a new AnaglyphUniversalCamera
  123760. * @param name defines camera name
  123761. * @param position defines initial position
  123762. * @param interaxialDistance defines distance between each color axis
  123763. * @param scene defines the hosting scene
  123764. */
  123765. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123766. /**
  123767. * Gets camera class name
  123768. * @returns AnaglyphUniversalCamera
  123769. */
  123770. getClassName(): string;
  123771. }
  123772. }
  123773. declare module BABYLON {
  123774. /**
  123775. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123776. * @see https://doc.babylonjs.com/features/cameras
  123777. */
  123778. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123779. /**
  123780. * Creates a new StereoscopicArcRotateCamera
  123781. * @param name defines camera name
  123782. * @param alpha defines alpha angle (in radians)
  123783. * @param beta defines beta angle (in radians)
  123784. * @param radius defines radius
  123785. * @param target defines camera target
  123786. * @param interaxialDistance defines distance between each color axis
  123787. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123788. * @param scene defines the hosting scene
  123789. */
  123790. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123791. /**
  123792. * Gets camera class name
  123793. * @returns StereoscopicArcRotateCamera
  123794. */
  123795. getClassName(): string;
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123801. * @see https://doc.babylonjs.com/features/cameras
  123802. */
  123803. export class StereoscopicFreeCamera extends FreeCamera {
  123804. /**
  123805. * Creates a new StereoscopicFreeCamera
  123806. * @param name defines camera name
  123807. * @param position defines initial position
  123808. * @param interaxialDistance defines distance between each color axis
  123809. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123810. * @param scene defines the hosting scene
  123811. */
  123812. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123813. /**
  123814. * Gets camera class name
  123815. * @returns StereoscopicFreeCamera
  123816. */
  123817. getClassName(): string;
  123818. }
  123819. }
  123820. declare module BABYLON {
  123821. /**
  123822. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123823. * @see https://doc.babylonjs.com/features/cameras
  123824. */
  123825. export class StereoscopicGamepadCamera extends GamepadCamera {
  123826. /**
  123827. * Creates a new StereoscopicGamepadCamera
  123828. * @param name defines camera name
  123829. * @param position defines initial position
  123830. * @param interaxialDistance defines distance between each color axis
  123831. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123832. * @param scene defines the hosting scene
  123833. */
  123834. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123835. /**
  123836. * Gets camera class name
  123837. * @returns StereoscopicGamepadCamera
  123838. */
  123839. getClassName(): string;
  123840. }
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123845. * @see https://doc.babylonjs.com/features/cameras
  123846. */
  123847. export class StereoscopicUniversalCamera extends UniversalCamera {
  123848. /**
  123849. * Creates a new StereoscopicUniversalCamera
  123850. * @param name defines camera name
  123851. * @param position defines initial position
  123852. * @param interaxialDistance defines distance between each color axis
  123853. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123854. * @param scene defines the hosting scene
  123855. */
  123856. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123857. /**
  123858. * Gets camera class name
  123859. * @returns StereoscopicUniversalCamera
  123860. */
  123861. getClassName(): string;
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /**
  123866. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123867. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123868. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123869. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123870. */
  123871. export class VirtualJoysticksCamera extends FreeCamera {
  123872. /**
  123873. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123874. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123875. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123876. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123877. * @param name Define the name of the camera in the scene
  123878. * @param position Define the start position of the camera in the scene
  123879. * @param scene Define the scene the camera belongs to
  123880. */
  123881. constructor(name: string, position: Vector3, scene: Scene);
  123882. /**
  123883. * Gets the current object class name.
  123884. * @return the class name
  123885. */
  123886. getClassName(): string;
  123887. }
  123888. }
  123889. declare module BABYLON {
  123890. /**
  123891. * This represents all the required metrics to create a VR camera.
  123892. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123893. */
  123894. export class VRCameraMetrics {
  123895. /**
  123896. * Define the horizontal resolution off the screen.
  123897. */
  123898. hResolution: number;
  123899. /**
  123900. * Define the vertical resolution off the screen.
  123901. */
  123902. vResolution: number;
  123903. /**
  123904. * Define the horizontal screen size.
  123905. */
  123906. hScreenSize: number;
  123907. /**
  123908. * Define the vertical screen size.
  123909. */
  123910. vScreenSize: number;
  123911. /**
  123912. * Define the vertical screen center position.
  123913. */
  123914. vScreenCenter: number;
  123915. /**
  123916. * Define the distance of the eyes to the screen.
  123917. */
  123918. eyeToScreenDistance: number;
  123919. /**
  123920. * Define the distance between both lenses
  123921. */
  123922. lensSeparationDistance: number;
  123923. /**
  123924. * Define the distance between both viewer's eyes.
  123925. */
  123926. interpupillaryDistance: number;
  123927. /**
  123928. * Define the distortion factor of the VR postprocess.
  123929. * Please, touch with care.
  123930. */
  123931. distortionK: number[];
  123932. /**
  123933. * Define the chromatic aberration correction factors for the VR post process.
  123934. */
  123935. chromaAbCorrection: number[];
  123936. /**
  123937. * Define the scale factor of the post process.
  123938. * The smaller the better but the slower.
  123939. */
  123940. postProcessScaleFactor: number;
  123941. /**
  123942. * Define an offset for the lens center.
  123943. */
  123944. lensCenterOffset: number;
  123945. /**
  123946. * Define if the current vr camera should compensate the distortion of the lense or not.
  123947. */
  123948. compensateDistortion: boolean;
  123949. /**
  123950. * Defines if multiview should be enabled when rendering (Default: false)
  123951. */
  123952. multiviewEnabled: boolean;
  123953. /**
  123954. * Gets the rendering aspect ratio based on the provided resolutions.
  123955. */
  123956. get aspectRatio(): number;
  123957. /**
  123958. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123959. */
  123960. get aspectRatioFov(): number;
  123961. /**
  123962. * @hidden
  123963. */
  123964. get leftHMatrix(): Matrix;
  123965. /**
  123966. * @hidden
  123967. */
  123968. get rightHMatrix(): Matrix;
  123969. /**
  123970. * @hidden
  123971. */
  123972. get leftPreViewMatrix(): Matrix;
  123973. /**
  123974. * @hidden
  123975. */
  123976. get rightPreViewMatrix(): Matrix;
  123977. /**
  123978. * Get the default VRMetrics based on the most generic setup.
  123979. * @returns the default vr metrics
  123980. */
  123981. static GetDefault(): VRCameraMetrics;
  123982. }
  123983. }
  123984. declare module BABYLON {
  123985. /** @hidden */
  123986. export var vrDistortionCorrectionPixelShader: {
  123987. name: string;
  123988. shader: string;
  123989. };
  123990. }
  123991. declare module BABYLON {
  123992. /**
  123993. * VRDistortionCorrectionPostProcess used for mobile VR
  123994. */
  123995. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123996. private _isRightEye;
  123997. private _distortionFactors;
  123998. private _postProcessScaleFactor;
  123999. private _lensCenterOffset;
  124000. private _scaleIn;
  124001. private _scaleFactor;
  124002. private _lensCenter;
  124003. /**
  124004. * Initializes the VRDistortionCorrectionPostProcess
  124005. * @param name The name of the effect.
  124006. * @param camera The camera to apply the render pass to.
  124007. * @param isRightEye If this is for the right eye distortion
  124008. * @param vrMetrics All the required metrics for the VR camera
  124009. */
  124010. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  124011. }
  124012. }
  124013. declare module BABYLON {
  124014. /**
  124015. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  124016. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124017. */
  124018. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  124019. /**
  124020. * Creates a new VRDeviceOrientationArcRotateCamera
  124021. * @param name defines camera name
  124022. * @param alpha defines the camera rotation along the logitudinal axis
  124023. * @param beta defines the camera rotation along the latitudinal axis
  124024. * @param radius defines the camera distance from its target
  124025. * @param target defines the camera target
  124026. * @param scene defines the scene the camera belongs to
  124027. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124028. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124029. */
  124030. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124031. /**
  124032. * Gets camera class name
  124033. * @returns VRDeviceOrientationArcRotateCamera
  124034. */
  124035. getClassName(): string;
  124036. }
  124037. }
  124038. declare module BABYLON {
  124039. /**
  124040. * Camera used to simulate VR rendering (based on FreeCamera)
  124041. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124042. */
  124043. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  124044. /**
  124045. * Creates a new VRDeviceOrientationFreeCamera
  124046. * @param name defines camera name
  124047. * @param position defines the start position of the camera
  124048. * @param scene defines the scene the camera belongs to
  124049. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124050. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124051. */
  124052. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124053. /**
  124054. * Gets camera class name
  124055. * @returns VRDeviceOrientationFreeCamera
  124056. */
  124057. getClassName(): string;
  124058. }
  124059. }
  124060. declare module BABYLON {
  124061. /**
  124062. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  124063. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124064. */
  124065. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  124066. /**
  124067. * Creates a new VRDeviceOrientationGamepadCamera
  124068. * @param name defines camera name
  124069. * @param position defines the start position of the camera
  124070. * @param scene defines the scene the camera belongs to
  124071. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124072. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124073. */
  124074. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124075. /**
  124076. * Gets camera class name
  124077. * @returns VRDeviceOrientationGamepadCamera
  124078. */
  124079. getClassName(): string;
  124080. }
  124081. }
  124082. declare module BABYLON {
  124083. /**
  124084. * A class extending Texture allowing drawing on a texture
  124085. * @see https://doc.babylonjs.com/how_to/dynamictexture
  124086. */
  124087. export class DynamicTexture extends Texture {
  124088. private _generateMipMaps;
  124089. private _canvas;
  124090. private _context;
  124091. /**
  124092. * Creates a DynamicTexture
  124093. * @param name defines the name of the texture
  124094. * @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
  124095. * @param scene defines the scene where you want the texture
  124096. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  124097. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124098. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  124099. */
  124100. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  124101. /**
  124102. * Get the current class name of the texture useful for serialization or dynamic coding.
  124103. * @returns "DynamicTexture"
  124104. */
  124105. getClassName(): string;
  124106. /**
  124107. * Gets the current state of canRescale
  124108. */
  124109. get canRescale(): boolean;
  124110. private _recreate;
  124111. /**
  124112. * Scales the texture
  124113. * @param ratio the scale factor to apply to both width and height
  124114. */
  124115. scale(ratio: number): void;
  124116. /**
  124117. * Resizes the texture
  124118. * @param width the new width
  124119. * @param height the new height
  124120. */
  124121. scaleTo(width: number, height: number): void;
  124122. /**
  124123. * Gets the context of the canvas used by the texture
  124124. * @returns the canvas context of the dynamic texture
  124125. */
  124126. getContext(): CanvasRenderingContext2D;
  124127. /**
  124128. * Clears the texture
  124129. */
  124130. clear(): void;
  124131. /**
  124132. * Updates the texture
  124133. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124134. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  124135. */
  124136. update(invertY?: boolean, premulAlpha?: boolean): void;
  124137. /**
  124138. * Draws text onto the texture
  124139. * @param text defines the text to be drawn
  124140. * @param x defines the placement of the text from the left
  124141. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  124142. * @param font defines the font to be used with font-style, font-size, font-name
  124143. * @param color defines the color used for the text
  124144. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  124145. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124146. * @param update defines whether texture is immediately update (default is true)
  124147. */
  124148. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  124149. /**
  124150. * Clones the texture
  124151. * @returns the clone of the texture.
  124152. */
  124153. clone(): DynamicTexture;
  124154. /**
  124155. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  124156. * @returns a serialized dynamic texture object
  124157. */
  124158. serialize(): any;
  124159. private _IsCanvasElement;
  124160. /** @hidden */
  124161. _rebuild(): void;
  124162. }
  124163. }
  124164. declare module BABYLON {
  124165. /** @hidden */
  124166. export var imageProcessingPixelShader: {
  124167. name: string;
  124168. shader: string;
  124169. };
  124170. }
  124171. declare module BABYLON {
  124172. /**
  124173. * ImageProcessingPostProcess
  124174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  124175. */
  124176. export class ImageProcessingPostProcess extends PostProcess {
  124177. /**
  124178. * Default configuration related to image processing available in the PBR Material.
  124179. */
  124180. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124181. /**
  124182. * Gets the image processing configuration used either in this material.
  124183. */
  124184. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124185. /**
  124186. * Sets the Default image processing configuration used either in the this material.
  124187. *
  124188. * If sets to null, the scene one is in use.
  124189. */
  124190. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124191. /**
  124192. * Keep track of the image processing observer to allow dispose and replace.
  124193. */
  124194. private _imageProcessingObserver;
  124195. /**
  124196. * Attaches a new image processing configuration to the PBR Material.
  124197. * @param configuration
  124198. */
  124199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  124200. /**
  124201. * If the post process is supported.
  124202. */
  124203. get isSupported(): boolean;
  124204. /**
  124205. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124206. */
  124207. get colorCurves(): Nullable<ColorCurves>;
  124208. /**
  124209. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124210. */
  124211. set colorCurves(value: Nullable<ColorCurves>);
  124212. /**
  124213. * Gets wether the color curves effect is enabled.
  124214. */
  124215. get colorCurvesEnabled(): boolean;
  124216. /**
  124217. * Sets wether the color curves effect is enabled.
  124218. */
  124219. set colorCurvesEnabled(value: boolean);
  124220. /**
  124221. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124222. */
  124223. get colorGradingTexture(): Nullable<BaseTexture>;
  124224. /**
  124225. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124226. */
  124227. set colorGradingTexture(value: Nullable<BaseTexture>);
  124228. /**
  124229. * Gets wether the color grading effect is enabled.
  124230. */
  124231. get colorGradingEnabled(): boolean;
  124232. /**
  124233. * Gets wether the color grading effect is enabled.
  124234. */
  124235. set colorGradingEnabled(value: boolean);
  124236. /**
  124237. * Gets exposure used in the effect.
  124238. */
  124239. get exposure(): number;
  124240. /**
  124241. * Sets exposure used in the effect.
  124242. */
  124243. set exposure(value: number);
  124244. /**
  124245. * Gets wether tonemapping is enabled or not.
  124246. */
  124247. get toneMappingEnabled(): boolean;
  124248. /**
  124249. * Sets wether tonemapping is enabled or not
  124250. */
  124251. set toneMappingEnabled(value: boolean);
  124252. /**
  124253. * Gets the type of tone mapping effect.
  124254. */
  124255. get toneMappingType(): number;
  124256. /**
  124257. * Sets the type of tone mapping effect.
  124258. */
  124259. set toneMappingType(value: number);
  124260. /**
  124261. * Gets contrast used in the effect.
  124262. */
  124263. get contrast(): number;
  124264. /**
  124265. * Sets contrast used in the effect.
  124266. */
  124267. set contrast(value: number);
  124268. /**
  124269. * Gets Vignette stretch size.
  124270. */
  124271. get vignetteStretch(): number;
  124272. /**
  124273. * Sets Vignette stretch size.
  124274. */
  124275. set vignetteStretch(value: number);
  124276. /**
  124277. * Gets Vignette centre X Offset.
  124278. */
  124279. get vignetteCentreX(): number;
  124280. /**
  124281. * Sets Vignette centre X Offset.
  124282. */
  124283. set vignetteCentreX(value: number);
  124284. /**
  124285. * Gets Vignette centre Y Offset.
  124286. */
  124287. get vignetteCentreY(): number;
  124288. /**
  124289. * Sets Vignette centre Y Offset.
  124290. */
  124291. set vignetteCentreY(value: number);
  124292. /**
  124293. * Gets Vignette weight or intensity of the vignette effect.
  124294. */
  124295. get vignetteWeight(): number;
  124296. /**
  124297. * Sets Vignette weight or intensity of the vignette effect.
  124298. */
  124299. set vignetteWeight(value: number);
  124300. /**
  124301. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124302. * if vignetteEnabled is set to true.
  124303. */
  124304. get vignetteColor(): Color4;
  124305. /**
  124306. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124307. * if vignetteEnabled is set to true.
  124308. */
  124309. set vignetteColor(value: Color4);
  124310. /**
  124311. * Gets Camera field of view used by the Vignette effect.
  124312. */
  124313. get vignetteCameraFov(): number;
  124314. /**
  124315. * Sets Camera field of view used by the Vignette effect.
  124316. */
  124317. set vignetteCameraFov(value: number);
  124318. /**
  124319. * Gets the vignette blend mode allowing different kind of effect.
  124320. */
  124321. get vignetteBlendMode(): number;
  124322. /**
  124323. * Sets the vignette blend mode allowing different kind of effect.
  124324. */
  124325. set vignetteBlendMode(value: number);
  124326. /**
  124327. * Gets wether the vignette effect is enabled.
  124328. */
  124329. get vignetteEnabled(): boolean;
  124330. /**
  124331. * Sets wether the vignette effect is enabled.
  124332. */
  124333. set vignetteEnabled(value: boolean);
  124334. private _fromLinearSpace;
  124335. /**
  124336. * Gets wether the input of the processing is in Gamma or Linear Space.
  124337. */
  124338. get fromLinearSpace(): boolean;
  124339. /**
  124340. * Sets wether the input of the processing is in Gamma or Linear Space.
  124341. */
  124342. set fromLinearSpace(value: boolean);
  124343. /**
  124344. * Defines cache preventing GC.
  124345. */
  124346. private _defines;
  124347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124348. /**
  124349. * "ImageProcessingPostProcess"
  124350. * @returns "ImageProcessingPostProcess"
  124351. */
  124352. getClassName(): string;
  124353. /**
  124354. * @hidden
  124355. */
  124356. _updateParameters(): void;
  124357. dispose(camera?: Camera): void;
  124358. }
  124359. }
  124360. declare module BABYLON {
  124361. /**
  124362. * Class containing static functions to help procedurally build meshes
  124363. */
  124364. export class GroundBuilder {
  124365. /**
  124366. * Creates a ground mesh
  124367. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124368. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124370. * @param name defines the name of the mesh
  124371. * @param options defines the options used to create the mesh
  124372. * @param scene defines the hosting scene
  124373. * @returns the ground mesh
  124374. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124375. */
  124376. static CreateGround(name: string, options: {
  124377. width?: number;
  124378. height?: number;
  124379. subdivisions?: number;
  124380. subdivisionsX?: number;
  124381. subdivisionsY?: number;
  124382. updatable?: boolean;
  124383. }, scene: any): Mesh;
  124384. /**
  124385. * Creates a tiled ground mesh
  124386. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124387. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124388. * * 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
  124389. * * 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
  124390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124391. * @param name defines the name of the mesh
  124392. * @param options defines the options used to create the mesh
  124393. * @param scene defines the hosting scene
  124394. * @returns the tiled ground mesh
  124395. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124396. */
  124397. static CreateTiledGround(name: string, options: {
  124398. xmin: number;
  124399. zmin: number;
  124400. xmax: number;
  124401. zmax: number;
  124402. subdivisions?: {
  124403. w: number;
  124404. h: number;
  124405. };
  124406. precision?: {
  124407. w: number;
  124408. h: number;
  124409. };
  124410. updatable?: boolean;
  124411. }, scene?: Nullable<Scene>): Mesh;
  124412. /**
  124413. * Creates a ground mesh from a height map
  124414. * * The parameter `url` sets the URL of the height map image resource.
  124415. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124416. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124417. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124418. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124419. * * 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.
  124420. * * 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).
  124421. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124423. * @param name defines the name of the mesh
  124424. * @param url defines the url to the height map
  124425. * @param options defines the options used to create the mesh
  124426. * @param scene defines the hosting scene
  124427. * @returns the ground mesh
  124428. * @see https://doc.babylonjs.com/babylon101/height_map
  124429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124430. */
  124431. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124432. width?: number;
  124433. height?: number;
  124434. subdivisions?: number;
  124435. minHeight?: number;
  124436. maxHeight?: number;
  124437. colorFilter?: Color3;
  124438. alphaFilter?: number;
  124439. updatable?: boolean;
  124440. onReady?: (mesh: GroundMesh) => void;
  124441. }, scene?: Nullable<Scene>): GroundMesh;
  124442. }
  124443. }
  124444. declare module BABYLON {
  124445. /**
  124446. * Class containing static functions to help procedurally build meshes
  124447. */
  124448. export class TorusBuilder {
  124449. /**
  124450. * Creates a torus mesh
  124451. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124452. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124453. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124457. * @param name defines the name of the mesh
  124458. * @param options defines the options used to create the mesh
  124459. * @param scene defines the hosting scene
  124460. * @returns the torus mesh
  124461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124462. */
  124463. static CreateTorus(name: string, options: {
  124464. diameter?: number;
  124465. thickness?: number;
  124466. tessellation?: number;
  124467. updatable?: boolean;
  124468. sideOrientation?: number;
  124469. frontUVs?: Vector4;
  124470. backUVs?: Vector4;
  124471. }, scene: any): Mesh;
  124472. }
  124473. }
  124474. declare module BABYLON {
  124475. /**
  124476. * Class containing static functions to help procedurally build meshes
  124477. */
  124478. export class CylinderBuilder {
  124479. /**
  124480. * Creates a cylinder or a cone mesh
  124481. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124482. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124483. * * 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.
  124484. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124485. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124486. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124487. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124488. * * 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).
  124489. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124490. * * 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).
  124491. * * 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
  124492. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124493. * * 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
  124494. * * 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.
  124495. * * If `enclose` is false, a ring surface is one element.
  124496. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124497. * * 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
  124498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124501. * @param name defines the name of the mesh
  124502. * @param options defines the options used to create the mesh
  124503. * @param scene defines the hosting scene
  124504. * @returns the cylinder mesh
  124505. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124506. */
  124507. static CreateCylinder(name: string, options: {
  124508. height?: number;
  124509. diameterTop?: number;
  124510. diameterBottom?: number;
  124511. diameter?: number;
  124512. tessellation?: number;
  124513. subdivisions?: number;
  124514. arc?: number;
  124515. faceColors?: Color4[];
  124516. faceUV?: Vector4[];
  124517. updatable?: boolean;
  124518. hasRings?: boolean;
  124519. enclose?: boolean;
  124520. cap?: number;
  124521. sideOrientation?: number;
  124522. frontUVs?: Vector4;
  124523. backUVs?: Vector4;
  124524. }, scene: any): Mesh;
  124525. }
  124526. }
  124527. declare module BABYLON {
  124528. /**
  124529. * States of the webXR experience
  124530. */
  124531. export enum WebXRState {
  124532. /**
  124533. * Transitioning to being in XR mode
  124534. */
  124535. ENTERING_XR = 0,
  124536. /**
  124537. * Transitioning to non XR mode
  124538. */
  124539. EXITING_XR = 1,
  124540. /**
  124541. * In XR mode and presenting
  124542. */
  124543. IN_XR = 2,
  124544. /**
  124545. * Not entered XR mode
  124546. */
  124547. NOT_IN_XR = 3
  124548. }
  124549. /**
  124550. * Abstraction of the XR render target
  124551. */
  124552. export interface WebXRRenderTarget extends IDisposable {
  124553. /**
  124554. * xrpresent context of the canvas which can be used to display/mirror xr content
  124555. */
  124556. canvasContext: WebGLRenderingContext;
  124557. /**
  124558. * xr layer for the canvas
  124559. */
  124560. xrLayer: Nullable<XRWebGLLayer>;
  124561. /**
  124562. * Initializes the xr layer for the session
  124563. * @param xrSession xr session
  124564. * @returns a promise that will resolve once the XR Layer has been created
  124565. */
  124566. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124567. }
  124568. }
  124569. declare module BABYLON {
  124570. /**
  124571. * COnfiguration object for WebXR output canvas
  124572. */
  124573. export class WebXRManagedOutputCanvasOptions {
  124574. /**
  124575. * An optional canvas in case you wish to create it yourself and provide it here.
  124576. * If not provided, a new canvas will be created
  124577. */
  124578. canvasElement?: HTMLCanvasElement;
  124579. /**
  124580. * Options for this XR Layer output
  124581. */
  124582. canvasOptions?: XRWebGLLayerOptions;
  124583. /**
  124584. * CSS styling for a newly created canvas (if not provided)
  124585. */
  124586. newCanvasCssStyle?: string;
  124587. /**
  124588. * Get the default values of the configuration object
  124589. * @returns default values of this configuration object
  124590. */
  124591. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124592. }
  124593. /**
  124594. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124595. */
  124596. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124597. private _options;
  124598. private _canvas;
  124599. private _engine;
  124600. private _originalCanvasSize;
  124601. /**
  124602. * Rendering context of the canvas which can be used to display/mirror xr content
  124603. */
  124604. canvasContext: WebGLRenderingContext;
  124605. /**
  124606. * xr layer for the canvas
  124607. */
  124608. xrLayer: Nullable<XRWebGLLayer>;
  124609. /**
  124610. * Obseervers registered here will be triggered when the xr layer was initialized
  124611. */
  124612. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124613. /**
  124614. * Initializes the canvas to be added/removed upon entering/exiting xr
  124615. * @param _xrSessionManager The XR Session manager
  124616. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124617. */
  124618. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124619. /**
  124620. * Disposes of the object
  124621. */
  124622. dispose(): void;
  124623. /**
  124624. * Initializes the xr layer for the session
  124625. * @param xrSession xr session
  124626. * @returns a promise that will resolve once the XR Layer has been created
  124627. */
  124628. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124629. private _addCanvas;
  124630. private _removeCanvas;
  124631. private _setCanvasSize;
  124632. private _setManagedOutputCanvas;
  124633. }
  124634. }
  124635. declare module BABYLON {
  124636. /**
  124637. * Manages an XRSession to work with Babylon's engine
  124638. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124639. */
  124640. export class WebXRSessionManager implements IDisposable {
  124641. /** The scene which the session should be created for */
  124642. scene: Scene;
  124643. private _referenceSpace;
  124644. private _rttProvider;
  124645. private _sessionEnded;
  124646. private _xrNavigator;
  124647. private baseLayer;
  124648. /**
  124649. * The base reference space from which the session started. good if you want to reset your
  124650. * reference space
  124651. */
  124652. baseReferenceSpace: XRReferenceSpace;
  124653. /**
  124654. * Current XR frame
  124655. */
  124656. currentFrame: Nullable<XRFrame>;
  124657. /** WebXR timestamp updated every frame */
  124658. currentTimestamp: number;
  124659. /**
  124660. * Used just in case of a failure to initialize an immersive session.
  124661. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124662. */
  124663. defaultHeightCompensation: number;
  124664. /**
  124665. * Fires every time a new xrFrame arrives which can be used to update the camera
  124666. */
  124667. onXRFrameObservable: Observable<XRFrame>;
  124668. /**
  124669. * Fires when the reference space changed
  124670. */
  124671. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124672. /**
  124673. * Fires when the xr session is ended either by the device or manually done
  124674. */
  124675. onXRSessionEnded: Observable<any>;
  124676. /**
  124677. * Fires when the xr session is ended either by the device or manually done
  124678. */
  124679. onXRSessionInit: Observable<XRSession>;
  124680. /**
  124681. * Underlying xr session
  124682. */
  124683. session: XRSession;
  124684. /**
  124685. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124686. * or get the offset the player is currently at.
  124687. */
  124688. viewerReferenceSpace: XRReferenceSpace;
  124689. /**
  124690. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124691. * @param scene The scene which the session should be created for
  124692. */
  124693. constructor(
  124694. /** The scene which the session should be created for */
  124695. scene: Scene);
  124696. /**
  124697. * The current reference space used in this session. This reference space can constantly change!
  124698. * It is mainly used to offset the camera's position.
  124699. */
  124700. get referenceSpace(): XRReferenceSpace;
  124701. /**
  124702. * Set a new reference space and triggers the observable
  124703. */
  124704. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124705. /**
  124706. * Disposes of the session manager
  124707. */
  124708. dispose(): void;
  124709. /**
  124710. * Stops the xrSession and restores the render loop
  124711. * @returns Promise which resolves after it exits XR
  124712. */
  124713. exitXRAsync(): Promise<void>;
  124714. /**
  124715. * Gets the correct render target texture to be rendered this frame for this eye
  124716. * @param eye the eye for which to get the render target
  124717. * @returns the render target for the specified eye
  124718. */
  124719. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124720. /**
  124721. * Creates a WebXRRenderTarget object for the XR session
  124722. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124723. * @param options optional options to provide when creating a new render target
  124724. * @returns a WebXR render target to which the session can render
  124725. */
  124726. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124727. /**
  124728. * Initializes the manager
  124729. * After initialization enterXR can be called to start an XR session
  124730. * @returns Promise which resolves after it is initialized
  124731. */
  124732. initializeAsync(): Promise<void>;
  124733. /**
  124734. * Initializes an xr session
  124735. * @param xrSessionMode mode to initialize
  124736. * @param xrSessionInit defines optional and required values to pass to the session builder
  124737. * @returns a promise which will resolve once the session has been initialized
  124738. */
  124739. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124740. /**
  124741. * Checks if a session would be supported for the creation options specified
  124742. * @param sessionMode session mode to check if supported eg. immersive-vr
  124743. * @returns A Promise that resolves to true if supported and false if not
  124744. */
  124745. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124746. /**
  124747. * Resets the reference space to the one started the session
  124748. */
  124749. resetReferenceSpace(): void;
  124750. /**
  124751. * Starts rendering to the xr layer
  124752. */
  124753. runXRRenderLoop(): void;
  124754. /**
  124755. * Sets the reference space on the xr session
  124756. * @param referenceSpaceType space to set
  124757. * @returns a promise that will resolve once the reference space has been set
  124758. */
  124759. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124760. /**
  124761. * Updates the render state of the session
  124762. * @param state state to set
  124763. * @returns a promise that resolves once the render state has been updated
  124764. */
  124765. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124766. /**
  124767. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124768. * @param sessionMode defines the session to test
  124769. * @returns a promise with boolean as final value
  124770. */
  124771. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124772. private _createRenderTargetTexture;
  124773. }
  124774. }
  124775. declare module BABYLON {
  124776. /**
  124777. * WebXR Camera which holds the views for the xrSession
  124778. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124779. */
  124780. export class WebXRCamera extends FreeCamera {
  124781. private _xrSessionManager;
  124782. private _firstFrame;
  124783. private _referenceQuaternion;
  124784. private _referencedPosition;
  124785. private _xrInvPositionCache;
  124786. private _xrInvQuaternionCache;
  124787. /**
  124788. * Should position compensation execute on first frame.
  124789. * This is used when copying the position from a native (non XR) camera
  124790. */
  124791. compensateOnFirstFrame: boolean;
  124792. /**
  124793. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124794. * @param name the name of the camera
  124795. * @param scene the scene to add the camera to
  124796. * @param _xrSessionManager a constructed xr session manager
  124797. */
  124798. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124799. /**
  124800. * Return the user's height, unrelated to the current ground.
  124801. * This will be the y position of this camera, when ground level is 0.
  124802. */
  124803. get realWorldHeight(): number;
  124804. /** @hidden */
  124805. _updateForDualEyeDebugging(): void;
  124806. /**
  124807. * Sets this camera's transformation based on a non-vr camera
  124808. * @param otherCamera the non-vr camera to copy the transformation from
  124809. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124810. */
  124811. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124812. /**
  124813. * Gets the current instance class name ("WebXRCamera").
  124814. * @returns the class name
  124815. */
  124816. getClassName(): string;
  124817. private _rotate180;
  124818. private _updateFromXRSession;
  124819. private _updateNumberOfRigCameras;
  124820. private _updateReferenceSpace;
  124821. private _updateReferenceSpaceOffset;
  124822. }
  124823. }
  124824. declare module BABYLON {
  124825. /**
  124826. * Defining the interface required for a (webxr) feature
  124827. */
  124828. export interface IWebXRFeature extends IDisposable {
  124829. /**
  124830. * Is this feature attached
  124831. */
  124832. attached: boolean;
  124833. /**
  124834. * Should auto-attach be disabled?
  124835. */
  124836. disableAutoAttach: boolean;
  124837. /**
  124838. * Attach the feature to the session
  124839. * Will usually be called by the features manager
  124840. *
  124841. * @param force should attachment be forced (even when already attached)
  124842. * @returns true if successful.
  124843. */
  124844. attach(force?: boolean): boolean;
  124845. /**
  124846. * Detach the feature from the session
  124847. * Will usually be called by the features manager
  124848. *
  124849. * @returns true if successful.
  124850. */
  124851. detach(): boolean;
  124852. }
  124853. /**
  124854. * A list of the currently available features without referencing them
  124855. */
  124856. export class WebXRFeatureName {
  124857. /**
  124858. * The name of the anchor system feature
  124859. */
  124860. static ANCHOR_SYSTEM: string;
  124861. /**
  124862. * The name of the background remover feature
  124863. */
  124864. static BACKGROUND_REMOVER: string;
  124865. /**
  124866. * The name of the hit test feature
  124867. */
  124868. static HIT_TEST: string;
  124869. /**
  124870. * physics impostors for xr controllers feature
  124871. */
  124872. static PHYSICS_CONTROLLERS: string;
  124873. /**
  124874. * The name of the plane detection feature
  124875. */
  124876. static PLANE_DETECTION: string;
  124877. /**
  124878. * The name of the pointer selection feature
  124879. */
  124880. static POINTER_SELECTION: string;
  124881. /**
  124882. * The name of the teleportation feature
  124883. */
  124884. static TELEPORTATION: string;
  124885. }
  124886. /**
  124887. * Defining the constructor of a feature. Used to register the modules.
  124888. */
  124889. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124890. /**
  124891. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124892. * It is mainly used in AR sessions.
  124893. *
  124894. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124895. */
  124896. export class WebXRFeaturesManager implements IDisposable {
  124897. private _xrSessionManager;
  124898. private static readonly _AvailableFeatures;
  124899. private _features;
  124900. /**
  124901. * constructs a new features manages.
  124902. *
  124903. * @param _xrSessionManager an instance of WebXRSessionManager
  124904. */
  124905. constructor(_xrSessionManager: WebXRSessionManager);
  124906. /**
  124907. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124908. * Mainly used internally.
  124909. *
  124910. * @param featureName the name of the feature to register
  124911. * @param constructorFunction the function used to construct the module
  124912. * @param version the (babylon) version of the module
  124913. * @param stable is that a stable version of this module
  124914. */
  124915. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124916. /**
  124917. * Returns a constructor of a specific feature.
  124918. *
  124919. * @param featureName the name of the feature to construct
  124920. * @param version the version of the feature to load
  124921. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124922. * @param options optional options provided to the module.
  124923. * @returns a function that, when called, will return a new instance of this feature
  124924. */
  124925. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124926. /**
  124927. * Can be used to return the list of features currently registered
  124928. *
  124929. * @returns an Array of available features
  124930. */
  124931. static GetAvailableFeatures(): string[];
  124932. /**
  124933. * Gets the versions available for a specific feature
  124934. * @param featureName the name of the feature
  124935. * @returns an array with the available versions
  124936. */
  124937. static GetAvailableVersions(featureName: string): string[];
  124938. /**
  124939. * Return the latest unstable version of this feature
  124940. * @param featureName the name of the feature to search
  124941. * @returns the version number. if not found will return -1
  124942. */
  124943. static GetLatestVersionOfFeature(featureName: string): number;
  124944. /**
  124945. * Return the latest stable version of this feature
  124946. * @param featureName the name of the feature to search
  124947. * @returns the version number. if not found will return -1
  124948. */
  124949. static GetStableVersionOfFeature(featureName: string): number;
  124950. /**
  124951. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124952. * Can be used during a session to start a feature
  124953. * @param featureName the name of feature to attach
  124954. */
  124955. attachFeature(featureName: string): void;
  124956. /**
  124957. * Can be used inside a session or when the session ends to detach a specific feature
  124958. * @param featureName the name of the feature to detach
  124959. */
  124960. detachFeature(featureName: string): void;
  124961. /**
  124962. * Used to disable an already-enabled feature
  124963. * The feature will be disposed and will be recreated once enabled.
  124964. * @param featureName the feature to disable
  124965. * @returns true if disable was successful
  124966. */
  124967. disableFeature(featureName: string | {
  124968. Name: string;
  124969. }): boolean;
  124970. /**
  124971. * dispose this features manager
  124972. */
  124973. dispose(): void;
  124974. /**
  124975. * 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.
  124976. * 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.
  124977. *
  124978. * @param featureName the name of the feature to load or the class of the feature
  124979. * @param version optional version to load. if not provided the latest version will be enabled
  124980. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124981. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124982. * @returns a new constructed feature or throws an error if feature not found.
  124983. */
  124984. enableFeature(featureName: string | {
  124985. Name: string;
  124986. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124987. /**
  124988. * get the implementation of an enabled feature.
  124989. * @param featureName the name of the feature to load
  124990. * @returns the feature class, if found
  124991. */
  124992. getEnabledFeature(featureName: string): IWebXRFeature;
  124993. /**
  124994. * Get the list of enabled features
  124995. * @returns an array of enabled features
  124996. */
  124997. getEnabledFeatures(): string[];
  124998. }
  124999. }
  125000. declare module BABYLON {
  125001. /**
  125002. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125003. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125004. */
  125005. export class WebXRExperienceHelper implements IDisposable {
  125006. private scene;
  125007. private _nonVRCamera;
  125008. private _originalSceneAutoClear;
  125009. private _supported;
  125010. /**
  125011. * Camera used to render xr content
  125012. */
  125013. camera: WebXRCamera;
  125014. /** A features manager for this xr session */
  125015. featuresManager: WebXRFeaturesManager;
  125016. /**
  125017. * Observers registered here will be triggered after the camera's initial transformation is set
  125018. * This can be used to set a different ground level or an extra rotation.
  125019. *
  125020. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125021. * to the position set after this observable is done executing.
  125022. */
  125023. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125024. /**
  125025. * Fires when the state of the experience helper has changed
  125026. */
  125027. onStateChangedObservable: Observable<WebXRState>;
  125028. /** Session manager used to keep track of xr session */
  125029. sessionManager: WebXRSessionManager;
  125030. /**
  125031. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125032. */
  125033. state: WebXRState;
  125034. /**
  125035. * Creates a WebXRExperienceHelper
  125036. * @param scene The scene the helper should be created in
  125037. */
  125038. private constructor();
  125039. /**
  125040. * Creates the experience helper
  125041. * @param scene the scene to attach the experience helper to
  125042. * @returns a promise for the experience helper
  125043. */
  125044. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125045. /**
  125046. * Disposes of the experience helper
  125047. */
  125048. dispose(): void;
  125049. /**
  125050. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125051. * @param sessionMode options for the XR session
  125052. * @param referenceSpaceType frame of reference of the XR session
  125053. * @param renderTarget the output canvas that will be used to enter XR mode
  125054. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125055. * @returns promise that resolves after xr mode has entered
  125056. */
  125057. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125058. /**
  125059. * Exits XR mode and returns the scene to its original state
  125060. * @returns promise that resolves after xr mode has exited
  125061. */
  125062. exitXRAsync(): Promise<void>;
  125063. private _nonXRToXRCamera;
  125064. private _setState;
  125065. }
  125066. }
  125067. declare module BABYLON {
  125068. /**
  125069. * X-Y values for axes in WebXR
  125070. */
  125071. export interface IWebXRMotionControllerAxesValue {
  125072. /**
  125073. * The value of the x axis
  125074. */
  125075. x: number;
  125076. /**
  125077. * The value of the y-axis
  125078. */
  125079. y: number;
  125080. }
  125081. /**
  125082. * changed / previous values for the values of this component
  125083. */
  125084. export interface IWebXRMotionControllerComponentChangesValues<T> {
  125085. /**
  125086. * current (this frame) value
  125087. */
  125088. current: T;
  125089. /**
  125090. * previous (last change) value
  125091. */
  125092. previous: T;
  125093. }
  125094. /**
  125095. * Represents changes in the component between current frame and last values recorded
  125096. */
  125097. export interface IWebXRMotionControllerComponentChanges {
  125098. /**
  125099. * will be populated with previous and current values if axes changed
  125100. */
  125101. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  125102. /**
  125103. * will be populated with previous and current values if pressed changed
  125104. */
  125105. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125106. /**
  125107. * will be populated with previous and current values if touched changed
  125108. */
  125109. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125110. /**
  125111. * will be populated with previous and current values if value changed
  125112. */
  125113. value?: IWebXRMotionControllerComponentChangesValues<number>;
  125114. }
  125115. /**
  125116. * This class represents a single component (for example button or thumbstick) of a motion controller
  125117. */
  125118. export class WebXRControllerComponent implements IDisposable {
  125119. /**
  125120. * the id of this component
  125121. */
  125122. id: string;
  125123. /**
  125124. * the type of the component
  125125. */
  125126. type: MotionControllerComponentType;
  125127. private _buttonIndex;
  125128. private _axesIndices;
  125129. private _axes;
  125130. private _changes;
  125131. private _currentValue;
  125132. private _hasChanges;
  125133. private _pressed;
  125134. private _touched;
  125135. /**
  125136. * button component type
  125137. */
  125138. static BUTTON_TYPE: MotionControllerComponentType;
  125139. /**
  125140. * squeeze component type
  125141. */
  125142. static SQUEEZE_TYPE: MotionControllerComponentType;
  125143. /**
  125144. * Thumbstick component type
  125145. */
  125146. static THUMBSTICK_TYPE: MotionControllerComponentType;
  125147. /**
  125148. * Touchpad component type
  125149. */
  125150. static TOUCHPAD_TYPE: MotionControllerComponentType;
  125151. /**
  125152. * trigger component type
  125153. */
  125154. static TRIGGER_TYPE: MotionControllerComponentType;
  125155. /**
  125156. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  125157. * the axes data changes
  125158. */
  125159. onAxisValueChangedObservable: Observable<{
  125160. x: number;
  125161. y: number;
  125162. }>;
  125163. /**
  125164. * Observers registered here will be triggered when the state of a button changes
  125165. * State change is either pressed / touched / value
  125166. */
  125167. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  125168. /**
  125169. * Creates a new component for a motion controller.
  125170. * It is created by the motion controller itself
  125171. *
  125172. * @param id the id of this component
  125173. * @param type the type of the component
  125174. * @param _buttonIndex index in the buttons array of the gamepad
  125175. * @param _axesIndices indices of the values in the axes array of the gamepad
  125176. */
  125177. constructor(
  125178. /**
  125179. * the id of this component
  125180. */
  125181. id: string,
  125182. /**
  125183. * the type of the component
  125184. */
  125185. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  125186. /**
  125187. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  125188. */
  125189. get axes(): IWebXRMotionControllerAxesValue;
  125190. /**
  125191. * Get the changes. Elements will be populated only if they changed with their previous and current value
  125192. */
  125193. get changes(): IWebXRMotionControllerComponentChanges;
  125194. /**
  125195. * Return whether or not the component changed the last frame
  125196. */
  125197. get hasChanges(): boolean;
  125198. /**
  125199. * is the button currently pressed
  125200. */
  125201. get pressed(): boolean;
  125202. /**
  125203. * is the button currently touched
  125204. */
  125205. get touched(): boolean;
  125206. /**
  125207. * Get the current value of this component
  125208. */
  125209. get value(): number;
  125210. /**
  125211. * Dispose this component
  125212. */
  125213. dispose(): void;
  125214. /**
  125215. * Are there axes correlating to this component
  125216. * @return true is axes data is available
  125217. */
  125218. isAxes(): boolean;
  125219. /**
  125220. * Is this component a button (hence - pressable)
  125221. * @returns true if can be pressed
  125222. */
  125223. isButton(): boolean;
  125224. /**
  125225. * update this component using the gamepad object it is in. Called on every frame
  125226. * @param nativeController the native gamepad controller object
  125227. */
  125228. update(nativeController: IMinimalMotionControllerObject): void;
  125229. }
  125230. }
  125231. declare module BABYLON {
  125232. /**
  125233. * Interface used to represent data loading progression
  125234. */
  125235. export interface ISceneLoaderProgressEvent {
  125236. /**
  125237. * Defines if data length to load can be evaluated
  125238. */
  125239. readonly lengthComputable: boolean;
  125240. /**
  125241. * Defines the loaded data length
  125242. */
  125243. readonly loaded: number;
  125244. /**
  125245. * Defines the data length to load
  125246. */
  125247. readonly total: number;
  125248. }
  125249. /**
  125250. * Interface used by SceneLoader plugins to define supported file extensions
  125251. */
  125252. export interface ISceneLoaderPluginExtensions {
  125253. /**
  125254. * Defines the list of supported extensions
  125255. */
  125256. [extension: string]: {
  125257. isBinary: boolean;
  125258. };
  125259. }
  125260. /**
  125261. * Interface used by SceneLoader plugin factory
  125262. */
  125263. export interface ISceneLoaderPluginFactory {
  125264. /**
  125265. * Defines the name of the factory
  125266. */
  125267. name: string;
  125268. /**
  125269. * Function called to create a new plugin
  125270. * @return the new plugin
  125271. */
  125272. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  125273. /**
  125274. * The callback that returns true if the data can be directly loaded.
  125275. * @param data string containing the file data
  125276. * @returns if the data can be loaded directly
  125277. */
  125278. canDirectLoad?(data: string): boolean;
  125279. }
  125280. /**
  125281. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  125282. */
  125283. export interface ISceneLoaderPluginBase {
  125284. /**
  125285. * The friendly name of this plugin.
  125286. */
  125287. name: string;
  125288. /**
  125289. * The file extensions supported by this plugin.
  125290. */
  125291. extensions: string | ISceneLoaderPluginExtensions;
  125292. /**
  125293. * The callback called when loading from a url.
  125294. * @param scene scene loading this url
  125295. * @param url url to load
  125296. * @param onSuccess callback called when the file successfully loads
  125297. * @param onProgress callback called while file is loading (if the server supports this mode)
  125298. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125299. * @param onError callback called when the file fails to load
  125300. * @returns a file request object
  125301. */
  125302. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125303. /**
  125304. * The callback called when loading from a file object.
  125305. * @param scene scene loading this file
  125306. * @param file defines the file to load
  125307. * @param onSuccess defines the callback to call when data is loaded
  125308. * @param onProgress defines the callback to call during loading process
  125309. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  125310. * @param onError defines the callback to call when an error occurs
  125311. * @returns a file request object
  125312. */
  125313. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125314. /**
  125315. * The callback that returns true if the data can be directly loaded.
  125316. * @param data string containing the file data
  125317. * @returns if the data can be loaded directly
  125318. */
  125319. canDirectLoad?(data: string): boolean;
  125320. /**
  125321. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125322. * @param scene scene loading this data
  125323. * @param data string containing the data
  125324. * @returns data to pass to the plugin
  125325. */
  125326. directLoad?(scene: Scene, data: string): any;
  125327. /**
  125328. * The callback that allows custom handling of the root url based on the response url.
  125329. * @param rootUrl the original root url
  125330. * @param responseURL the response url if available
  125331. * @returns the new root url
  125332. */
  125333. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125334. }
  125335. /**
  125336. * Interface used to define a SceneLoader plugin
  125337. */
  125338. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125339. /**
  125340. * Import meshes into a scene.
  125341. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125342. * @param scene The scene to import into
  125343. * @param data The data to import
  125344. * @param rootUrl The root url for scene and resources
  125345. * @param meshes The meshes array to import into
  125346. * @param particleSystems The particle systems array to import into
  125347. * @param skeletons The skeletons array to import into
  125348. * @param onError The callback when import fails
  125349. * @returns True if successful or false otherwise
  125350. */
  125351. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125352. /**
  125353. * Load into a scene.
  125354. * @param scene The scene to load into
  125355. * @param data The data to import
  125356. * @param rootUrl The root url for scene and resources
  125357. * @param onError The callback when import fails
  125358. * @returns True if successful or false otherwise
  125359. */
  125360. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125361. /**
  125362. * Load into an asset container.
  125363. * @param scene The scene to load into
  125364. * @param data The data to import
  125365. * @param rootUrl The root url for scene and resources
  125366. * @param onError The callback when import fails
  125367. * @returns The loaded asset container
  125368. */
  125369. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125370. }
  125371. /**
  125372. * Interface used to define an async SceneLoader plugin
  125373. */
  125374. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125375. /**
  125376. * Import meshes into a scene.
  125377. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125378. * @param scene The scene to import into
  125379. * @param data The data to import
  125380. * @param rootUrl The root url for scene and resources
  125381. * @param onProgress The callback when the load progresses
  125382. * @param fileName Defines the name of the file to load
  125383. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125384. */
  125385. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125386. meshes: AbstractMesh[];
  125387. particleSystems: IParticleSystem[];
  125388. skeletons: Skeleton[];
  125389. animationGroups: AnimationGroup[];
  125390. }>;
  125391. /**
  125392. * Load into a scene.
  125393. * @param scene The scene to load into
  125394. * @param data The data to import
  125395. * @param rootUrl The root url for scene and resources
  125396. * @param onProgress The callback when the load progresses
  125397. * @param fileName Defines the name of the file to load
  125398. * @returns Nothing
  125399. */
  125400. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125401. /**
  125402. * Load into an asset container.
  125403. * @param scene The scene to load into
  125404. * @param data The data to import
  125405. * @param rootUrl The root url for scene and resources
  125406. * @param onProgress The callback when the load progresses
  125407. * @param fileName Defines the name of the file to load
  125408. * @returns The loaded asset container
  125409. */
  125410. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125411. }
  125412. /**
  125413. * Mode that determines how to handle old animation groups before loading new ones.
  125414. */
  125415. export enum SceneLoaderAnimationGroupLoadingMode {
  125416. /**
  125417. * Reset all old animations to initial state then dispose them.
  125418. */
  125419. Clean = 0,
  125420. /**
  125421. * Stop all old animations.
  125422. */
  125423. Stop = 1,
  125424. /**
  125425. * Restart old animations from first frame.
  125426. */
  125427. Sync = 2,
  125428. /**
  125429. * Old animations remains untouched.
  125430. */
  125431. NoSync = 3
  125432. }
  125433. /**
  125434. * Class used to load scene from various file formats using registered plugins
  125435. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125436. */
  125437. export class SceneLoader {
  125438. /**
  125439. * No logging while loading
  125440. */
  125441. static readonly NO_LOGGING: number;
  125442. /**
  125443. * Minimal logging while loading
  125444. */
  125445. static readonly MINIMAL_LOGGING: number;
  125446. /**
  125447. * Summary logging while loading
  125448. */
  125449. static readonly SUMMARY_LOGGING: number;
  125450. /**
  125451. * Detailled logging while loading
  125452. */
  125453. static readonly DETAILED_LOGGING: number;
  125454. /**
  125455. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125456. */
  125457. static get ForceFullSceneLoadingForIncremental(): boolean;
  125458. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125459. /**
  125460. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125461. */
  125462. static get ShowLoadingScreen(): boolean;
  125463. static set ShowLoadingScreen(value: boolean);
  125464. /**
  125465. * Defines the current logging level (while loading the scene)
  125466. * @ignorenaming
  125467. */
  125468. static get loggingLevel(): number;
  125469. static set loggingLevel(value: number);
  125470. /**
  125471. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125472. */
  125473. static get CleanBoneMatrixWeights(): boolean;
  125474. static set CleanBoneMatrixWeights(value: boolean);
  125475. /**
  125476. * Event raised when a plugin is used to load a scene
  125477. */
  125478. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125479. private static _registeredPlugins;
  125480. private static _showingLoadingScreen;
  125481. private static _getDefaultPlugin;
  125482. private static _getPluginForExtension;
  125483. private static _getPluginForDirectLoad;
  125484. private static _getPluginForFilename;
  125485. private static _getDirectLoad;
  125486. private static _loadData;
  125487. private static _getFileInfo;
  125488. /**
  125489. * Gets a plugin that can load the given extension
  125490. * @param extension defines the extension to load
  125491. * @returns a plugin or null if none works
  125492. */
  125493. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125494. /**
  125495. * Gets a boolean indicating that the given extension can be loaded
  125496. * @param extension defines the extension to load
  125497. * @returns true if the extension is supported
  125498. */
  125499. static IsPluginForExtensionAvailable(extension: string): boolean;
  125500. /**
  125501. * Adds a new plugin to the list of registered plugins
  125502. * @param plugin defines the plugin to add
  125503. */
  125504. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125505. /**
  125506. * Import meshes into a scene
  125507. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125508. * @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)
  125509. * @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)
  125510. * @param scene the instance of BABYLON.Scene to append to
  125511. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125512. * @param onProgress a callback with a progress event for each file being loaded
  125513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125514. * @param pluginExtension the extension used to determine the plugin
  125515. * @returns The loaded plugin
  125516. */
  125517. 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>;
  125518. /**
  125519. * Import meshes into a scene
  125520. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125521. * @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)
  125522. * @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)
  125523. * @param scene the instance of BABYLON.Scene to append to
  125524. * @param onProgress a callback with a progress event for each file being loaded
  125525. * @param pluginExtension the extension used to determine the plugin
  125526. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125527. */
  125528. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125529. meshes: AbstractMesh[];
  125530. particleSystems: IParticleSystem[];
  125531. skeletons: Skeleton[];
  125532. animationGroups: AnimationGroup[];
  125533. }>;
  125534. /**
  125535. * Load a scene
  125536. * @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)
  125537. * @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)
  125538. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125539. * @param onSuccess a callback with the scene when import succeeds
  125540. * @param onProgress a callback with a progress event for each file being loaded
  125541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125542. * @param pluginExtension the extension used to determine the plugin
  125543. * @returns The loaded plugin
  125544. */
  125545. 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>;
  125546. /**
  125547. * Load a scene
  125548. * @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)
  125549. * @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)
  125550. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125551. * @param onProgress a callback with a progress event for each file being loaded
  125552. * @param pluginExtension the extension used to determine the plugin
  125553. * @returns The loaded scene
  125554. */
  125555. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125556. /**
  125557. * Append a scene
  125558. * @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)
  125559. * @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)
  125560. * @param scene is the instance of BABYLON.Scene to append to
  125561. * @param onSuccess a callback with the scene when import succeeds
  125562. * @param onProgress a callback with a progress event for each file being loaded
  125563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125564. * @param pluginExtension the extension used to determine the plugin
  125565. * @returns The loaded plugin
  125566. */
  125567. 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>;
  125568. /**
  125569. * Append a scene
  125570. * @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)
  125571. * @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)
  125572. * @param scene is the instance of BABYLON.Scene to append to
  125573. * @param onProgress a callback with a progress event for each file being loaded
  125574. * @param pluginExtension the extension used to determine the plugin
  125575. * @returns The given scene
  125576. */
  125577. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125578. /**
  125579. * Load a scene into an asset container
  125580. * @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)
  125581. * @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)
  125582. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125583. * @param onSuccess a callback with the scene when import succeeds
  125584. * @param onProgress a callback with a progress event for each file being loaded
  125585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125586. * @param pluginExtension the extension used to determine the plugin
  125587. * @returns The loaded plugin
  125588. */
  125589. 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>;
  125590. /**
  125591. * Load a scene into an asset container
  125592. * @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)
  125593. * @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)
  125594. * @param scene is the instance of Scene to append to
  125595. * @param onProgress a callback with a progress event for each file being loaded
  125596. * @param pluginExtension the extension used to determine the plugin
  125597. * @returns The loaded asset container
  125598. */
  125599. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125600. /**
  125601. * Import animations from a file into a scene
  125602. * @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)
  125603. * @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)
  125604. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125605. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125606. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125607. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125608. * @param onSuccess a callback with the scene when import succeeds
  125609. * @param onProgress a callback with a progress event for each file being loaded
  125610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125611. * @param pluginExtension the extension used to determine the plugin
  125612. */
  125613. 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;
  125614. /**
  125615. * Import animations from a file into a scene
  125616. * @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)
  125617. * @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)
  125618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125619. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125620. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125621. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125622. * @param onSuccess a callback with the scene when import succeeds
  125623. * @param onProgress a callback with a progress event for each file being loaded
  125624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125625. * @param pluginExtension the extension used to determine the plugin
  125626. * @returns the updated scene with imported animations
  125627. */
  125628. 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>;
  125629. }
  125630. }
  125631. declare module BABYLON {
  125632. /**
  125633. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125634. */
  125635. export type MotionControllerHandedness = "none" | "left" | "right";
  125636. /**
  125637. * The type of components available in motion controllers.
  125638. * This is not the name of the component.
  125639. */
  125640. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125641. /**
  125642. * The state of a controller component
  125643. */
  125644. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125645. /**
  125646. * The schema of motion controller layout.
  125647. * No object will be initialized using this interface
  125648. * This is used just to define the profile.
  125649. */
  125650. export interface IMotionControllerLayout {
  125651. /**
  125652. * Path to load the assets. Usually relative to the base path
  125653. */
  125654. assetPath: string;
  125655. /**
  125656. * Available components (unsorted)
  125657. */
  125658. components: {
  125659. /**
  125660. * A map of component Ids
  125661. */
  125662. [componentId: string]: {
  125663. /**
  125664. * The type of input the component outputs
  125665. */
  125666. type: MotionControllerComponentType;
  125667. /**
  125668. * The indices of this component in the gamepad object
  125669. */
  125670. gamepadIndices: {
  125671. /**
  125672. * Index of button
  125673. */
  125674. button?: number;
  125675. /**
  125676. * If available, index of x-axis
  125677. */
  125678. xAxis?: number;
  125679. /**
  125680. * If available, index of y-axis
  125681. */
  125682. yAxis?: number;
  125683. };
  125684. /**
  125685. * The mesh's root node name
  125686. */
  125687. rootNodeName: string;
  125688. /**
  125689. * Animation definitions for this model
  125690. */
  125691. visualResponses: {
  125692. [stateKey: string]: {
  125693. /**
  125694. * What property will be animated
  125695. */
  125696. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125697. /**
  125698. * What states influence this visual response
  125699. */
  125700. states: MotionControllerComponentStateType[];
  125701. /**
  125702. * Type of animation - movement or visibility
  125703. */
  125704. valueNodeProperty: "transform" | "visibility";
  125705. /**
  125706. * Base node name to move. Its position will be calculated according to the min and max nodes
  125707. */
  125708. valueNodeName?: string;
  125709. /**
  125710. * Minimum movement node
  125711. */
  125712. minNodeName?: string;
  125713. /**
  125714. * Max movement node
  125715. */
  125716. maxNodeName?: string;
  125717. };
  125718. };
  125719. /**
  125720. * If touch enabled, what is the name of node to display user feedback
  125721. */
  125722. touchPointNodeName?: string;
  125723. };
  125724. };
  125725. /**
  125726. * Is it xr standard mapping or not
  125727. */
  125728. gamepadMapping: "" | "xr-standard";
  125729. /**
  125730. * Base root node of this entire model
  125731. */
  125732. rootNodeName: string;
  125733. /**
  125734. * Defines the main button component id
  125735. */
  125736. selectComponentId: string;
  125737. }
  125738. /**
  125739. * A definition for the layout map in the input profile
  125740. */
  125741. export interface IMotionControllerLayoutMap {
  125742. /**
  125743. * Layouts with handedness type as a key
  125744. */
  125745. [handedness: string]: IMotionControllerLayout;
  125746. }
  125747. /**
  125748. * The XR Input profile schema
  125749. * Profiles can be found here:
  125750. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125751. */
  125752. export interface IMotionControllerProfile {
  125753. /**
  125754. * fallback profiles for this profileId
  125755. */
  125756. fallbackProfileIds: string[];
  125757. /**
  125758. * The layout map, with handedness as key
  125759. */
  125760. layouts: IMotionControllerLayoutMap;
  125761. /**
  125762. * The id of this profile
  125763. * correlates to the profile(s) in the xrInput.profiles array
  125764. */
  125765. profileId: string;
  125766. }
  125767. /**
  125768. * A helper-interface for the 3 meshes needed for controller button animation
  125769. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125770. */
  125771. export interface IMotionControllerButtonMeshMap {
  125772. /**
  125773. * the mesh that defines the pressed value mesh position.
  125774. * This is used to find the max-position of this button
  125775. */
  125776. pressedMesh: AbstractMesh;
  125777. /**
  125778. * the mesh that defines the unpressed value mesh position.
  125779. * This is used to find the min (or initial) position of this button
  125780. */
  125781. unpressedMesh: AbstractMesh;
  125782. /**
  125783. * The mesh that will be changed when value changes
  125784. */
  125785. valueMesh: AbstractMesh;
  125786. }
  125787. /**
  125788. * A helper-interface for the 3 meshes needed for controller axis animation.
  125789. * This will be expanded when touchpad animations are fully supported
  125790. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125791. */
  125792. export interface IMotionControllerMeshMap {
  125793. /**
  125794. * the mesh that defines the maximum value mesh position.
  125795. */
  125796. maxMesh?: AbstractMesh;
  125797. /**
  125798. * the mesh that defines the minimum value mesh position.
  125799. */
  125800. minMesh?: AbstractMesh;
  125801. /**
  125802. * The mesh that will be changed when axis value changes
  125803. */
  125804. valueMesh: AbstractMesh;
  125805. }
  125806. /**
  125807. * The elements needed for change-detection of the gamepad objects in motion controllers
  125808. */
  125809. export interface IMinimalMotionControllerObject {
  125810. /**
  125811. * Available axes of this controller
  125812. */
  125813. axes: number[];
  125814. /**
  125815. * An array of available buttons
  125816. */
  125817. buttons: Array<{
  125818. /**
  125819. * Value of the button/trigger
  125820. */
  125821. value: number;
  125822. /**
  125823. * If the button/trigger is currently touched
  125824. */
  125825. touched: boolean;
  125826. /**
  125827. * If the button/trigger is currently pressed
  125828. */
  125829. pressed: boolean;
  125830. }>;
  125831. /**
  125832. * EXPERIMENTAL haptic support.
  125833. */
  125834. hapticActuators?: Array<{
  125835. pulse: (value: number, duration: number) => Promise<boolean>;
  125836. }>;
  125837. }
  125838. /**
  125839. * An Abstract Motion controller
  125840. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125841. * Each component has an observable to check for changes in value and state
  125842. */
  125843. export abstract class WebXRAbstractMotionController implements IDisposable {
  125844. protected scene: Scene;
  125845. protected layout: IMotionControllerLayout;
  125846. /**
  125847. * The gamepad object correlating to this controller
  125848. */
  125849. gamepadObject: IMinimalMotionControllerObject;
  125850. /**
  125851. * handedness (left/right/none) of this controller
  125852. */
  125853. handedness: MotionControllerHandedness;
  125854. private _initComponent;
  125855. private _modelReady;
  125856. /**
  125857. * A map of components (WebXRControllerComponent) in this motion controller
  125858. * Components have a ComponentType and can also have both button and axis definitions
  125859. */
  125860. readonly components: {
  125861. [id: string]: WebXRControllerComponent;
  125862. };
  125863. /**
  125864. * Disable the model's animation. Can be set at any time.
  125865. */
  125866. disableAnimation: boolean;
  125867. /**
  125868. * Observers registered here will be triggered when the model of this controller is done loading
  125869. */
  125870. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125871. /**
  125872. * The profile id of this motion controller
  125873. */
  125874. abstract profileId: string;
  125875. /**
  125876. * The root mesh of the model. It is null if the model was not yet initialized
  125877. */
  125878. rootMesh: Nullable<AbstractMesh>;
  125879. /**
  125880. * constructs a new abstract motion controller
  125881. * @param scene the scene to which the model of the controller will be added
  125882. * @param layout The profile layout to load
  125883. * @param gamepadObject The gamepad object correlating to this controller
  125884. * @param handedness handedness (left/right/none) of this controller
  125885. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125886. */
  125887. constructor(scene: Scene, layout: IMotionControllerLayout,
  125888. /**
  125889. * The gamepad object correlating to this controller
  125890. */
  125891. gamepadObject: IMinimalMotionControllerObject,
  125892. /**
  125893. * handedness (left/right/none) of this controller
  125894. */
  125895. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125896. /**
  125897. * Dispose this controller, the model mesh and all its components
  125898. */
  125899. dispose(): void;
  125900. /**
  125901. * Returns all components of specific type
  125902. * @param type the type to search for
  125903. * @return an array of components with this type
  125904. */
  125905. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125906. /**
  125907. * get a component based an its component id as defined in layout.components
  125908. * @param id the id of the component
  125909. * @returns the component correlates to the id or undefined if not found
  125910. */
  125911. getComponent(id: string): WebXRControllerComponent;
  125912. /**
  125913. * Get the list of components available in this motion controller
  125914. * @returns an array of strings correlating to available components
  125915. */
  125916. getComponentIds(): string[];
  125917. /**
  125918. * Get the first component of specific type
  125919. * @param type type of component to find
  125920. * @return a controller component or null if not found
  125921. */
  125922. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125923. /**
  125924. * Get the main (Select) component of this controller as defined in the layout
  125925. * @returns the main component of this controller
  125926. */
  125927. getMainComponent(): WebXRControllerComponent;
  125928. /**
  125929. * Loads the model correlating to this controller
  125930. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125931. * @returns A promise fulfilled with the result of the model loading
  125932. */
  125933. loadModel(): Promise<boolean>;
  125934. /**
  125935. * Update this model using the current XRFrame
  125936. * @param xrFrame the current xr frame to use and update the model
  125937. */
  125938. updateFromXRFrame(xrFrame: XRFrame): void;
  125939. /**
  125940. * Backwards compatibility due to a deeply-integrated typo
  125941. */
  125942. get handness(): XREye;
  125943. /**
  125944. * Pulse (vibrate) this controller
  125945. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125946. * Consecutive calls to this function will cancel the last pulse call
  125947. *
  125948. * @param value the strength of the pulse in 0.0...1.0 range
  125949. * @param duration Duration of the pulse in milliseconds
  125950. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125951. * @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
  125952. */
  125953. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125954. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125955. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125956. /**
  125957. * Moves the axis on the controller mesh based on its current state
  125958. * @param axis the index of the axis
  125959. * @param axisValue the value of the axis which determines the meshes new position
  125960. * @hidden
  125961. */
  125962. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125963. /**
  125964. * Update the model itself with the current frame data
  125965. * @param xrFrame the frame to use for updating the model mesh
  125966. */
  125967. protected updateModel(xrFrame: XRFrame): void;
  125968. /**
  125969. * Get the filename and path for this controller's model
  125970. * @returns a map of filename and path
  125971. */
  125972. protected abstract _getFilenameAndPath(): {
  125973. filename: string;
  125974. path: string;
  125975. };
  125976. /**
  125977. * This function is called before the mesh is loaded. It checks for loading constraints.
  125978. * For example, this function can check if the GLB loader is available
  125979. * If this function returns false, the generic controller will be loaded instead
  125980. * @returns Is the client ready to load the mesh
  125981. */
  125982. protected abstract _getModelLoadingConstraints(): boolean;
  125983. /**
  125984. * This function will be called after the model was successfully loaded and can be used
  125985. * for mesh transformations before it is available for the user
  125986. * @param meshes the loaded meshes
  125987. */
  125988. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125989. /**
  125990. * Set the root mesh for this controller. Important for the WebXR controller class
  125991. * @param meshes the loaded meshes
  125992. */
  125993. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125994. /**
  125995. * A function executed each frame that updates the mesh (if needed)
  125996. * @param xrFrame the current xrFrame
  125997. */
  125998. protected abstract _updateModel(xrFrame: XRFrame): void;
  125999. private _getGenericFilenameAndPath;
  126000. private _getGenericParentMesh;
  126001. }
  126002. }
  126003. declare module BABYLON {
  126004. /**
  126005. * A generic trigger-only motion controller for WebXR
  126006. */
  126007. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126008. /**
  126009. * Static version of the profile id of this controller
  126010. */
  126011. static ProfileId: string;
  126012. profileId: string;
  126013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126014. protected _getFilenameAndPath(): {
  126015. filename: string;
  126016. path: string;
  126017. };
  126018. protected _getModelLoadingConstraints(): boolean;
  126019. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126020. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126021. protected _updateModel(): void;
  126022. }
  126023. }
  126024. declare module BABYLON {
  126025. /**
  126026. * Class containing static functions to help procedurally build meshes
  126027. */
  126028. export class SphereBuilder {
  126029. /**
  126030. * Creates a sphere mesh
  126031. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126032. * * 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`)
  126033. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126034. * * 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
  126035. * * 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)
  126036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126039. * @param name defines the name of the mesh
  126040. * @param options defines the options used to create the mesh
  126041. * @param scene defines the hosting scene
  126042. * @returns the sphere mesh
  126043. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126044. */
  126045. static CreateSphere(name: string, options: {
  126046. segments?: number;
  126047. diameter?: number;
  126048. diameterX?: number;
  126049. diameterY?: number;
  126050. diameterZ?: number;
  126051. arc?: number;
  126052. slice?: number;
  126053. sideOrientation?: number;
  126054. frontUVs?: Vector4;
  126055. backUVs?: Vector4;
  126056. updatable?: boolean;
  126057. }, scene?: Nullable<Scene>): Mesh;
  126058. }
  126059. }
  126060. declare module BABYLON {
  126061. /**
  126062. * A profiled motion controller has its profile loaded from an online repository.
  126063. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  126064. */
  126065. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  126066. private _repositoryUrl;
  126067. private _buttonMeshMapping;
  126068. private _touchDots;
  126069. /**
  126070. * The profile ID of this controller. Will be populated when the controller initializes.
  126071. */
  126072. profileId: string;
  126073. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  126074. dispose(): void;
  126075. protected _getFilenameAndPath(): {
  126076. filename: string;
  126077. path: string;
  126078. };
  126079. protected _getModelLoadingConstraints(): boolean;
  126080. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  126081. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126082. protected _updateModel(_xrFrame: XRFrame): void;
  126083. }
  126084. }
  126085. declare module BABYLON {
  126086. /**
  126087. * A construction function type to create a new controller based on an xrInput object
  126088. */
  126089. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  126090. /**
  126091. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  126092. *
  126093. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  126094. * it should be replaced with auto-loaded controllers.
  126095. *
  126096. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  126097. */
  126098. export class WebXRMotionControllerManager {
  126099. private static _AvailableControllers;
  126100. private static _Fallbacks;
  126101. private static _ProfileLoadingPromises;
  126102. private static _ProfilesList;
  126103. /**
  126104. * The base URL of the online controller repository. Can be changed at any time.
  126105. */
  126106. static BaseRepositoryUrl: string;
  126107. /**
  126108. * Which repository gets priority - local or online
  126109. */
  126110. static PrioritizeOnlineRepository: boolean;
  126111. /**
  126112. * Use the online repository, or use only locally-defined controllers
  126113. */
  126114. static UseOnlineRepository: boolean;
  126115. /**
  126116. * Clear the cache used for profile loading and reload when requested again
  126117. */
  126118. static ClearProfilesCache(): void;
  126119. /**
  126120. * Register the default fallbacks.
  126121. * This function is called automatically when this file is imported.
  126122. */
  126123. static DefaultFallbacks(): void;
  126124. /**
  126125. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  126126. * @param profileId the profile to which a fallback needs to be found
  126127. * @return an array with corresponding fallback profiles
  126128. */
  126129. static FindFallbackWithProfileId(profileId: string): string[];
  126130. /**
  126131. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  126132. * The order of search:
  126133. *
  126134. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  126135. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  126136. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  126137. * 4) return the generic trigger controller if none were found
  126138. *
  126139. * @param xrInput the xrInput to which a new controller is initialized
  126140. * @param scene the scene to which the model will be added
  126141. * @param forceProfile force a certain profile for this controller
  126142. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  126143. */
  126144. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  126145. /**
  126146. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  126147. *
  126148. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  126149. *
  126150. * @param type the profile type to register
  126151. * @param constructFunction the function to be called when loading this profile
  126152. */
  126153. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  126154. /**
  126155. * Register a fallback to a specific profile.
  126156. * @param profileId the profileId that will receive the fallbacks
  126157. * @param fallbacks A list of fallback profiles
  126158. */
  126159. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  126160. /**
  126161. * Will update the list of profiles available in the repository
  126162. * @return a promise that resolves to a map of profiles available online
  126163. */
  126164. static UpdateProfilesList(): Promise<{
  126165. [profile: string]: string;
  126166. }>;
  126167. private static _LoadProfileFromRepository;
  126168. private static _LoadProfilesFromAvailableControllers;
  126169. }
  126170. }
  126171. declare module BABYLON {
  126172. /**
  126173. * Configuration options for the WebXR controller creation
  126174. */
  126175. export interface IWebXRControllerOptions {
  126176. /**
  126177. * Should the controller mesh be animated when a user interacts with it
  126178. * The pressed buttons / thumbstick and touchpad animations will be disabled
  126179. */
  126180. disableMotionControllerAnimation?: boolean;
  126181. /**
  126182. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  126183. */
  126184. doNotLoadControllerMesh?: boolean;
  126185. /**
  126186. * Force a specific controller type for this controller.
  126187. * This can be used when creating your own profile or when testing different controllers
  126188. */
  126189. forceControllerProfile?: string;
  126190. /**
  126191. * Defines a rendering group ID for meshes that will be loaded.
  126192. * This is for the default controllers only.
  126193. */
  126194. renderingGroupId?: number;
  126195. }
  126196. /**
  126197. * Represents an XR controller
  126198. */
  126199. export class WebXRInputSource {
  126200. private _scene;
  126201. /** The underlying input source for the controller */
  126202. inputSource: XRInputSource;
  126203. private _options;
  126204. private _tmpVector;
  126205. private _uniqueId;
  126206. /**
  126207. * 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
  126208. */
  126209. grip?: AbstractMesh;
  126210. /**
  126211. * If available, this is the gamepad object related to this controller.
  126212. * Using this object it is possible to get click events and trackpad changes of the
  126213. * webxr controller that is currently being used.
  126214. */
  126215. motionController?: WebXRAbstractMotionController;
  126216. /**
  126217. * Event that fires when the controller is removed/disposed.
  126218. * The object provided as event data is this controller, after associated assets were disposed.
  126219. * uniqueId is still available.
  126220. */
  126221. onDisposeObservable: Observable<WebXRInputSource>;
  126222. /**
  126223. * Will be triggered when the mesh associated with the motion controller is done loading.
  126224. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  126225. * A shortened version of controller -> motion controller -> on mesh loaded.
  126226. */
  126227. onMeshLoadedObservable: Observable<AbstractMesh>;
  126228. /**
  126229. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  126230. */
  126231. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  126232. /**
  126233. * Pointer which can be used to select objects or attach a visible laser to
  126234. */
  126235. pointer: AbstractMesh;
  126236. /**
  126237. * Creates the input source object
  126238. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  126239. * @param _scene the scene which the controller should be associated to
  126240. * @param inputSource the underlying input source for the controller
  126241. * @param _options options for this controller creation
  126242. */
  126243. constructor(_scene: Scene,
  126244. /** The underlying input source for the controller */
  126245. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  126246. /**
  126247. * Get this controllers unique id
  126248. */
  126249. get uniqueId(): string;
  126250. /**
  126251. * Disposes of the object
  126252. */
  126253. dispose(): void;
  126254. /**
  126255. * Gets a world space ray coming from the pointer or grip
  126256. * @param result the resulting ray
  126257. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  126258. */
  126259. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  126260. /**
  126261. * Updates the controller pose based on the given XRFrame
  126262. * @param xrFrame xr frame to update the pose with
  126263. * @param referenceSpace reference space to use
  126264. */
  126265. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  126266. }
  126267. }
  126268. declare module BABYLON {
  126269. /**
  126270. * The schema for initialization options of the XR Input class
  126271. */
  126272. export interface IWebXRInputOptions {
  126273. /**
  126274. * If set to true no model will be automatically loaded
  126275. */
  126276. doNotLoadControllerMeshes?: boolean;
  126277. /**
  126278. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  126279. * If not found, the xr input profile data will be used.
  126280. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  126281. */
  126282. forceInputProfile?: string;
  126283. /**
  126284. * Do not send a request to the controller repository to load the profile.
  126285. *
  126286. * Instead, use the controllers available in babylon itself.
  126287. */
  126288. disableOnlineControllerRepository?: boolean;
  126289. /**
  126290. * A custom URL for the controllers repository
  126291. */
  126292. customControllersRepositoryURL?: string;
  126293. /**
  126294. * Should the controller model's components not move according to the user input
  126295. */
  126296. disableControllerAnimation?: boolean;
  126297. /**
  126298. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  126299. */
  126300. controllerOptions?: IWebXRControllerOptions;
  126301. }
  126302. /**
  126303. * XR input used to track XR inputs such as controllers/rays
  126304. */
  126305. export class WebXRInput implements IDisposable {
  126306. /**
  126307. * the xr session manager for this session
  126308. */
  126309. xrSessionManager: WebXRSessionManager;
  126310. /**
  126311. * the WebXR camera for this session. Mainly used for teleportation
  126312. */
  126313. xrCamera: WebXRCamera;
  126314. private readonly options;
  126315. /**
  126316. * XR controllers being tracked
  126317. */
  126318. controllers: Array<WebXRInputSource>;
  126319. private _frameObserver;
  126320. private _sessionEndedObserver;
  126321. private _sessionInitObserver;
  126322. /**
  126323. * Event when a controller has been connected/added
  126324. */
  126325. onControllerAddedObservable: Observable<WebXRInputSource>;
  126326. /**
  126327. * Event when a controller has been removed/disconnected
  126328. */
  126329. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126330. /**
  126331. * Initializes the WebXRInput
  126332. * @param xrSessionManager the xr session manager for this session
  126333. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126334. * @param options = initialization options for this xr input
  126335. */
  126336. constructor(
  126337. /**
  126338. * the xr session manager for this session
  126339. */
  126340. xrSessionManager: WebXRSessionManager,
  126341. /**
  126342. * the WebXR camera for this session. Mainly used for teleportation
  126343. */
  126344. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126345. private _onInputSourcesChange;
  126346. private _addAndRemoveControllers;
  126347. /**
  126348. * Disposes of the object
  126349. */
  126350. dispose(): void;
  126351. }
  126352. }
  126353. declare module BABYLON {
  126354. /**
  126355. * This is the base class for all WebXR features.
  126356. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126357. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126358. */
  126359. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126360. protected _xrSessionManager: WebXRSessionManager;
  126361. private _attached;
  126362. private _removeOnDetach;
  126363. /**
  126364. * Should auto-attach be disabled?
  126365. */
  126366. disableAutoAttach: boolean;
  126367. /**
  126368. * Construct a new (abstract) WebXR feature
  126369. * @param _xrSessionManager the xr session manager for this feature
  126370. */
  126371. constructor(_xrSessionManager: WebXRSessionManager);
  126372. /**
  126373. * Is this feature attached
  126374. */
  126375. get attached(): boolean;
  126376. /**
  126377. * attach this feature
  126378. *
  126379. * @param force should attachment be forced (even when already attached)
  126380. * @returns true if successful, false is failed or already attached
  126381. */
  126382. attach(force?: boolean): boolean;
  126383. /**
  126384. * detach this feature.
  126385. *
  126386. * @returns true if successful, false if failed or already detached
  126387. */
  126388. detach(): boolean;
  126389. /**
  126390. * Dispose this feature and all of the resources attached
  126391. */
  126392. dispose(): void;
  126393. /**
  126394. * This is used to register callbacks that will automatically be removed when detach is called.
  126395. * @param observable the observable to which the observer will be attached
  126396. * @param callback the callback to register
  126397. */
  126398. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126399. /**
  126400. * Code in this function will be executed on each xrFrame received from the browser.
  126401. * This function will not execute after the feature is detached.
  126402. * @param _xrFrame the current frame
  126403. */
  126404. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. /**
  126409. * Renders a layer on top of an existing scene
  126410. */
  126411. export class UtilityLayerRenderer implements IDisposable {
  126412. /** the original scene that will be rendered on top of */
  126413. originalScene: Scene;
  126414. private _pointerCaptures;
  126415. private _lastPointerEvents;
  126416. private static _DefaultUtilityLayer;
  126417. private static _DefaultKeepDepthUtilityLayer;
  126418. private _sharedGizmoLight;
  126419. private _renderCamera;
  126420. /**
  126421. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126422. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126423. * @returns the camera that is used when rendering the utility layer
  126424. */
  126425. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126426. /**
  126427. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126428. * @param cam the camera that should be used when rendering the utility layer
  126429. */
  126430. setRenderCamera(cam: Nullable<Camera>): void;
  126431. /**
  126432. * @hidden
  126433. * Light which used by gizmos to get light shading
  126434. */
  126435. _getSharedGizmoLight(): HemisphericLight;
  126436. /**
  126437. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126438. */
  126439. pickUtilitySceneFirst: boolean;
  126440. /**
  126441. * 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)
  126442. */
  126443. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126444. /**
  126445. * 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)
  126446. */
  126447. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126448. /**
  126449. * The scene that is rendered on top of the original scene
  126450. */
  126451. utilityLayerScene: Scene;
  126452. /**
  126453. * If the utility layer should automatically be rendered on top of existing scene
  126454. */
  126455. shouldRender: boolean;
  126456. /**
  126457. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126458. */
  126459. onlyCheckPointerDownEvents: boolean;
  126460. /**
  126461. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126462. */
  126463. processAllEvents: boolean;
  126464. /**
  126465. * Observable raised when the pointer move from the utility layer scene to the main scene
  126466. */
  126467. onPointerOutObservable: Observable<number>;
  126468. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126469. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126470. private _afterRenderObserver;
  126471. private _sceneDisposeObserver;
  126472. private _originalPointerObserver;
  126473. /**
  126474. * Instantiates a UtilityLayerRenderer
  126475. * @param originalScene the original scene that will be rendered on top of
  126476. * @param handleEvents boolean indicating if the utility layer should handle events
  126477. */
  126478. constructor(
  126479. /** the original scene that will be rendered on top of */
  126480. originalScene: Scene, handleEvents?: boolean);
  126481. private _notifyObservers;
  126482. /**
  126483. * Renders the utility layers scene on top of the original scene
  126484. */
  126485. render(): void;
  126486. /**
  126487. * Disposes of the renderer
  126488. */
  126489. dispose(): void;
  126490. private _updateCamera;
  126491. }
  126492. }
  126493. declare module BABYLON {
  126494. /**
  126495. * Options interface for the pointer selection module
  126496. */
  126497. export interface IWebXRControllerPointerSelectionOptions {
  126498. /**
  126499. * if provided, this scene will be used to render meshes.
  126500. */
  126501. customUtilityLayerScene?: Scene;
  126502. /**
  126503. * 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)
  126504. * If not disabled, the last picked point will be used to execute a pointer up event
  126505. * If disabled, pointer up event will be triggered right after the pointer down event.
  126506. * Used in screen and gaze target ray mode only
  126507. */
  126508. disablePointerUpOnTouchOut: boolean;
  126509. /**
  126510. * For gaze mode (time to select instead of press)
  126511. */
  126512. forceGazeMode: boolean;
  126513. /**
  126514. * 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
  126515. * to start a new countdown to the pointer down event.
  126516. * Defaults to 1.
  126517. */
  126518. gazeModePointerMovedFactor?: number;
  126519. /**
  126520. * Different button type to use instead of the main component
  126521. */
  126522. overrideButtonId?: string;
  126523. /**
  126524. * use this rendering group id for the meshes (optional)
  126525. */
  126526. renderingGroupId?: number;
  126527. /**
  126528. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126529. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126530. * 3000 means 3 seconds between pointing at something and selecting it
  126531. */
  126532. timeToSelect?: number;
  126533. /**
  126534. * Should meshes created here be added to a utility layer or the main scene
  126535. */
  126536. useUtilityLayer?: boolean;
  126537. /**
  126538. * the xr input to use with this pointer selection
  126539. */
  126540. xrInput: WebXRInput;
  126541. }
  126542. /**
  126543. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126544. */
  126545. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126546. private readonly _options;
  126547. private static _idCounter;
  126548. private _attachController;
  126549. private _controllers;
  126550. private _scene;
  126551. private _tmpVectorForPickCompare;
  126552. /**
  126553. * The module's name
  126554. */
  126555. static readonly Name: string;
  126556. /**
  126557. * The (Babylon) version of this module.
  126558. * This is an integer representing the implementation version.
  126559. * This number does not correspond to the WebXR specs version
  126560. */
  126561. static readonly Version: number;
  126562. /**
  126563. * Disable lighting on the laser pointer (so it will always be visible)
  126564. */
  126565. disablePointerLighting: boolean;
  126566. /**
  126567. * Disable lighting on the selection mesh (so it will always be visible)
  126568. */
  126569. disableSelectionMeshLighting: boolean;
  126570. /**
  126571. * Should the laser pointer be displayed
  126572. */
  126573. displayLaserPointer: boolean;
  126574. /**
  126575. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126576. */
  126577. displaySelectionMesh: boolean;
  126578. /**
  126579. * This color will be set to the laser pointer when selection is triggered
  126580. */
  126581. laserPointerPickedColor: Color3;
  126582. /**
  126583. * Default color of the laser pointer
  126584. */
  126585. laserPointerDefaultColor: Color3;
  126586. /**
  126587. * default color of the selection ring
  126588. */
  126589. selectionMeshDefaultColor: Color3;
  126590. /**
  126591. * This color will be applied to the selection ring when selection is triggered
  126592. */
  126593. selectionMeshPickedColor: Color3;
  126594. /**
  126595. * Optional filter to be used for ray selection. This predicate shares behavior with
  126596. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126597. */
  126598. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126599. /**
  126600. * constructs a new background remover module
  126601. * @param _xrSessionManager the session manager for this module
  126602. * @param _options read-only options to be used in this module
  126603. */
  126604. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126605. /**
  126606. * attach this feature
  126607. * Will usually be called by the features manager
  126608. *
  126609. * @returns true if successful.
  126610. */
  126611. attach(): boolean;
  126612. /**
  126613. * detach this feature.
  126614. * Will usually be called by the features manager
  126615. *
  126616. * @returns true if successful.
  126617. */
  126618. detach(): boolean;
  126619. /**
  126620. * Will get the mesh under a specific pointer.
  126621. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126622. * @param controllerId the controllerId to check
  126623. * @returns The mesh under pointer or null if no mesh is under the pointer
  126624. */
  126625. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126626. /**
  126627. * Get the xr controller that correlates to the pointer id in the pointer event
  126628. *
  126629. * @param id the pointer id to search for
  126630. * @returns the controller that correlates to this id or null if not found
  126631. */
  126632. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126633. protected _onXRFrame(_xrFrame: XRFrame): void;
  126634. private _attachGazeMode;
  126635. private _attachScreenRayMode;
  126636. private _attachTrackedPointerRayMode;
  126637. private _convertNormalToDirectionOfRay;
  126638. private _detachController;
  126639. private _generateNewMeshPair;
  126640. private _pickingMoved;
  126641. private _updatePointerDistance;
  126642. /** @hidden */
  126643. get lasterPointerDefaultColor(): Color3;
  126644. }
  126645. }
  126646. declare module BABYLON {
  126647. /**
  126648. * Button which can be used to enter a different mode of XR
  126649. */
  126650. export class WebXREnterExitUIButton {
  126651. /** button element */
  126652. element: HTMLElement;
  126653. /** XR initialization options for the button */
  126654. sessionMode: XRSessionMode;
  126655. /** Reference space type */
  126656. referenceSpaceType: XRReferenceSpaceType;
  126657. /**
  126658. * Creates a WebXREnterExitUIButton
  126659. * @param element button element
  126660. * @param sessionMode XR initialization session mode
  126661. * @param referenceSpaceType the type of reference space to be used
  126662. */
  126663. constructor(
  126664. /** button element */
  126665. element: HTMLElement,
  126666. /** XR initialization options for the button */
  126667. sessionMode: XRSessionMode,
  126668. /** Reference space type */
  126669. referenceSpaceType: XRReferenceSpaceType);
  126670. /**
  126671. * Extendable function which can be used to update the button's visuals when the state changes
  126672. * @param activeButton the current active button in the UI
  126673. */
  126674. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126675. }
  126676. /**
  126677. * Options to create the webXR UI
  126678. */
  126679. export class WebXREnterExitUIOptions {
  126680. /**
  126681. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126682. */
  126683. customButtons?: Array<WebXREnterExitUIButton>;
  126684. /**
  126685. * A reference space type to use when creating the default button.
  126686. * Default is local-floor
  126687. */
  126688. referenceSpaceType?: XRReferenceSpaceType;
  126689. /**
  126690. * Context to enter xr with
  126691. */
  126692. renderTarget?: Nullable<WebXRRenderTarget>;
  126693. /**
  126694. * A session mode to use when creating the default button.
  126695. * Default is immersive-vr
  126696. */
  126697. sessionMode?: XRSessionMode;
  126698. /**
  126699. * A list of optional features to init the session with
  126700. */
  126701. optionalFeatures?: string[];
  126702. /**
  126703. * A list of optional features to init the session with
  126704. */
  126705. requiredFeatures?: string[];
  126706. }
  126707. /**
  126708. * UI to allow the user to enter/exit XR mode
  126709. */
  126710. export class WebXREnterExitUI implements IDisposable {
  126711. private scene;
  126712. /** version of the options passed to this UI */
  126713. options: WebXREnterExitUIOptions;
  126714. private _activeButton;
  126715. private _buttons;
  126716. private _overlay;
  126717. /**
  126718. * Fired every time the active button is changed.
  126719. *
  126720. * When xr is entered via a button that launches xr that button will be the callback parameter
  126721. *
  126722. * When exiting xr the callback parameter will be null)
  126723. */
  126724. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126725. /**
  126726. *
  126727. * @param scene babylon scene object to use
  126728. * @param options (read-only) version of the options passed to this UI
  126729. */
  126730. private constructor();
  126731. /**
  126732. * Creates UI to allow the user to enter/exit XR mode
  126733. * @param scene the scene to add the ui to
  126734. * @param helper the xr experience helper to enter/exit xr with
  126735. * @param options options to configure the UI
  126736. * @returns the created ui
  126737. */
  126738. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126739. /**
  126740. * Disposes of the XR UI component
  126741. */
  126742. dispose(): void;
  126743. private _updateButtons;
  126744. }
  126745. }
  126746. declare module BABYLON {
  126747. /**
  126748. * Class containing static functions to help procedurally build meshes
  126749. */
  126750. export class LinesBuilder {
  126751. /**
  126752. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126753. * * 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
  126754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126755. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126756. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126757. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126759. * * 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
  126760. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126763. * @param name defines the name of the new line system
  126764. * @param options defines the options used to create the line system
  126765. * @param scene defines the hosting scene
  126766. * @returns a new line system mesh
  126767. */
  126768. static CreateLineSystem(name: string, options: {
  126769. lines: Vector3[][];
  126770. updatable?: boolean;
  126771. instance?: Nullable<LinesMesh>;
  126772. colors?: Nullable<Color4[][]>;
  126773. useVertexAlpha?: boolean;
  126774. }, scene: Nullable<Scene>): LinesMesh;
  126775. /**
  126776. * Creates a line mesh
  126777. * 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
  126778. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126779. * * The parameter `points` is an array successive Vector3
  126780. * * 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
  126781. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126782. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126783. * * When updating an instance, remember that only point positions can change, not the number of points
  126784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126786. * @param name defines the name of the new line system
  126787. * @param options defines the options used to create the line system
  126788. * @param scene defines the hosting scene
  126789. * @returns a new line mesh
  126790. */
  126791. static CreateLines(name: string, options: {
  126792. points: Vector3[];
  126793. updatable?: boolean;
  126794. instance?: Nullable<LinesMesh>;
  126795. colors?: Color4[];
  126796. useVertexAlpha?: boolean;
  126797. }, scene?: Nullable<Scene>): LinesMesh;
  126798. /**
  126799. * Creates a dashed line mesh
  126800. * * 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
  126801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126802. * * The parameter `points` is an array successive Vector3
  126803. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126804. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126805. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126806. * * 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
  126807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126808. * * When updating an instance, remember that only point positions can change, not the number of points
  126809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126810. * @param name defines the name of the mesh
  126811. * @param options defines the options used to create the mesh
  126812. * @param scene defines the hosting scene
  126813. * @returns the dashed line mesh
  126814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126815. */
  126816. static CreateDashedLines(name: string, options: {
  126817. points: Vector3[];
  126818. dashSize?: number;
  126819. gapSize?: number;
  126820. dashNb?: number;
  126821. updatable?: boolean;
  126822. instance?: LinesMesh;
  126823. useVertexAlpha?: boolean;
  126824. }, scene?: Nullable<Scene>): LinesMesh;
  126825. }
  126826. }
  126827. declare module BABYLON {
  126828. /**
  126829. * Construction options for a timer
  126830. */
  126831. export interface ITimerOptions<T> {
  126832. /**
  126833. * Time-to-end
  126834. */
  126835. timeout: number;
  126836. /**
  126837. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126838. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126839. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126840. */
  126841. contextObservable: Observable<T>;
  126842. /**
  126843. * Optional parameters when adding an observer to the observable
  126844. */
  126845. observableParameters?: {
  126846. mask?: number;
  126847. insertFirst?: boolean;
  126848. scope?: any;
  126849. };
  126850. /**
  126851. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126852. */
  126853. breakCondition?: (data?: ITimerData<T>) => boolean;
  126854. /**
  126855. * Will be triggered when the time condition has met
  126856. */
  126857. onEnded?: (data: ITimerData<any>) => void;
  126858. /**
  126859. * Will be triggered when the break condition has met (prematurely ended)
  126860. */
  126861. onAborted?: (data: ITimerData<any>) => void;
  126862. /**
  126863. * Optional function to execute on each tick (or count)
  126864. */
  126865. onTick?: (data: ITimerData<any>) => void;
  126866. }
  126867. /**
  126868. * An interface defining the data sent by the timer
  126869. */
  126870. export interface ITimerData<T> {
  126871. /**
  126872. * When did it start
  126873. */
  126874. startTime: number;
  126875. /**
  126876. * Time now
  126877. */
  126878. currentTime: number;
  126879. /**
  126880. * Time passed since started
  126881. */
  126882. deltaTime: number;
  126883. /**
  126884. * How much is completed, in [0.0...1.0].
  126885. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126886. */
  126887. completeRate: number;
  126888. /**
  126889. * What the registered observable sent in the last count
  126890. */
  126891. payload: T;
  126892. }
  126893. /**
  126894. * The current state of the timer
  126895. */
  126896. export enum TimerState {
  126897. /**
  126898. * Timer initialized, not yet started
  126899. */
  126900. INIT = 0,
  126901. /**
  126902. * Timer started and counting
  126903. */
  126904. STARTED = 1,
  126905. /**
  126906. * Timer ended (whether aborted or time reached)
  126907. */
  126908. ENDED = 2
  126909. }
  126910. /**
  126911. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126912. *
  126913. * @param options options with which to initialize this timer
  126914. */
  126915. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126916. /**
  126917. * An advanced implementation of a timer class
  126918. */
  126919. export class AdvancedTimer<T = any> implements IDisposable {
  126920. /**
  126921. * Will notify each time the timer calculates the remaining time
  126922. */
  126923. onEachCountObservable: Observable<ITimerData<T>>;
  126924. /**
  126925. * Will trigger when the timer was aborted due to the break condition
  126926. */
  126927. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126928. /**
  126929. * Will trigger when the timer ended successfully
  126930. */
  126931. onTimerEndedObservable: Observable<ITimerData<T>>;
  126932. /**
  126933. * Will trigger when the timer state has changed
  126934. */
  126935. onStateChangedObservable: Observable<TimerState>;
  126936. private _observer;
  126937. private _contextObservable;
  126938. private _observableParameters;
  126939. private _startTime;
  126940. private _timer;
  126941. private _state;
  126942. private _breakCondition;
  126943. private _timeToEnd;
  126944. private _breakOnNextTick;
  126945. /**
  126946. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126947. * @param options construction options for this advanced timer
  126948. */
  126949. constructor(options: ITimerOptions<T>);
  126950. /**
  126951. * set a breaking condition for this timer. Default is to never break during count
  126952. * @param predicate the new break condition. Returns true to break, false otherwise
  126953. */
  126954. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126955. /**
  126956. * Reset ALL associated observables in this advanced timer
  126957. */
  126958. clearObservables(): void;
  126959. /**
  126960. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126961. *
  126962. * @param timeToEnd how much time to measure until timer ended
  126963. */
  126964. start(timeToEnd?: number): void;
  126965. /**
  126966. * Will force a stop on the next tick.
  126967. */
  126968. stop(): void;
  126969. /**
  126970. * Dispose this timer, clearing all resources
  126971. */
  126972. dispose(): void;
  126973. private _setState;
  126974. private _tick;
  126975. private _stop;
  126976. }
  126977. }
  126978. declare module BABYLON {
  126979. /**
  126980. * The options container for the teleportation module
  126981. */
  126982. export interface IWebXRTeleportationOptions {
  126983. /**
  126984. * if provided, this scene will be used to render meshes.
  126985. */
  126986. customUtilityLayerScene?: Scene;
  126987. /**
  126988. * Values to configure the default target mesh
  126989. */
  126990. defaultTargetMeshOptions?: {
  126991. /**
  126992. * Fill color of the teleportation area
  126993. */
  126994. teleportationFillColor?: string;
  126995. /**
  126996. * Border color for the teleportation area
  126997. */
  126998. teleportationBorderColor?: string;
  126999. /**
  127000. * Disable the mesh's animation sequence
  127001. */
  127002. disableAnimation?: boolean;
  127003. /**
  127004. * Disable lighting on the material or the ring and arrow
  127005. */
  127006. disableLighting?: boolean;
  127007. /**
  127008. * Override the default material of the torus and arrow
  127009. */
  127010. torusArrowMaterial?: Material;
  127011. };
  127012. /**
  127013. * A list of meshes to use as floor meshes.
  127014. * Meshes can be added and removed after initializing the feature using the
  127015. * addFloorMesh and removeFloorMesh functions
  127016. * If empty, rotation will still work
  127017. */
  127018. floorMeshes?: AbstractMesh[];
  127019. /**
  127020. * use this rendering group id for the meshes (optional)
  127021. */
  127022. renderingGroupId?: number;
  127023. /**
  127024. * Should teleportation move only to snap points
  127025. */
  127026. snapPointsOnly?: boolean;
  127027. /**
  127028. * An array of points to which the teleportation will snap to.
  127029. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  127030. */
  127031. snapPositions?: Vector3[];
  127032. /**
  127033. * How close should the teleportation ray be in order to snap to position.
  127034. * Default to 0.8 units (meters)
  127035. */
  127036. snapToPositionRadius?: number;
  127037. /**
  127038. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  127039. * If you want to support rotation, make sure your mesh has a direction indicator.
  127040. *
  127041. * When left untouched, the default mesh will be initialized.
  127042. */
  127043. teleportationTargetMesh?: AbstractMesh;
  127044. /**
  127045. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  127046. */
  127047. timeToTeleport?: number;
  127048. /**
  127049. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  127050. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  127051. */
  127052. useMainComponentOnly?: boolean;
  127053. /**
  127054. * Should meshes created here be added to a utility layer or the main scene
  127055. */
  127056. useUtilityLayer?: boolean;
  127057. /**
  127058. * Babylon XR Input class for controller
  127059. */
  127060. xrInput: WebXRInput;
  127061. }
  127062. /**
  127063. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  127064. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  127065. * the input of the attached controllers.
  127066. */
  127067. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  127068. private _options;
  127069. private _controllers;
  127070. private _currentTeleportationControllerId;
  127071. private _floorMeshes;
  127072. private _quadraticBezierCurve;
  127073. private _selectionFeature;
  127074. private _snapToPositions;
  127075. private _snappedToPoint;
  127076. private _teleportationRingMaterial?;
  127077. private _tmpRay;
  127078. private _tmpVector;
  127079. /**
  127080. * The module's name
  127081. */
  127082. static readonly Name: string;
  127083. /**
  127084. * The (Babylon) version of this module.
  127085. * This is an integer representing the implementation version.
  127086. * This number does not correspond to the webxr specs version
  127087. */
  127088. static readonly Version: number;
  127089. /**
  127090. * Is movement backwards enabled
  127091. */
  127092. backwardsMovementEnabled: boolean;
  127093. /**
  127094. * Distance to travel when moving backwards
  127095. */
  127096. backwardsTeleportationDistance: number;
  127097. /**
  127098. * The distance from the user to the inspection point in the direction of the controller
  127099. * A higher number will allow the user to move further
  127100. * defaults to 5 (meters, in xr units)
  127101. */
  127102. parabolicCheckRadius: number;
  127103. /**
  127104. * Should the module support parabolic ray on top of direct ray
  127105. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  127106. * Very helpful when moving between floors / different heights
  127107. */
  127108. parabolicRayEnabled: boolean;
  127109. /**
  127110. * How much rotation should be applied when rotating right and left
  127111. */
  127112. rotationAngle: number;
  127113. /**
  127114. * Is rotation enabled when moving forward?
  127115. * Disabling this feature will prevent the user from deciding the direction when teleporting
  127116. */
  127117. rotationEnabled: boolean;
  127118. /**
  127119. * constructs a new anchor system
  127120. * @param _xrSessionManager an instance of WebXRSessionManager
  127121. * @param _options configuration object for this feature
  127122. */
  127123. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  127124. /**
  127125. * Get the snapPointsOnly flag
  127126. */
  127127. get snapPointsOnly(): boolean;
  127128. /**
  127129. * Sets the snapPointsOnly flag
  127130. * @param snapToPoints should teleportation be exclusively to snap points
  127131. */
  127132. set snapPointsOnly(snapToPoints: boolean);
  127133. /**
  127134. * Add a new mesh to the floor meshes array
  127135. * @param mesh the mesh to use as floor mesh
  127136. */
  127137. addFloorMesh(mesh: AbstractMesh): void;
  127138. /**
  127139. * Add a new snap-to point to fix teleportation to this position
  127140. * @param newSnapPoint The new Snap-To point
  127141. */
  127142. addSnapPoint(newSnapPoint: Vector3): void;
  127143. attach(): boolean;
  127144. detach(): boolean;
  127145. dispose(): void;
  127146. /**
  127147. * Remove a mesh from the floor meshes array
  127148. * @param mesh the mesh to remove
  127149. */
  127150. removeFloorMesh(mesh: AbstractMesh): void;
  127151. /**
  127152. * Remove a mesh from the floor meshes array using its name
  127153. * @param name the mesh name to remove
  127154. */
  127155. removeFloorMeshByName(name: string): void;
  127156. /**
  127157. * 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
  127158. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  127159. * @returns was the point found and removed or not
  127160. */
  127161. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  127162. /**
  127163. * This function sets a selection feature that will be disabled when
  127164. * the forward ray is shown and will be reattached when hidden.
  127165. * This is used to remove the selection rays when moving.
  127166. * @param selectionFeature the feature to disable when forward movement is enabled
  127167. */
  127168. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  127169. protected _onXRFrame(_xrFrame: XRFrame): void;
  127170. private _attachController;
  127171. private _createDefaultTargetMesh;
  127172. private _detachController;
  127173. private _findClosestSnapPointWithRadius;
  127174. private _setTargetMeshPosition;
  127175. private _setTargetMeshVisibility;
  127176. private _showParabolicPath;
  127177. private _teleportForward;
  127178. }
  127179. }
  127180. declare module BABYLON {
  127181. /**
  127182. * Options for the default xr helper
  127183. */
  127184. export class WebXRDefaultExperienceOptions {
  127185. /**
  127186. * Enable or disable default UI to enter XR
  127187. */
  127188. disableDefaultUI?: boolean;
  127189. /**
  127190. * Should teleportation not initialize. defaults to false.
  127191. */
  127192. disableTeleportation?: boolean;
  127193. /**
  127194. * Floor meshes that will be used for teleport
  127195. */
  127196. floorMeshes?: Array<AbstractMesh>;
  127197. /**
  127198. * If set to true, the first frame will not be used to reset position
  127199. * The first frame is mainly used when copying transformation from the old camera
  127200. * Mainly used in AR
  127201. */
  127202. ignoreNativeCameraTransformation?: boolean;
  127203. /**
  127204. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  127205. */
  127206. inputOptions?: IWebXRInputOptions;
  127207. /**
  127208. * optional configuration for the output canvas
  127209. */
  127210. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  127211. /**
  127212. * optional UI options. This can be used among other to change session mode and reference space type
  127213. */
  127214. uiOptions?: WebXREnterExitUIOptions;
  127215. /**
  127216. * When loading teleportation and pointer select, use stable versions instead of latest.
  127217. */
  127218. useStablePlugins?: boolean;
  127219. /**
  127220. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  127221. */
  127222. renderingGroupId?: number;
  127223. /**
  127224. * A list of optional features to init the session with
  127225. * If set to true, all features we support will be added
  127226. */
  127227. optionalFeatures?: boolean | string[];
  127228. }
  127229. /**
  127230. * Default experience which provides a similar setup to the previous webVRExperience
  127231. */
  127232. export class WebXRDefaultExperience {
  127233. /**
  127234. * Base experience
  127235. */
  127236. baseExperience: WebXRExperienceHelper;
  127237. /**
  127238. * Enables ui for entering/exiting xr
  127239. */
  127240. enterExitUI: WebXREnterExitUI;
  127241. /**
  127242. * Input experience extension
  127243. */
  127244. input: WebXRInput;
  127245. /**
  127246. * Enables laser pointer and selection
  127247. */
  127248. pointerSelection: WebXRControllerPointerSelection;
  127249. /**
  127250. * Default target xr should render to
  127251. */
  127252. renderTarget: WebXRRenderTarget;
  127253. /**
  127254. * Enables teleportation
  127255. */
  127256. teleportation: WebXRMotionControllerTeleportation;
  127257. private constructor();
  127258. /**
  127259. * Creates the default xr experience
  127260. * @param scene scene
  127261. * @param options options for basic configuration
  127262. * @returns resulting WebXRDefaultExperience
  127263. */
  127264. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127265. /**
  127266. * DIsposes of the experience helper
  127267. */
  127268. dispose(): void;
  127269. }
  127270. }
  127271. declare module BABYLON {
  127272. /**
  127273. * Options to modify the vr teleportation behavior.
  127274. */
  127275. export interface VRTeleportationOptions {
  127276. /**
  127277. * The name of the mesh which should be used as the teleportation floor. (default: null)
  127278. */
  127279. floorMeshName?: string;
  127280. /**
  127281. * A list of meshes to be used as the teleportation floor. (default: empty)
  127282. */
  127283. floorMeshes?: Mesh[];
  127284. /**
  127285. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  127286. */
  127287. teleportationMode?: number;
  127288. /**
  127289. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  127290. */
  127291. teleportationTime?: number;
  127292. /**
  127293. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  127294. */
  127295. teleportationSpeed?: number;
  127296. /**
  127297. * The easing function used in the animation or null for Linear. (default CircleEase)
  127298. */
  127299. easingFunction?: EasingFunction;
  127300. }
  127301. /**
  127302. * Options to modify the vr experience helper's behavior.
  127303. */
  127304. export interface VRExperienceHelperOptions extends WebVROptions {
  127305. /**
  127306. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  127307. */
  127308. createDeviceOrientationCamera?: boolean;
  127309. /**
  127310. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  127311. */
  127312. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  127313. /**
  127314. * Uses the main button on the controller to toggle the laser casted. (default: true)
  127315. */
  127316. laserToggle?: boolean;
  127317. /**
  127318. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  127319. */
  127320. floorMeshes?: Mesh[];
  127321. /**
  127322. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127323. */
  127324. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127325. /**
  127326. * Defines if WebXR should be used instead of WebVR (if available)
  127327. */
  127328. useXR?: boolean;
  127329. }
  127330. /**
  127331. * Event containing information after VR has been entered
  127332. */
  127333. export class OnAfterEnteringVRObservableEvent {
  127334. /**
  127335. * If entering vr was successful
  127336. */
  127337. success: boolean;
  127338. }
  127339. /**
  127340. * Helps to quickly add VR support to an existing scene.
  127341. * See https://doc.babylonjs.com/how_to/webvr_helper
  127342. */
  127343. export class VRExperienceHelper {
  127344. /** Options to modify the vr experience helper's behavior. */
  127345. webVROptions: VRExperienceHelperOptions;
  127346. private _scene;
  127347. private _position;
  127348. private _btnVR;
  127349. private _btnVRDisplayed;
  127350. private _webVRsupported;
  127351. private _webVRready;
  127352. private _webVRrequesting;
  127353. private _webVRpresenting;
  127354. private _hasEnteredVR;
  127355. private _fullscreenVRpresenting;
  127356. private _inputElement;
  127357. private _webVRCamera;
  127358. private _vrDeviceOrientationCamera;
  127359. private _deviceOrientationCamera;
  127360. private _existingCamera;
  127361. private _onKeyDown;
  127362. private _onVrDisplayPresentChange;
  127363. private _onVRDisplayChanged;
  127364. private _onVRRequestPresentStart;
  127365. private _onVRRequestPresentComplete;
  127366. /**
  127367. * 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)
  127368. */
  127369. enableGazeEvenWhenNoPointerLock: boolean;
  127370. /**
  127371. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127372. */
  127373. exitVROnDoubleTap: boolean;
  127374. /**
  127375. * Observable raised right before entering VR.
  127376. */
  127377. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127378. /**
  127379. * Observable raised when entering VR has completed.
  127380. */
  127381. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127382. /**
  127383. * Observable raised when exiting VR.
  127384. */
  127385. onExitingVRObservable: Observable<VRExperienceHelper>;
  127386. /**
  127387. * Observable raised when controller mesh is loaded.
  127388. */
  127389. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127390. /** Return this.onEnteringVRObservable
  127391. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127392. */
  127393. get onEnteringVR(): Observable<VRExperienceHelper>;
  127394. /** Return this.onExitingVRObservable
  127395. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127396. */
  127397. get onExitingVR(): Observable<VRExperienceHelper>;
  127398. /** Return this.onControllerMeshLoadedObservable
  127399. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127400. */
  127401. get onControllerMeshLoaded(): Observable<WebVRController>;
  127402. private _rayLength;
  127403. private _useCustomVRButton;
  127404. private _teleportationRequested;
  127405. private _teleportActive;
  127406. private _floorMeshName;
  127407. private _floorMeshesCollection;
  127408. private _teleportationMode;
  127409. private _teleportationTime;
  127410. private _teleportationSpeed;
  127411. private _teleportationEasing;
  127412. private _rotationAllowed;
  127413. private _teleportBackwardsVector;
  127414. private _teleportationTarget;
  127415. private _isDefaultTeleportationTarget;
  127416. private _postProcessMove;
  127417. private _teleportationFillColor;
  127418. private _teleportationBorderColor;
  127419. private _rotationAngle;
  127420. private _haloCenter;
  127421. private _cameraGazer;
  127422. private _padSensibilityUp;
  127423. private _padSensibilityDown;
  127424. private _leftController;
  127425. private _rightController;
  127426. private _gazeColor;
  127427. private _laserColor;
  127428. private _pickedLaserColor;
  127429. private _pickedGazeColor;
  127430. /**
  127431. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127432. */
  127433. onNewMeshSelected: Observable<AbstractMesh>;
  127434. /**
  127435. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127436. * This observable will provide the mesh and the controller used to select the mesh
  127437. */
  127438. onMeshSelectedWithController: Observable<{
  127439. mesh: AbstractMesh;
  127440. controller: WebVRController;
  127441. }>;
  127442. /**
  127443. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127444. */
  127445. onNewMeshPicked: Observable<PickingInfo>;
  127446. private _circleEase;
  127447. /**
  127448. * Observable raised before camera teleportation
  127449. */
  127450. onBeforeCameraTeleport: Observable<Vector3>;
  127451. /**
  127452. * Observable raised after camera teleportation
  127453. */
  127454. onAfterCameraTeleport: Observable<Vector3>;
  127455. /**
  127456. * Observable raised when current selected mesh gets unselected
  127457. */
  127458. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127459. private _raySelectionPredicate;
  127460. /**
  127461. * To be optionaly changed by user to define custom ray selection
  127462. */
  127463. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127464. /**
  127465. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127466. */
  127467. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127468. /**
  127469. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127470. */
  127471. teleportationEnabled: boolean;
  127472. private _defaultHeight;
  127473. private _teleportationInitialized;
  127474. private _interactionsEnabled;
  127475. private _interactionsRequested;
  127476. private _displayGaze;
  127477. private _displayLaserPointer;
  127478. /**
  127479. * The mesh used to display where the user is going to teleport.
  127480. */
  127481. get teleportationTarget(): Mesh;
  127482. /**
  127483. * Sets the mesh to be used to display where the user is going to teleport.
  127484. */
  127485. set teleportationTarget(value: Mesh);
  127486. /**
  127487. * 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
  127488. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127489. * See https://doc.babylonjs.com/resources/baking_transformations
  127490. */
  127491. get gazeTrackerMesh(): Mesh;
  127492. set gazeTrackerMesh(value: Mesh);
  127493. /**
  127494. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127495. */
  127496. updateGazeTrackerScale: boolean;
  127497. /**
  127498. * If the gaze trackers color should be updated when selecting meshes
  127499. */
  127500. updateGazeTrackerColor: boolean;
  127501. /**
  127502. * If the controller laser color should be updated when selecting meshes
  127503. */
  127504. updateControllerLaserColor: boolean;
  127505. /**
  127506. * The gaze tracking mesh corresponding to the left controller
  127507. */
  127508. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127509. /**
  127510. * The gaze tracking mesh corresponding to the right controller
  127511. */
  127512. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127513. /**
  127514. * If the ray of the gaze should be displayed.
  127515. */
  127516. get displayGaze(): boolean;
  127517. /**
  127518. * Sets if the ray of the gaze should be displayed.
  127519. */
  127520. set displayGaze(value: boolean);
  127521. /**
  127522. * If the ray of the LaserPointer should be displayed.
  127523. */
  127524. get displayLaserPointer(): boolean;
  127525. /**
  127526. * Sets if the ray of the LaserPointer should be displayed.
  127527. */
  127528. set displayLaserPointer(value: boolean);
  127529. /**
  127530. * The deviceOrientationCamera used as the camera when not in VR.
  127531. */
  127532. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127533. /**
  127534. * Based on the current WebVR support, returns the current VR camera used.
  127535. */
  127536. get currentVRCamera(): Nullable<Camera>;
  127537. /**
  127538. * The webVRCamera which is used when in VR.
  127539. */
  127540. get webVRCamera(): WebVRFreeCamera;
  127541. /**
  127542. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127543. */
  127544. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127545. /**
  127546. * The html button that is used to trigger entering into VR.
  127547. */
  127548. get vrButton(): Nullable<HTMLButtonElement>;
  127549. private get _teleportationRequestInitiated();
  127550. /**
  127551. * Defines whether or not Pointer lock should be requested when switching to
  127552. * full screen.
  127553. */
  127554. requestPointerLockOnFullScreen: boolean;
  127555. /**
  127556. * If asking to force XR, this will be populated with the default xr experience
  127557. */
  127558. xr: WebXRDefaultExperience;
  127559. /**
  127560. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127561. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127562. */
  127563. xrTestDone: boolean;
  127564. /**
  127565. * Instantiates a VRExperienceHelper.
  127566. * Helps to quickly add VR support to an existing scene.
  127567. * @param scene The scene the VRExperienceHelper belongs to.
  127568. * @param webVROptions Options to modify the vr experience helper's behavior.
  127569. */
  127570. constructor(scene: Scene,
  127571. /** Options to modify the vr experience helper's behavior. */
  127572. webVROptions?: VRExperienceHelperOptions);
  127573. private completeVRInit;
  127574. private _onDefaultMeshLoaded;
  127575. private _onResize;
  127576. private _onFullscreenChange;
  127577. /**
  127578. * Gets a value indicating if we are currently in VR mode.
  127579. */
  127580. get isInVRMode(): boolean;
  127581. private onVrDisplayPresentChange;
  127582. private onVRDisplayChanged;
  127583. private moveButtonToBottomRight;
  127584. private displayVRButton;
  127585. private updateButtonVisibility;
  127586. private _cachedAngularSensibility;
  127587. /**
  127588. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127589. * Otherwise, will use the fullscreen API.
  127590. */
  127591. enterVR(): void;
  127592. /**
  127593. * Attempt to exit VR, or fullscreen.
  127594. */
  127595. exitVR(): void;
  127596. /**
  127597. * The position of the vr experience helper.
  127598. */
  127599. get position(): Vector3;
  127600. /**
  127601. * Sets the position of the vr experience helper.
  127602. */
  127603. set position(value: Vector3);
  127604. /**
  127605. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127606. */
  127607. enableInteractions(): void;
  127608. private get _noControllerIsActive();
  127609. private beforeRender;
  127610. private _isTeleportationFloor;
  127611. /**
  127612. * Adds a floor mesh to be used for teleportation.
  127613. * @param floorMesh the mesh to be used for teleportation.
  127614. */
  127615. addFloorMesh(floorMesh: Mesh): void;
  127616. /**
  127617. * Removes a floor mesh from being used for teleportation.
  127618. * @param floorMesh the mesh to be removed.
  127619. */
  127620. removeFloorMesh(floorMesh: Mesh): void;
  127621. /**
  127622. * Enables interactions and teleportation using the VR controllers and gaze.
  127623. * @param vrTeleportationOptions options to modify teleportation behavior.
  127624. */
  127625. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127626. private _onNewGamepadConnected;
  127627. private _tryEnableInteractionOnController;
  127628. private _onNewGamepadDisconnected;
  127629. private _enableInteractionOnController;
  127630. private _checkTeleportWithRay;
  127631. private _checkRotate;
  127632. private _checkTeleportBackwards;
  127633. private _enableTeleportationOnController;
  127634. private _createTeleportationCircles;
  127635. private _displayTeleportationTarget;
  127636. private _hideTeleportationTarget;
  127637. private _rotateCamera;
  127638. private _moveTeleportationSelectorTo;
  127639. private _workingVector;
  127640. private _workingQuaternion;
  127641. private _workingMatrix;
  127642. /**
  127643. * Time Constant Teleportation Mode
  127644. */
  127645. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127646. /**
  127647. * Speed Constant Teleportation Mode
  127648. */
  127649. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127650. /**
  127651. * Teleports the users feet to the desired location
  127652. * @param location The location where the user's feet should be placed
  127653. */
  127654. teleportCamera(location: Vector3): void;
  127655. private _convertNormalToDirectionOfRay;
  127656. private _castRayAndSelectObject;
  127657. private _notifySelectedMeshUnselected;
  127658. /**
  127659. * Permanently set new colors for the laser pointer
  127660. * @param color the new laser color
  127661. * @param pickedColor the new laser color when picked mesh detected
  127662. */
  127663. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127664. /**
  127665. * Set lighting enabled / disabled on the laser pointer of both controllers
  127666. * @param enabled should the lighting be enabled on the laser pointer
  127667. */
  127668. setLaserLightingState(enabled?: boolean): void;
  127669. /**
  127670. * Permanently set new colors for the gaze pointer
  127671. * @param color the new gaze color
  127672. * @param pickedColor the new gaze color when picked mesh detected
  127673. */
  127674. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127675. /**
  127676. * Sets the color of the laser ray from the vr controllers.
  127677. * @param color new color for the ray.
  127678. */
  127679. changeLaserColor(color: Color3): void;
  127680. /**
  127681. * Sets the color of the ray from the vr headsets gaze.
  127682. * @param color new color for the ray.
  127683. */
  127684. changeGazeColor(color: Color3): void;
  127685. /**
  127686. * Exits VR and disposes of the vr experience helper
  127687. */
  127688. dispose(): void;
  127689. /**
  127690. * Gets the name of the VRExperienceHelper class
  127691. * @returns "VRExperienceHelper"
  127692. */
  127693. getClassName(): string;
  127694. }
  127695. }
  127696. declare module BABYLON {
  127697. /**
  127698. * Contains an array of blocks representing the octree
  127699. */
  127700. export interface IOctreeContainer<T> {
  127701. /**
  127702. * Blocks within the octree
  127703. */
  127704. blocks: Array<OctreeBlock<T>>;
  127705. }
  127706. /**
  127707. * Class used to store a cell in an octree
  127708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127709. */
  127710. export class OctreeBlock<T> {
  127711. /**
  127712. * Gets the content of the current block
  127713. */
  127714. entries: T[];
  127715. /**
  127716. * Gets the list of block children
  127717. */
  127718. blocks: Array<OctreeBlock<T>>;
  127719. private _depth;
  127720. private _maxDepth;
  127721. private _capacity;
  127722. private _minPoint;
  127723. private _maxPoint;
  127724. private _boundingVectors;
  127725. private _creationFunc;
  127726. /**
  127727. * Creates a new block
  127728. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127729. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127730. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127731. * @param depth defines the current depth of this block in the octree
  127732. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127733. * @param creationFunc defines a callback to call when an element is added to the block
  127734. */
  127735. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127736. /**
  127737. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127738. */
  127739. get capacity(): number;
  127740. /**
  127741. * Gets the minimum vector (in world space) of the block's bounding box
  127742. */
  127743. get minPoint(): Vector3;
  127744. /**
  127745. * Gets the maximum vector (in world space) of the block's bounding box
  127746. */
  127747. get maxPoint(): Vector3;
  127748. /**
  127749. * Add a new element to this block
  127750. * @param entry defines the element to add
  127751. */
  127752. addEntry(entry: T): void;
  127753. /**
  127754. * Remove an element from this block
  127755. * @param entry defines the element to remove
  127756. */
  127757. removeEntry(entry: T): void;
  127758. /**
  127759. * Add an array of elements to this block
  127760. * @param entries defines the array of elements to add
  127761. */
  127762. addEntries(entries: T[]): void;
  127763. /**
  127764. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127765. * @param frustumPlanes defines the frustum planes to test
  127766. * @param selection defines the array to store current content if selection is positive
  127767. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127768. */
  127769. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127770. /**
  127771. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127772. * @param sphereCenter defines the bounding sphere center
  127773. * @param sphereRadius defines the bounding sphere radius
  127774. * @param selection defines the array to store current content if selection is positive
  127775. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127776. */
  127777. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127778. /**
  127779. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127780. * @param ray defines the ray to test with
  127781. * @param selection defines the array to store current content if selection is positive
  127782. */
  127783. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127784. /**
  127785. * Subdivide the content into child blocks (this block will then be empty)
  127786. */
  127787. createInnerBlocks(): void;
  127788. /**
  127789. * @hidden
  127790. */
  127791. 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;
  127792. }
  127793. }
  127794. declare module BABYLON {
  127795. /**
  127796. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127797. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127798. */
  127799. export class Octree<T> {
  127800. /** 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.) */
  127801. maxDepth: number;
  127802. /**
  127803. * Blocks within the octree containing objects
  127804. */
  127805. blocks: Array<OctreeBlock<T>>;
  127806. /**
  127807. * Content stored in the octree
  127808. */
  127809. dynamicContent: T[];
  127810. private _maxBlockCapacity;
  127811. private _selectionContent;
  127812. private _creationFunc;
  127813. /**
  127814. * Creates a octree
  127815. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127816. * @param creationFunc function to be used to instatiate the octree
  127817. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127818. * @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.)
  127819. */
  127820. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127821. /** 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.) */
  127822. maxDepth?: number);
  127823. /**
  127824. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127825. * @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);
  127826. * @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);
  127827. * @param entries meshes to be added to the octree blocks
  127828. */
  127829. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127830. /**
  127831. * Adds a mesh to the octree
  127832. * @param entry Mesh to add to the octree
  127833. */
  127834. addMesh(entry: T): void;
  127835. /**
  127836. * Remove an element from the octree
  127837. * @param entry defines the element to remove
  127838. */
  127839. removeMesh(entry: T): void;
  127840. /**
  127841. * Selects an array of meshes within the frustum
  127842. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127843. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127844. * @returns array of meshes within the frustum
  127845. */
  127846. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127847. /**
  127848. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127849. * @param sphereCenter defines the bounding sphere center
  127850. * @param sphereRadius defines the bounding sphere radius
  127851. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127852. * @returns an array of objects that intersect the sphere
  127853. */
  127854. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127855. /**
  127856. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127857. * @param ray defines the ray to test with
  127858. * @returns array of intersected objects
  127859. */
  127860. intersectsRay(ray: Ray): SmartArray<T>;
  127861. /**
  127862. * Adds a mesh into the octree block if it intersects the block
  127863. */
  127864. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127865. /**
  127866. * Adds a submesh into the octree block if it intersects the block
  127867. */
  127868. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127869. }
  127870. }
  127871. declare module BABYLON {
  127872. interface Scene {
  127873. /**
  127874. * @hidden
  127875. * Backing Filed
  127876. */
  127877. _selectionOctree: Octree<AbstractMesh>;
  127878. /**
  127879. * Gets the octree used to boost mesh selection (picking)
  127880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127881. */
  127882. selectionOctree: Octree<AbstractMesh>;
  127883. /**
  127884. * Creates or updates the octree used to boost selection (picking)
  127885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127886. * @param maxCapacity defines the maximum capacity per leaf
  127887. * @param maxDepth defines the maximum depth of the octree
  127888. * @returns an octree of AbstractMesh
  127889. */
  127890. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127891. }
  127892. interface AbstractMesh {
  127893. /**
  127894. * @hidden
  127895. * Backing Field
  127896. */
  127897. _submeshesOctree: Octree<SubMesh>;
  127898. /**
  127899. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127900. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127901. * @param maxCapacity defines the maximum size of each block (64 by default)
  127902. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127903. * @returns the new octree
  127904. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127906. */
  127907. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127908. }
  127909. /**
  127910. * Defines the octree scene component responsible to manage any octrees
  127911. * in a given scene.
  127912. */
  127913. export class OctreeSceneComponent {
  127914. /**
  127915. * The component name help to identify the component in the list of scene components.
  127916. */
  127917. readonly name: string;
  127918. /**
  127919. * The scene the component belongs to.
  127920. */
  127921. scene: Scene;
  127922. /**
  127923. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127924. */
  127925. readonly checksIsEnabled: boolean;
  127926. /**
  127927. * Creates a new instance of the component for the given scene
  127928. * @param scene Defines the scene to register the component in
  127929. */
  127930. constructor(scene: Scene);
  127931. /**
  127932. * Registers the component in a given scene
  127933. */
  127934. register(): void;
  127935. /**
  127936. * Return the list of active meshes
  127937. * @returns the list of active meshes
  127938. */
  127939. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127940. /**
  127941. * Return the list of active sub meshes
  127942. * @param mesh The mesh to get the candidates sub meshes from
  127943. * @returns the list of active sub meshes
  127944. */
  127945. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127946. private _tempRay;
  127947. /**
  127948. * Return the list of sub meshes intersecting with a given local ray
  127949. * @param mesh defines the mesh to find the submesh for
  127950. * @param localRay defines the ray in local space
  127951. * @returns the list of intersecting sub meshes
  127952. */
  127953. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127954. /**
  127955. * Return the list of sub meshes colliding with a collider
  127956. * @param mesh defines the mesh to find the submesh for
  127957. * @param collider defines the collider to evaluate the collision against
  127958. * @returns the list of colliding sub meshes
  127959. */
  127960. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127961. /**
  127962. * Rebuilds the elements related to this component in case of
  127963. * context lost for instance.
  127964. */
  127965. rebuild(): void;
  127966. /**
  127967. * Disposes the component and the associated ressources.
  127968. */
  127969. dispose(): void;
  127970. }
  127971. }
  127972. declare module BABYLON {
  127973. /**
  127974. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127975. */
  127976. export class Gizmo implements IDisposable {
  127977. /** The utility layer the gizmo will be added to */
  127978. gizmoLayer: UtilityLayerRenderer;
  127979. /**
  127980. * The root mesh of the gizmo
  127981. */
  127982. _rootMesh: Mesh;
  127983. private _attachedMesh;
  127984. private _attachedNode;
  127985. /**
  127986. * Ratio for the scale of the gizmo (Default: 1)
  127987. */
  127988. scaleRatio: number;
  127989. /**
  127990. * If a custom mesh has been set (Default: false)
  127991. */
  127992. protected _customMeshSet: boolean;
  127993. /**
  127994. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127995. * * When set, interactions will be enabled
  127996. */
  127997. get attachedMesh(): Nullable<AbstractMesh>;
  127998. set attachedMesh(value: Nullable<AbstractMesh>);
  127999. /**
  128000. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128001. * * When set, interactions will be enabled
  128002. */
  128003. get attachedNode(): Nullable<Node>;
  128004. set attachedNode(value: Nullable<Node>);
  128005. /**
  128006. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128007. * @param mesh The mesh to replace the default mesh of the gizmo
  128008. */
  128009. setCustomMesh(mesh: Mesh): void;
  128010. /**
  128011. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128012. */
  128013. updateGizmoRotationToMatchAttachedMesh: boolean;
  128014. /**
  128015. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128016. */
  128017. updateGizmoPositionToMatchAttachedMesh: boolean;
  128018. /**
  128019. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128020. */
  128021. updateScale: boolean;
  128022. protected _interactionsEnabled: boolean;
  128023. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128024. private _beforeRenderObserver;
  128025. private _tempVector;
  128026. /**
  128027. * Creates a gizmo
  128028. * @param gizmoLayer The utility layer the gizmo will be added to
  128029. */
  128030. constructor(
  128031. /** The utility layer the gizmo will be added to */
  128032. gizmoLayer?: UtilityLayerRenderer);
  128033. /**
  128034. * Updates the gizmo to match the attached mesh's position/rotation
  128035. */
  128036. protected _update(): void;
  128037. /**
  128038. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  128039. * @param value Node, TransformNode or mesh
  128040. */
  128041. protected _matrixChanged(): void;
  128042. /**
  128043. * Disposes of the gizmo
  128044. */
  128045. dispose(): void;
  128046. }
  128047. }
  128048. declare module BABYLON {
  128049. /**
  128050. * Single plane drag gizmo
  128051. */
  128052. export class PlaneDragGizmo extends Gizmo {
  128053. /**
  128054. * Drag behavior responsible for the gizmos dragging interactions
  128055. */
  128056. dragBehavior: PointerDragBehavior;
  128057. private _pointerObserver;
  128058. /**
  128059. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128060. */
  128061. snapDistance: number;
  128062. /**
  128063. * Event that fires each time the gizmo snaps to a new location.
  128064. * * snapDistance is the the change in distance
  128065. */
  128066. onSnapObservable: Observable<{
  128067. snapDistance: number;
  128068. }>;
  128069. private _plane;
  128070. private _coloredMaterial;
  128071. private _hoverMaterial;
  128072. private _isEnabled;
  128073. private _parent;
  128074. /** @hidden */
  128075. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  128076. /** @hidden */
  128077. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128078. /**
  128079. * Creates a PlaneDragGizmo
  128080. * @param gizmoLayer The utility layer the gizmo will be added to
  128081. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  128082. * @param color The color of the gizmo
  128083. */
  128084. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  128085. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128086. /**
  128087. * If the gizmo is enabled
  128088. */
  128089. set isEnabled(value: boolean);
  128090. get isEnabled(): boolean;
  128091. /**
  128092. * Disposes of the gizmo
  128093. */
  128094. dispose(): void;
  128095. }
  128096. }
  128097. declare module BABYLON {
  128098. /**
  128099. * Gizmo that enables dragging a mesh along 3 axis
  128100. */
  128101. export class PositionGizmo extends Gizmo {
  128102. /**
  128103. * Internal gizmo used for interactions on the x axis
  128104. */
  128105. xGizmo: AxisDragGizmo;
  128106. /**
  128107. * Internal gizmo used for interactions on the y axis
  128108. */
  128109. yGizmo: AxisDragGizmo;
  128110. /**
  128111. * Internal gizmo used for interactions on the z axis
  128112. */
  128113. zGizmo: AxisDragGizmo;
  128114. /**
  128115. * Internal gizmo used for interactions on the yz plane
  128116. */
  128117. xPlaneGizmo: PlaneDragGizmo;
  128118. /**
  128119. * Internal gizmo used for interactions on the xz plane
  128120. */
  128121. yPlaneGizmo: PlaneDragGizmo;
  128122. /**
  128123. * Internal gizmo used for interactions on the xy plane
  128124. */
  128125. zPlaneGizmo: PlaneDragGizmo;
  128126. /**
  128127. * private variables
  128128. */
  128129. private _meshAttached;
  128130. private _nodeAttached;
  128131. private _updateGizmoRotationToMatchAttachedMesh;
  128132. private _snapDistance;
  128133. private _scaleRatio;
  128134. /** Fires an event when any of it's sub gizmos are dragged */
  128135. onDragStartObservable: Observable<unknown>;
  128136. /** Fires an event when any of it's sub gizmos are released from dragging */
  128137. onDragEndObservable: Observable<unknown>;
  128138. /**
  128139. * If set to true, planar drag is enabled
  128140. */
  128141. private _planarGizmoEnabled;
  128142. get attachedMesh(): Nullable<AbstractMesh>;
  128143. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128144. get attachedNode(): Nullable<Node>;
  128145. set attachedNode(node: Nullable<Node>);
  128146. /**
  128147. * Creates a PositionGizmo
  128148. * @param gizmoLayer The utility layer the gizmo will be added to
  128149. */
  128150. constructor(gizmoLayer?: UtilityLayerRenderer);
  128151. /**
  128152. * If the planar drag gizmo is enabled
  128153. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  128154. */
  128155. set planarGizmoEnabled(value: boolean);
  128156. get planarGizmoEnabled(): boolean;
  128157. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128158. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128159. /**
  128160. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128161. */
  128162. set snapDistance(value: number);
  128163. get snapDistance(): number;
  128164. /**
  128165. * Ratio for the scale of the gizmo (Default: 1)
  128166. */
  128167. set scaleRatio(value: number);
  128168. get scaleRatio(): number;
  128169. /**
  128170. * Disposes of the gizmo
  128171. */
  128172. dispose(): void;
  128173. /**
  128174. * CustomMeshes are not supported by this gizmo
  128175. * @param mesh The mesh to replace the default mesh of the gizmo
  128176. */
  128177. setCustomMesh(mesh: Mesh): void;
  128178. }
  128179. }
  128180. declare module BABYLON {
  128181. /**
  128182. * Single axis drag gizmo
  128183. */
  128184. export class AxisDragGizmo extends Gizmo {
  128185. /**
  128186. * Drag behavior responsible for the gizmos dragging interactions
  128187. */
  128188. dragBehavior: PointerDragBehavior;
  128189. private _pointerObserver;
  128190. /**
  128191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128192. */
  128193. snapDistance: number;
  128194. /**
  128195. * Event that fires each time the gizmo snaps to a new location.
  128196. * * snapDistance is the the change in distance
  128197. */
  128198. onSnapObservable: Observable<{
  128199. snapDistance: number;
  128200. }>;
  128201. private _isEnabled;
  128202. private _parent;
  128203. private _arrow;
  128204. private _coloredMaterial;
  128205. private _hoverMaterial;
  128206. /** @hidden */
  128207. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  128208. /** @hidden */
  128209. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128210. /**
  128211. * Creates an AxisDragGizmo
  128212. * @param gizmoLayer The utility layer the gizmo will be added to
  128213. * @param dragAxis The axis which the gizmo will be able to drag on
  128214. * @param color The color of the gizmo
  128215. */
  128216. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  128217. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128218. /**
  128219. * If the gizmo is enabled
  128220. */
  128221. set isEnabled(value: boolean);
  128222. get isEnabled(): boolean;
  128223. /**
  128224. * Disposes of the gizmo
  128225. */
  128226. dispose(): void;
  128227. }
  128228. }
  128229. declare module BABYLON.Debug {
  128230. /**
  128231. * The Axes viewer will show 3 axes in a specific point in space
  128232. */
  128233. export class AxesViewer {
  128234. private _xAxis;
  128235. private _yAxis;
  128236. private _zAxis;
  128237. private _scaleLinesFactor;
  128238. private _instanced;
  128239. /**
  128240. * Gets the hosting scene
  128241. */
  128242. scene: Scene;
  128243. /**
  128244. * Gets or sets a number used to scale line length
  128245. */
  128246. scaleLines: number;
  128247. /** Gets the node hierarchy used to render x-axis */
  128248. get xAxis(): TransformNode;
  128249. /** Gets the node hierarchy used to render y-axis */
  128250. get yAxis(): TransformNode;
  128251. /** Gets the node hierarchy used to render z-axis */
  128252. get zAxis(): TransformNode;
  128253. /**
  128254. * Creates a new AxesViewer
  128255. * @param scene defines the hosting scene
  128256. * @param scaleLines defines a number used to scale line length (1 by default)
  128257. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  128258. * @param xAxis defines the node hierarchy used to render the x-axis
  128259. * @param yAxis defines the node hierarchy used to render the y-axis
  128260. * @param zAxis defines the node hierarchy used to render the z-axis
  128261. */
  128262. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  128263. /**
  128264. * Force the viewer to update
  128265. * @param position defines the position of the viewer
  128266. * @param xaxis defines the x axis of the viewer
  128267. * @param yaxis defines the y axis of the viewer
  128268. * @param zaxis defines the z axis of the viewer
  128269. */
  128270. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  128271. /**
  128272. * Creates an instance of this axes viewer.
  128273. * @returns a new axes viewer with instanced meshes
  128274. */
  128275. createInstance(): AxesViewer;
  128276. /** Releases resources */
  128277. dispose(): void;
  128278. private static _SetRenderingGroupId;
  128279. }
  128280. }
  128281. declare module BABYLON.Debug {
  128282. /**
  128283. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  128284. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  128285. */
  128286. export class BoneAxesViewer extends AxesViewer {
  128287. /**
  128288. * Gets or sets the target mesh where to display the axes viewer
  128289. */
  128290. mesh: Nullable<Mesh>;
  128291. /**
  128292. * Gets or sets the target bone where to display the axes viewer
  128293. */
  128294. bone: Nullable<Bone>;
  128295. /** Gets current position */
  128296. pos: Vector3;
  128297. /** Gets direction of X axis */
  128298. xaxis: Vector3;
  128299. /** Gets direction of Y axis */
  128300. yaxis: Vector3;
  128301. /** Gets direction of Z axis */
  128302. zaxis: Vector3;
  128303. /**
  128304. * Creates a new BoneAxesViewer
  128305. * @param scene defines the hosting scene
  128306. * @param bone defines the target bone
  128307. * @param mesh defines the target mesh
  128308. * @param scaleLines defines a scaling factor for line length (1 by default)
  128309. */
  128310. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  128311. /**
  128312. * Force the viewer to update
  128313. */
  128314. update(): void;
  128315. /** Releases resources */
  128316. dispose(): void;
  128317. }
  128318. }
  128319. declare module BABYLON {
  128320. /**
  128321. * Interface used to define scene explorer extensibility option
  128322. */
  128323. export interface IExplorerExtensibilityOption {
  128324. /**
  128325. * Define the option label
  128326. */
  128327. label: string;
  128328. /**
  128329. * Defines the action to execute on click
  128330. */
  128331. action: (entity: any) => void;
  128332. }
  128333. /**
  128334. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  128335. */
  128336. export interface IExplorerExtensibilityGroup {
  128337. /**
  128338. * Defines a predicate to test if a given type mut be extended
  128339. */
  128340. predicate: (entity: any) => boolean;
  128341. /**
  128342. * Gets the list of options added to a type
  128343. */
  128344. entries: IExplorerExtensibilityOption[];
  128345. }
  128346. /**
  128347. * Interface used to define the options to use to create the Inspector
  128348. */
  128349. export interface IInspectorOptions {
  128350. /**
  128351. * Display in overlay mode (default: false)
  128352. */
  128353. overlay?: boolean;
  128354. /**
  128355. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128356. */
  128357. globalRoot?: HTMLElement;
  128358. /**
  128359. * Display the Scene explorer
  128360. */
  128361. showExplorer?: boolean;
  128362. /**
  128363. * Display the property inspector
  128364. */
  128365. showInspector?: boolean;
  128366. /**
  128367. * Display in embed mode (both panes on the right)
  128368. */
  128369. embedMode?: boolean;
  128370. /**
  128371. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128372. */
  128373. handleResize?: boolean;
  128374. /**
  128375. * Allow the panes to popup (default: true)
  128376. */
  128377. enablePopup?: boolean;
  128378. /**
  128379. * Allow the panes to be closed by users (default: true)
  128380. */
  128381. enableClose?: boolean;
  128382. /**
  128383. * Optional list of extensibility entries
  128384. */
  128385. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128386. /**
  128387. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128388. */
  128389. inspectorURL?: string;
  128390. /**
  128391. * Optional initial tab (default to DebugLayerTab.Properties)
  128392. */
  128393. initialTab?: DebugLayerTab;
  128394. }
  128395. interface Scene {
  128396. /**
  128397. * @hidden
  128398. * Backing field
  128399. */
  128400. _debugLayer: DebugLayer;
  128401. /**
  128402. * Gets the debug layer (aka Inspector) associated with the scene
  128403. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128404. */
  128405. debugLayer: DebugLayer;
  128406. }
  128407. /**
  128408. * Enum of inspector action tab
  128409. */
  128410. export enum DebugLayerTab {
  128411. /**
  128412. * Properties tag (default)
  128413. */
  128414. Properties = 0,
  128415. /**
  128416. * Debug tab
  128417. */
  128418. Debug = 1,
  128419. /**
  128420. * Statistics tab
  128421. */
  128422. Statistics = 2,
  128423. /**
  128424. * Tools tab
  128425. */
  128426. Tools = 3,
  128427. /**
  128428. * Settings tab
  128429. */
  128430. Settings = 4
  128431. }
  128432. /**
  128433. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128434. * what is happening in your scene
  128435. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128436. */
  128437. export class DebugLayer {
  128438. /**
  128439. * Define the url to get the inspector script from.
  128440. * By default it uses the babylonjs CDN.
  128441. * @ignoreNaming
  128442. */
  128443. static InspectorURL: string;
  128444. private _scene;
  128445. private BJSINSPECTOR;
  128446. private _onPropertyChangedObservable?;
  128447. /**
  128448. * Observable triggered when a property is changed through the inspector.
  128449. */
  128450. get onPropertyChangedObservable(): any;
  128451. /**
  128452. * Instantiates a new debug layer.
  128453. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128454. * what is happening in your scene
  128455. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128456. * @param scene Defines the scene to inspect
  128457. */
  128458. constructor(scene: Scene);
  128459. /** Creates the inspector window. */
  128460. private _createInspector;
  128461. /**
  128462. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128463. * @param entity defines the entity to select
  128464. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128465. */
  128466. select(entity: any, lineContainerTitles?: string | string[]): void;
  128467. /** Get the inspector from bundle or global */
  128468. private _getGlobalInspector;
  128469. /**
  128470. * Get if the inspector is visible or not.
  128471. * @returns true if visible otherwise, false
  128472. */
  128473. isVisible(): boolean;
  128474. /**
  128475. * Hide the inspector and close its window.
  128476. */
  128477. hide(): void;
  128478. /**
  128479. * Update the scene in the inspector
  128480. */
  128481. setAsActiveScene(): void;
  128482. /**
  128483. * Launch the debugLayer.
  128484. * @param config Define the configuration of the inspector
  128485. * @return a promise fulfilled when the debug layer is visible
  128486. */
  128487. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128488. }
  128489. }
  128490. declare module BABYLON {
  128491. /**
  128492. * Class containing static functions to help procedurally build meshes
  128493. */
  128494. export class BoxBuilder {
  128495. /**
  128496. * Creates a box mesh
  128497. * * The parameter `size` sets the size (float) of each box side (default 1)
  128498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128499. * * 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)
  128500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128505. * @param name defines the name of the mesh
  128506. * @param options defines the options used to create the mesh
  128507. * @param scene defines the hosting scene
  128508. * @returns the box mesh
  128509. */
  128510. static CreateBox(name: string, options: {
  128511. size?: number;
  128512. width?: number;
  128513. height?: number;
  128514. depth?: number;
  128515. faceUV?: Vector4[];
  128516. faceColors?: Color4[];
  128517. sideOrientation?: number;
  128518. frontUVs?: Vector4;
  128519. backUVs?: Vector4;
  128520. wrap?: boolean;
  128521. topBaseAt?: number;
  128522. bottomBaseAt?: number;
  128523. updatable?: boolean;
  128524. }, scene?: Nullable<Scene>): Mesh;
  128525. }
  128526. }
  128527. declare module BABYLON.Debug {
  128528. /**
  128529. * Used to show the physics impostor around the specific mesh
  128530. */
  128531. export class PhysicsViewer {
  128532. /** @hidden */
  128533. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128534. /** @hidden */
  128535. protected _meshes: Array<Nullable<AbstractMesh>>;
  128536. /** @hidden */
  128537. protected _scene: Nullable<Scene>;
  128538. /** @hidden */
  128539. protected _numMeshes: number;
  128540. /** @hidden */
  128541. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128542. private _renderFunction;
  128543. private _utilityLayer;
  128544. private _debugBoxMesh;
  128545. private _debugSphereMesh;
  128546. private _debugCylinderMesh;
  128547. private _debugMaterial;
  128548. private _debugMeshMeshes;
  128549. /**
  128550. * Creates a new PhysicsViewer
  128551. * @param scene defines the hosting scene
  128552. */
  128553. constructor(scene: Scene);
  128554. /** @hidden */
  128555. protected _updateDebugMeshes(): void;
  128556. /**
  128557. * Renders a specified physic impostor
  128558. * @param impostor defines the impostor to render
  128559. * @param targetMesh defines the mesh represented by the impostor
  128560. * @returns the new debug mesh used to render the impostor
  128561. */
  128562. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128563. /**
  128564. * Hides a specified physic impostor
  128565. * @param impostor defines the impostor to hide
  128566. */
  128567. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128568. private _getDebugMaterial;
  128569. private _getDebugBoxMesh;
  128570. private _getDebugSphereMesh;
  128571. private _getDebugCylinderMesh;
  128572. private _getDebugMeshMesh;
  128573. private _getDebugMesh;
  128574. /** Releases all resources */
  128575. dispose(): void;
  128576. }
  128577. }
  128578. declare module BABYLON {
  128579. /**
  128580. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128581. * in order to better appreciate the issue one might have.
  128582. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128583. */
  128584. export class RayHelper {
  128585. /**
  128586. * Defines the ray we are currently tryin to visualize.
  128587. */
  128588. ray: Nullable<Ray>;
  128589. private _renderPoints;
  128590. private _renderLine;
  128591. private _renderFunction;
  128592. private _scene;
  128593. private _updateToMeshFunction;
  128594. private _attachedToMesh;
  128595. private _meshSpaceDirection;
  128596. private _meshSpaceOrigin;
  128597. /**
  128598. * Helper function to create a colored helper in a scene in one line.
  128599. * @param ray Defines the ray we are currently tryin to visualize
  128600. * @param scene Defines the scene the ray is used in
  128601. * @param color Defines the color we want to see the ray in
  128602. * @returns The newly created ray helper.
  128603. */
  128604. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128605. /**
  128606. * Instantiate a new ray helper.
  128607. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128608. * in order to better appreciate the issue one might have.
  128609. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128610. * @param ray Defines the ray we are currently tryin to visualize
  128611. */
  128612. constructor(ray: Ray);
  128613. /**
  128614. * Shows the ray we are willing to debug.
  128615. * @param scene Defines the scene the ray needs to be rendered in
  128616. * @param color Defines the color the ray needs to be rendered in
  128617. */
  128618. show(scene: Scene, color?: Color3): void;
  128619. /**
  128620. * Hides the ray we are debugging.
  128621. */
  128622. hide(): void;
  128623. private _render;
  128624. /**
  128625. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128626. * @param mesh Defines the mesh we want the helper attached to
  128627. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128628. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128629. * @param length Defines the length of the ray
  128630. */
  128631. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128632. /**
  128633. * Detach the ray helper from the mesh it has previously been attached to.
  128634. */
  128635. detachFromMesh(): void;
  128636. private _updateToMesh;
  128637. /**
  128638. * Dispose the helper and release its associated resources.
  128639. */
  128640. dispose(): void;
  128641. }
  128642. }
  128643. declare module BABYLON.Debug {
  128644. /**
  128645. * Class used to render a debug view of a given skeleton
  128646. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128647. */
  128648. export class SkeletonViewer {
  128649. /** defines the skeleton to render */
  128650. skeleton: Skeleton;
  128651. /** defines the mesh attached to the skeleton */
  128652. mesh: AbstractMesh;
  128653. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128654. autoUpdateBonesMatrices: boolean;
  128655. /** defines the rendering group id to use with the viewer */
  128656. renderingGroupId: number;
  128657. /** Gets or sets the color used to render the skeleton */
  128658. color: Color3;
  128659. private _scene;
  128660. private _debugLines;
  128661. private _debugMesh;
  128662. private _isEnabled;
  128663. private _renderFunction;
  128664. private _utilityLayer;
  128665. /**
  128666. * Returns the mesh used to render the bones
  128667. */
  128668. get debugMesh(): Nullable<LinesMesh>;
  128669. /**
  128670. * Creates a new SkeletonViewer
  128671. * @param skeleton defines the skeleton to render
  128672. * @param mesh defines the mesh attached to the skeleton
  128673. * @param scene defines the hosting scene
  128674. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128675. * @param renderingGroupId defines the rendering group id to use with the viewer
  128676. */
  128677. constructor(
  128678. /** defines the skeleton to render */
  128679. skeleton: Skeleton,
  128680. /** defines the mesh attached to the skeleton */
  128681. mesh: AbstractMesh, scene: Scene,
  128682. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128683. autoUpdateBonesMatrices?: boolean,
  128684. /** defines the rendering group id to use with the viewer */
  128685. renderingGroupId?: number);
  128686. /** Gets or sets a boolean indicating if the viewer is enabled */
  128687. set isEnabled(value: boolean);
  128688. get isEnabled(): boolean;
  128689. private _getBonePosition;
  128690. private _getLinesForBonesWithLength;
  128691. private _getLinesForBonesNoLength;
  128692. /** Update the viewer to sync with current skeleton state */
  128693. update(): void;
  128694. /** Release associated resources */
  128695. dispose(): void;
  128696. }
  128697. }
  128698. declare module BABYLON {
  128699. /**
  128700. * Enum for Device Types
  128701. */
  128702. export enum DeviceType {
  128703. /** Generic */
  128704. Generic = 0,
  128705. /** Keyboard */
  128706. Keyboard = 1,
  128707. /** Mouse */
  128708. Mouse = 2,
  128709. /** Touch Pointers */
  128710. Touch = 3,
  128711. /** PS4 Dual Shock */
  128712. DualShock = 4,
  128713. /** Xbox */
  128714. Xbox = 5,
  128715. /** Switch Controller */
  128716. Switch = 6
  128717. }
  128718. /**
  128719. * Enum for All Pointers (Touch/Mouse)
  128720. */
  128721. export enum PointerInput {
  128722. /** Horizontal Axis */
  128723. Horizontal = 0,
  128724. /** Vertical Axis */
  128725. Vertical = 1,
  128726. /** Left Click or Touch */
  128727. LeftClick = 2,
  128728. /** Middle Click */
  128729. MiddleClick = 3,
  128730. /** Right Click */
  128731. RightClick = 4,
  128732. /** Browser Back */
  128733. BrowserBack = 5,
  128734. /** Browser Forward */
  128735. BrowserForward = 6
  128736. }
  128737. /**
  128738. * Enum for Dual Shock Gamepad
  128739. */
  128740. export enum DualShockInput {
  128741. /** Cross */
  128742. Cross = 0,
  128743. /** Circle */
  128744. Circle = 1,
  128745. /** Square */
  128746. Square = 2,
  128747. /** Triangle */
  128748. Triangle = 3,
  128749. /** L1 */
  128750. L1 = 4,
  128751. /** R1 */
  128752. R1 = 5,
  128753. /** L2 */
  128754. L2 = 6,
  128755. /** R2 */
  128756. R2 = 7,
  128757. /** Share */
  128758. Share = 8,
  128759. /** Options */
  128760. Options = 9,
  128761. /** L3 */
  128762. L3 = 10,
  128763. /** R3 */
  128764. R3 = 11,
  128765. /** DPadUp */
  128766. DPadUp = 12,
  128767. /** DPadDown */
  128768. DPadDown = 13,
  128769. /** DPadLeft */
  128770. DPadLeft = 14,
  128771. /** DRight */
  128772. DPadRight = 15,
  128773. /** Home */
  128774. Home = 16,
  128775. /** TouchPad */
  128776. TouchPad = 17,
  128777. /** LStickXAxis */
  128778. LStickXAxis = 18,
  128779. /** LStickYAxis */
  128780. LStickYAxis = 19,
  128781. /** RStickXAxis */
  128782. RStickXAxis = 20,
  128783. /** RStickYAxis */
  128784. RStickYAxis = 21
  128785. }
  128786. /**
  128787. * Enum for Xbox Gamepad
  128788. */
  128789. export enum XboxInput {
  128790. /** A */
  128791. A = 0,
  128792. /** B */
  128793. B = 1,
  128794. /** X */
  128795. X = 2,
  128796. /** Y */
  128797. Y = 3,
  128798. /** LB */
  128799. LB = 4,
  128800. /** RB */
  128801. RB = 5,
  128802. /** LT */
  128803. LT = 6,
  128804. /** RT */
  128805. RT = 7,
  128806. /** Back */
  128807. Back = 8,
  128808. /** Start */
  128809. Start = 9,
  128810. /** LS */
  128811. LS = 10,
  128812. /** RS */
  128813. RS = 11,
  128814. /** DPadUp */
  128815. DPadUp = 12,
  128816. /** DPadDown */
  128817. DPadDown = 13,
  128818. /** DPadLeft */
  128819. DPadLeft = 14,
  128820. /** DRight */
  128821. DPadRight = 15,
  128822. /** Home */
  128823. Home = 16,
  128824. /** LStickXAxis */
  128825. LStickXAxis = 17,
  128826. /** LStickYAxis */
  128827. LStickYAxis = 18,
  128828. /** RStickXAxis */
  128829. RStickXAxis = 19,
  128830. /** RStickYAxis */
  128831. RStickYAxis = 20
  128832. }
  128833. /**
  128834. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128835. */
  128836. export enum SwitchInput {
  128837. /** B */
  128838. B = 0,
  128839. /** A */
  128840. A = 1,
  128841. /** Y */
  128842. Y = 2,
  128843. /** X */
  128844. X = 3,
  128845. /** L */
  128846. L = 4,
  128847. /** R */
  128848. R = 5,
  128849. /** ZL */
  128850. ZL = 6,
  128851. /** ZR */
  128852. ZR = 7,
  128853. /** Minus */
  128854. Minus = 8,
  128855. /** Plus */
  128856. Plus = 9,
  128857. /** LS */
  128858. LS = 10,
  128859. /** RS */
  128860. RS = 11,
  128861. /** DPadUp */
  128862. DPadUp = 12,
  128863. /** DPadDown */
  128864. DPadDown = 13,
  128865. /** DPadLeft */
  128866. DPadLeft = 14,
  128867. /** DRight */
  128868. DPadRight = 15,
  128869. /** Home */
  128870. Home = 16,
  128871. /** Capture */
  128872. Capture = 17,
  128873. /** LStickXAxis */
  128874. LStickXAxis = 18,
  128875. /** LStickYAxis */
  128876. LStickYAxis = 19,
  128877. /** RStickXAxis */
  128878. RStickXAxis = 20,
  128879. /** RStickYAxis */
  128880. RStickYAxis = 21
  128881. }
  128882. }
  128883. declare module BABYLON {
  128884. /**
  128885. * This class will take all inputs from Keyboard, Pointer, and
  128886. * any Gamepads and provide a polling system that all devices
  128887. * will use. This class assumes that there will only be one
  128888. * pointer device and one keyboard.
  128889. */
  128890. export class DeviceInputSystem implements IDisposable {
  128891. /**
  128892. * Callback to be triggered when a device is connected
  128893. */
  128894. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128895. /**
  128896. * Callback to be triggered when a device is disconnected
  128897. */
  128898. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128899. /**
  128900. * Callback to be triggered when event driven input is updated
  128901. */
  128902. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128903. private _inputs;
  128904. private _gamepads;
  128905. private _keyboardActive;
  128906. private _pointerActive;
  128907. private _elementToAttachTo;
  128908. private _keyboardDownEvent;
  128909. private _keyboardUpEvent;
  128910. private _pointerMoveEvent;
  128911. private _pointerDownEvent;
  128912. private _pointerUpEvent;
  128913. private _gamepadConnectedEvent;
  128914. private _gamepadDisconnectedEvent;
  128915. private static _MAX_KEYCODES;
  128916. private static _MAX_POINTER_INPUTS;
  128917. private constructor();
  128918. /**
  128919. * Creates a new DeviceInputSystem instance
  128920. * @param engine Engine to pull input element from
  128921. * @returns The new instance
  128922. */
  128923. static Create(engine: Engine): DeviceInputSystem;
  128924. /**
  128925. * Checks for current device input value, given an id and input index
  128926. * @param deviceName Id of connected device
  128927. * @param inputIndex Index of device input
  128928. * @returns Current value of input
  128929. */
  128930. /**
  128931. * Checks for current device input value, given an id and input index
  128932. * @param deviceType Enum specifiying device type
  128933. * @param deviceSlot "Slot" or index that device is referenced in
  128934. * @param inputIndex Id of input to be checked
  128935. * @returns Current value of input
  128936. */
  128937. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128938. /**
  128939. * Dispose of all the eventlisteners
  128940. */
  128941. dispose(): void;
  128942. /**
  128943. * Add device and inputs to device array
  128944. * @param deviceType Enum specifiying device type
  128945. * @param deviceSlot "Slot" or index that device is referenced in
  128946. * @param numberOfInputs Number of input entries to create for given device
  128947. */
  128948. private _registerDevice;
  128949. /**
  128950. * Given a specific device name, remove that device from the device map
  128951. * @param deviceType Enum specifiying device type
  128952. * @param deviceSlot "Slot" or index that device is referenced in
  128953. */
  128954. private _unregisterDevice;
  128955. /**
  128956. * Handle all actions that come from keyboard interaction
  128957. */
  128958. private _handleKeyActions;
  128959. /**
  128960. * Handle all actions that come from pointer interaction
  128961. */
  128962. private _handlePointerActions;
  128963. /**
  128964. * Handle all actions that come from gamepad interaction
  128965. */
  128966. private _handleGamepadActions;
  128967. /**
  128968. * Update all non-event based devices with each frame
  128969. * @param deviceType Enum specifiying device type
  128970. * @param deviceSlot "Slot" or index that device is referenced in
  128971. * @param inputIndex Id of input to be checked
  128972. */
  128973. private _updateDevice;
  128974. /**
  128975. * Gets DeviceType from the device name
  128976. * @param deviceName Name of Device from DeviceInputSystem
  128977. * @returns DeviceType enum value
  128978. */
  128979. private _getGamepadDeviceType;
  128980. }
  128981. }
  128982. declare module BABYLON {
  128983. /**
  128984. * Type to handle enforcement of inputs
  128985. */
  128986. 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;
  128987. }
  128988. declare module BABYLON {
  128989. /**
  128990. * Class that handles all input for a specific device
  128991. */
  128992. export class DeviceSource<T extends DeviceType> {
  128993. /** Type of device */
  128994. readonly deviceType: DeviceType;
  128995. /** "Slot" or index that device is referenced in */
  128996. readonly deviceSlot: number;
  128997. /**
  128998. * Observable to handle device input changes per device
  128999. */
  129000. readonly onInputChangedObservable: Observable<{
  129001. inputIndex: DeviceInput<T>;
  129002. previousState: Nullable<number>;
  129003. currentState: Nullable<number>;
  129004. }>;
  129005. private readonly _deviceInputSystem;
  129006. /**
  129007. * Default Constructor
  129008. * @param deviceInputSystem Reference to DeviceInputSystem
  129009. * @param deviceType Type of device
  129010. * @param deviceSlot "Slot" or index that device is referenced in
  129011. */
  129012. constructor(deviceInputSystem: DeviceInputSystem,
  129013. /** Type of device */
  129014. deviceType: DeviceType,
  129015. /** "Slot" or index that device is referenced in */
  129016. deviceSlot?: number);
  129017. /**
  129018. * Get input for specific input
  129019. * @param inputIndex index of specific input on device
  129020. * @returns Input value from DeviceInputSystem
  129021. */
  129022. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  129023. }
  129024. /**
  129025. * Class to keep track of devices
  129026. */
  129027. export class DeviceSourceManager implements IDisposable {
  129028. /**
  129029. * Observable to be triggered when before a device is connected
  129030. */
  129031. readonly onBeforeDeviceConnectedObservable: Observable<{
  129032. deviceType: DeviceType;
  129033. deviceSlot: number;
  129034. }>;
  129035. /**
  129036. * Observable to be triggered when before a device is disconnected
  129037. */
  129038. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  129039. deviceType: DeviceType;
  129040. deviceSlot: number;
  129041. }>;
  129042. /**
  129043. * Observable to be triggered when after a device is connected
  129044. */
  129045. readonly onAfterDeviceConnectedObservable: Observable<{
  129046. deviceType: DeviceType;
  129047. deviceSlot: number;
  129048. }>;
  129049. /**
  129050. * Observable to be triggered when after a device is disconnected
  129051. */
  129052. readonly onAfterDeviceDisconnectedObservable: Observable<{
  129053. deviceType: DeviceType;
  129054. deviceSlot: number;
  129055. }>;
  129056. private readonly _devices;
  129057. private readonly _firstDevice;
  129058. private readonly _deviceInputSystem;
  129059. /**
  129060. * Default Constructor
  129061. * @param engine engine to pull input element from
  129062. */
  129063. constructor(engine: Engine);
  129064. /**
  129065. * Gets a DeviceSource, given a type and slot
  129066. * @param deviceType Enum specifying device type
  129067. * @param deviceSlot "Slot" or index that device is referenced in
  129068. * @returns DeviceSource object
  129069. */
  129070. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  129071. /**
  129072. * Gets an array of DeviceSource objects for a given device type
  129073. * @param deviceType Enum specifying device type
  129074. * @returns Array of DeviceSource objects
  129075. */
  129076. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  129077. /**
  129078. * Dispose of DeviceInputSystem and other parts
  129079. */
  129080. dispose(): void;
  129081. /**
  129082. * Function to add device name to device list
  129083. * @param deviceType Enum specifying device type
  129084. * @param deviceSlot "Slot" or index that device is referenced in
  129085. */
  129086. private _addDevice;
  129087. /**
  129088. * Function to remove device name to device list
  129089. * @param deviceType Enum specifying device type
  129090. * @param deviceSlot "Slot" or index that device is referenced in
  129091. */
  129092. private _removeDevice;
  129093. /**
  129094. * Updates array storing first connected device of each type
  129095. * @param type Type of Device
  129096. */
  129097. private _updateFirstDevices;
  129098. }
  129099. }
  129100. declare module BABYLON {
  129101. /**
  129102. * Options to create the null engine
  129103. */
  129104. export class NullEngineOptions {
  129105. /**
  129106. * Render width (Default: 512)
  129107. */
  129108. renderWidth: number;
  129109. /**
  129110. * Render height (Default: 256)
  129111. */
  129112. renderHeight: number;
  129113. /**
  129114. * Texture size (Default: 512)
  129115. */
  129116. textureSize: number;
  129117. /**
  129118. * If delta time between frames should be constant
  129119. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129120. */
  129121. deterministicLockstep: boolean;
  129122. /**
  129123. * Maximum about of steps between frames (Default: 4)
  129124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129125. */
  129126. lockstepMaxSteps: number;
  129127. /**
  129128. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  129129. */
  129130. useHighPrecisionMatrix?: boolean;
  129131. }
  129132. /**
  129133. * The null engine class provides support for headless version of babylon.js.
  129134. * This can be used in server side scenario or for testing purposes
  129135. */
  129136. export class NullEngine extends Engine {
  129137. private _options;
  129138. /**
  129139. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  129140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129141. * @returns true if engine is in deterministic lock step mode
  129142. */
  129143. isDeterministicLockStep(): boolean;
  129144. /**
  129145. * Gets the max steps when engine is running in deterministic lock step
  129146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129147. * @returns the max steps
  129148. */
  129149. getLockstepMaxSteps(): number;
  129150. /**
  129151. * Gets the current hardware scaling level.
  129152. * By default the hardware scaling level is computed from the window device ratio.
  129153. * 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.
  129154. * @returns a number indicating the current hardware scaling level
  129155. */
  129156. getHardwareScalingLevel(): number;
  129157. constructor(options?: NullEngineOptions);
  129158. /**
  129159. * Creates a vertex buffer
  129160. * @param vertices the data for the vertex buffer
  129161. * @returns the new WebGL static buffer
  129162. */
  129163. createVertexBuffer(vertices: FloatArray): DataBuffer;
  129164. /**
  129165. * Creates a new index buffer
  129166. * @param indices defines the content of the index buffer
  129167. * @param updatable defines if the index buffer must be updatable
  129168. * @returns a new webGL buffer
  129169. */
  129170. createIndexBuffer(indices: IndicesArray): DataBuffer;
  129171. /**
  129172. * Clear the current render buffer or the current render target (if any is set up)
  129173. * @param color defines the color to use
  129174. * @param backBuffer defines if the back buffer must be cleared
  129175. * @param depth defines if the depth buffer must be cleared
  129176. * @param stencil defines if the stencil buffer must be cleared
  129177. */
  129178. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129179. /**
  129180. * Gets the current render width
  129181. * @param useScreen defines if screen size must be used (or the current render target if any)
  129182. * @returns a number defining the current render width
  129183. */
  129184. getRenderWidth(useScreen?: boolean): number;
  129185. /**
  129186. * Gets the current render height
  129187. * @param useScreen defines if screen size must be used (or the current render target if any)
  129188. * @returns a number defining the current render height
  129189. */
  129190. getRenderHeight(useScreen?: boolean): number;
  129191. /**
  129192. * Set the WebGL's viewport
  129193. * @param viewport defines the viewport element to be used
  129194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  129195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  129196. */
  129197. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  129198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  129199. /**
  129200. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  129201. * @param pipelineContext defines the pipeline context to use
  129202. * @param uniformsNames defines the list of uniform names
  129203. * @returns an array of webGL uniform locations
  129204. */
  129205. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  129206. /**
  129207. * Gets the lsit of active attributes for a given webGL program
  129208. * @param pipelineContext defines the pipeline context to use
  129209. * @param attributesNames defines the list of attribute names to get
  129210. * @returns an array of indices indicating the offset of each attribute
  129211. */
  129212. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129213. /**
  129214. * Binds an effect to the webGL context
  129215. * @param effect defines the effect to bind
  129216. */
  129217. bindSamplers(effect: Effect): void;
  129218. /**
  129219. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129220. * @param effect defines the effect to activate
  129221. */
  129222. enableEffect(effect: Effect): void;
  129223. /**
  129224. * Set various states to the webGL context
  129225. * @param culling defines backface culling state
  129226. * @param zOffset defines the value to apply to zOffset (0 by default)
  129227. * @param force defines if states must be applied even if cache is up to date
  129228. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  129229. */
  129230. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129231. /**
  129232. * Set the value of an uniform to an array of int32
  129233. * @param uniform defines the webGL uniform location where to store the value
  129234. * @param array defines the array of int32 to store
  129235. */
  129236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129237. /**
  129238. * Set the value of an uniform to an array of int32 (stored as vec2)
  129239. * @param uniform defines the webGL uniform location where to store the value
  129240. * @param array defines the array of int32 to store
  129241. */
  129242. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129243. /**
  129244. * Set the value of an uniform to an array of int32 (stored as vec3)
  129245. * @param uniform defines the webGL uniform location where to store the value
  129246. * @param array defines the array of int32 to store
  129247. */
  129248. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129249. /**
  129250. * Set the value of an uniform to an array of int32 (stored as vec4)
  129251. * @param uniform defines the webGL uniform location where to store the value
  129252. * @param array defines the array of int32 to store
  129253. */
  129254. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129255. /**
  129256. * Set the value of an uniform to an array of float32
  129257. * @param uniform defines the webGL uniform location where to store the value
  129258. * @param array defines the array of float32 to store
  129259. */
  129260. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129261. /**
  129262. * Set the value of an uniform to an array of float32 (stored as vec2)
  129263. * @param uniform defines the webGL uniform location where to store the value
  129264. * @param array defines the array of float32 to store
  129265. */
  129266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129267. /**
  129268. * Set the value of an uniform to an array of float32 (stored as vec3)
  129269. * @param uniform defines the webGL uniform location where to store the value
  129270. * @param array defines the array of float32 to store
  129271. */
  129272. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129273. /**
  129274. * Set the value of an uniform to an array of float32 (stored as vec4)
  129275. * @param uniform defines the webGL uniform location where to store the value
  129276. * @param array defines the array of float32 to store
  129277. */
  129278. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129279. /**
  129280. * Set the value of an uniform to an array of number
  129281. * @param uniform defines the webGL uniform location where to store the value
  129282. * @param array defines the array of number to store
  129283. */
  129284. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129285. /**
  129286. * Set the value of an uniform to an array of number (stored as vec2)
  129287. * @param uniform defines the webGL uniform location where to store the value
  129288. * @param array defines the array of number to store
  129289. */
  129290. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129291. /**
  129292. * Set the value of an uniform to an array of number (stored as vec3)
  129293. * @param uniform defines the webGL uniform location where to store the value
  129294. * @param array defines the array of number to store
  129295. */
  129296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129297. /**
  129298. * Set the value of an uniform to an array of number (stored as vec4)
  129299. * @param uniform defines the webGL uniform location where to store the value
  129300. * @param array defines the array of number to store
  129301. */
  129302. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129303. /**
  129304. * Set the value of an uniform to an array of float32 (stored as matrices)
  129305. * @param uniform defines the webGL uniform location where to store the value
  129306. * @param matrices defines the array of float32 to store
  129307. */
  129308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129309. /**
  129310. * Set the value of an uniform to a matrix (3x3)
  129311. * @param uniform defines the webGL uniform location where to store the value
  129312. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  129313. */
  129314. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129315. /**
  129316. * Set the value of an uniform to a matrix (2x2)
  129317. * @param uniform defines the webGL uniform location where to store the value
  129318. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  129319. */
  129320. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129321. /**
  129322. * Set the value of an uniform to a number (float)
  129323. * @param uniform defines the webGL uniform location where to store the value
  129324. * @param value defines the float number to store
  129325. */
  129326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129327. /**
  129328. * Set the value of an uniform to a vec2
  129329. * @param uniform defines the webGL uniform location where to store the value
  129330. * @param x defines the 1st component of the value
  129331. * @param y defines the 2nd component of the value
  129332. */
  129333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129334. /**
  129335. * Set the value of an uniform to a vec3
  129336. * @param uniform defines the webGL uniform location where to store the value
  129337. * @param x defines the 1st component of the value
  129338. * @param y defines the 2nd component of the value
  129339. * @param z defines the 3rd component of the value
  129340. */
  129341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129342. /**
  129343. * Set the value of an uniform to a boolean
  129344. * @param uniform defines the webGL uniform location where to store the value
  129345. * @param bool defines the boolean to store
  129346. */
  129347. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129348. /**
  129349. * Set the value of an uniform to a vec4
  129350. * @param uniform defines the webGL uniform location where to store the value
  129351. * @param x defines the 1st component of the value
  129352. * @param y defines the 2nd component of the value
  129353. * @param z defines the 3rd component of the value
  129354. * @param w defines the 4th component of the value
  129355. */
  129356. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129357. /**
  129358. * Sets the current alpha mode
  129359. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129360. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129361. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129362. */
  129363. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129364. /**
  129365. * Bind webGl buffers directly to the webGL context
  129366. * @param vertexBuffers defines the vertex buffer to bind
  129367. * @param indexBuffer defines the index buffer to bind
  129368. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129369. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129370. * @param effect defines the effect associated with the vertex buffer
  129371. */
  129372. bindBuffers(vertexBuffers: {
  129373. [key: string]: VertexBuffer;
  129374. }, indexBuffer: DataBuffer, effect: Effect): void;
  129375. /**
  129376. * Force the entire cache to be cleared
  129377. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129378. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129379. */
  129380. wipeCaches(bruteForce?: boolean): void;
  129381. /**
  129382. * Send a draw order
  129383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129384. * @param indexStart defines the starting index
  129385. * @param indexCount defines the number of index to draw
  129386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129387. */
  129388. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129389. /**
  129390. * Draw a list of indexed primitives
  129391. * @param fillMode defines the primitive to use
  129392. * @param indexStart defines the starting index
  129393. * @param indexCount defines the number of index to draw
  129394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129395. */
  129396. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129397. /**
  129398. * Draw a list of unindexed primitives
  129399. * @param fillMode defines the primitive to use
  129400. * @param verticesStart defines the index of first vertex to draw
  129401. * @param verticesCount defines the count of vertices to draw
  129402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129403. */
  129404. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129405. /** @hidden */
  129406. _createTexture(): WebGLTexture;
  129407. /** @hidden */
  129408. _releaseTexture(texture: InternalTexture): void;
  129409. /**
  129410. * Usually called from Texture.ts.
  129411. * Passed information to create a WebGLTexture
  129412. * @param urlArg defines a value which contains one of the following:
  129413. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129414. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129415. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129417. * @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)
  129418. * @param scene needed for loading to the correct scene
  129419. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129420. * @param onLoad optional callback to be called upon successful completion
  129421. * @param onError optional callback to be called upon failure
  129422. * @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
  129423. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129424. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129425. * @param forcedExtension defines the extension to use to pick the right loader
  129426. * @param mimeType defines an optional mime type
  129427. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129428. */
  129429. 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;
  129430. /**
  129431. * Creates a new render target texture
  129432. * @param size defines the size of the texture
  129433. * @param options defines the options used to create the texture
  129434. * @returns a new render target texture stored in an InternalTexture
  129435. */
  129436. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129437. /**
  129438. * Update the sampling mode of a given texture
  129439. * @param samplingMode defines the required sampling mode
  129440. * @param texture defines the texture to update
  129441. */
  129442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129443. /**
  129444. * Binds the frame buffer to the specified texture.
  129445. * @param texture The texture to render to or null for the default canvas
  129446. * @param faceIndex The face of the texture to render to in case of cube texture
  129447. * @param requiredWidth The width of the target to render to
  129448. * @param requiredHeight The height of the target to render to
  129449. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129450. * @param lodLevel defines le lod level to bind to the frame buffer
  129451. */
  129452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129453. /**
  129454. * Unbind the current render target texture from the webGL context
  129455. * @param texture defines the render target texture to unbind
  129456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129458. */
  129459. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129460. /**
  129461. * Creates a dynamic vertex buffer
  129462. * @param vertices the data for the dynamic vertex buffer
  129463. * @returns the new WebGL dynamic buffer
  129464. */
  129465. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129466. /**
  129467. * Update the content of a dynamic texture
  129468. * @param texture defines the texture to update
  129469. * @param canvas defines the canvas containing the source
  129470. * @param invertY defines if data must be stored with Y axis inverted
  129471. * @param premulAlpha defines if alpha is stored as premultiplied
  129472. * @param format defines the format of the data
  129473. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129474. */
  129475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129476. /**
  129477. * Gets a boolean indicating if all created effects are ready
  129478. * @returns true if all effects are ready
  129479. */
  129480. areAllEffectsReady(): boolean;
  129481. /**
  129482. * @hidden
  129483. * Get the current error code of the webGL context
  129484. * @returns the error code
  129485. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129486. */
  129487. getError(): number;
  129488. /** @hidden */
  129489. _getUnpackAlignement(): number;
  129490. /** @hidden */
  129491. _unpackFlipY(value: boolean): void;
  129492. /**
  129493. * Update a dynamic index buffer
  129494. * @param indexBuffer defines the target index buffer
  129495. * @param indices defines the data to update
  129496. * @param offset defines the offset in the target index buffer where update should start
  129497. */
  129498. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129499. /**
  129500. * Updates a dynamic vertex buffer.
  129501. * @param vertexBuffer the vertex buffer to update
  129502. * @param vertices the data used to update the vertex buffer
  129503. * @param byteOffset the byte offset of the data (optional)
  129504. * @param byteLength the byte length of the data (optional)
  129505. */
  129506. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129507. /** @hidden */
  129508. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129509. /** @hidden */
  129510. _bindTexture(channel: number, texture: InternalTexture): void;
  129511. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129512. /**
  129513. * 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
  129514. */
  129515. releaseEffects(): void;
  129516. displayLoadingUI(): void;
  129517. hideLoadingUI(): void;
  129518. /** @hidden */
  129519. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129520. /** @hidden */
  129521. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129522. /** @hidden */
  129523. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129524. /** @hidden */
  129525. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129526. }
  129527. }
  129528. declare module BABYLON {
  129529. /**
  129530. * @hidden
  129531. **/
  129532. export class _TimeToken {
  129533. _startTimeQuery: Nullable<WebGLQuery>;
  129534. _endTimeQuery: Nullable<WebGLQuery>;
  129535. _timeElapsedQuery: Nullable<WebGLQuery>;
  129536. _timeElapsedQueryEnded: boolean;
  129537. }
  129538. }
  129539. declare module BABYLON {
  129540. /** @hidden */
  129541. export class _OcclusionDataStorage {
  129542. /** @hidden */
  129543. occlusionInternalRetryCounter: number;
  129544. /** @hidden */
  129545. isOcclusionQueryInProgress: boolean;
  129546. /** @hidden */
  129547. isOccluded: boolean;
  129548. /** @hidden */
  129549. occlusionRetryCount: number;
  129550. /** @hidden */
  129551. occlusionType: number;
  129552. /** @hidden */
  129553. occlusionQueryAlgorithmType: number;
  129554. }
  129555. interface Engine {
  129556. /**
  129557. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129558. * @return the new query
  129559. */
  129560. createQuery(): WebGLQuery;
  129561. /**
  129562. * Delete and release a webGL query
  129563. * @param query defines the query to delete
  129564. * @return the current engine
  129565. */
  129566. deleteQuery(query: WebGLQuery): Engine;
  129567. /**
  129568. * Check if a given query has resolved and got its value
  129569. * @param query defines the query to check
  129570. * @returns true if the query got its value
  129571. */
  129572. isQueryResultAvailable(query: WebGLQuery): boolean;
  129573. /**
  129574. * Gets the value of a given query
  129575. * @param query defines the query to check
  129576. * @returns the value of the query
  129577. */
  129578. getQueryResult(query: WebGLQuery): number;
  129579. /**
  129580. * Initiates an occlusion query
  129581. * @param algorithmType defines the algorithm to use
  129582. * @param query defines the query to use
  129583. * @returns the current engine
  129584. * @see https://doc.babylonjs.com/features/occlusionquery
  129585. */
  129586. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129587. /**
  129588. * Ends an occlusion query
  129589. * @see https://doc.babylonjs.com/features/occlusionquery
  129590. * @param algorithmType defines the algorithm to use
  129591. * @returns the current engine
  129592. */
  129593. endOcclusionQuery(algorithmType: number): Engine;
  129594. /**
  129595. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129596. * Please note that only one query can be issued at a time
  129597. * @returns a time token used to track the time span
  129598. */
  129599. startTimeQuery(): Nullable<_TimeToken>;
  129600. /**
  129601. * Ends a time query
  129602. * @param token defines the token used to measure the time span
  129603. * @returns the time spent (in ns)
  129604. */
  129605. endTimeQuery(token: _TimeToken): int;
  129606. /** @hidden */
  129607. _currentNonTimestampToken: Nullable<_TimeToken>;
  129608. /** @hidden */
  129609. _createTimeQuery(): WebGLQuery;
  129610. /** @hidden */
  129611. _deleteTimeQuery(query: WebGLQuery): void;
  129612. /** @hidden */
  129613. _getGlAlgorithmType(algorithmType: number): number;
  129614. /** @hidden */
  129615. _getTimeQueryResult(query: WebGLQuery): any;
  129616. /** @hidden */
  129617. _getTimeQueryAvailability(query: WebGLQuery): any;
  129618. }
  129619. interface AbstractMesh {
  129620. /**
  129621. * Backing filed
  129622. * @hidden
  129623. */
  129624. __occlusionDataStorage: _OcclusionDataStorage;
  129625. /**
  129626. * Access property
  129627. * @hidden
  129628. */
  129629. _occlusionDataStorage: _OcclusionDataStorage;
  129630. /**
  129631. * 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.
  129632. * The default value is -1 which means don't break the query and wait till the result
  129633. * @see https://doc.babylonjs.com/features/occlusionquery
  129634. */
  129635. occlusionRetryCount: number;
  129636. /**
  129637. * 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:
  129638. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129639. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129640. * * 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.
  129641. * @see https://doc.babylonjs.com/features/occlusionquery
  129642. */
  129643. occlusionType: number;
  129644. /**
  129645. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129646. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129647. * * 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.
  129648. * @see https://doc.babylonjs.com/features/occlusionquery
  129649. */
  129650. occlusionQueryAlgorithmType: number;
  129651. /**
  129652. * 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
  129653. * @see https://doc.babylonjs.com/features/occlusionquery
  129654. */
  129655. isOccluded: boolean;
  129656. /**
  129657. * Flag to check the progress status of the query
  129658. * @see https://doc.babylonjs.com/features/occlusionquery
  129659. */
  129660. isOcclusionQueryInProgress: boolean;
  129661. }
  129662. }
  129663. declare module BABYLON {
  129664. /** @hidden */
  129665. export var _forceTransformFeedbackToBundle: boolean;
  129666. interface Engine {
  129667. /**
  129668. * Creates a webGL transform feedback object
  129669. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129670. * @returns the webGL transform feedback object
  129671. */
  129672. createTransformFeedback(): WebGLTransformFeedback;
  129673. /**
  129674. * Delete a webGL transform feedback object
  129675. * @param value defines the webGL transform feedback object to delete
  129676. */
  129677. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129678. /**
  129679. * Bind a webGL transform feedback object to the webgl context
  129680. * @param value defines the webGL transform feedback object to bind
  129681. */
  129682. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129683. /**
  129684. * Begins a transform feedback operation
  129685. * @param usePoints defines if points or triangles must be used
  129686. */
  129687. beginTransformFeedback(usePoints: boolean): void;
  129688. /**
  129689. * Ends a transform feedback operation
  129690. */
  129691. endTransformFeedback(): void;
  129692. /**
  129693. * Specify the varyings to use with transform feedback
  129694. * @param program defines the associated webGL program
  129695. * @param value defines the list of strings representing the varying names
  129696. */
  129697. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129698. /**
  129699. * Bind a webGL buffer for a transform feedback operation
  129700. * @param value defines the webGL buffer to bind
  129701. */
  129702. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129703. }
  129704. }
  129705. declare module BABYLON {
  129706. /**
  129707. * Creation options of the multi render target texture.
  129708. */
  129709. export interface IMultiRenderTargetOptions {
  129710. /**
  129711. * Define if the texture needs to create mip maps after render.
  129712. */
  129713. generateMipMaps?: boolean;
  129714. /**
  129715. * Define the types of all the draw buffers we want to create
  129716. */
  129717. types?: number[];
  129718. /**
  129719. * Define the sampling modes of all the draw buffers we want to create
  129720. */
  129721. samplingModes?: number[];
  129722. /**
  129723. * Define if a depth buffer is required
  129724. */
  129725. generateDepthBuffer?: boolean;
  129726. /**
  129727. * Define if a stencil buffer is required
  129728. */
  129729. generateStencilBuffer?: boolean;
  129730. /**
  129731. * Define if a depth texture is required instead of a depth buffer
  129732. */
  129733. generateDepthTexture?: boolean;
  129734. /**
  129735. * Define the number of desired draw buffers
  129736. */
  129737. textureCount?: number;
  129738. /**
  129739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129740. */
  129741. doNotChangeAspectRatio?: boolean;
  129742. /**
  129743. * Define the default type of the buffers we are creating
  129744. */
  129745. defaultType?: number;
  129746. }
  129747. /**
  129748. * A multi render target, like a render target provides the ability to render to a texture.
  129749. * Unlike the render target, it can render to several draw buffers in one draw.
  129750. * This is specially interesting in deferred rendering or for any effects requiring more than
  129751. * just one color from a single pass.
  129752. */
  129753. export class MultiRenderTarget extends RenderTargetTexture {
  129754. private _internalTextures;
  129755. private _textures;
  129756. private _multiRenderTargetOptions;
  129757. private _count;
  129758. /**
  129759. * Get if draw buffers are currently supported by the used hardware and browser.
  129760. */
  129761. get isSupported(): boolean;
  129762. /**
  129763. * Get the list of textures generated by the multi render target.
  129764. */
  129765. get textures(): Texture[];
  129766. /**
  129767. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129768. */
  129769. get count(): number;
  129770. /**
  129771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129772. */
  129773. get depthTexture(): Texture;
  129774. /**
  129775. * Set the wrapping mode on U of all the textures we are rendering to.
  129776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129777. */
  129778. set wrapU(wrap: number);
  129779. /**
  129780. * Set the wrapping mode on V of all the textures we are rendering to.
  129781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129782. */
  129783. set wrapV(wrap: number);
  129784. /**
  129785. * Instantiate a new multi render target texture.
  129786. * A multi render target, like a render target provides the ability to render to a texture.
  129787. * Unlike the render target, it can render to several draw buffers in one draw.
  129788. * This is specially interesting in deferred rendering or for any effects requiring more than
  129789. * just one color from a single pass.
  129790. * @param name Define the name of the texture
  129791. * @param size Define the size of the buffers to render to
  129792. * @param count Define the number of target we are rendering into
  129793. * @param scene Define the scene the texture belongs to
  129794. * @param options Define the options used to create the multi render target
  129795. */
  129796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129797. /** @hidden */
  129798. _rebuild(): void;
  129799. private _createInternalTextures;
  129800. private _createTextures;
  129801. /**
  129802. * Define the number of samples used if MSAA is enabled.
  129803. */
  129804. get samples(): number;
  129805. set samples(value: number);
  129806. /**
  129807. * Resize all the textures in the multi render target.
  129808. * Be carrefull as it will recreate all the data in the new texture.
  129809. * @param size Define the new size
  129810. */
  129811. resize(size: any): void;
  129812. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129813. /**
  129814. * Dispose the render targets and their associated resources
  129815. */
  129816. dispose(): void;
  129817. /**
  129818. * Release all the underlying texture used as draw buffers.
  129819. */
  129820. releaseInternalTextures(): void;
  129821. }
  129822. }
  129823. declare module BABYLON {
  129824. interface ThinEngine {
  129825. /**
  129826. * Unbind a list of render target textures from the webGL context
  129827. * This is used only when drawBuffer extension or webGL2 are active
  129828. * @param textures defines the render target textures to unbind
  129829. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129830. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129831. */
  129832. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129833. /**
  129834. * Create a multi render target texture
  129835. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129836. * @param size defines the size of the texture
  129837. * @param options defines the creation options
  129838. * @returns the cube texture as an InternalTexture
  129839. */
  129840. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129841. /**
  129842. * Update the sample count for a given multiple render target texture
  129843. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129844. * @param textures defines the textures to update
  129845. * @param samples defines the sample count to set
  129846. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129847. */
  129848. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129849. /**
  129850. * Select a subsets of attachments to draw to.
  129851. * @param attachments gl attachments
  129852. */
  129853. bindAttachments(attachments: number[]): void;
  129854. }
  129855. }
  129856. declare module BABYLON {
  129857. /**
  129858. * Class used to define an additional view for the engine
  129859. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129860. */
  129861. export class EngineView {
  129862. /** Defines the canvas where to render the view */
  129863. target: HTMLCanvasElement;
  129864. /** Defines an optional camera used to render the view (will use active camera else) */
  129865. camera?: Camera;
  129866. }
  129867. interface Engine {
  129868. /**
  129869. * Gets or sets the HTML element to use for attaching events
  129870. */
  129871. inputElement: Nullable<HTMLElement>;
  129872. /**
  129873. * Gets the current engine view
  129874. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129875. */
  129876. activeView: Nullable<EngineView>;
  129877. /** Gets or sets the list of views */
  129878. views: EngineView[];
  129879. /**
  129880. * Register a new child canvas
  129881. * @param canvas defines the canvas to register
  129882. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129883. * @returns the associated view
  129884. */
  129885. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129886. /**
  129887. * Remove a registered child canvas
  129888. * @param canvas defines the canvas to remove
  129889. * @returns the current engine
  129890. */
  129891. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129892. }
  129893. }
  129894. declare module BABYLON {
  129895. interface Engine {
  129896. /** @hidden */
  129897. _excludedCompressedTextures: string[];
  129898. /** @hidden */
  129899. _textureFormatInUse: string;
  129900. /**
  129901. * Gets the list of texture formats supported
  129902. */
  129903. readonly texturesSupported: Array<string>;
  129904. /**
  129905. * Gets the texture format in use
  129906. */
  129907. readonly textureFormatInUse: Nullable<string>;
  129908. /**
  129909. * Set the compressed texture extensions or file names to skip.
  129910. *
  129911. * @param skippedFiles defines the list of those texture files you want to skip
  129912. * Example: [".dds", ".env", "myfile.png"]
  129913. */
  129914. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129915. /**
  129916. * Set the compressed texture format to use, based on the formats you have, and the formats
  129917. * supported by the hardware / browser.
  129918. *
  129919. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129920. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129921. * to API arguments needed to compressed textures. This puts the burden on the container
  129922. * generator to house the arcane code for determining these for current & future formats.
  129923. *
  129924. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129925. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129926. *
  129927. * Note: The result of this call is not taken into account when a texture is base64.
  129928. *
  129929. * @param formatsAvailable defines the list of those format families you have created
  129930. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129931. *
  129932. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129933. * @returns The extension selected.
  129934. */
  129935. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129936. }
  129937. }
  129938. declare module BABYLON {
  129939. /**
  129940. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129941. */
  129942. export interface CubeMapInfo {
  129943. /**
  129944. * The pixel array for the front face.
  129945. * This is stored in format, left to right, up to down format.
  129946. */
  129947. front: Nullable<ArrayBufferView>;
  129948. /**
  129949. * The pixel array for the back face.
  129950. * This is stored in format, left to right, up to down format.
  129951. */
  129952. back: Nullable<ArrayBufferView>;
  129953. /**
  129954. * The pixel array for the left face.
  129955. * This is stored in format, left to right, up to down format.
  129956. */
  129957. left: Nullable<ArrayBufferView>;
  129958. /**
  129959. * The pixel array for the right face.
  129960. * This is stored in format, left to right, up to down format.
  129961. */
  129962. right: Nullable<ArrayBufferView>;
  129963. /**
  129964. * The pixel array for the up face.
  129965. * This is stored in format, left to right, up to down format.
  129966. */
  129967. up: Nullable<ArrayBufferView>;
  129968. /**
  129969. * The pixel array for the down face.
  129970. * This is stored in format, left to right, up to down format.
  129971. */
  129972. down: Nullable<ArrayBufferView>;
  129973. /**
  129974. * The size of the cubemap stored.
  129975. *
  129976. * Each faces will be size * size pixels.
  129977. */
  129978. size: number;
  129979. /**
  129980. * The format of the texture.
  129981. *
  129982. * RGBA, RGB.
  129983. */
  129984. format: number;
  129985. /**
  129986. * The type of the texture data.
  129987. *
  129988. * UNSIGNED_INT, FLOAT.
  129989. */
  129990. type: number;
  129991. /**
  129992. * Specifies whether the texture is in gamma space.
  129993. */
  129994. gammaSpace: boolean;
  129995. }
  129996. /**
  129997. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129998. */
  129999. export class PanoramaToCubeMapTools {
  130000. private static FACE_LEFT;
  130001. private static FACE_RIGHT;
  130002. private static FACE_FRONT;
  130003. private static FACE_BACK;
  130004. private static FACE_DOWN;
  130005. private static FACE_UP;
  130006. /**
  130007. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  130008. *
  130009. * @param float32Array The source data.
  130010. * @param inputWidth The width of the input panorama.
  130011. * @param inputHeight The height of the input panorama.
  130012. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  130013. * @return The cubemap data
  130014. */
  130015. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  130016. private static CreateCubemapTexture;
  130017. private static CalcProjectionSpherical;
  130018. }
  130019. }
  130020. declare module BABYLON {
  130021. /**
  130022. * Helper class dealing with the extraction of spherical polynomial dataArray
  130023. * from a cube map.
  130024. */
  130025. export class CubeMapToSphericalPolynomialTools {
  130026. private static FileFaces;
  130027. /**
  130028. * Converts a texture to the according Spherical Polynomial data.
  130029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130030. *
  130031. * @param texture The texture to extract the information from.
  130032. * @return The Spherical Polynomial data.
  130033. */
  130034. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  130035. /**
  130036. * Converts a cubemap to the according Spherical Polynomial data.
  130037. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130038. *
  130039. * @param cubeInfo The Cube map to extract the information from.
  130040. * @return The Spherical Polynomial data.
  130041. */
  130042. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  130043. }
  130044. }
  130045. declare module BABYLON {
  130046. interface BaseTexture {
  130047. /**
  130048. * Get the polynomial representation of the texture data.
  130049. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  130050. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  130051. */
  130052. sphericalPolynomial: Nullable<SphericalPolynomial>;
  130053. }
  130054. }
  130055. declare module BABYLON {
  130056. /** @hidden */
  130057. export var rgbdEncodePixelShader: {
  130058. name: string;
  130059. shader: string;
  130060. };
  130061. }
  130062. declare module BABYLON {
  130063. /** @hidden */
  130064. export var rgbdDecodePixelShader: {
  130065. name: string;
  130066. shader: string;
  130067. };
  130068. }
  130069. declare module BABYLON {
  130070. /**
  130071. * Raw texture data and descriptor sufficient for WebGL texture upload
  130072. */
  130073. export interface EnvironmentTextureInfo {
  130074. /**
  130075. * Version of the environment map
  130076. */
  130077. version: number;
  130078. /**
  130079. * Width of image
  130080. */
  130081. width: number;
  130082. /**
  130083. * Irradiance information stored in the file.
  130084. */
  130085. irradiance: any;
  130086. /**
  130087. * Specular information stored in the file.
  130088. */
  130089. specular: any;
  130090. }
  130091. /**
  130092. * Defines One Image in the file. It requires only the position in the file
  130093. * as well as the length.
  130094. */
  130095. interface BufferImageData {
  130096. /**
  130097. * Length of the image data.
  130098. */
  130099. length: number;
  130100. /**
  130101. * Position of the data from the null terminator delimiting the end of the JSON.
  130102. */
  130103. position: number;
  130104. }
  130105. /**
  130106. * Defines the specular data enclosed in the file.
  130107. * This corresponds to the version 1 of the data.
  130108. */
  130109. export interface EnvironmentTextureSpecularInfoV1 {
  130110. /**
  130111. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  130112. */
  130113. specularDataPosition?: number;
  130114. /**
  130115. * This contains all the images data needed to reconstruct the cubemap.
  130116. */
  130117. mipmaps: Array<BufferImageData>;
  130118. /**
  130119. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  130120. */
  130121. lodGenerationScale: number;
  130122. }
  130123. /**
  130124. * Sets of helpers addressing the serialization and deserialization of environment texture
  130125. * stored in a BabylonJS env file.
  130126. * Those files are usually stored as .env files.
  130127. */
  130128. export class EnvironmentTextureTools {
  130129. /**
  130130. * Magic number identifying the env file.
  130131. */
  130132. private static _MagicBytes;
  130133. /**
  130134. * Gets the environment info from an env file.
  130135. * @param data The array buffer containing the .env bytes.
  130136. * @returns the environment file info (the json header) if successfully parsed.
  130137. */
  130138. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  130139. /**
  130140. * Creates an environment texture from a loaded cube texture.
  130141. * @param texture defines the cube texture to convert in env file
  130142. * @return a promise containing the environment data if succesfull.
  130143. */
  130144. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  130145. /**
  130146. * Creates a JSON representation of the spherical data.
  130147. * @param texture defines the texture containing the polynomials
  130148. * @return the JSON representation of the spherical info
  130149. */
  130150. private static _CreateEnvTextureIrradiance;
  130151. /**
  130152. * Creates the ArrayBufferViews used for initializing environment texture image data.
  130153. * @param data the image data
  130154. * @param info parameters that determine what views will be created for accessing the underlying buffer
  130155. * @return the views described by info providing access to the underlying buffer
  130156. */
  130157. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  130158. /**
  130159. * Uploads the texture info contained in the env file to the GPU.
  130160. * @param texture defines the internal texture to upload to
  130161. * @param data defines the data to load
  130162. * @param info defines the texture info retrieved through the GetEnvInfo method
  130163. * @returns a promise
  130164. */
  130165. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  130166. private static _OnImageReadyAsync;
  130167. /**
  130168. * Uploads the levels of image data to the GPU.
  130169. * @param texture defines the internal texture to upload to
  130170. * @param imageData defines the array buffer views of image data [mipmap][face]
  130171. * @returns a promise
  130172. */
  130173. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  130174. /**
  130175. * Uploads spherical polynomials information to the texture.
  130176. * @param texture defines the texture we are trying to upload the information to
  130177. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  130178. */
  130179. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  130180. /** @hidden */
  130181. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130182. }
  130183. }
  130184. declare module BABYLON {
  130185. /**
  130186. * Class used to inline functions in shader code
  130187. */
  130188. export class ShaderCodeInliner {
  130189. private static readonly _RegexpFindFunctionNameAndType;
  130190. private _sourceCode;
  130191. private _functionDescr;
  130192. private _numMaxIterations;
  130193. /** Gets or sets the token used to mark the functions to inline */
  130194. inlineToken: string;
  130195. /** Gets or sets the debug mode */
  130196. debug: boolean;
  130197. /** Gets the code after the inlining process */
  130198. get code(): string;
  130199. /**
  130200. * Initializes the inliner
  130201. * @param sourceCode shader code source to inline
  130202. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  130203. */
  130204. constructor(sourceCode: string, numMaxIterations?: number);
  130205. /**
  130206. * Start the processing of the shader code
  130207. */
  130208. processCode(): void;
  130209. private _collectFunctions;
  130210. private _processInlining;
  130211. private _extractBetweenMarkers;
  130212. private _skipWhitespaces;
  130213. private _removeComments;
  130214. private _replaceFunctionCallsByCode;
  130215. private _findBackward;
  130216. private _escapeRegExp;
  130217. private _replaceNames;
  130218. }
  130219. }
  130220. declare module BABYLON {
  130221. /**
  130222. * Container for accessors for natively-stored mesh data buffers.
  130223. */
  130224. class NativeDataBuffer extends DataBuffer {
  130225. /**
  130226. * Accessor value used to identify/retrieve a natively-stored index buffer.
  130227. */
  130228. nativeIndexBuffer?: any;
  130229. /**
  130230. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  130231. */
  130232. nativeVertexBuffer?: any;
  130233. }
  130234. /** @hidden */
  130235. class NativeTexture extends InternalTexture {
  130236. getInternalTexture(): InternalTexture;
  130237. getViewCount(): number;
  130238. }
  130239. /** @hidden */
  130240. export class NativeEngine extends Engine {
  130241. private readonly _native;
  130242. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  130243. private readonly INVALID_HANDLE;
  130244. getHardwareScalingLevel(): number;
  130245. constructor();
  130246. dispose(): void;
  130247. /**
  130248. * Can be used to override the current requestAnimationFrame requester.
  130249. * @hidden
  130250. */
  130251. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  130252. /**
  130253. * Override default engine behavior.
  130254. * @param color
  130255. * @param backBuffer
  130256. * @param depth
  130257. * @param stencil
  130258. */
  130259. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  130260. /**
  130261. * Gets host document
  130262. * @returns the host document object
  130263. */
  130264. getHostDocument(): Nullable<Document>;
  130265. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130266. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  130267. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  130268. recordVertexArrayObject(vertexBuffers: {
  130269. [key: string]: VertexBuffer;
  130270. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  130271. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130272. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130274. /**
  130275. * Draw a list of indexed primitives
  130276. * @param fillMode defines the primitive to use
  130277. * @param indexStart defines the starting index
  130278. * @param indexCount defines the number of index to draw
  130279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130280. */
  130281. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130282. /**
  130283. * Draw a list of unindexed primitives
  130284. * @param fillMode defines the primitive to use
  130285. * @param verticesStart defines the index of first vertex to draw
  130286. * @param verticesCount defines the count of vertices to draw
  130287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130288. */
  130289. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130290. createPipelineContext(): IPipelineContext;
  130291. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  130292. /** @hidden */
  130293. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130294. /** @hidden */
  130295. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130296. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130297. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130298. protected _setProgram(program: WebGLProgram): void;
  130299. _releaseEffect(effect: Effect): void;
  130300. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130301. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  130302. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130303. bindSamplers(effect: Effect): void;
  130304. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  130305. getRenderWidth(useScreen?: boolean): number;
  130306. getRenderHeight(useScreen?: boolean): number;
  130307. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  130308. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130309. /**
  130310. * Set the z offset to apply to current rendering
  130311. * @param value defines the offset to apply
  130312. */
  130313. setZOffset(value: number): void;
  130314. /**
  130315. * Gets the current value of the zOffset
  130316. * @returns the current zOffset state
  130317. */
  130318. getZOffset(): number;
  130319. /**
  130320. * Enable or disable depth buffering
  130321. * @param enable defines the state to set
  130322. */
  130323. setDepthBuffer(enable: boolean): void;
  130324. /**
  130325. * Gets a boolean indicating if depth writing is enabled
  130326. * @returns the current depth writing state
  130327. */
  130328. getDepthWrite(): boolean;
  130329. /**
  130330. * Enable or disable depth writing
  130331. * @param enable defines the state to set
  130332. */
  130333. setDepthWrite(enable: boolean): void;
  130334. /**
  130335. * Enable or disable color writing
  130336. * @param enable defines the state to set
  130337. */
  130338. setColorWrite(enable: boolean): void;
  130339. /**
  130340. * Gets a boolean indicating if color writing is enabled
  130341. * @returns the current color writing state
  130342. */
  130343. getColorWrite(): boolean;
  130344. /**
  130345. * Sets alpha constants used by some alpha blending modes
  130346. * @param r defines the red component
  130347. * @param g defines the green component
  130348. * @param b defines the blue component
  130349. * @param a defines the alpha component
  130350. */
  130351. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130352. /**
  130353. * Sets the current alpha mode
  130354. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130355. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130357. */
  130358. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130359. /**
  130360. * Gets the current alpha mode
  130361. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130362. * @returns the current alpha mode
  130363. */
  130364. getAlphaMode(): number;
  130365. setInt(uniform: WebGLUniformLocation, int: number): void;
  130366. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130367. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130368. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130369. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130370. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130371. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130372. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130373. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130374. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130375. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130376. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130377. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130378. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130379. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130380. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130381. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130382. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130383. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130384. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130385. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130386. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130387. wipeCaches(bruteForce?: boolean): void;
  130388. _createTexture(): WebGLTexture;
  130389. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130390. /**
  130391. * Usually called from Texture.ts.
  130392. * Passed information to create a WebGLTexture
  130393. * @param url defines a value which contains one of the following:
  130394. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130395. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130396. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130397. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130398. * @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)
  130399. * @param scene needed for loading to the correct scene
  130400. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130401. * @param onLoad optional callback to be called upon successful completion
  130402. * @param onError optional callback to be called upon failure
  130403. * @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
  130404. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130405. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130406. * @param forcedExtension defines the extension to use to pick the right loader
  130407. * @param mimeType defines an optional mime type
  130408. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130409. */
  130410. 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;
  130411. /**
  130412. * Creates a cube texture
  130413. * @param rootUrl defines the url where the files to load is located
  130414. * @param scene defines the current scene
  130415. * @param files defines the list of files to load (1 per face)
  130416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130417. * @param onLoad defines an optional callback raised when the texture is loaded
  130418. * @param onError defines an optional callback raised if there is an issue to load the texture
  130419. * @param format defines the format of the data
  130420. * @param forcedExtension defines the extension to use to pick the right loader
  130421. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130424. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130425. * @returns the cube texture as an InternalTexture
  130426. */
  130427. 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;
  130428. private _getSamplingFilter;
  130429. private static _GetNativeTextureFormat;
  130430. createRenderTargetTexture(size: number | {
  130431. width: number;
  130432. height: number;
  130433. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130434. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130435. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130436. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130437. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130438. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130439. /**
  130440. * Updates a dynamic vertex buffer.
  130441. * @param vertexBuffer the vertex buffer to update
  130442. * @param data the data used to update the vertex buffer
  130443. * @param byteOffset the byte offset of the data (optional)
  130444. * @param byteLength the byte length of the data (optional)
  130445. */
  130446. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130447. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130448. private _updateAnisotropicLevel;
  130449. private _getAddressMode;
  130450. /** @hidden */
  130451. _bindTexture(channel: number, texture: InternalTexture): void;
  130452. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130453. releaseEffects(): void;
  130454. /** @hidden */
  130455. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130456. /** @hidden */
  130457. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130458. /** @hidden */
  130459. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130460. /** @hidden */
  130461. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130462. }
  130463. }
  130464. declare module BABYLON {
  130465. /**
  130466. * Gather the list of clipboard event types as constants.
  130467. */
  130468. export class ClipboardEventTypes {
  130469. /**
  130470. * The clipboard event is fired when a copy command is active (pressed).
  130471. */
  130472. static readonly COPY: number;
  130473. /**
  130474. * The clipboard event is fired when a cut command is active (pressed).
  130475. */
  130476. static readonly CUT: number;
  130477. /**
  130478. * The clipboard event is fired when a paste command is active (pressed).
  130479. */
  130480. static readonly PASTE: number;
  130481. }
  130482. /**
  130483. * This class is used to store clipboard related info for the onClipboardObservable event.
  130484. */
  130485. export class ClipboardInfo {
  130486. /**
  130487. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130488. */
  130489. type: number;
  130490. /**
  130491. * Defines the related dom event
  130492. */
  130493. event: ClipboardEvent;
  130494. /**
  130495. *Creates an instance of ClipboardInfo.
  130496. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130497. * @param event Defines the related dom event
  130498. */
  130499. constructor(
  130500. /**
  130501. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130502. */
  130503. type: number,
  130504. /**
  130505. * Defines the related dom event
  130506. */
  130507. event: ClipboardEvent);
  130508. /**
  130509. * Get the clipboard event's type from the keycode.
  130510. * @param keyCode Defines the keyCode for the current keyboard event.
  130511. * @return {number}
  130512. */
  130513. static GetTypeFromCharacter(keyCode: number): number;
  130514. }
  130515. }
  130516. declare module BABYLON {
  130517. /**
  130518. * Google Daydream controller
  130519. */
  130520. export class DaydreamController extends WebVRController {
  130521. /**
  130522. * Base Url for the controller model.
  130523. */
  130524. static MODEL_BASE_URL: string;
  130525. /**
  130526. * File name for the controller model.
  130527. */
  130528. static MODEL_FILENAME: string;
  130529. /**
  130530. * Gamepad Id prefix used to identify Daydream Controller.
  130531. */
  130532. static readonly GAMEPAD_ID_PREFIX: string;
  130533. /**
  130534. * Creates a new DaydreamController from a gamepad
  130535. * @param vrGamepad the gamepad that the controller should be created from
  130536. */
  130537. constructor(vrGamepad: any);
  130538. /**
  130539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130540. * @param scene scene in which to add meshes
  130541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130542. */
  130543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130544. /**
  130545. * Called once for each button that changed state since the last frame
  130546. * @param buttonIdx Which button index changed
  130547. * @param state New state of the button
  130548. * @param changes Which properties on the state changed since last frame
  130549. */
  130550. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130551. }
  130552. }
  130553. declare module BABYLON {
  130554. /**
  130555. * Gear VR Controller
  130556. */
  130557. export class GearVRController extends WebVRController {
  130558. /**
  130559. * Base Url for the controller model.
  130560. */
  130561. static MODEL_BASE_URL: string;
  130562. /**
  130563. * File name for the controller model.
  130564. */
  130565. static MODEL_FILENAME: string;
  130566. /**
  130567. * Gamepad Id prefix used to identify this controller.
  130568. */
  130569. static readonly GAMEPAD_ID_PREFIX: string;
  130570. private readonly _buttonIndexToObservableNameMap;
  130571. /**
  130572. * Creates a new GearVRController from a gamepad
  130573. * @param vrGamepad the gamepad that the controller should be created from
  130574. */
  130575. constructor(vrGamepad: any);
  130576. /**
  130577. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130578. * @param scene scene in which to add meshes
  130579. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130580. */
  130581. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130582. /**
  130583. * Called once for each button that changed state since the last frame
  130584. * @param buttonIdx Which button index changed
  130585. * @param state New state of the button
  130586. * @param changes Which properties on the state changed since last frame
  130587. */
  130588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130589. }
  130590. }
  130591. declare module BABYLON {
  130592. /**
  130593. * Generic Controller
  130594. */
  130595. export class GenericController extends WebVRController {
  130596. /**
  130597. * Base Url for the controller model.
  130598. */
  130599. static readonly MODEL_BASE_URL: string;
  130600. /**
  130601. * File name for the controller model.
  130602. */
  130603. static readonly MODEL_FILENAME: string;
  130604. /**
  130605. * Creates a new GenericController from a gamepad
  130606. * @param vrGamepad the gamepad that the controller should be created from
  130607. */
  130608. constructor(vrGamepad: any);
  130609. /**
  130610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130611. * @param scene scene in which to add meshes
  130612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130613. */
  130614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130615. /**
  130616. * Called once for each button that changed state since the last frame
  130617. * @param buttonIdx Which button index changed
  130618. * @param state New state of the button
  130619. * @param changes Which properties on the state changed since last frame
  130620. */
  130621. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130622. }
  130623. }
  130624. declare module BABYLON {
  130625. /**
  130626. * Oculus Touch Controller
  130627. */
  130628. export class OculusTouchController extends WebVRController {
  130629. /**
  130630. * Base Url for the controller model.
  130631. */
  130632. static MODEL_BASE_URL: string;
  130633. /**
  130634. * File name for the left controller model.
  130635. */
  130636. static MODEL_LEFT_FILENAME: string;
  130637. /**
  130638. * File name for the right controller model.
  130639. */
  130640. static MODEL_RIGHT_FILENAME: string;
  130641. /**
  130642. * Base Url for the Quest controller model.
  130643. */
  130644. static QUEST_MODEL_BASE_URL: string;
  130645. /**
  130646. * @hidden
  130647. * If the controllers are running on a device that needs the updated Quest controller models
  130648. */
  130649. static _IsQuest: boolean;
  130650. /**
  130651. * Fired when the secondary trigger on this controller is modified
  130652. */
  130653. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130654. /**
  130655. * Fired when the thumb rest on this controller is modified
  130656. */
  130657. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130658. /**
  130659. * Creates a new OculusTouchController from a gamepad
  130660. * @param vrGamepad the gamepad that the controller should be created from
  130661. */
  130662. constructor(vrGamepad: any);
  130663. /**
  130664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130665. * @param scene scene in which to add meshes
  130666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130667. */
  130668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130669. /**
  130670. * Fired when the A button on this controller is modified
  130671. */
  130672. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130673. /**
  130674. * Fired when the B button on this controller is modified
  130675. */
  130676. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130677. /**
  130678. * Fired when the X button on this controller is modified
  130679. */
  130680. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130681. /**
  130682. * Fired when the Y button on this controller is modified
  130683. */
  130684. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130685. /**
  130686. * Called once for each button that changed state since the last frame
  130687. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130688. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130689. * 2) secondary trigger (same)
  130690. * 3) A (right) X (left), touch, pressed = value
  130691. * 4) B / Y
  130692. * 5) thumb rest
  130693. * @param buttonIdx Which button index changed
  130694. * @param state New state of the button
  130695. * @param changes Which properties on the state changed since last frame
  130696. */
  130697. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130698. }
  130699. }
  130700. declare module BABYLON {
  130701. /**
  130702. * Vive Controller
  130703. */
  130704. export class ViveController extends WebVRController {
  130705. /**
  130706. * Base Url for the controller model.
  130707. */
  130708. static MODEL_BASE_URL: string;
  130709. /**
  130710. * File name for the controller model.
  130711. */
  130712. static MODEL_FILENAME: string;
  130713. /**
  130714. * Creates a new ViveController from a gamepad
  130715. * @param vrGamepad the gamepad that the controller should be created from
  130716. */
  130717. constructor(vrGamepad: any);
  130718. /**
  130719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130720. * @param scene scene in which to add meshes
  130721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130722. */
  130723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130724. /**
  130725. * Fired when the left button on this controller is modified
  130726. */
  130727. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130728. /**
  130729. * Fired when the right button on this controller is modified
  130730. */
  130731. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130732. /**
  130733. * Fired when the menu button on this controller is modified
  130734. */
  130735. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130736. /**
  130737. * Called once for each button that changed state since the last frame
  130738. * Vive mapping:
  130739. * 0: touchpad
  130740. * 1: trigger
  130741. * 2: left AND right buttons
  130742. * 3: menu button
  130743. * @param buttonIdx Which button index changed
  130744. * @param state New state of the button
  130745. * @param changes Which properties on the state changed since last frame
  130746. */
  130747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130748. }
  130749. }
  130750. declare module BABYLON {
  130751. /**
  130752. * Defines the WindowsMotionController object that the state of the windows motion controller
  130753. */
  130754. export class WindowsMotionController extends WebVRController {
  130755. /**
  130756. * The base url used to load the left and right controller models
  130757. */
  130758. static MODEL_BASE_URL: string;
  130759. /**
  130760. * The name of the left controller model file
  130761. */
  130762. static MODEL_LEFT_FILENAME: string;
  130763. /**
  130764. * The name of the right controller model file
  130765. */
  130766. static MODEL_RIGHT_FILENAME: string;
  130767. /**
  130768. * The controller name prefix for this controller type
  130769. */
  130770. static readonly GAMEPAD_ID_PREFIX: string;
  130771. /**
  130772. * The controller id pattern for this controller type
  130773. */
  130774. private static readonly GAMEPAD_ID_PATTERN;
  130775. private _loadedMeshInfo;
  130776. protected readonly _mapping: {
  130777. buttons: string[];
  130778. buttonMeshNames: {
  130779. trigger: string;
  130780. menu: string;
  130781. grip: string;
  130782. thumbstick: string;
  130783. trackpad: string;
  130784. };
  130785. buttonObservableNames: {
  130786. trigger: string;
  130787. menu: string;
  130788. grip: string;
  130789. thumbstick: string;
  130790. trackpad: string;
  130791. };
  130792. axisMeshNames: string[];
  130793. pointingPoseMeshName: string;
  130794. };
  130795. /**
  130796. * Fired when the trackpad on this controller is clicked
  130797. */
  130798. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130799. /**
  130800. * Fired when the trackpad on this controller is modified
  130801. */
  130802. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130803. /**
  130804. * The current x and y values of this controller's trackpad
  130805. */
  130806. trackpad: StickValues;
  130807. /**
  130808. * Creates a new WindowsMotionController from a gamepad
  130809. * @param vrGamepad the gamepad that the controller should be created from
  130810. */
  130811. constructor(vrGamepad: any);
  130812. /**
  130813. * Fired when the trigger on this controller is modified
  130814. */
  130815. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130816. /**
  130817. * Fired when the menu button on this controller is modified
  130818. */
  130819. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130820. /**
  130821. * Fired when the grip button on this controller is modified
  130822. */
  130823. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130824. /**
  130825. * Fired when the thumbstick button on this controller is modified
  130826. */
  130827. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130828. /**
  130829. * Fired when the touchpad button on this controller is modified
  130830. */
  130831. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130832. /**
  130833. * Fired when the touchpad values on this controller are modified
  130834. */
  130835. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130836. protected _updateTrackpad(): void;
  130837. /**
  130838. * Called once per frame by the engine.
  130839. */
  130840. update(): void;
  130841. /**
  130842. * Called once for each button that changed state since the last frame
  130843. * @param buttonIdx Which button index changed
  130844. * @param state New state of the button
  130845. * @param changes Which properties on the state changed since last frame
  130846. */
  130847. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130848. /**
  130849. * Moves the buttons on the controller mesh based on their current state
  130850. * @param buttonName the name of the button to move
  130851. * @param buttonValue the value of the button which determines the buttons new position
  130852. */
  130853. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130854. /**
  130855. * Moves the axis on the controller mesh based on its current state
  130856. * @param axis the index of the axis
  130857. * @param axisValue the value of the axis which determines the meshes new position
  130858. * @hidden
  130859. */
  130860. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130861. /**
  130862. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130863. * @param scene scene in which to add meshes
  130864. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130865. */
  130866. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130867. /**
  130868. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130869. * can be transformed by button presses and axes values, based on this._mapping.
  130870. *
  130871. * @param scene scene in which the meshes exist
  130872. * @param meshes list of meshes that make up the controller model to process
  130873. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130874. */
  130875. private processModel;
  130876. private createMeshInfo;
  130877. /**
  130878. * Gets the ray of the controller in the direction the controller is pointing
  130879. * @param length the length the resulting ray should be
  130880. * @returns a ray in the direction the controller is pointing
  130881. */
  130882. getForwardRay(length?: number): Ray;
  130883. /**
  130884. * Disposes of the controller
  130885. */
  130886. dispose(): void;
  130887. }
  130888. /**
  130889. * This class represents a new windows motion controller in XR.
  130890. */
  130891. export class XRWindowsMotionController extends WindowsMotionController {
  130892. /**
  130893. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130894. */
  130895. protected readonly _mapping: {
  130896. buttons: string[];
  130897. buttonMeshNames: {
  130898. trigger: string;
  130899. menu: string;
  130900. grip: string;
  130901. thumbstick: string;
  130902. trackpad: string;
  130903. };
  130904. buttonObservableNames: {
  130905. trigger: string;
  130906. menu: string;
  130907. grip: string;
  130908. thumbstick: string;
  130909. trackpad: string;
  130910. };
  130911. axisMeshNames: string[];
  130912. pointingPoseMeshName: string;
  130913. };
  130914. /**
  130915. * Construct a new XR-Based windows motion controller
  130916. *
  130917. * @param gamepadInfo the gamepad object from the browser
  130918. */
  130919. constructor(gamepadInfo: any);
  130920. /**
  130921. * holds the thumbstick values (X,Y)
  130922. */
  130923. thumbstickValues: StickValues;
  130924. /**
  130925. * Fired when the thumbstick on this controller is clicked
  130926. */
  130927. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130928. /**
  130929. * Fired when the thumbstick on this controller is modified
  130930. */
  130931. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130932. /**
  130933. * Fired when the touchpad button on this controller is modified
  130934. */
  130935. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130936. /**
  130937. * Fired when the touchpad values on this controller are modified
  130938. */
  130939. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130940. /**
  130941. * Fired when the thumbstick button on this controller is modified
  130942. * here to prevent breaking changes
  130943. */
  130944. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130945. /**
  130946. * updating the thumbstick(!) and not the trackpad.
  130947. * This is named this way due to the difference between WebVR and XR and to avoid
  130948. * changing the parent class.
  130949. */
  130950. protected _updateTrackpad(): void;
  130951. /**
  130952. * Disposes the class with joy
  130953. */
  130954. dispose(): void;
  130955. }
  130956. }
  130957. declare module BABYLON {
  130958. /**
  130959. * Class containing static functions to help procedurally build meshes
  130960. */
  130961. export class PolyhedronBuilder {
  130962. /**
  130963. * Creates a polyhedron mesh
  130964. * * 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
  130965. * * The parameter `size` (positive float, default 1) sets the polygon size
  130966. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130967. * * 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`
  130968. * * 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
  130969. * * 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)`)
  130970. * * 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
  130971. * * 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
  130972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130975. * @param name defines the name of the mesh
  130976. * @param options defines the options used to create the mesh
  130977. * @param scene defines the hosting scene
  130978. * @returns the polyhedron mesh
  130979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130980. */
  130981. static CreatePolyhedron(name: string, options: {
  130982. type?: number;
  130983. size?: number;
  130984. sizeX?: number;
  130985. sizeY?: number;
  130986. sizeZ?: number;
  130987. custom?: any;
  130988. faceUV?: Vector4[];
  130989. faceColors?: Color4[];
  130990. flat?: boolean;
  130991. updatable?: boolean;
  130992. sideOrientation?: number;
  130993. frontUVs?: Vector4;
  130994. backUVs?: Vector4;
  130995. }, scene?: Nullable<Scene>): Mesh;
  130996. }
  130997. }
  130998. declare module BABYLON {
  130999. /**
  131000. * Gizmo that enables scaling a mesh along 3 axis
  131001. */
  131002. export class ScaleGizmo extends Gizmo {
  131003. /**
  131004. * Internal gizmo used for interactions on the x axis
  131005. */
  131006. xGizmo: AxisScaleGizmo;
  131007. /**
  131008. * Internal gizmo used for interactions on the y axis
  131009. */
  131010. yGizmo: AxisScaleGizmo;
  131011. /**
  131012. * Internal gizmo used for interactions on the z axis
  131013. */
  131014. zGizmo: AxisScaleGizmo;
  131015. /**
  131016. * Internal gizmo used to scale all axis equally
  131017. */
  131018. uniformScaleGizmo: AxisScaleGizmo;
  131019. private _meshAttached;
  131020. private _nodeAttached;
  131021. private _updateGizmoRotationToMatchAttachedMesh;
  131022. private _snapDistance;
  131023. private _scaleRatio;
  131024. private _uniformScalingMesh;
  131025. private _octahedron;
  131026. private _sensitivity;
  131027. /** Fires an event when any of it's sub gizmos are dragged */
  131028. onDragStartObservable: Observable<unknown>;
  131029. /** Fires an event when any of it's sub gizmos are released from dragging */
  131030. onDragEndObservable: Observable<unknown>;
  131031. get attachedMesh(): Nullable<AbstractMesh>;
  131032. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131033. get attachedNode(): Nullable<Node>;
  131034. set attachedNode(node: Nullable<Node>);
  131035. /**
  131036. * Creates a ScaleGizmo
  131037. * @param gizmoLayer The utility layer the gizmo will be added to
  131038. */
  131039. constructor(gizmoLayer?: UtilityLayerRenderer);
  131040. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131041. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131042. /**
  131043. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131044. */
  131045. set snapDistance(value: number);
  131046. get snapDistance(): number;
  131047. /**
  131048. * Ratio for the scale of the gizmo (Default: 1)
  131049. */
  131050. set scaleRatio(value: number);
  131051. get scaleRatio(): number;
  131052. /**
  131053. * Sensitivity factor for dragging (Default: 1)
  131054. */
  131055. set sensitivity(value: number);
  131056. get sensitivity(): number;
  131057. /**
  131058. * Disposes of the gizmo
  131059. */
  131060. dispose(): void;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * Single axis scale gizmo
  131066. */
  131067. export class AxisScaleGizmo extends Gizmo {
  131068. /**
  131069. * Drag behavior responsible for the gizmos dragging interactions
  131070. */
  131071. dragBehavior: PointerDragBehavior;
  131072. private _pointerObserver;
  131073. /**
  131074. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131075. */
  131076. snapDistance: number;
  131077. /**
  131078. * Event that fires each time the gizmo snaps to a new location.
  131079. * * snapDistance is the the change in distance
  131080. */
  131081. onSnapObservable: Observable<{
  131082. snapDistance: number;
  131083. }>;
  131084. /**
  131085. * If the scaling operation should be done on all axis (default: false)
  131086. */
  131087. uniformScaling: boolean;
  131088. /**
  131089. * Custom sensitivity value for the drag strength
  131090. */
  131091. sensitivity: number;
  131092. private _isEnabled;
  131093. private _parent;
  131094. private _arrow;
  131095. private _coloredMaterial;
  131096. private _hoverMaterial;
  131097. /**
  131098. * Creates an AxisScaleGizmo
  131099. * @param gizmoLayer The utility layer the gizmo will be added to
  131100. * @param dragAxis The axis which the gizmo will be able to scale on
  131101. * @param color The color of the gizmo
  131102. */
  131103. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  131104. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131105. /**
  131106. * If the gizmo is enabled
  131107. */
  131108. set isEnabled(value: boolean);
  131109. get isEnabled(): boolean;
  131110. /**
  131111. * Disposes of the gizmo
  131112. */
  131113. dispose(): void;
  131114. /**
  131115. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131116. * @param mesh The mesh to replace the default mesh of the gizmo
  131117. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  131118. */
  131119. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  131120. }
  131121. }
  131122. declare module BABYLON {
  131123. /**
  131124. * Bounding box gizmo
  131125. */
  131126. export class BoundingBoxGizmo extends Gizmo {
  131127. private _lineBoundingBox;
  131128. private _rotateSpheresParent;
  131129. private _scaleBoxesParent;
  131130. private _boundingDimensions;
  131131. private _renderObserver;
  131132. private _pointerObserver;
  131133. private _scaleDragSpeed;
  131134. private _tmpQuaternion;
  131135. private _tmpVector;
  131136. private _tmpRotationMatrix;
  131137. /**
  131138. * 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)
  131139. */
  131140. ignoreChildren: boolean;
  131141. /**
  131142. * 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)
  131143. */
  131144. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  131145. /**
  131146. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  131147. */
  131148. rotationSphereSize: number;
  131149. /**
  131150. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  131151. */
  131152. scaleBoxSize: number;
  131153. /**
  131154. * 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)
  131155. */
  131156. fixedDragMeshScreenSize: boolean;
  131157. /**
  131158. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  131159. */
  131160. fixedDragMeshScreenSizeDistanceFactor: number;
  131161. /**
  131162. * Fired when a rotation sphere or scale box is dragged
  131163. */
  131164. onDragStartObservable: Observable<{}>;
  131165. /**
  131166. * Fired when a scale box is dragged
  131167. */
  131168. onScaleBoxDragObservable: Observable<{}>;
  131169. /**
  131170. * Fired when a scale box drag is ended
  131171. */
  131172. onScaleBoxDragEndObservable: Observable<{}>;
  131173. /**
  131174. * Fired when a rotation sphere is dragged
  131175. */
  131176. onRotationSphereDragObservable: Observable<{}>;
  131177. /**
  131178. * Fired when a rotation sphere drag is ended
  131179. */
  131180. onRotationSphereDragEndObservable: Observable<{}>;
  131181. /**
  131182. * 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)
  131183. */
  131184. scalePivot: Nullable<Vector3>;
  131185. /**
  131186. * Mesh used as a pivot to rotate the attached node
  131187. */
  131188. private _anchorMesh;
  131189. private _existingMeshScale;
  131190. private _dragMesh;
  131191. private pointerDragBehavior;
  131192. private coloredMaterial;
  131193. private hoverColoredMaterial;
  131194. /**
  131195. * Sets the color of the bounding box gizmo
  131196. * @param color the color to set
  131197. */
  131198. setColor(color: Color3): void;
  131199. /**
  131200. * Creates an BoundingBoxGizmo
  131201. * @param gizmoLayer The utility layer the gizmo will be added to
  131202. * @param color The color of the gizmo
  131203. */
  131204. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  131205. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  131206. private _selectNode;
  131207. /**
  131208. * Updates the bounding box information for the Gizmo
  131209. */
  131210. updateBoundingBox(): void;
  131211. private _updateRotationSpheres;
  131212. private _updateScaleBoxes;
  131213. /**
  131214. * Enables rotation on the specified axis and disables rotation on the others
  131215. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  131216. */
  131217. setEnabledRotationAxis(axis: string): void;
  131218. /**
  131219. * Enables/disables scaling
  131220. * @param enable if scaling should be enabled
  131221. * @param homogeneousScaling defines if scaling should only be homogeneous
  131222. */
  131223. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  131224. private _updateDummy;
  131225. /**
  131226. * Enables a pointer drag behavior on the bounding box of the gizmo
  131227. */
  131228. enableDragBehavior(): void;
  131229. /**
  131230. * Disposes of the gizmo
  131231. */
  131232. dispose(): void;
  131233. /**
  131234. * 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)
  131235. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  131236. * @returns the bounding box mesh with the passed in mesh as a child
  131237. */
  131238. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  131239. /**
  131240. * CustomMeshes are not supported by this gizmo
  131241. * @param mesh The mesh to replace the default mesh of the gizmo
  131242. */
  131243. setCustomMesh(mesh: Mesh): void;
  131244. }
  131245. }
  131246. declare module BABYLON {
  131247. /**
  131248. * Single plane rotation gizmo
  131249. */
  131250. export class PlaneRotationGizmo extends Gizmo {
  131251. /**
  131252. * Drag behavior responsible for the gizmos dragging interactions
  131253. */
  131254. dragBehavior: PointerDragBehavior;
  131255. private _pointerObserver;
  131256. /**
  131257. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  131258. */
  131259. snapDistance: number;
  131260. /**
  131261. * Event that fires each time the gizmo snaps to a new location.
  131262. * * snapDistance is the the change in distance
  131263. */
  131264. onSnapObservable: Observable<{
  131265. snapDistance: number;
  131266. }>;
  131267. private _isEnabled;
  131268. private _parent;
  131269. /**
  131270. * Creates a PlaneRotationGizmo
  131271. * @param gizmoLayer The utility layer the gizmo will be added to
  131272. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  131273. * @param color The color of the gizmo
  131274. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131275. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131276. */
  131277. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  131278. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131279. /**
  131280. * If the gizmo is enabled
  131281. */
  131282. set isEnabled(value: boolean);
  131283. get isEnabled(): boolean;
  131284. /**
  131285. * Disposes of the gizmo
  131286. */
  131287. dispose(): void;
  131288. }
  131289. }
  131290. declare module BABYLON {
  131291. /**
  131292. * Gizmo that enables rotating a mesh along 3 axis
  131293. */
  131294. export class RotationGizmo extends Gizmo {
  131295. /**
  131296. * Internal gizmo used for interactions on the x axis
  131297. */
  131298. xGizmo: PlaneRotationGizmo;
  131299. /**
  131300. * Internal gizmo used for interactions on the y axis
  131301. */
  131302. yGizmo: PlaneRotationGizmo;
  131303. /**
  131304. * Internal gizmo used for interactions on the z axis
  131305. */
  131306. zGizmo: PlaneRotationGizmo;
  131307. /** Fires an event when any of it's sub gizmos are dragged */
  131308. onDragStartObservable: Observable<unknown>;
  131309. /** Fires an event when any of it's sub gizmos are released from dragging */
  131310. onDragEndObservable: Observable<unknown>;
  131311. private _meshAttached;
  131312. private _nodeAttached;
  131313. get attachedMesh(): Nullable<AbstractMesh>;
  131314. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131315. get attachedNode(): Nullable<Node>;
  131316. set attachedNode(node: Nullable<Node>);
  131317. /**
  131318. * Creates a RotationGizmo
  131319. * @param gizmoLayer The utility layer the gizmo will be added to
  131320. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131321. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131322. */
  131323. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  131324. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131325. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131326. /**
  131327. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131328. */
  131329. set snapDistance(value: number);
  131330. get snapDistance(): number;
  131331. /**
  131332. * Ratio for the scale of the gizmo (Default: 1)
  131333. */
  131334. set scaleRatio(value: number);
  131335. get scaleRatio(): number;
  131336. /**
  131337. * Disposes of the gizmo
  131338. */
  131339. dispose(): void;
  131340. /**
  131341. * CustomMeshes are not supported by this gizmo
  131342. * @param mesh The mesh to replace the default mesh of the gizmo
  131343. */
  131344. setCustomMesh(mesh: Mesh): void;
  131345. }
  131346. }
  131347. declare module BABYLON {
  131348. /**
  131349. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131350. */
  131351. export class GizmoManager implements IDisposable {
  131352. private scene;
  131353. /**
  131354. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131355. */
  131356. gizmos: {
  131357. positionGizmo: Nullable<PositionGizmo>;
  131358. rotationGizmo: Nullable<RotationGizmo>;
  131359. scaleGizmo: Nullable<ScaleGizmo>;
  131360. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131361. };
  131362. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131363. clearGizmoOnEmptyPointerEvent: boolean;
  131364. /** Fires an event when the manager is attached to a mesh */
  131365. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131366. private _gizmosEnabled;
  131367. private _pointerObserver;
  131368. private _attachedMesh;
  131369. private _boundingBoxColor;
  131370. private _defaultUtilityLayer;
  131371. private _defaultKeepDepthUtilityLayer;
  131372. /**
  131373. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131374. */
  131375. boundingBoxDragBehavior: SixDofDragBehavior;
  131376. /**
  131377. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131378. */
  131379. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131380. /**
  131381. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131382. */
  131383. usePointerToAttachGizmos: boolean;
  131384. /**
  131385. * Utility layer that the bounding box gizmo belongs to
  131386. */
  131387. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131388. /**
  131389. * Utility layer that all gizmos besides bounding box belong to
  131390. */
  131391. get utilityLayer(): UtilityLayerRenderer;
  131392. /**
  131393. * Instatiates a gizmo manager
  131394. * @param scene the scene to overlay the gizmos on top of
  131395. */
  131396. constructor(scene: Scene);
  131397. /**
  131398. * Attaches a set of gizmos to the specified mesh
  131399. * @param mesh The mesh the gizmo's should be attached to
  131400. */
  131401. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131402. /**
  131403. * If the position gizmo is enabled
  131404. */
  131405. set positionGizmoEnabled(value: boolean);
  131406. get positionGizmoEnabled(): boolean;
  131407. /**
  131408. * If the rotation gizmo is enabled
  131409. */
  131410. set rotationGizmoEnabled(value: boolean);
  131411. get rotationGizmoEnabled(): boolean;
  131412. /**
  131413. * If the scale gizmo is enabled
  131414. */
  131415. set scaleGizmoEnabled(value: boolean);
  131416. get scaleGizmoEnabled(): boolean;
  131417. /**
  131418. * If the boundingBox gizmo is enabled
  131419. */
  131420. set boundingBoxGizmoEnabled(value: boolean);
  131421. get boundingBoxGizmoEnabled(): boolean;
  131422. /**
  131423. * Disposes of the gizmo manager
  131424. */
  131425. dispose(): void;
  131426. }
  131427. }
  131428. declare module BABYLON {
  131429. /**
  131430. * A directional light is defined by a direction (what a surprise!).
  131431. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131432. * 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.
  131433. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131434. */
  131435. export class DirectionalLight extends ShadowLight {
  131436. private _shadowFrustumSize;
  131437. /**
  131438. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131439. */
  131440. get shadowFrustumSize(): number;
  131441. /**
  131442. * Specifies a fix frustum size for the shadow generation.
  131443. */
  131444. set shadowFrustumSize(value: number);
  131445. private _shadowOrthoScale;
  131446. /**
  131447. * Gets the shadow projection scale against the optimal computed one.
  131448. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131449. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131450. */
  131451. get shadowOrthoScale(): number;
  131452. /**
  131453. * Sets the shadow projection scale against the optimal computed one.
  131454. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131455. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131456. */
  131457. set shadowOrthoScale(value: number);
  131458. /**
  131459. * Automatically compute the projection matrix to best fit (including all the casters)
  131460. * on each frame.
  131461. */
  131462. autoUpdateExtends: boolean;
  131463. /**
  131464. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131465. * on each frame. autoUpdateExtends must be set to true for this to work
  131466. */
  131467. autoCalcShadowZBounds: boolean;
  131468. private _orthoLeft;
  131469. private _orthoRight;
  131470. private _orthoTop;
  131471. private _orthoBottom;
  131472. /**
  131473. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131474. * The directional light is emitted from everywhere in the given direction.
  131475. * It can cast shadows.
  131476. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131477. * @param name The friendly name of the light
  131478. * @param direction The direction of the light
  131479. * @param scene The scene the light belongs to
  131480. */
  131481. constructor(name: string, direction: Vector3, scene: Scene);
  131482. /**
  131483. * Returns the string "DirectionalLight".
  131484. * @return The class name
  131485. */
  131486. getClassName(): string;
  131487. /**
  131488. * Returns the integer 1.
  131489. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131490. */
  131491. getTypeID(): number;
  131492. /**
  131493. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131494. * Returns the DirectionalLight Shadow projection matrix.
  131495. */
  131496. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131497. /**
  131498. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131499. * Returns the DirectionalLight Shadow projection matrix.
  131500. */
  131501. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131502. /**
  131503. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131504. * Returns the DirectionalLight Shadow projection matrix.
  131505. */
  131506. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131507. protected _buildUniformLayout(): void;
  131508. /**
  131509. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131510. * @param effect The effect to update
  131511. * @param lightIndex The index of the light in the effect to update
  131512. * @returns The directional light
  131513. */
  131514. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131515. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131516. /**
  131517. * Gets the minZ used for shadow according to both the scene and the light.
  131518. *
  131519. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131520. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131521. * @param activeCamera The camera we are returning the min for
  131522. * @returns the depth min z
  131523. */
  131524. getDepthMinZ(activeCamera: Camera): number;
  131525. /**
  131526. * Gets the maxZ used for shadow according to both the scene and the light.
  131527. *
  131528. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131529. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131530. * @param activeCamera The camera we are returning the max for
  131531. * @returns the depth max z
  131532. */
  131533. getDepthMaxZ(activeCamera: Camera): number;
  131534. /**
  131535. * Prepares the list of defines specific to the light type.
  131536. * @param defines the list of defines
  131537. * @param lightIndex defines the index of the light for the effect
  131538. */
  131539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131540. }
  131541. }
  131542. declare module BABYLON {
  131543. /**
  131544. * Class containing static functions to help procedurally build meshes
  131545. */
  131546. export class HemisphereBuilder {
  131547. /**
  131548. * Creates a hemisphere mesh
  131549. * @param name defines the name of the mesh
  131550. * @param options defines the options used to create the mesh
  131551. * @param scene defines the hosting scene
  131552. * @returns the hemisphere mesh
  131553. */
  131554. static CreateHemisphere(name: string, options: {
  131555. segments?: number;
  131556. diameter?: number;
  131557. sideOrientation?: number;
  131558. }, scene: any): Mesh;
  131559. }
  131560. }
  131561. declare module BABYLON {
  131562. /**
  131563. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131564. * These values define a cone of light starting from the position, emitting toward the direction.
  131565. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131566. * and the exponent defines the speed of the decay of the light with distance (reach).
  131567. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131568. */
  131569. export class SpotLight extends ShadowLight {
  131570. private _angle;
  131571. private _innerAngle;
  131572. private _cosHalfAngle;
  131573. private _lightAngleScale;
  131574. private _lightAngleOffset;
  131575. /**
  131576. * Gets the cone angle of the spot light in Radians.
  131577. */
  131578. get angle(): number;
  131579. /**
  131580. * Sets the cone angle of the spot light in Radians.
  131581. */
  131582. set angle(value: number);
  131583. /**
  131584. * Only used in gltf falloff mode, this defines the angle where
  131585. * the directional falloff will start before cutting at angle which could be seen
  131586. * as outer angle.
  131587. */
  131588. get innerAngle(): number;
  131589. /**
  131590. * Only used in gltf falloff mode, this defines the angle where
  131591. * the directional falloff will start before cutting at angle which could be seen
  131592. * as outer angle.
  131593. */
  131594. set innerAngle(value: number);
  131595. private _shadowAngleScale;
  131596. /**
  131597. * Allows scaling the angle of the light for shadow generation only.
  131598. */
  131599. get shadowAngleScale(): number;
  131600. /**
  131601. * Allows scaling the angle of the light for shadow generation only.
  131602. */
  131603. set shadowAngleScale(value: number);
  131604. /**
  131605. * The light decay speed with the distance from the emission spot.
  131606. */
  131607. exponent: number;
  131608. private _projectionTextureMatrix;
  131609. /**
  131610. * Allows reading the projecton texture
  131611. */
  131612. get projectionTextureMatrix(): Matrix;
  131613. protected _projectionTextureLightNear: number;
  131614. /**
  131615. * Gets the near clip of the Spotlight for texture projection.
  131616. */
  131617. get projectionTextureLightNear(): number;
  131618. /**
  131619. * Sets the near clip of the Spotlight for texture projection.
  131620. */
  131621. set projectionTextureLightNear(value: number);
  131622. protected _projectionTextureLightFar: number;
  131623. /**
  131624. * Gets the far clip of the Spotlight for texture projection.
  131625. */
  131626. get projectionTextureLightFar(): number;
  131627. /**
  131628. * Sets the far clip of the Spotlight for texture projection.
  131629. */
  131630. set projectionTextureLightFar(value: number);
  131631. protected _projectionTextureUpDirection: Vector3;
  131632. /**
  131633. * Gets the Up vector of the Spotlight for texture projection.
  131634. */
  131635. get projectionTextureUpDirection(): Vector3;
  131636. /**
  131637. * Sets the Up vector of the Spotlight for texture projection.
  131638. */
  131639. set projectionTextureUpDirection(value: Vector3);
  131640. private _projectionTexture;
  131641. /**
  131642. * Gets the projection texture of the light.
  131643. */
  131644. get projectionTexture(): Nullable<BaseTexture>;
  131645. /**
  131646. * Sets the projection texture of the light.
  131647. */
  131648. set projectionTexture(value: Nullable<BaseTexture>);
  131649. private _projectionTextureViewLightDirty;
  131650. private _projectionTextureProjectionLightDirty;
  131651. private _projectionTextureDirty;
  131652. private _projectionTextureViewTargetVector;
  131653. private _projectionTextureViewLightMatrix;
  131654. private _projectionTextureProjectionLightMatrix;
  131655. private _projectionTextureScalingMatrix;
  131656. /**
  131657. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131658. * It can cast shadows.
  131659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131660. * @param name The light friendly name
  131661. * @param position The position of the spot light in the scene
  131662. * @param direction The direction of the light in the scene
  131663. * @param angle The cone angle of the light in Radians
  131664. * @param exponent The light decay speed with the distance from the emission spot
  131665. * @param scene The scene the lights belongs to
  131666. */
  131667. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131668. /**
  131669. * Returns the string "SpotLight".
  131670. * @returns the class name
  131671. */
  131672. getClassName(): string;
  131673. /**
  131674. * Returns the integer 2.
  131675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131676. */
  131677. getTypeID(): number;
  131678. /**
  131679. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131680. */
  131681. protected _setDirection(value: Vector3): void;
  131682. /**
  131683. * Overrides the position setter to recompute the projection texture view light Matrix.
  131684. */
  131685. protected _setPosition(value: Vector3): void;
  131686. /**
  131687. * 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.
  131688. * Returns the SpotLight.
  131689. */
  131690. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131691. protected _computeProjectionTextureViewLightMatrix(): void;
  131692. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131693. /**
  131694. * Main function for light texture projection matrix computing.
  131695. */
  131696. protected _computeProjectionTextureMatrix(): void;
  131697. protected _buildUniformLayout(): void;
  131698. private _computeAngleValues;
  131699. /**
  131700. * Sets the passed Effect "effect" with the Light textures.
  131701. * @param effect The effect to update
  131702. * @param lightIndex The index of the light in the effect to update
  131703. * @returns The light
  131704. */
  131705. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131706. /**
  131707. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131708. * @param effect The effect to update
  131709. * @param lightIndex The index of the light in the effect to update
  131710. * @returns The spot light
  131711. */
  131712. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131713. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131714. /**
  131715. * Disposes the light and the associated resources.
  131716. */
  131717. dispose(): void;
  131718. /**
  131719. * Prepares the list of defines specific to the light type.
  131720. * @param defines the list of defines
  131721. * @param lightIndex defines the index of the light for the effect
  131722. */
  131723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131724. }
  131725. }
  131726. declare module BABYLON {
  131727. /**
  131728. * Gizmo that enables viewing a light
  131729. */
  131730. export class LightGizmo extends Gizmo {
  131731. private _lightMesh;
  131732. private _material;
  131733. private _cachedPosition;
  131734. private _cachedForward;
  131735. private _attachedMeshParent;
  131736. /**
  131737. * Creates a LightGizmo
  131738. * @param gizmoLayer The utility layer the gizmo will be added to
  131739. */
  131740. constructor(gizmoLayer?: UtilityLayerRenderer);
  131741. private _light;
  131742. /**
  131743. * The light that the gizmo is attached to
  131744. */
  131745. set light(light: Nullable<Light>);
  131746. get light(): Nullable<Light>;
  131747. /**
  131748. * Gets the material used to render the light gizmo
  131749. */
  131750. get material(): StandardMaterial;
  131751. /**
  131752. * @hidden
  131753. * Updates the gizmo to match the attached mesh's position/rotation
  131754. */
  131755. protected _update(): void;
  131756. private static _Scale;
  131757. /**
  131758. * Creates the lines for a light mesh
  131759. */
  131760. private static _CreateLightLines;
  131761. /**
  131762. * Disposes of the light gizmo
  131763. */
  131764. dispose(): void;
  131765. private static _CreateHemisphericLightMesh;
  131766. private static _CreatePointLightMesh;
  131767. private static _CreateSpotLightMesh;
  131768. private static _CreateDirectionalLightMesh;
  131769. }
  131770. }
  131771. declare module BABYLON {
  131772. /** @hidden */
  131773. export var backgroundFragmentDeclaration: {
  131774. name: string;
  131775. shader: string;
  131776. };
  131777. }
  131778. declare module BABYLON {
  131779. /** @hidden */
  131780. export var backgroundUboDeclaration: {
  131781. name: string;
  131782. shader: string;
  131783. };
  131784. }
  131785. declare module BABYLON {
  131786. /** @hidden */
  131787. export var backgroundPixelShader: {
  131788. name: string;
  131789. shader: string;
  131790. };
  131791. }
  131792. declare module BABYLON {
  131793. /** @hidden */
  131794. export var backgroundVertexDeclaration: {
  131795. name: string;
  131796. shader: string;
  131797. };
  131798. }
  131799. declare module BABYLON {
  131800. /** @hidden */
  131801. export var backgroundVertexShader: {
  131802. name: string;
  131803. shader: string;
  131804. };
  131805. }
  131806. declare module BABYLON {
  131807. /**
  131808. * Background material used to create an efficient environement around your scene.
  131809. */
  131810. export class BackgroundMaterial extends PushMaterial {
  131811. /**
  131812. * Standard reflectance value at parallel view angle.
  131813. */
  131814. static StandardReflectance0: number;
  131815. /**
  131816. * Standard reflectance value at grazing angle.
  131817. */
  131818. static StandardReflectance90: number;
  131819. protected _primaryColor: Color3;
  131820. /**
  131821. * Key light Color (multiply against the environement texture)
  131822. */
  131823. primaryColor: Color3;
  131824. protected __perceptualColor: Nullable<Color3>;
  131825. /**
  131826. * Experimental Internal Use Only.
  131827. *
  131828. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131829. * This acts as a helper to set the primary color to a more "human friendly" value.
  131830. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131831. * output color as close as possible from the chosen value.
  131832. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131833. * part of lighting setup.)
  131834. */
  131835. get _perceptualColor(): Nullable<Color3>;
  131836. set _perceptualColor(value: Nullable<Color3>);
  131837. protected _primaryColorShadowLevel: float;
  131838. /**
  131839. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131840. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131841. */
  131842. get primaryColorShadowLevel(): float;
  131843. set primaryColorShadowLevel(value: float);
  131844. protected _primaryColorHighlightLevel: float;
  131845. /**
  131846. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131847. * The primary color is used at the level chosen to define what the white area would look.
  131848. */
  131849. get primaryColorHighlightLevel(): float;
  131850. set primaryColorHighlightLevel(value: float);
  131851. protected _reflectionTexture: Nullable<BaseTexture>;
  131852. /**
  131853. * Reflection Texture used in the material.
  131854. * Should be author in a specific way for the best result (refer to the documentation).
  131855. */
  131856. reflectionTexture: Nullable<BaseTexture>;
  131857. protected _reflectionBlur: float;
  131858. /**
  131859. * Reflection Texture level of blur.
  131860. *
  131861. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131862. * texture twice.
  131863. */
  131864. reflectionBlur: float;
  131865. protected _diffuseTexture: Nullable<BaseTexture>;
  131866. /**
  131867. * Diffuse Texture used in the material.
  131868. * Should be author in a specific way for the best result (refer to the documentation).
  131869. */
  131870. diffuseTexture: Nullable<BaseTexture>;
  131871. protected _shadowLights: Nullable<IShadowLight[]>;
  131872. /**
  131873. * Specify the list of lights casting shadow on the material.
  131874. * All scene shadow lights will be included if null.
  131875. */
  131876. shadowLights: Nullable<IShadowLight[]>;
  131877. protected _shadowLevel: float;
  131878. /**
  131879. * Helps adjusting the shadow to a softer level if required.
  131880. * 0 means black shadows and 1 means no shadows.
  131881. */
  131882. shadowLevel: float;
  131883. protected _sceneCenter: Vector3;
  131884. /**
  131885. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131886. * It is usually zero but might be interesting to modify according to your setup.
  131887. */
  131888. sceneCenter: Vector3;
  131889. protected _opacityFresnel: boolean;
  131890. /**
  131891. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131892. * This helps ensuring a nice transition when the camera goes under the ground.
  131893. */
  131894. opacityFresnel: boolean;
  131895. protected _reflectionFresnel: boolean;
  131896. /**
  131897. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131898. * This helps adding a mirror texture on the ground.
  131899. */
  131900. reflectionFresnel: boolean;
  131901. protected _reflectionFalloffDistance: number;
  131902. /**
  131903. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131904. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131905. */
  131906. reflectionFalloffDistance: number;
  131907. protected _reflectionAmount: number;
  131908. /**
  131909. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131910. */
  131911. reflectionAmount: number;
  131912. protected _reflectionReflectance0: number;
  131913. /**
  131914. * This specifies the weight of the reflection at grazing angle.
  131915. */
  131916. reflectionReflectance0: number;
  131917. protected _reflectionReflectance90: number;
  131918. /**
  131919. * This specifies the weight of the reflection at a perpendicular point of view.
  131920. */
  131921. reflectionReflectance90: number;
  131922. /**
  131923. * Sets the reflection reflectance fresnel values according to the default standard
  131924. * empirically know to work well :-)
  131925. */
  131926. set reflectionStandardFresnelWeight(value: number);
  131927. protected _useRGBColor: boolean;
  131928. /**
  131929. * Helps to directly use the maps channels instead of their level.
  131930. */
  131931. useRGBColor: boolean;
  131932. protected _enableNoise: boolean;
  131933. /**
  131934. * This helps reducing the banding effect that could occur on the background.
  131935. */
  131936. enableNoise: boolean;
  131937. /**
  131938. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131939. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131940. * Recommended to be keep at 1.0 except for special cases.
  131941. */
  131942. get fovMultiplier(): number;
  131943. set fovMultiplier(value: number);
  131944. private _fovMultiplier;
  131945. /**
  131946. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131947. */
  131948. useEquirectangularFOV: boolean;
  131949. private _maxSimultaneousLights;
  131950. /**
  131951. * Number of Simultaneous lights allowed on the material.
  131952. */
  131953. maxSimultaneousLights: int;
  131954. private _shadowOnly;
  131955. /**
  131956. * Make the material only render shadows
  131957. */
  131958. shadowOnly: boolean;
  131959. /**
  131960. * Default configuration related to image processing available in the Background Material.
  131961. */
  131962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131963. /**
  131964. * Keep track of the image processing observer to allow dispose and replace.
  131965. */
  131966. private _imageProcessingObserver;
  131967. /**
  131968. * Attaches a new image processing configuration to the PBR Material.
  131969. * @param configuration (if null the scene configuration will be use)
  131970. */
  131971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131972. /**
  131973. * Gets the image processing configuration used either in this material.
  131974. */
  131975. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131976. /**
  131977. * Sets the Default image processing configuration used either in the this material.
  131978. *
  131979. * If sets to null, the scene one is in use.
  131980. */
  131981. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131982. /**
  131983. * Gets wether the color curves effect is enabled.
  131984. */
  131985. get cameraColorCurvesEnabled(): boolean;
  131986. /**
  131987. * Sets wether the color curves effect is enabled.
  131988. */
  131989. set cameraColorCurvesEnabled(value: boolean);
  131990. /**
  131991. * Gets wether the color grading effect is enabled.
  131992. */
  131993. get cameraColorGradingEnabled(): boolean;
  131994. /**
  131995. * Gets wether the color grading effect is enabled.
  131996. */
  131997. set cameraColorGradingEnabled(value: boolean);
  131998. /**
  131999. * Gets wether tonemapping is enabled or not.
  132000. */
  132001. get cameraToneMappingEnabled(): boolean;
  132002. /**
  132003. * Sets wether tonemapping is enabled or not
  132004. */
  132005. set cameraToneMappingEnabled(value: boolean);
  132006. /**
  132007. * The camera exposure used on this material.
  132008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132009. * This corresponds to a photographic exposure.
  132010. */
  132011. get cameraExposure(): float;
  132012. /**
  132013. * The camera exposure used on this material.
  132014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132015. * This corresponds to a photographic exposure.
  132016. */
  132017. set cameraExposure(value: float);
  132018. /**
  132019. * Gets The camera contrast used on this material.
  132020. */
  132021. get cameraContrast(): float;
  132022. /**
  132023. * Sets The camera contrast used on this material.
  132024. */
  132025. set cameraContrast(value: float);
  132026. /**
  132027. * Gets the Color Grading 2D Lookup Texture.
  132028. */
  132029. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132030. /**
  132031. * Sets the Color Grading 2D Lookup Texture.
  132032. */
  132033. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132034. /**
  132035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132037. * 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;
  132038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132039. */
  132040. get cameraColorCurves(): Nullable<ColorCurves>;
  132041. /**
  132042. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132043. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132044. * 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;
  132045. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132046. */
  132047. set cameraColorCurves(value: Nullable<ColorCurves>);
  132048. /**
  132049. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  132050. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  132051. */
  132052. switchToBGR: boolean;
  132053. private _renderTargets;
  132054. private _reflectionControls;
  132055. private _white;
  132056. private _primaryShadowColor;
  132057. private _primaryHighlightColor;
  132058. /**
  132059. * Instantiates a Background Material in the given scene
  132060. * @param name The friendly name of the material
  132061. * @param scene The scene to add the material to
  132062. */
  132063. constructor(name: string, scene: Scene);
  132064. /**
  132065. * Gets a boolean indicating that current material needs to register RTT
  132066. */
  132067. get hasRenderTargetTextures(): boolean;
  132068. /**
  132069. * The entire material has been created in order to prevent overdraw.
  132070. * @returns false
  132071. */
  132072. needAlphaTesting(): boolean;
  132073. /**
  132074. * The entire material has been created in order to prevent overdraw.
  132075. * @returns true if blending is enable
  132076. */
  132077. needAlphaBlending(): boolean;
  132078. /**
  132079. * Checks wether the material is ready to be rendered for a given mesh.
  132080. * @param mesh The mesh to render
  132081. * @param subMesh The submesh to check against
  132082. * @param useInstances Specify wether or not the material is used with instances
  132083. * @returns true if all the dependencies are ready (Textures, Effects...)
  132084. */
  132085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132086. /**
  132087. * Compute the primary color according to the chosen perceptual color.
  132088. */
  132089. private _computePrimaryColorFromPerceptualColor;
  132090. /**
  132091. * Compute the highlights and shadow colors according to their chosen levels.
  132092. */
  132093. private _computePrimaryColors;
  132094. /**
  132095. * Build the uniform buffer used in the material.
  132096. */
  132097. buildUniformLayout(): void;
  132098. /**
  132099. * Unbind the material.
  132100. */
  132101. unbind(): void;
  132102. /**
  132103. * Bind only the world matrix to the material.
  132104. * @param world The world matrix to bind.
  132105. */
  132106. bindOnlyWorldMatrix(world: Matrix): void;
  132107. /**
  132108. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  132109. * @param world The world matrix to bind.
  132110. * @param subMesh The submesh to bind for.
  132111. */
  132112. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132113. /**
  132114. * Checks to see if a texture is used in the material.
  132115. * @param texture - Base texture to use.
  132116. * @returns - Boolean specifying if a texture is used in the material.
  132117. */
  132118. hasTexture(texture: BaseTexture): boolean;
  132119. /**
  132120. * Dispose the material.
  132121. * @param forceDisposeEffect Force disposal of the associated effect.
  132122. * @param forceDisposeTextures Force disposal of the associated textures.
  132123. */
  132124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132125. /**
  132126. * Clones the material.
  132127. * @param name The cloned name.
  132128. * @returns The cloned material.
  132129. */
  132130. clone(name: string): BackgroundMaterial;
  132131. /**
  132132. * Serializes the current material to its JSON representation.
  132133. * @returns The JSON representation.
  132134. */
  132135. serialize(): any;
  132136. /**
  132137. * Gets the class name of the material
  132138. * @returns "BackgroundMaterial"
  132139. */
  132140. getClassName(): string;
  132141. /**
  132142. * Parse a JSON input to create back a background material.
  132143. * @param source The JSON data to parse
  132144. * @param scene The scene to create the parsed material in
  132145. * @param rootUrl The root url of the assets the material depends upon
  132146. * @returns the instantiated BackgroundMaterial.
  132147. */
  132148. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  132149. }
  132150. }
  132151. declare module BABYLON {
  132152. /**
  132153. * Represents the different options available during the creation of
  132154. * a Environment helper.
  132155. *
  132156. * This can control the default ground, skybox and image processing setup of your scene.
  132157. */
  132158. export interface IEnvironmentHelperOptions {
  132159. /**
  132160. * Specifies whether or not to create a ground.
  132161. * True by default.
  132162. */
  132163. createGround: boolean;
  132164. /**
  132165. * Specifies the ground size.
  132166. * 15 by default.
  132167. */
  132168. groundSize: number;
  132169. /**
  132170. * The texture used on the ground for the main color.
  132171. * Comes from the BabylonJS CDN by default.
  132172. *
  132173. * Remarks: Can be either a texture or a url.
  132174. */
  132175. groundTexture: string | BaseTexture;
  132176. /**
  132177. * The color mixed in the ground texture by default.
  132178. * BabylonJS clearColor by default.
  132179. */
  132180. groundColor: Color3;
  132181. /**
  132182. * Specifies the ground opacity.
  132183. * 1 by default.
  132184. */
  132185. groundOpacity: number;
  132186. /**
  132187. * Enables the ground to receive shadows.
  132188. * True by default.
  132189. */
  132190. enableGroundShadow: boolean;
  132191. /**
  132192. * Helps preventing the shadow to be fully black on the ground.
  132193. * 0.5 by default.
  132194. */
  132195. groundShadowLevel: number;
  132196. /**
  132197. * Creates a mirror texture attach to the ground.
  132198. * false by default.
  132199. */
  132200. enableGroundMirror: boolean;
  132201. /**
  132202. * Specifies the ground mirror size ratio.
  132203. * 0.3 by default as the default kernel is 64.
  132204. */
  132205. groundMirrorSizeRatio: number;
  132206. /**
  132207. * Specifies the ground mirror blur kernel size.
  132208. * 64 by default.
  132209. */
  132210. groundMirrorBlurKernel: number;
  132211. /**
  132212. * Specifies the ground mirror visibility amount.
  132213. * 1 by default
  132214. */
  132215. groundMirrorAmount: number;
  132216. /**
  132217. * Specifies the ground mirror reflectance weight.
  132218. * This uses the standard weight of the background material to setup the fresnel effect
  132219. * of the mirror.
  132220. * 1 by default.
  132221. */
  132222. groundMirrorFresnelWeight: number;
  132223. /**
  132224. * Specifies the ground mirror Falloff distance.
  132225. * This can helps reducing the size of the reflection.
  132226. * 0 by Default.
  132227. */
  132228. groundMirrorFallOffDistance: number;
  132229. /**
  132230. * Specifies the ground mirror texture type.
  132231. * Unsigned Int by Default.
  132232. */
  132233. groundMirrorTextureType: number;
  132234. /**
  132235. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  132236. * the shown objects.
  132237. */
  132238. groundYBias: number;
  132239. /**
  132240. * Specifies whether or not to create a skybox.
  132241. * True by default.
  132242. */
  132243. createSkybox: boolean;
  132244. /**
  132245. * Specifies the skybox size.
  132246. * 20 by default.
  132247. */
  132248. skyboxSize: number;
  132249. /**
  132250. * The texture used on the skybox for the main color.
  132251. * Comes from the BabylonJS CDN by default.
  132252. *
  132253. * Remarks: Can be either a texture or a url.
  132254. */
  132255. skyboxTexture: string | BaseTexture;
  132256. /**
  132257. * The color mixed in the skybox texture by default.
  132258. * BabylonJS clearColor by default.
  132259. */
  132260. skyboxColor: Color3;
  132261. /**
  132262. * The background rotation around the Y axis of the scene.
  132263. * This helps aligning the key lights of your scene with the background.
  132264. * 0 by default.
  132265. */
  132266. backgroundYRotation: number;
  132267. /**
  132268. * Compute automatically the size of the elements to best fit with the scene.
  132269. */
  132270. sizeAuto: boolean;
  132271. /**
  132272. * Default position of the rootMesh if autoSize is not true.
  132273. */
  132274. rootPosition: Vector3;
  132275. /**
  132276. * Sets up the image processing in the scene.
  132277. * true by default.
  132278. */
  132279. setupImageProcessing: boolean;
  132280. /**
  132281. * The texture used as your environment texture in the scene.
  132282. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  132283. *
  132284. * Remarks: Can be either a texture or a url.
  132285. */
  132286. environmentTexture: string | BaseTexture;
  132287. /**
  132288. * The value of the exposure to apply to the scene.
  132289. * 0.6 by default if setupImageProcessing is true.
  132290. */
  132291. cameraExposure: number;
  132292. /**
  132293. * The value of the contrast to apply to the scene.
  132294. * 1.6 by default if setupImageProcessing is true.
  132295. */
  132296. cameraContrast: number;
  132297. /**
  132298. * Specifies whether or not tonemapping should be enabled in the scene.
  132299. * true by default if setupImageProcessing is true.
  132300. */
  132301. toneMappingEnabled: boolean;
  132302. }
  132303. /**
  132304. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  132305. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  132306. * It also helps with the default setup of your imageProcessing configuration.
  132307. */
  132308. export class EnvironmentHelper {
  132309. /**
  132310. * Default ground texture URL.
  132311. */
  132312. private static _groundTextureCDNUrl;
  132313. /**
  132314. * Default skybox texture URL.
  132315. */
  132316. private static _skyboxTextureCDNUrl;
  132317. /**
  132318. * Default environment texture URL.
  132319. */
  132320. private static _environmentTextureCDNUrl;
  132321. /**
  132322. * Creates the default options for the helper.
  132323. */
  132324. private static _getDefaultOptions;
  132325. private _rootMesh;
  132326. /**
  132327. * Gets the root mesh created by the helper.
  132328. */
  132329. get rootMesh(): Mesh;
  132330. private _skybox;
  132331. /**
  132332. * Gets the skybox created by the helper.
  132333. */
  132334. get skybox(): Nullable<Mesh>;
  132335. private _skyboxTexture;
  132336. /**
  132337. * Gets the skybox texture created by the helper.
  132338. */
  132339. get skyboxTexture(): Nullable<BaseTexture>;
  132340. private _skyboxMaterial;
  132341. /**
  132342. * Gets the skybox material created by the helper.
  132343. */
  132344. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132345. private _ground;
  132346. /**
  132347. * Gets the ground mesh created by the helper.
  132348. */
  132349. get ground(): Nullable<Mesh>;
  132350. private _groundTexture;
  132351. /**
  132352. * Gets the ground texture created by the helper.
  132353. */
  132354. get groundTexture(): Nullable<BaseTexture>;
  132355. private _groundMirror;
  132356. /**
  132357. * Gets the ground mirror created by the helper.
  132358. */
  132359. get groundMirror(): Nullable<MirrorTexture>;
  132360. /**
  132361. * Gets the ground mirror render list to helps pushing the meshes
  132362. * you wish in the ground reflection.
  132363. */
  132364. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132365. private _groundMaterial;
  132366. /**
  132367. * Gets the ground material created by the helper.
  132368. */
  132369. get groundMaterial(): Nullable<BackgroundMaterial>;
  132370. /**
  132371. * Stores the creation options.
  132372. */
  132373. private readonly _scene;
  132374. private _options;
  132375. /**
  132376. * This observable will be notified with any error during the creation of the environment,
  132377. * mainly texture creation errors.
  132378. */
  132379. onErrorObservable: Observable<{
  132380. message?: string;
  132381. exception?: any;
  132382. }>;
  132383. /**
  132384. * constructor
  132385. * @param options Defines the options we want to customize the helper
  132386. * @param scene The scene to add the material to
  132387. */
  132388. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132389. /**
  132390. * Updates the background according to the new options
  132391. * @param options
  132392. */
  132393. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132394. /**
  132395. * Sets the primary color of all the available elements.
  132396. * @param color the main color to affect to the ground and the background
  132397. */
  132398. setMainColor(color: Color3): void;
  132399. /**
  132400. * Setup the image processing according to the specified options.
  132401. */
  132402. private _setupImageProcessing;
  132403. /**
  132404. * Setup the environment texture according to the specified options.
  132405. */
  132406. private _setupEnvironmentTexture;
  132407. /**
  132408. * Setup the background according to the specified options.
  132409. */
  132410. private _setupBackground;
  132411. /**
  132412. * Get the scene sizes according to the setup.
  132413. */
  132414. private _getSceneSize;
  132415. /**
  132416. * Setup the ground according to the specified options.
  132417. */
  132418. private _setupGround;
  132419. /**
  132420. * Setup the ground material according to the specified options.
  132421. */
  132422. private _setupGroundMaterial;
  132423. /**
  132424. * Setup the ground diffuse texture according to the specified options.
  132425. */
  132426. private _setupGroundDiffuseTexture;
  132427. /**
  132428. * Setup the ground mirror texture according to the specified options.
  132429. */
  132430. private _setupGroundMirrorTexture;
  132431. /**
  132432. * Setup the ground to receive the mirror texture.
  132433. */
  132434. private _setupMirrorInGroundMaterial;
  132435. /**
  132436. * Setup the skybox according to the specified options.
  132437. */
  132438. private _setupSkybox;
  132439. /**
  132440. * Setup the skybox material according to the specified options.
  132441. */
  132442. private _setupSkyboxMaterial;
  132443. /**
  132444. * Setup the skybox reflection texture according to the specified options.
  132445. */
  132446. private _setupSkyboxReflectionTexture;
  132447. private _errorHandler;
  132448. /**
  132449. * Dispose all the elements created by the Helper.
  132450. */
  132451. dispose(): void;
  132452. }
  132453. }
  132454. declare module BABYLON {
  132455. /**
  132456. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132457. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132458. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132459. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132460. */
  132461. export class PhotoDome extends TransformNode {
  132462. /**
  132463. * Define the image as a Monoscopic panoramic 360 image.
  132464. */
  132465. static readonly MODE_MONOSCOPIC: number;
  132466. /**
  132467. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132468. */
  132469. static readonly MODE_TOPBOTTOM: number;
  132470. /**
  132471. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132472. */
  132473. static readonly MODE_SIDEBYSIDE: number;
  132474. private _useDirectMapping;
  132475. /**
  132476. * The texture being displayed on the sphere
  132477. */
  132478. protected _photoTexture: Texture;
  132479. /**
  132480. * Gets or sets the texture being displayed on the sphere
  132481. */
  132482. get photoTexture(): Texture;
  132483. set photoTexture(value: Texture);
  132484. /**
  132485. * Observable raised when an error occured while loading the 360 image
  132486. */
  132487. onLoadErrorObservable: Observable<string>;
  132488. /**
  132489. * The skybox material
  132490. */
  132491. protected _material: BackgroundMaterial;
  132492. /**
  132493. * The surface used for the skybox
  132494. */
  132495. protected _mesh: Mesh;
  132496. /**
  132497. * Gets the mesh used for the skybox.
  132498. */
  132499. get mesh(): Mesh;
  132500. /**
  132501. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132502. * Also see the options.resolution property.
  132503. */
  132504. get fovMultiplier(): number;
  132505. set fovMultiplier(value: number);
  132506. private _imageMode;
  132507. /**
  132508. * Gets or set the current video mode for the video. It can be:
  132509. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132510. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132511. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132512. */
  132513. get imageMode(): number;
  132514. set imageMode(value: number);
  132515. /**
  132516. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132517. * @param name Element's name, child elements will append suffixes for their own names.
  132518. * @param urlsOfPhoto defines the url of the photo to display
  132519. * @param options defines an object containing optional or exposed sub element properties
  132520. * @param onError defines a callback called when an error occured while loading the texture
  132521. */
  132522. constructor(name: string, urlOfPhoto: string, options: {
  132523. resolution?: number;
  132524. size?: number;
  132525. useDirectMapping?: boolean;
  132526. faceForward?: boolean;
  132527. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132528. private _onBeforeCameraRenderObserver;
  132529. private _changeImageMode;
  132530. /**
  132531. * Releases resources associated with this node.
  132532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132534. */
  132535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132536. }
  132537. }
  132538. declare module BABYLON {
  132539. /**
  132540. * Class used to host RGBD texture specific utilities
  132541. */
  132542. export class RGBDTextureTools {
  132543. /**
  132544. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132545. * @param texture the texture to expand.
  132546. */
  132547. static ExpandRGBDTexture(texture: Texture): void;
  132548. }
  132549. }
  132550. declare module BABYLON {
  132551. /**
  132552. * Class used to host texture specific utilities
  132553. */
  132554. export class BRDFTextureTools {
  132555. /**
  132556. * Prevents texture cache collision
  132557. */
  132558. private static _instanceNumber;
  132559. /**
  132560. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132561. * @param scene defines the hosting scene
  132562. * @returns the environment BRDF texture
  132563. */
  132564. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132565. private static _environmentBRDFBase64Texture;
  132566. }
  132567. }
  132568. declare module BABYLON {
  132569. /**
  132570. * @hidden
  132571. */
  132572. export interface IMaterialClearCoatDefines {
  132573. CLEARCOAT: boolean;
  132574. CLEARCOAT_DEFAULTIOR: boolean;
  132575. CLEARCOAT_TEXTURE: boolean;
  132576. CLEARCOAT_TEXTUREDIRECTUV: number;
  132577. CLEARCOAT_BUMP: boolean;
  132578. CLEARCOAT_BUMPDIRECTUV: number;
  132579. CLEARCOAT_TINT: boolean;
  132580. CLEARCOAT_TINT_TEXTURE: boolean;
  132581. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132582. /** @hidden */
  132583. _areTexturesDirty: boolean;
  132584. }
  132585. /**
  132586. * Define the code related to the clear coat parameters of the pbr material.
  132587. */
  132588. export class PBRClearCoatConfiguration {
  132589. /**
  132590. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132591. * The default fits with a polyurethane material.
  132592. */
  132593. private static readonly _DefaultIndexOfRefraction;
  132594. private _isEnabled;
  132595. /**
  132596. * Defines if the clear coat is enabled in the material.
  132597. */
  132598. isEnabled: boolean;
  132599. /**
  132600. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132601. */
  132602. intensity: number;
  132603. /**
  132604. * Defines the clear coat layer roughness.
  132605. */
  132606. roughness: number;
  132607. private _indexOfRefraction;
  132608. /**
  132609. * Defines the index of refraction of the clear coat.
  132610. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132611. * The default fits with a polyurethane material.
  132612. * Changing the default value is more performance intensive.
  132613. */
  132614. indexOfRefraction: number;
  132615. private _texture;
  132616. /**
  132617. * Stores the clear coat values in a texture.
  132618. */
  132619. texture: Nullable<BaseTexture>;
  132620. private _bumpTexture;
  132621. /**
  132622. * Define the clear coat specific bump texture.
  132623. */
  132624. bumpTexture: Nullable<BaseTexture>;
  132625. private _isTintEnabled;
  132626. /**
  132627. * Defines if the clear coat tint is enabled in the material.
  132628. */
  132629. isTintEnabled: boolean;
  132630. /**
  132631. * Defines the clear coat tint of the material.
  132632. * This is only use if tint is enabled
  132633. */
  132634. tintColor: Color3;
  132635. /**
  132636. * Defines the distance at which the tint color should be found in the
  132637. * clear coat media.
  132638. * This is only use if tint is enabled
  132639. */
  132640. tintColorAtDistance: number;
  132641. /**
  132642. * Defines the clear coat layer thickness.
  132643. * This is only use if tint is enabled
  132644. */
  132645. tintThickness: number;
  132646. private _tintTexture;
  132647. /**
  132648. * Stores the clear tint values in a texture.
  132649. * rgb is tint
  132650. * a is a thickness factor
  132651. */
  132652. tintTexture: Nullable<BaseTexture>;
  132653. /** @hidden */
  132654. private _internalMarkAllSubMeshesAsTexturesDirty;
  132655. /** @hidden */
  132656. _markAllSubMeshesAsTexturesDirty(): void;
  132657. /**
  132658. * Instantiate a new istance of clear coat configuration.
  132659. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132660. */
  132661. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132662. /**
  132663. * Gets wehter the submesh is ready to be used or not.
  132664. * @param defines the list of "defines" to update.
  132665. * @param scene defines the scene the material belongs to.
  132666. * @param engine defines the engine the material belongs to.
  132667. * @param disableBumpMap defines wether the material disables bump or not.
  132668. * @returns - boolean indicating that the submesh is ready or not.
  132669. */
  132670. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132671. /**
  132672. * Checks to see if a texture is used in the material.
  132673. * @param defines the list of "defines" to update.
  132674. * @param scene defines the scene to the material belongs to.
  132675. */
  132676. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132677. /**
  132678. * Binds the material data.
  132679. * @param uniformBuffer defines the Uniform buffer to fill in.
  132680. * @param scene defines the scene the material belongs to.
  132681. * @param engine defines the engine the material belongs to.
  132682. * @param disableBumpMap defines wether the material disables bump or not.
  132683. * @param isFrozen defines wether the material is frozen or not.
  132684. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132685. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132686. */
  132687. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132688. /**
  132689. * Checks to see if a texture is used in the material.
  132690. * @param texture - Base texture to use.
  132691. * @returns - Boolean specifying if a texture is used in the material.
  132692. */
  132693. hasTexture(texture: BaseTexture): boolean;
  132694. /**
  132695. * Returns an array of the actively used textures.
  132696. * @param activeTextures Array of BaseTextures
  132697. */
  132698. getActiveTextures(activeTextures: BaseTexture[]): void;
  132699. /**
  132700. * Returns the animatable textures.
  132701. * @param animatables Array of animatable textures.
  132702. */
  132703. getAnimatables(animatables: IAnimatable[]): void;
  132704. /**
  132705. * Disposes the resources of the material.
  132706. * @param forceDisposeTextures - Forces the disposal of all textures.
  132707. */
  132708. dispose(forceDisposeTextures?: boolean): void;
  132709. /**
  132710. * Get the current class name of the texture useful for serialization or dynamic coding.
  132711. * @returns "PBRClearCoatConfiguration"
  132712. */
  132713. getClassName(): string;
  132714. /**
  132715. * Add fallbacks to the effect fallbacks list.
  132716. * @param defines defines the Base texture to use.
  132717. * @param fallbacks defines the current fallback list.
  132718. * @param currentRank defines the current fallback rank.
  132719. * @returns the new fallback rank.
  132720. */
  132721. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132722. /**
  132723. * Add the required uniforms to the current list.
  132724. * @param uniforms defines the current uniform list.
  132725. */
  132726. static AddUniforms(uniforms: string[]): void;
  132727. /**
  132728. * Add the required samplers to the current list.
  132729. * @param samplers defines the current sampler list.
  132730. */
  132731. static AddSamplers(samplers: string[]): void;
  132732. /**
  132733. * Add the required uniforms to the current buffer.
  132734. * @param uniformBuffer defines the current uniform buffer.
  132735. */
  132736. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132737. /**
  132738. * Makes a duplicate of the current configuration into another one.
  132739. * @param clearCoatConfiguration define the config where to copy the info
  132740. */
  132741. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132742. /**
  132743. * Serializes this clear coat configuration.
  132744. * @returns - An object with the serialized config.
  132745. */
  132746. serialize(): any;
  132747. /**
  132748. * Parses a anisotropy Configuration from a serialized object.
  132749. * @param source - Serialized object.
  132750. * @param scene Defines the scene we are parsing for
  132751. * @param rootUrl Defines the rootUrl to load from
  132752. */
  132753. parse(source: any, scene: Scene, rootUrl: string): void;
  132754. }
  132755. }
  132756. declare module BABYLON {
  132757. /**
  132758. * @hidden
  132759. */
  132760. export interface IMaterialAnisotropicDefines {
  132761. ANISOTROPIC: boolean;
  132762. ANISOTROPIC_TEXTURE: boolean;
  132763. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132764. MAINUV1: boolean;
  132765. _areTexturesDirty: boolean;
  132766. _needUVs: boolean;
  132767. }
  132768. /**
  132769. * Define the code related to the anisotropic parameters of the pbr material.
  132770. */
  132771. export class PBRAnisotropicConfiguration {
  132772. private _isEnabled;
  132773. /**
  132774. * Defines if the anisotropy is enabled in the material.
  132775. */
  132776. isEnabled: boolean;
  132777. /**
  132778. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132779. */
  132780. intensity: number;
  132781. /**
  132782. * Defines if the effect is along the tangents, bitangents or in between.
  132783. * By default, the effect is "strectching" the highlights along the tangents.
  132784. */
  132785. direction: Vector2;
  132786. private _texture;
  132787. /**
  132788. * Stores the anisotropy values in a texture.
  132789. * rg is direction (like normal from -1 to 1)
  132790. * b is a intensity
  132791. */
  132792. texture: Nullable<BaseTexture>;
  132793. /** @hidden */
  132794. private _internalMarkAllSubMeshesAsTexturesDirty;
  132795. /** @hidden */
  132796. _markAllSubMeshesAsTexturesDirty(): void;
  132797. /**
  132798. * Instantiate a new istance of anisotropy configuration.
  132799. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132800. */
  132801. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132802. /**
  132803. * Specifies that the submesh is ready to be used.
  132804. * @param defines the list of "defines" to update.
  132805. * @param scene defines the scene the material belongs to.
  132806. * @returns - boolean indicating that the submesh is ready or not.
  132807. */
  132808. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132809. /**
  132810. * Checks to see if a texture is used in the material.
  132811. * @param defines the list of "defines" to update.
  132812. * @param mesh the mesh we are preparing the defines for.
  132813. * @param scene defines the scene the material belongs to.
  132814. */
  132815. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132816. /**
  132817. * Binds the material data.
  132818. * @param uniformBuffer defines the Uniform buffer to fill in.
  132819. * @param scene defines the scene the material belongs to.
  132820. * @param isFrozen defines wether the material is frozen or not.
  132821. */
  132822. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132823. /**
  132824. * Checks to see if a texture is used in the material.
  132825. * @param texture - Base texture to use.
  132826. * @returns - Boolean specifying if a texture is used in the material.
  132827. */
  132828. hasTexture(texture: BaseTexture): boolean;
  132829. /**
  132830. * Returns an array of the actively used textures.
  132831. * @param activeTextures Array of BaseTextures
  132832. */
  132833. getActiveTextures(activeTextures: BaseTexture[]): void;
  132834. /**
  132835. * Returns the animatable textures.
  132836. * @param animatables Array of animatable textures.
  132837. */
  132838. getAnimatables(animatables: IAnimatable[]): void;
  132839. /**
  132840. * Disposes the resources of the material.
  132841. * @param forceDisposeTextures - Forces the disposal of all textures.
  132842. */
  132843. dispose(forceDisposeTextures?: boolean): void;
  132844. /**
  132845. * Get the current class name of the texture useful for serialization or dynamic coding.
  132846. * @returns "PBRAnisotropicConfiguration"
  132847. */
  132848. getClassName(): string;
  132849. /**
  132850. * Add fallbacks to the effect fallbacks list.
  132851. * @param defines defines the Base texture to use.
  132852. * @param fallbacks defines the current fallback list.
  132853. * @param currentRank defines the current fallback rank.
  132854. * @returns the new fallback rank.
  132855. */
  132856. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132857. /**
  132858. * Add the required uniforms to the current list.
  132859. * @param uniforms defines the current uniform list.
  132860. */
  132861. static AddUniforms(uniforms: string[]): void;
  132862. /**
  132863. * Add the required uniforms to the current buffer.
  132864. * @param uniformBuffer defines the current uniform buffer.
  132865. */
  132866. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132867. /**
  132868. * Add the required samplers to the current list.
  132869. * @param samplers defines the current sampler list.
  132870. */
  132871. static AddSamplers(samplers: string[]): void;
  132872. /**
  132873. * Makes a duplicate of the current configuration into another one.
  132874. * @param anisotropicConfiguration define the config where to copy the info
  132875. */
  132876. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132877. /**
  132878. * Serializes this anisotropy configuration.
  132879. * @returns - An object with the serialized config.
  132880. */
  132881. serialize(): any;
  132882. /**
  132883. * Parses a anisotropy Configuration from a serialized object.
  132884. * @param source - Serialized object.
  132885. * @param scene Defines the scene we are parsing for
  132886. * @param rootUrl Defines the rootUrl to load from
  132887. */
  132888. parse(source: any, scene: Scene, rootUrl: string): void;
  132889. }
  132890. }
  132891. declare module BABYLON {
  132892. /**
  132893. * @hidden
  132894. */
  132895. export interface IMaterialBRDFDefines {
  132896. BRDF_V_HEIGHT_CORRELATED: boolean;
  132897. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132898. SPHERICAL_HARMONICS: boolean;
  132899. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132900. /** @hidden */
  132901. _areMiscDirty: boolean;
  132902. }
  132903. /**
  132904. * Define the code related to the BRDF parameters of the pbr material.
  132905. */
  132906. export class PBRBRDFConfiguration {
  132907. /**
  132908. * Default value used for the energy conservation.
  132909. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132910. */
  132911. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132912. /**
  132913. * Default value used for the Smith Visibility Height Correlated mode.
  132914. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132915. */
  132916. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132917. /**
  132918. * Default value used for the IBL diffuse part.
  132919. * This can help switching back to the polynomials mode globally which is a tiny bit
  132920. * less GPU intensive at the drawback of a lower quality.
  132921. */
  132922. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132923. /**
  132924. * Default value used for activating energy conservation for the specular workflow.
  132925. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132926. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132927. */
  132928. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132929. private _useEnergyConservation;
  132930. /**
  132931. * Defines if the material uses energy conservation.
  132932. */
  132933. useEnergyConservation: boolean;
  132934. private _useSmithVisibilityHeightCorrelated;
  132935. /**
  132936. * LEGACY Mode set to false
  132937. * Defines if the material uses height smith correlated visibility term.
  132938. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132939. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132940. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132941. * Not relying on height correlated will also disable energy conservation.
  132942. */
  132943. useSmithVisibilityHeightCorrelated: boolean;
  132944. private _useSphericalHarmonics;
  132945. /**
  132946. * LEGACY Mode set to false
  132947. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132948. * diffuse part of the IBL.
  132949. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132950. * to the ground truth.
  132951. */
  132952. useSphericalHarmonics: boolean;
  132953. private _useSpecularGlossinessInputEnergyConservation;
  132954. /**
  132955. * Defines if the material uses energy conservation, when the specular workflow is active.
  132956. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132957. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132958. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132959. */
  132960. useSpecularGlossinessInputEnergyConservation: boolean;
  132961. /** @hidden */
  132962. private _internalMarkAllSubMeshesAsMiscDirty;
  132963. /** @hidden */
  132964. _markAllSubMeshesAsMiscDirty(): void;
  132965. /**
  132966. * Instantiate a new istance of clear coat configuration.
  132967. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132968. */
  132969. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132970. /**
  132971. * Checks to see if a texture is used in the material.
  132972. * @param defines the list of "defines" to update.
  132973. */
  132974. prepareDefines(defines: IMaterialBRDFDefines): void;
  132975. /**
  132976. * Get the current class name of the texture useful for serialization or dynamic coding.
  132977. * @returns "PBRClearCoatConfiguration"
  132978. */
  132979. getClassName(): string;
  132980. /**
  132981. * Makes a duplicate of the current configuration into another one.
  132982. * @param brdfConfiguration define the config where to copy the info
  132983. */
  132984. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132985. /**
  132986. * Serializes this BRDF configuration.
  132987. * @returns - An object with the serialized config.
  132988. */
  132989. serialize(): any;
  132990. /**
  132991. * Parses a anisotropy Configuration from a serialized object.
  132992. * @param source - Serialized object.
  132993. * @param scene Defines the scene we are parsing for
  132994. * @param rootUrl Defines the rootUrl to load from
  132995. */
  132996. parse(source: any, scene: Scene, rootUrl: string): void;
  132997. }
  132998. }
  132999. declare module BABYLON {
  133000. /**
  133001. * @hidden
  133002. */
  133003. export interface IMaterialSheenDefines {
  133004. SHEEN: boolean;
  133005. SHEEN_TEXTURE: boolean;
  133006. SHEEN_TEXTUREDIRECTUV: number;
  133007. SHEEN_LINKWITHALBEDO: boolean;
  133008. SHEEN_ROUGHNESS: boolean;
  133009. SHEEN_ALBEDOSCALING: boolean;
  133010. /** @hidden */
  133011. _areTexturesDirty: boolean;
  133012. }
  133013. /**
  133014. * Define the code related to the Sheen parameters of the pbr material.
  133015. */
  133016. export class PBRSheenConfiguration {
  133017. private _isEnabled;
  133018. /**
  133019. * Defines if the material uses sheen.
  133020. */
  133021. isEnabled: boolean;
  133022. private _linkSheenWithAlbedo;
  133023. /**
  133024. * Defines if the sheen is linked to the sheen color.
  133025. */
  133026. linkSheenWithAlbedo: boolean;
  133027. /**
  133028. * Defines the sheen intensity.
  133029. */
  133030. intensity: number;
  133031. /**
  133032. * Defines the sheen color.
  133033. */
  133034. color: Color3;
  133035. private _texture;
  133036. /**
  133037. * Stores the sheen tint values in a texture.
  133038. * rgb is tint
  133039. * a is a intensity or roughness if roughness has been defined
  133040. */
  133041. texture: Nullable<BaseTexture>;
  133042. private _roughness;
  133043. /**
  133044. * Defines the sheen roughness.
  133045. * It is not taken into account if linkSheenWithAlbedo is true.
  133046. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  133047. */
  133048. roughness: Nullable<number>;
  133049. private _albedoScaling;
  133050. /**
  133051. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  133052. * It allows the strength of the sheen effect to not depend on the base color of the material,
  133053. * making it easier to setup and tweak the effect
  133054. */
  133055. albedoScaling: boolean;
  133056. /** @hidden */
  133057. private _internalMarkAllSubMeshesAsTexturesDirty;
  133058. /** @hidden */
  133059. _markAllSubMeshesAsTexturesDirty(): void;
  133060. /**
  133061. * Instantiate a new istance of clear coat configuration.
  133062. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133063. */
  133064. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133065. /**
  133066. * Specifies that the submesh is ready to be used.
  133067. * @param defines the list of "defines" to update.
  133068. * @param scene defines the scene the material belongs to.
  133069. * @returns - boolean indicating that the submesh is ready or not.
  133070. */
  133071. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  133072. /**
  133073. * Checks to see if a texture is used in the material.
  133074. * @param defines the list of "defines" to update.
  133075. * @param scene defines the scene the material belongs to.
  133076. */
  133077. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  133078. /**
  133079. * Binds the material data.
  133080. * @param uniformBuffer defines the Uniform buffer to fill in.
  133081. * @param scene defines the scene the material belongs to.
  133082. * @param isFrozen defines wether the material is frozen or not.
  133083. */
  133084. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133085. /**
  133086. * Checks to see if a texture is used in the material.
  133087. * @param texture - Base texture to use.
  133088. * @returns - Boolean specifying if a texture is used in the material.
  133089. */
  133090. hasTexture(texture: BaseTexture): boolean;
  133091. /**
  133092. * Returns an array of the actively used textures.
  133093. * @param activeTextures Array of BaseTextures
  133094. */
  133095. getActiveTextures(activeTextures: BaseTexture[]): void;
  133096. /**
  133097. * Returns the animatable textures.
  133098. * @param animatables Array of animatable textures.
  133099. */
  133100. getAnimatables(animatables: IAnimatable[]): void;
  133101. /**
  133102. * Disposes the resources of the material.
  133103. * @param forceDisposeTextures - Forces the disposal of all textures.
  133104. */
  133105. dispose(forceDisposeTextures?: boolean): void;
  133106. /**
  133107. * Get the current class name of the texture useful for serialization or dynamic coding.
  133108. * @returns "PBRSheenConfiguration"
  133109. */
  133110. getClassName(): string;
  133111. /**
  133112. * Add fallbacks to the effect fallbacks list.
  133113. * @param defines defines the Base texture to use.
  133114. * @param fallbacks defines the current fallback list.
  133115. * @param currentRank defines the current fallback rank.
  133116. * @returns the new fallback rank.
  133117. */
  133118. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133119. /**
  133120. * Add the required uniforms to the current list.
  133121. * @param uniforms defines the current uniform list.
  133122. */
  133123. static AddUniforms(uniforms: string[]): void;
  133124. /**
  133125. * Add the required uniforms to the current buffer.
  133126. * @param uniformBuffer defines the current uniform buffer.
  133127. */
  133128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133129. /**
  133130. * Add the required samplers to the current list.
  133131. * @param samplers defines the current sampler list.
  133132. */
  133133. static AddSamplers(samplers: string[]): void;
  133134. /**
  133135. * Makes a duplicate of the current configuration into another one.
  133136. * @param sheenConfiguration define the config where to copy the info
  133137. */
  133138. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  133139. /**
  133140. * Serializes this BRDF configuration.
  133141. * @returns - An object with the serialized config.
  133142. */
  133143. serialize(): any;
  133144. /**
  133145. * Parses a anisotropy Configuration from a serialized object.
  133146. * @param source - Serialized object.
  133147. * @param scene Defines the scene we are parsing for
  133148. * @param rootUrl Defines the rootUrl to load from
  133149. */
  133150. parse(source: any, scene: Scene, rootUrl: string): void;
  133151. }
  133152. }
  133153. declare module BABYLON {
  133154. /**
  133155. * @hidden
  133156. */
  133157. export interface IMaterialSubSurfaceDefines {
  133158. SUBSURFACE: boolean;
  133159. SS_REFRACTION: boolean;
  133160. SS_TRANSLUCENCY: boolean;
  133161. SS_SCATTERING: boolean;
  133162. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133163. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133164. SS_REFRACTIONMAP_3D: boolean;
  133165. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133166. SS_LODINREFRACTIONALPHA: boolean;
  133167. SS_GAMMAREFRACTION: boolean;
  133168. SS_RGBDREFRACTION: boolean;
  133169. SS_LINEARSPECULARREFRACTION: boolean;
  133170. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133171. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133172. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133173. /** @hidden */
  133174. _areTexturesDirty: boolean;
  133175. }
  133176. /**
  133177. * Define the code related to the sub surface parameters of the pbr material.
  133178. */
  133179. export class PBRSubSurfaceConfiguration {
  133180. private _isRefractionEnabled;
  133181. /**
  133182. * Defines if the refraction is enabled in the material.
  133183. */
  133184. isRefractionEnabled: boolean;
  133185. private _isTranslucencyEnabled;
  133186. /**
  133187. * Defines if the translucency is enabled in the material.
  133188. */
  133189. isTranslucencyEnabled: boolean;
  133190. private _isScatteringEnabled;
  133191. /**
  133192. * Defines if the sub surface scattering is enabled in the material.
  133193. */
  133194. isScatteringEnabled: boolean;
  133195. private _scatteringDiffusionProfileIndex;
  133196. /**
  133197. * Diffusion profile for subsurface scattering.
  133198. * Useful for better scattering in the skins or foliages.
  133199. */
  133200. get scatteringDiffusionProfile(): Nullable<Color3>;
  133201. set scatteringDiffusionProfile(c: Nullable<Color3>);
  133202. /**
  133203. * Defines the refraction intensity of the material.
  133204. * The refraction when enabled replaces the Diffuse part of the material.
  133205. * The intensity helps transitionning between diffuse and refraction.
  133206. */
  133207. refractionIntensity: number;
  133208. /**
  133209. * Defines the translucency intensity of the material.
  133210. * When translucency has been enabled, this defines how much of the "translucency"
  133211. * is addded to the diffuse part of the material.
  133212. */
  133213. translucencyIntensity: number;
  133214. /**
  133215. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  133216. */
  133217. useAlbedoToTintRefraction: boolean;
  133218. private _thicknessTexture;
  133219. /**
  133220. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  133221. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  133222. * 0 would mean minimumThickness
  133223. * 1 would mean maximumThickness
  133224. * The other channels might be use as a mask to vary the different effects intensity.
  133225. */
  133226. thicknessTexture: Nullable<BaseTexture>;
  133227. private _refractionTexture;
  133228. /**
  133229. * Defines the texture to use for refraction.
  133230. */
  133231. refractionTexture: Nullable<BaseTexture>;
  133232. private _indexOfRefraction;
  133233. /**
  133234. * Index of refraction of the material base layer.
  133235. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133236. *
  133237. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133238. *
  133239. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133240. */
  133241. indexOfRefraction: number;
  133242. private _volumeIndexOfRefraction;
  133243. /**
  133244. * Index of refraction of the material's volume.
  133245. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133246. *
  133247. * This ONLY impacts refraction. If not provided or given a non-valid value,
  133248. * the volume will use the same IOR as the surface.
  133249. */
  133250. get volumeIndexOfRefraction(): number;
  133251. set volumeIndexOfRefraction(value: number);
  133252. private _invertRefractionY;
  133253. /**
  133254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133255. */
  133256. invertRefractionY: boolean;
  133257. private _linkRefractionWithTransparency;
  133258. /**
  133259. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133260. * Materials half opaque for instance using refraction could benefit from this control.
  133261. */
  133262. linkRefractionWithTransparency: boolean;
  133263. /**
  133264. * Defines the minimum thickness stored in the thickness map.
  133265. * If no thickness map is defined, this value will be used to simulate thickness.
  133266. */
  133267. minimumThickness: number;
  133268. /**
  133269. * Defines the maximum thickness stored in the thickness map.
  133270. */
  133271. maximumThickness: number;
  133272. /**
  133273. * Defines the volume tint of the material.
  133274. * This is used for both translucency and scattering.
  133275. */
  133276. tintColor: Color3;
  133277. /**
  133278. * Defines the distance at which the tint color should be found in the media.
  133279. * This is used for refraction only.
  133280. */
  133281. tintColorAtDistance: number;
  133282. /**
  133283. * Defines how far each channel transmit through the media.
  133284. * It is defined as a color to simplify it selection.
  133285. */
  133286. diffusionDistance: Color3;
  133287. private _useMaskFromThicknessTexture;
  133288. /**
  133289. * Stores the intensity of the different subsurface effects in the thickness texture.
  133290. * * the green channel is the translucency intensity.
  133291. * * the blue channel is the scattering intensity.
  133292. * * the alpha channel is the refraction intensity.
  133293. */
  133294. useMaskFromThicknessTexture: boolean;
  133295. private _scene;
  133296. /** @hidden */
  133297. private _internalMarkAllSubMeshesAsTexturesDirty;
  133298. private _internalMarkScenePrePassDirty;
  133299. /** @hidden */
  133300. _markAllSubMeshesAsTexturesDirty(): void;
  133301. /** @hidden */
  133302. _markScenePrePassDirty(): void;
  133303. /**
  133304. * Instantiate a new istance of sub surface configuration.
  133305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133306. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  133307. * @param scene The scene
  133308. */
  133309. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  133310. /**
  133311. * Gets wehter the submesh is ready to be used or not.
  133312. * @param defines the list of "defines" to update.
  133313. * @param scene defines the scene the material belongs to.
  133314. * @returns - boolean indicating that the submesh is ready or not.
  133315. */
  133316. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  133317. /**
  133318. * Checks to see if a texture is used in the material.
  133319. * @param defines the list of "defines" to update.
  133320. * @param scene defines the scene to the material belongs to.
  133321. */
  133322. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  133323. /**
  133324. * Binds the material data.
  133325. * @param uniformBuffer defines the Uniform buffer to fill in.
  133326. * @param scene defines the scene the material belongs to.
  133327. * @param engine defines the engine the material belongs to.
  133328. * @param isFrozen defines whether the material is frozen or not.
  133329. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  133330. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  133331. */
  133332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  133333. /**
  133334. * Unbinds the material from the mesh.
  133335. * @param activeEffect defines the effect that should be unbound from.
  133336. * @returns true if unbound, otherwise false
  133337. */
  133338. unbind(activeEffect: Effect): boolean;
  133339. /**
  133340. * Returns the texture used for refraction or null if none is used.
  133341. * @param scene defines the scene the material belongs to.
  133342. * @returns - Refraction texture if present. If no refraction texture and refraction
  133343. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133344. */
  133345. private _getRefractionTexture;
  133346. /**
  133347. * Returns true if alpha blending should be disabled.
  133348. */
  133349. get disableAlphaBlending(): boolean;
  133350. /**
  133351. * Fills the list of render target textures.
  133352. * @param renderTargets the list of render targets to update
  133353. */
  133354. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133355. /**
  133356. * Checks to see if a texture is used in the material.
  133357. * @param texture - Base texture to use.
  133358. * @returns - Boolean specifying if a texture is used in the material.
  133359. */
  133360. hasTexture(texture: BaseTexture): boolean;
  133361. /**
  133362. * Gets a boolean indicating that current material needs to register RTT
  133363. * @returns true if this uses a render target otherwise false.
  133364. */
  133365. hasRenderTargetTextures(): boolean;
  133366. /**
  133367. * Returns an array of the actively used textures.
  133368. * @param activeTextures Array of BaseTextures
  133369. */
  133370. getActiveTextures(activeTextures: BaseTexture[]): void;
  133371. /**
  133372. * Returns the animatable textures.
  133373. * @param animatables Array of animatable textures.
  133374. */
  133375. getAnimatables(animatables: IAnimatable[]): void;
  133376. /**
  133377. * Disposes the resources of the material.
  133378. * @param forceDisposeTextures - Forces the disposal of all textures.
  133379. */
  133380. dispose(forceDisposeTextures?: boolean): void;
  133381. /**
  133382. * Get the current class name of the texture useful for serialization or dynamic coding.
  133383. * @returns "PBRSubSurfaceConfiguration"
  133384. */
  133385. getClassName(): string;
  133386. /**
  133387. * Add fallbacks to the effect fallbacks list.
  133388. * @param defines defines the Base texture to use.
  133389. * @param fallbacks defines the current fallback list.
  133390. * @param currentRank defines the current fallback rank.
  133391. * @returns the new fallback rank.
  133392. */
  133393. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133394. /**
  133395. * Add the required uniforms to the current list.
  133396. * @param uniforms defines the current uniform list.
  133397. */
  133398. static AddUniforms(uniforms: string[]): void;
  133399. /**
  133400. * Add the required samplers to the current list.
  133401. * @param samplers defines the current sampler list.
  133402. */
  133403. static AddSamplers(samplers: string[]): void;
  133404. /**
  133405. * Add the required uniforms to the current buffer.
  133406. * @param uniformBuffer defines the current uniform buffer.
  133407. */
  133408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133409. /**
  133410. * Makes a duplicate of the current configuration into another one.
  133411. * @param configuration define the config where to copy the info
  133412. */
  133413. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133414. /**
  133415. * Serializes this Sub Surface configuration.
  133416. * @returns - An object with the serialized config.
  133417. */
  133418. serialize(): any;
  133419. /**
  133420. * Parses a anisotropy Configuration from a serialized object.
  133421. * @param source - Serialized object.
  133422. * @param scene Defines the scene we are parsing for
  133423. * @param rootUrl Defines the rootUrl to load from
  133424. */
  133425. parse(source: any, scene: Scene, rootUrl: string): void;
  133426. }
  133427. }
  133428. declare module BABYLON {
  133429. /** @hidden */
  133430. export var pbrFragmentDeclaration: {
  133431. name: string;
  133432. shader: string;
  133433. };
  133434. }
  133435. declare module BABYLON {
  133436. /** @hidden */
  133437. export var pbrUboDeclaration: {
  133438. name: string;
  133439. shader: string;
  133440. };
  133441. }
  133442. declare module BABYLON {
  133443. /** @hidden */
  133444. export var pbrFragmentExtraDeclaration: {
  133445. name: string;
  133446. shader: string;
  133447. };
  133448. }
  133449. declare module BABYLON {
  133450. /** @hidden */
  133451. export var pbrFragmentSamplersDeclaration: {
  133452. name: string;
  133453. shader: string;
  133454. };
  133455. }
  133456. declare module BABYLON {
  133457. /** @hidden */
  133458. export var subSurfaceScatteringFunctions: {
  133459. name: string;
  133460. shader: string;
  133461. };
  133462. }
  133463. declare module BABYLON {
  133464. /** @hidden */
  133465. export var importanceSampling: {
  133466. name: string;
  133467. shader: string;
  133468. };
  133469. }
  133470. declare module BABYLON {
  133471. /** @hidden */
  133472. export var pbrHelperFunctions: {
  133473. name: string;
  133474. shader: string;
  133475. };
  133476. }
  133477. declare module BABYLON {
  133478. /** @hidden */
  133479. export var harmonicsFunctions: {
  133480. name: string;
  133481. shader: string;
  133482. };
  133483. }
  133484. declare module BABYLON {
  133485. /** @hidden */
  133486. export var pbrDirectLightingSetupFunctions: {
  133487. name: string;
  133488. shader: string;
  133489. };
  133490. }
  133491. declare module BABYLON {
  133492. /** @hidden */
  133493. export var pbrDirectLightingFalloffFunctions: {
  133494. name: string;
  133495. shader: string;
  133496. };
  133497. }
  133498. declare module BABYLON {
  133499. /** @hidden */
  133500. export var pbrBRDFFunctions: {
  133501. name: string;
  133502. shader: string;
  133503. };
  133504. }
  133505. declare module BABYLON {
  133506. /** @hidden */
  133507. export var hdrFilteringFunctions: {
  133508. name: string;
  133509. shader: string;
  133510. };
  133511. }
  133512. declare module BABYLON {
  133513. /** @hidden */
  133514. export var pbrDirectLightingFunctions: {
  133515. name: string;
  133516. shader: string;
  133517. };
  133518. }
  133519. declare module BABYLON {
  133520. /** @hidden */
  133521. export var pbrIBLFunctions: {
  133522. name: string;
  133523. shader: string;
  133524. };
  133525. }
  133526. declare module BABYLON {
  133527. /** @hidden */
  133528. export var pbrBlockAlbedoOpacity: {
  133529. name: string;
  133530. shader: string;
  133531. };
  133532. }
  133533. declare module BABYLON {
  133534. /** @hidden */
  133535. export var pbrBlockReflectivity: {
  133536. name: string;
  133537. shader: string;
  133538. };
  133539. }
  133540. declare module BABYLON {
  133541. /** @hidden */
  133542. export var pbrBlockAmbientOcclusion: {
  133543. name: string;
  133544. shader: string;
  133545. };
  133546. }
  133547. declare module BABYLON {
  133548. /** @hidden */
  133549. export var pbrBlockAlphaFresnel: {
  133550. name: string;
  133551. shader: string;
  133552. };
  133553. }
  133554. declare module BABYLON {
  133555. /** @hidden */
  133556. export var pbrBlockAnisotropic: {
  133557. name: string;
  133558. shader: string;
  133559. };
  133560. }
  133561. declare module BABYLON {
  133562. /** @hidden */
  133563. export var pbrBlockReflection: {
  133564. name: string;
  133565. shader: string;
  133566. };
  133567. }
  133568. declare module BABYLON {
  133569. /** @hidden */
  133570. export var pbrBlockSheen: {
  133571. name: string;
  133572. shader: string;
  133573. };
  133574. }
  133575. declare module BABYLON {
  133576. /** @hidden */
  133577. export var pbrBlockClearcoat: {
  133578. name: string;
  133579. shader: string;
  133580. };
  133581. }
  133582. declare module BABYLON {
  133583. /** @hidden */
  133584. export var pbrBlockSubSurface: {
  133585. name: string;
  133586. shader: string;
  133587. };
  133588. }
  133589. declare module BABYLON {
  133590. /** @hidden */
  133591. export var pbrBlockNormalGeometric: {
  133592. name: string;
  133593. shader: string;
  133594. };
  133595. }
  133596. declare module BABYLON {
  133597. /** @hidden */
  133598. export var pbrBlockNormalFinal: {
  133599. name: string;
  133600. shader: string;
  133601. };
  133602. }
  133603. declare module BABYLON {
  133604. /** @hidden */
  133605. export var pbrBlockGeometryInfo: {
  133606. name: string;
  133607. shader: string;
  133608. };
  133609. }
  133610. declare module BABYLON {
  133611. /** @hidden */
  133612. export var pbrBlockReflectance0: {
  133613. name: string;
  133614. shader: string;
  133615. };
  133616. }
  133617. declare module BABYLON {
  133618. /** @hidden */
  133619. export var pbrBlockReflectance: {
  133620. name: string;
  133621. shader: string;
  133622. };
  133623. }
  133624. declare module BABYLON {
  133625. /** @hidden */
  133626. export var pbrBlockDirectLighting: {
  133627. name: string;
  133628. shader: string;
  133629. };
  133630. }
  133631. declare module BABYLON {
  133632. /** @hidden */
  133633. export var pbrBlockFinalLitComponents: {
  133634. name: string;
  133635. shader: string;
  133636. };
  133637. }
  133638. declare module BABYLON {
  133639. /** @hidden */
  133640. export var pbrBlockFinalUnlitComponents: {
  133641. name: string;
  133642. shader: string;
  133643. };
  133644. }
  133645. declare module BABYLON {
  133646. /** @hidden */
  133647. export var pbrBlockFinalColorComposition: {
  133648. name: string;
  133649. shader: string;
  133650. };
  133651. }
  133652. declare module BABYLON {
  133653. /** @hidden */
  133654. export var pbrBlockImageProcessing: {
  133655. name: string;
  133656. shader: string;
  133657. };
  133658. }
  133659. declare module BABYLON {
  133660. /** @hidden */
  133661. export var pbrDebug: {
  133662. name: string;
  133663. shader: string;
  133664. };
  133665. }
  133666. declare module BABYLON {
  133667. /** @hidden */
  133668. export var pbrPixelShader: {
  133669. name: string;
  133670. shader: string;
  133671. };
  133672. }
  133673. declare module BABYLON {
  133674. /** @hidden */
  133675. export var pbrVertexDeclaration: {
  133676. name: string;
  133677. shader: string;
  133678. };
  133679. }
  133680. declare module BABYLON {
  133681. /** @hidden */
  133682. export var pbrVertexShader: {
  133683. name: string;
  133684. shader: string;
  133685. };
  133686. }
  133687. declare module BABYLON {
  133688. /**
  133689. * Manages the defines for the PBR Material.
  133690. * @hidden
  133691. */
  133692. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133693. PBR: boolean;
  133694. NUM_SAMPLES: string;
  133695. REALTIME_FILTERING: boolean;
  133696. MAINUV1: boolean;
  133697. MAINUV2: boolean;
  133698. UV1: boolean;
  133699. UV2: boolean;
  133700. ALBEDO: boolean;
  133701. GAMMAALBEDO: boolean;
  133702. ALBEDODIRECTUV: number;
  133703. VERTEXCOLOR: boolean;
  133704. DETAIL: boolean;
  133705. DETAILDIRECTUV: number;
  133706. DETAIL_NORMALBLENDMETHOD: number;
  133707. AMBIENT: boolean;
  133708. AMBIENTDIRECTUV: number;
  133709. AMBIENTINGRAYSCALE: boolean;
  133710. OPACITY: boolean;
  133711. VERTEXALPHA: boolean;
  133712. OPACITYDIRECTUV: number;
  133713. OPACITYRGB: boolean;
  133714. ALPHATEST: boolean;
  133715. DEPTHPREPASS: boolean;
  133716. ALPHABLEND: boolean;
  133717. ALPHAFROMALBEDO: boolean;
  133718. ALPHATESTVALUE: string;
  133719. SPECULAROVERALPHA: boolean;
  133720. RADIANCEOVERALPHA: boolean;
  133721. ALPHAFRESNEL: boolean;
  133722. LINEARALPHAFRESNEL: boolean;
  133723. PREMULTIPLYALPHA: boolean;
  133724. EMISSIVE: boolean;
  133725. EMISSIVEDIRECTUV: number;
  133726. REFLECTIVITY: boolean;
  133727. REFLECTIVITYDIRECTUV: number;
  133728. SPECULARTERM: boolean;
  133729. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133730. MICROSURFACEAUTOMATIC: boolean;
  133731. LODBASEDMICROSFURACE: boolean;
  133732. MICROSURFACEMAP: boolean;
  133733. MICROSURFACEMAPDIRECTUV: number;
  133734. METALLICWORKFLOW: boolean;
  133735. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133736. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133737. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133738. AOSTOREINMETALMAPRED: boolean;
  133739. METALLIC_REFLECTANCE: boolean;
  133740. METALLIC_REFLECTANCEDIRECTUV: number;
  133741. ENVIRONMENTBRDF: boolean;
  133742. ENVIRONMENTBRDF_RGBD: boolean;
  133743. NORMAL: boolean;
  133744. TANGENT: boolean;
  133745. BUMP: boolean;
  133746. BUMPDIRECTUV: number;
  133747. OBJECTSPACE_NORMALMAP: boolean;
  133748. PARALLAX: boolean;
  133749. PARALLAXOCCLUSION: boolean;
  133750. NORMALXYSCALE: boolean;
  133751. LIGHTMAP: boolean;
  133752. LIGHTMAPDIRECTUV: number;
  133753. USELIGHTMAPASSHADOWMAP: boolean;
  133754. GAMMALIGHTMAP: boolean;
  133755. RGBDLIGHTMAP: boolean;
  133756. REFLECTION: boolean;
  133757. REFLECTIONMAP_3D: boolean;
  133758. REFLECTIONMAP_SPHERICAL: boolean;
  133759. REFLECTIONMAP_PLANAR: boolean;
  133760. REFLECTIONMAP_CUBIC: boolean;
  133761. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133762. REFLECTIONMAP_PROJECTION: boolean;
  133763. REFLECTIONMAP_SKYBOX: boolean;
  133764. REFLECTIONMAP_EXPLICIT: boolean;
  133765. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133766. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133767. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133768. INVERTCUBICMAP: boolean;
  133769. USESPHERICALFROMREFLECTIONMAP: boolean;
  133770. USEIRRADIANCEMAP: boolean;
  133771. SPHERICAL_HARMONICS: boolean;
  133772. USESPHERICALINVERTEX: boolean;
  133773. REFLECTIONMAP_OPPOSITEZ: boolean;
  133774. LODINREFLECTIONALPHA: boolean;
  133775. GAMMAREFLECTION: boolean;
  133776. RGBDREFLECTION: boolean;
  133777. LINEARSPECULARREFLECTION: boolean;
  133778. RADIANCEOCCLUSION: boolean;
  133779. HORIZONOCCLUSION: boolean;
  133780. INSTANCES: boolean;
  133781. THIN_INSTANCES: boolean;
  133782. PREPASS: boolean;
  133783. SCENE_MRT_COUNT: number;
  133784. NUM_BONE_INFLUENCERS: number;
  133785. BonesPerMesh: number;
  133786. BONETEXTURE: boolean;
  133787. NONUNIFORMSCALING: boolean;
  133788. MORPHTARGETS: boolean;
  133789. MORPHTARGETS_NORMAL: boolean;
  133790. MORPHTARGETS_TANGENT: boolean;
  133791. MORPHTARGETS_UV: boolean;
  133792. NUM_MORPH_INFLUENCERS: number;
  133793. IMAGEPROCESSING: boolean;
  133794. VIGNETTE: boolean;
  133795. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133796. VIGNETTEBLENDMODEOPAQUE: boolean;
  133797. TONEMAPPING: boolean;
  133798. TONEMAPPING_ACES: boolean;
  133799. CONTRAST: boolean;
  133800. COLORCURVES: boolean;
  133801. COLORGRADING: boolean;
  133802. COLORGRADING3D: boolean;
  133803. SAMPLER3DGREENDEPTH: boolean;
  133804. SAMPLER3DBGRMAP: boolean;
  133805. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133806. EXPOSURE: boolean;
  133807. MULTIVIEW: boolean;
  133808. USEPHYSICALLIGHTFALLOFF: boolean;
  133809. USEGLTFLIGHTFALLOFF: boolean;
  133810. TWOSIDEDLIGHTING: boolean;
  133811. SHADOWFLOAT: boolean;
  133812. CLIPPLANE: boolean;
  133813. CLIPPLANE2: boolean;
  133814. CLIPPLANE3: boolean;
  133815. CLIPPLANE4: boolean;
  133816. CLIPPLANE5: boolean;
  133817. CLIPPLANE6: boolean;
  133818. POINTSIZE: boolean;
  133819. FOG: boolean;
  133820. LOGARITHMICDEPTH: boolean;
  133821. FORCENORMALFORWARD: boolean;
  133822. SPECULARAA: boolean;
  133823. CLEARCOAT: boolean;
  133824. CLEARCOAT_DEFAULTIOR: boolean;
  133825. CLEARCOAT_TEXTURE: boolean;
  133826. CLEARCOAT_TEXTUREDIRECTUV: number;
  133827. CLEARCOAT_BUMP: boolean;
  133828. CLEARCOAT_BUMPDIRECTUV: number;
  133829. CLEARCOAT_TINT: boolean;
  133830. CLEARCOAT_TINT_TEXTURE: boolean;
  133831. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133832. ANISOTROPIC: boolean;
  133833. ANISOTROPIC_TEXTURE: boolean;
  133834. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133835. BRDF_V_HEIGHT_CORRELATED: boolean;
  133836. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133837. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133838. SHEEN: boolean;
  133839. SHEEN_TEXTURE: boolean;
  133840. SHEEN_TEXTUREDIRECTUV: number;
  133841. SHEEN_LINKWITHALBEDO: boolean;
  133842. SHEEN_ROUGHNESS: boolean;
  133843. SHEEN_ALBEDOSCALING: boolean;
  133844. SUBSURFACE: boolean;
  133845. SS_REFRACTION: boolean;
  133846. SS_TRANSLUCENCY: boolean;
  133847. SS_SCATTERING: boolean;
  133848. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133849. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133850. SS_REFRACTIONMAP_3D: boolean;
  133851. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133852. SS_LODINREFRACTIONALPHA: boolean;
  133853. SS_GAMMAREFRACTION: boolean;
  133854. SS_RGBDREFRACTION: boolean;
  133855. SS_LINEARSPECULARREFRACTION: boolean;
  133856. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133857. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133858. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133859. UNLIT: boolean;
  133860. DEBUGMODE: number;
  133861. /**
  133862. * Initializes the PBR Material defines.
  133863. */
  133864. constructor();
  133865. /**
  133866. * Resets the PBR Material defines.
  133867. */
  133868. reset(): void;
  133869. }
  133870. /**
  133871. * The Physically based material base class of BJS.
  133872. *
  133873. * This offers the main features of a standard PBR material.
  133874. * For more information, please refer to the documentation :
  133875. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133876. */
  133877. export abstract class PBRBaseMaterial extends PushMaterial {
  133878. /**
  133879. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133880. */
  133881. static readonly PBRMATERIAL_OPAQUE: number;
  133882. /**
  133883. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133884. */
  133885. static readonly PBRMATERIAL_ALPHATEST: number;
  133886. /**
  133887. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133888. */
  133889. static readonly PBRMATERIAL_ALPHABLEND: number;
  133890. /**
  133891. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133892. * They are also discarded below the alpha cutoff threshold to improve performances.
  133893. */
  133894. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133895. /**
  133896. * Defines the default value of how much AO map is occluding the analytical lights
  133897. * (point spot...).
  133898. */
  133899. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133900. /**
  133901. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133902. */
  133903. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133904. /**
  133905. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133906. * to enhance interoperability with other engines.
  133907. */
  133908. static readonly LIGHTFALLOFF_GLTF: number;
  133909. /**
  133910. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133911. * to enhance interoperability with other materials.
  133912. */
  133913. static readonly LIGHTFALLOFF_STANDARD: number;
  133914. /**
  133915. * Intensity of the direct lights e.g. the four lights available in your scene.
  133916. * This impacts both the direct diffuse and specular highlights.
  133917. */
  133918. protected _directIntensity: number;
  133919. /**
  133920. * Intensity of the emissive part of the material.
  133921. * This helps controlling the emissive effect without modifying the emissive color.
  133922. */
  133923. protected _emissiveIntensity: number;
  133924. /**
  133925. * Intensity of the environment e.g. how much the environment will light the object
  133926. * either through harmonics for rough material or through the refelction for shiny ones.
  133927. */
  133928. protected _environmentIntensity: number;
  133929. /**
  133930. * This is a special control allowing the reduction of the specular highlights coming from the
  133931. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133932. */
  133933. protected _specularIntensity: number;
  133934. /**
  133935. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133936. */
  133937. private _lightingInfos;
  133938. /**
  133939. * Debug Control allowing disabling the bump map on this material.
  133940. */
  133941. protected _disableBumpMap: boolean;
  133942. /**
  133943. * AKA Diffuse Texture in standard nomenclature.
  133944. */
  133945. protected _albedoTexture: Nullable<BaseTexture>;
  133946. /**
  133947. * AKA Occlusion Texture in other nomenclature.
  133948. */
  133949. protected _ambientTexture: Nullable<BaseTexture>;
  133950. /**
  133951. * AKA Occlusion Texture Intensity in other nomenclature.
  133952. */
  133953. protected _ambientTextureStrength: number;
  133954. /**
  133955. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133956. * 1 means it completely occludes it
  133957. * 0 mean it has no impact
  133958. */
  133959. protected _ambientTextureImpactOnAnalyticalLights: number;
  133960. /**
  133961. * Stores the alpha values in a texture.
  133962. */
  133963. protected _opacityTexture: Nullable<BaseTexture>;
  133964. /**
  133965. * Stores the reflection values in a texture.
  133966. */
  133967. protected _reflectionTexture: Nullable<BaseTexture>;
  133968. /**
  133969. * Stores the emissive values in a texture.
  133970. */
  133971. protected _emissiveTexture: Nullable<BaseTexture>;
  133972. /**
  133973. * AKA Specular texture in other nomenclature.
  133974. */
  133975. protected _reflectivityTexture: Nullable<BaseTexture>;
  133976. /**
  133977. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133978. */
  133979. protected _metallicTexture: Nullable<BaseTexture>;
  133980. /**
  133981. * Specifies the metallic scalar of the metallic/roughness workflow.
  133982. * Can also be used to scale the metalness values of the metallic texture.
  133983. */
  133984. protected _metallic: Nullable<number>;
  133985. /**
  133986. * Specifies the roughness scalar of the metallic/roughness workflow.
  133987. * Can also be used to scale the roughness values of the metallic texture.
  133988. */
  133989. protected _roughness: Nullable<number>;
  133990. /**
  133991. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133992. * By default the indexOfrefraction is used to compute F0;
  133993. *
  133994. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133995. *
  133996. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133997. * F90 = metallicReflectanceColor;
  133998. */
  133999. protected _metallicF0Factor: number;
  134000. /**
  134001. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134002. * By default the F90 is always 1;
  134003. *
  134004. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134005. *
  134006. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134007. * F90 = metallicReflectanceColor;
  134008. */
  134009. protected _metallicReflectanceColor: Color3;
  134010. /**
  134011. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134012. * This is multiply against the scalar values defined in the material.
  134013. */
  134014. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  134015. /**
  134016. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134017. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134018. */
  134019. protected _microSurfaceTexture: Nullable<BaseTexture>;
  134020. /**
  134021. * Stores surface normal data used to displace a mesh in a texture.
  134022. */
  134023. protected _bumpTexture: Nullable<BaseTexture>;
  134024. /**
  134025. * Stores the pre-calculated light information of a mesh in a texture.
  134026. */
  134027. protected _lightmapTexture: Nullable<BaseTexture>;
  134028. /**
  134029. * The color of a material in ambient lighting.
  134030. */
  134031. protected _ambientColor: Color3;
  134032. /**
  134033. * AKA Diffuse Color in other nomenclature.
  134034. */
  134035. protected _albedoColor: Color3;
  134036. /**
  134037. * AKA Specular Color in other nomenclature.
  134038. */
  134039. protected _reflectivityColor: Color3;
  134040. /**
  134041. * The color applied when light is reflected from a material.
  134042. */
  134043. protected _reflectionColor: Color3;
  134044. /**
  134045. * The color applied when light is emitted from a material.
  134046. */
  134047. protected _emissiveColor: Color3;
  134048. /**
  134049. * AKA Glossiness in other nomenclature.
  134050. */
  134051. protected _microSurface: number;
  134052. /**
  134053. * Specifies that the material will use the light map as a show map.
  134054. */
  134055. protected _useLightmapAsShadowmap: boolean;
  134056. /**
  134057. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134058. * makes the reflect vector face the model (under horizon).
  134059. */
  134060. protected _useHorizonOcclusion: boolean;
  134061. /**
  134062. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134063. * too much the area relying on ambient texture to define their ambient occlusion.
  134064. */
  134065. protected _useRadianceOcclusion: boolean;
  134066. /**
  134067. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134068. */
  134069. protected _useAlphaFromAlbedoTexture: boolean;
  134070. /**
  134071. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  134072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134073. */
  134074. protected _useSpecularOverAlpha: boolean;
  134075. /**
  134076. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134077. */
  134078. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134079. /**
  134080. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134081. */
  134082. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  134083. /**
  134084. * Specifies if the metallic texture contains the roughness information in its green channel.
  134085. */
  134086. protected _useRoughnessFromMetallicTextureGreen: boolean;
  134087. /**
  134088. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134089. */
  134090. protected _useMetallnessFromMetallicTextureBlue: boolean;
  134091. /**
  134092. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134093. */
  134094. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  134095. /**
  134096. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134097. */
  134098. protected _useAmbientInGrayScale: boolean;
  134099. /**
  134100. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134101. * The material will try to infer what glossiness each pixel should be.
  134102. */
  134103. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  134104. /**
  134105. * Defines the falloff type used in this material.
  134106. * It by default is Physical.
  134107. */
  134108. protected _lightFalloff: number;
  134109. /**
  134110. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134111. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134112. */
  134113. protected _useRadianceOverAlpha: boolean;
  134114. /**
  134115. * Allows using an object space normal map (instead of tangent space).
  134116. */
  134117. protected _useObjectSpaceNormalMap: boolean;
  134118. /**
  134119. * Allows using the bump map in parallax mode.
  134120. */
  134121. protected _useParallax: boolean;
  134122. /**
  134123. * Allows using the bump map in parallax occlusion mode.
  134124. */
  134125. protected _useParallaxOcclusion: boolean;
  134126. /**
  134127. * Controls the scale bias of the parallax mode.
  134128. */
  134129. protected _parallaxScaleBias: number;
  134130. /**
  134131. * If sets to true, disables all the lights affecting the material.
  134132. */
  134133. protected _disableLighting: boolean;
  134134. /**
  134135. * Number of Simultaneous lights allowed on the material.
  134136. */
  134137. protected _maxSimultaneousLights: number;
  134138. /**
  134139. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134140. */
  134141. protected _invertNormalMapX: boolean;
  134142. /**
  134143. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134144. */
  134145. protected _invertNormalMapY: boolean;
  134146. /**
  134147. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134148. */
  134149. protected _twoSidedLighting: boolean;
  134150. /**
  134151. * Defines the alpha limits in alpha test mode.
  134152. */
  134153. protected _alphaCutOff: number;
  134154. /**
  134155. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134156. */
  134157. protected _forceAlphaTest: boolean;
  134158. /**
  134159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134160. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134161. */
  134162. protected _useAlphaFresnel: boolean;
  134163. /**
  134164. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134165. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134166. */
  134167. protected _useLinearAlphaFresnel: boolean;
  134168. /**
  134169. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  134170. * from cos thetav and roughness:
  134171. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  134172. */
  134173. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  134174. /**
  134175. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134176. */
  134177. protected _forceIrradianceInFragment: boolean;
  134178. private _realTimeFiltering;
  134179. /**
  134180. * Enables realtime filtering on the texture.
  134181. */
  134182. get realTimeFiltering(): boolean;
  134183. set realTimeFiltering(b: boolean);
  134184. private _realTimeFilteringQuality;
  134185. /**
  134186. * Quality switch for realtime filtering
  134187. */
  134188. get realTimeFilteringQuality(): number;
  134189. set realTimeFilteringQuality(n: number);
  134190. /**
  134191. * Should this material render to several textures at once
  134192. */
  134193. get shouldRenderToMRT(): boolean;
  134194. /**
  134195. * Force normal to face away from face.
  134196. */
  134197. protected _forceNormalForward: boolean;
  134198. /**
  134199. * Enables specular anti aliasing in the PBR shader.
  134200. * It will both interacts on the Geometry for analytical and IBL lighting.
  134201. * It also prefilter the roughness map based on the bump values.
  134202. */
  134203. protected _enableSpecularAntiAliasing: boolean;
  134204. /**
  134205. * Default configuration related to image processing available in the PBR Material.
  134206. */
  134207. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134208. /**
  134209. * Keep track of the image processing observer to allow dispose and replace.
  134210. */
  134211. private _imageProcessingObserver;
  134212. /**
  134213. * Attaches a new image processing configuration to the PBR Material.
  134214. * @param configuration
  134215. */
  134216. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134217. /**
  134218. * Stores the available render targets.
  134219. */
  134220. private _renderTargets;
  134221. /**
  134222. * Sets the global ambient color for the material used in lighting calculations.
  134223. */
  134224. private _globalAmbientColor;
  134225. /**
  134226. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  134227. */
  134228. private _useLogarithmicDepth;
  134229. /**
  134230. * If set to true, no lighting calculations will be applied.
  134231. */
  134232. private _unlit;
  134233. private _debugMode;
  134234. /**
  134235. * @hidden
  134236. * This is reserved for the inspector.
  134237. * Defines the material debug mode.
  134238. * It helps seeing only some components of the material while troubleshooting.
  134239. */
  134240. debugMode: number;
  134241. /**
  134242. * @hidden
  134243. * This is reserved for the inspector.
  134244. * Specify from where on screen the debug mode should start.
  134245. * The value goes from -1 (full screen) to 1 (not visible)
  134246. * It helps with side by side comparison against the final render
  134247. * This defaults to -1
  134248. */
  134249. private debugLimit;
  134250. /**
  134251. * @hidden
  134252. * This is reserved for the inspector.
  134253. * As the default viewing range might not be enough (if the ambient is really small for instance)
  134254. * You can use the factor to better multiply the final value.
  134255. */
  134256. private debugFactor;
  134257. /**
  134258. * Defines the clear coat layer parameters for the material.
  134259. */
  134260. readonly clearCoat: PBRClearCoatConfiguration;
  134261. /**
  134262. * Defines the anisotropic parameters for the material.
  134263. */
  134264. readonly anisotropy: PBRAnisotropicConfiguration;
  134265. /**
  134266. * Defines the BRDF parameters for the material.
  134267. */
  134268. readonly brdf: PBRBRDFConfiguration;
  134269. /**
  134270. * Defines the Sheen parameters for the material.
  134271. */
  134272. readonly sheen: PBRSheenConfiguration;
  134273. /**
  134274. * Defines the SubSurface parameters for the material.
  134275. */
  134276. readonly subSurface: PBRSubSurfaceConfiguration;
  134277. /**
  134278. * Defines the detail map parameters for the material.
  134279. */
  134280. readonly detailMap: DetailMapConfiguration;
  134281. protected _rebuildInParallel: boolean;
  134282. /**
  134283. * Instantiates a new PBRMaterial instance.
  134284. *
  134285. * @param name The material name
  134286. * @param scene The scene the material will be use in.
  134287. */
  134288. constructor(name: string, scene: Scene);
  134289. /**
  134290. * Gets a boolean indicating that current material needs to register RTT
  134291. */
  134292. get hasRenderTargetTextures(): boolean;
  134293. /**
  134294. * Gets the name of the material class.
  134295. */
  134296. getClassName(): string;
  134297. /**
  134298. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134299. */
  134300. get useLogarithmicDepth(): boolean;
  134301. /**
  134302. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134303. */
  134304. set useLogarithmicDepth(value: boolean);
  134305. /**
  134306. * Returns true if alpha blending should be disabled.
  134307. */
  134308. protected get _disableAlphaBlending(): boolean;
  134309. /**
  134310. * Specifies whether or not this material should be rendered in alpha blend mode.
  134311. */
  134312. needAlphaBlending(): boolean;
  134313. /**
  134314. * Specifies whether or not this material should be rendered in alpha test mode.
  134315. */
  134316. needAlphaTesting(): boolean;
  134317. /**
  134318. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  134319. */
  134320. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  134321. /**
  134322. * Gets the texture used for the alpha test.
  134323. */
  134324. getAlphaTestTexture(): Nullable<BaseTexture>;
  134325. /**
  134326. * Specifies that the submesh is ready to be used.
  134327. * @param mesh - BJS mesh.
  134328. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  134329. * @param useInstances - Specifies that instances should be used.
  134330. * @returns - boolean indicating that the submesh is ready or not.
  134331. */
  134332. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134333. /**
  134334. * Specifies if the material uses metallic roughness workflow.
  134335. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134336. */
  134337. isMetallicWorkflow(): boolean;
  134338. private _prepareEffect;
  134339. private _prepareDefines;
  134340. /**
  134341. * Force shader compilation
  134342. */
  134343. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134344. /**
  134345. * Initializes the uniform buffer layout for the shader.
  134346. */
  134347. buildUniformLayout(): void;
  134348. /**
  134349. * Unbinds the material from the mesh
  134350. */
  134351. unbind(): void;
  134352. /**
  134353. * Binds the submesh data.
  134354. * @param world - The world matrix.
  134355. * @param mesh - The BJS mesh.
  134356. * @param subMesh - A submesh of the BJS mesh.
  134357. */
  134358. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134359. /**
  134360. * Returns the animatable textures.
  134361. * @returns - Array of animatable textures.
  134362. */
  134363. getAnimatables(): IAnimatable[];
  134364. /**
  134365. * Returns the texture used for reflections.
  134366. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134367. */
  134368. private _getReflectionTexture;
  134369. /**
  134370. * Returns an array of the actively used textures.
  134371. * @returns - Array of BaseTextures
  134372. */
  134373. getActiveTextures(): BaseTexture[];
  134374. /**
  134375. * Checks to see if a texture is used in the material.
  134376. * @param texture - Base texture to use.
  134377. * @returns - Boolean specifying if a texture is used in the material.
  134378. */
  134379. hasTexture(texture: BaseTexture): boolean;
  134380. /**
  134381. * Disposes the resources of the material.
  134382. * @param forceDisposeEffect - Forces the disposal of effects.
  134383. * @param forceDisposeTextures - Forces the disposal of all textures.
  134384. */
  134385. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134386. }
  134387. }
  134388. declare module BABYLON {
  134389. /**
  134390. * The Physically based material of BJS.
  134391. *
  134392. * This offers the main features of a standard PBR material.
  134393. * For more information, please refer to the documentation :
  134394. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134395. */
  134396. export class PBRMaterial extends PBRBaseMaterial {
  134397. /**
  134398. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134399. */
  134400. static readonly PBRMATERIAL_OPAQUE: number;
  134401. /**
  134402. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134403. */
  134404. static readonly PBRMATERIAL_ALPHATEST: number;
  134405. /**
  134406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134407. */
  134408. static readonly PBRMATERIAL_ALPHABLEND: number;
  134409. /**
  134410. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134411. * They are also discarded below the alpha cutoff threshold to improve performances.
  134412. */
  134413. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134414. /**
  134415. * Defines the default value of how much AO map is occluding the analytical lights
  134416. * (point spot...).
  134417. */
  134418. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134419. /**
  134420. * Intensity of the direct lights e.g. the four lights available in your scene.
  134421. * This impacts both the direct diffuse and specular highlights.
  134422. */
  134423. directIntensity: number;
  134424. /**
  134425. * Intensity of the emissive part of the material.
  134426. * This helps controlling the emissive effect without modifying the emissive color.
  134427. */
  134428. emissiveIntensity: number;
  134429. /**
  134430. * Intensity of the environment e.g. how much the environment will light the object
  134431. * either through harmonics for rough material or through the refelction for shiny ones.
  134432. */
  134433. environmentIntensity: number;
  134434. /**
  134435. * This is a special control allowing the reduction of the specular highlights coming from the
  134436. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134437. */
  134438. specularIntensity: number;
  134439. /**
  134440. * Debug Control allowing disabling the bump map on this material.
  134441. */
  134442. disableBumpMap: boolean;
  134443. /**
  134444. * AKA Diffuse Texture in standard nomenclature.
  134445. */
  134446. albedoTexture: BaseTexture;
  134447. /**
  134448. * AKA Occlusion Texture in other nomenclature.
  134449. */
  134450. ambientTexture: BaseTexture;
  134451. /**
  134452. * AKA Occlusion Texture Intensity in other nomenclature.
  134453. */
  134454. ambientTextureStrength: number;
  134455. /**
  134456. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134457. * 1 means it completely occludes it
  134458. * 0 mean it has no impact
  134459. */
  134460. ambientTextureImpactOnAnalyticalLights: number;
  134461. /**
  134462. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134463. */
  134464. opacityTexture: BaseTexture;
  134465. /**
  134466. * Stores the reflection values in a texture.
  134467. */
  134468. reflectionTexture: Nullable<BaseTexture>;
  134469. /**
  134470. * Stores the emissive values in a texture.
  134471. */
  134472. emissiveTexture: BaseTexture;
  134473. /**
  134474. * AKA Specular texture in other nomenclature.
  134475. */
  134476. reflectivityTexture: BaseTexture;
  134477. /**
  134478. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134479. */
  134480. metallicTexture: BaseTexture;
  134481. /**
  134482. * Specifies the metallic scalar of the metallic/roughness workflow.
  134483. * Can also be used to scale the metalness values of the metallic texture.
  134484. */
  134485. metallic: Nullable<number>;
  134486. /**
  134487. * Specifies the roughness scalar of the metallic/roughness workflow.
  134488. * Can also be used to scale the roughness values of the metallic texture.
  134489. */
  134490. roughness: Nullable<number>;
  134491. /**
  134492. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134493. * By default the indexOfrefraction is used to compute F0;
  134494. *
  134495. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134496. *
  134497. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134498. * F90 = metallicReflectanceColor;
  134499. */
  134500. metallicF0Factor: number;
  134501. /**
  134502. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134503. * By default the F90 is always 1;
  134504. *
  134505. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134506. *
  134507. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134508. * F90 = metallicReflectanceColor;
  134509. */
  134510. metallicReflectanceColor: Color3;
  134511. /**
  134512. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134513. * This is multiply against the scalar values defined in the material.
  134514. */
  134515. metallicReflectanceTexture: Nullable<BaseTexture>;
  134516. /**
  134517. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134518. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134519. */
  134520. microSurfaceTexture: BaseTexture;
  134521. /**
  134522. * Stores surface normal data used to displace a mesh in a texture.
  134523. */
  134524. bumpTexture: BaseTexture;
  134525. /**
  134526. * Stores the pre-calculated light information of a mesh in a texture.
  134527. */
  134528. lightmapTexture: BaseTexture;
  134529. /**
  134530. * Stores the refracted light information in a texture.
  134531. */
  134532. get refractionTexture(): Nullable<BaseTexture>;
  134533. set refractionTexture(value: Nullable<BaseTexture>);
  134534. /**
  134535. * The color of a material in ambient lighting.
  134536. */
  134537. ambientColor: Color3;
  134538. /**
  134539. * AKA Diffuse Color in other nomenclature.
  134540. */
  134541. albedoColor: Color3;
  134542. /**
  134543. * AKA Specular Color in other nomenclature.
  134544. */
  134545. reflectivityColor: Color3;
  134546. /**
  134547. * The color reflected from the material.
  134548. */
  134549. reflectionColor: Color3;
  134550. /**
  134551. * The color emitted from the material.
  134552. */
  134553. emissiveColor: Color3;
  134554. /**
  134555. * AKA Glossiness in other nomenclature.
  134556. */
  134557. microSurface: number;
  134558. /**
  134559. * Index of refraction of the material base layer.
  134560. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134561. *
  134562. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134563. *
  134564. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134565. */
  134566. get indexOfRefraction(): number;
  134567. set indexOfRefraction(value: number);
  134568. /**
  134569. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134570. */
  134571. get invertRefractionY(): boolean;
  134572. set invertRefractionY(value: boolean);
  134573. /**
  134574. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134575. * Materials half opaque for instance using refraction could benefit from this control.
  134576. */
  134577. get linkRefractionWithTransparency(): boolean;
  134578. set linkRefractionWithTransparency(value: boolean);
  134579. /**
  134580. * If true, the light map contains occlusion information instead of lighting info.
  134581. */
  134582. useLightmapAsShadowmap: boolean;
  134583. /**
  134584. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134585. */
  134586. useAlphaFromAlbedoTexture: boolean;
  134587. /**
  134588. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134589. */
  134590. forceAlphaTest: boolean;
  134591. /**
  134592. * Defines the alpha limits in alpha test mode.
  134593. */
  134594. alphaCutOff: number;
  134595. /**
  134596. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134598. */
  134599. useSpecularOverAlpha: boolean;
  134600. /**
  134601. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134602. */
  134603. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134604. /**
  134605. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134606. */
  134607. useRoughnessFromMetallicTextureAlpha: boolean;
  134608. /**
  134609. * Specifies if the metallic texture contains the roughness information in its green channel.
  134610. */
  134611. useRoughnessFromMetallicTextureGreen: boolean;
  134612. /**
  134613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134614. */
  134615. useMetallnessFromMetallicTextureBlue: boolean;
  134616. /**
  134617. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134618. */
  134619. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134620. /**
  134621. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134622. */
  134623. useAmbientInGrayScale: boolean;
  134624. /**
  134625. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134626. * The material will try to infer what glossiness each pixel should be.
  134627. */
  134628. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134629. /**
  134630. * BJS is using an harcoded light falloff based on a manually sets up range.
  134631. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134632. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134633. */
  134634. get usePhysicalLightFalloff(): boolean;
  134635. /**
  134636. * BJS is using an harcoded light falloff based on a manually sets up range.
  134637. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134638. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134639. */
  134640. set usePhysicalLightFalloff(value: boolean);
  134641. /**
  134642. * In order to support the falloff compatibility with gltf, a special mode has been added
  134643. * to reproduce the gltf light falloff.
  134644. */
  134645. get useGLTFLightFalloff(): boolean;
  134646. /**
  134647. * In order to support the falloff compatibility with gltf, a special mode has been added
  134648. * to reproduce the gltf light falloff.
  134649. */
  134650. set useGLTFLightFalloff(value: boolean);
  134651. /**
  134652. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134653. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134654. */
  134655. useRadianceOverAlpha: boolean;
  134656. /**
  134657. * Allows using an object space normal map (instead of tangent space).
  134658. */
  134659. useObjectSpaceNormalMap: boolean;
  134660. /**
  134661. * Allows using the bump map in parallax mode.
  134662. */
  134663. useParallax: boolean;
  134664. /**
  134665. * Allows using the bump map in parallax occlusion mode.
  134666. */
  134667. useParallaxOcclusion: boolean;
  134668. /**
  134669. * Controls the scale bias of the parallax mode.
  134670. */
  134671. parallaxScaleBias: number;
  134672. /**
  134673. * If sets to true, disables all the lights affecting the material.
  134674. */
  134675. disableLighting: boolean;
  134676. /**
  134677. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134678. */
  134679. forceIrradianceInFragment: boolean;
  134680. /**
  134681. * Number of Simultaneous lights allowed on the material.
  134682. */
  134683. maxSimultaneousLights: number;
  134684. /**
  134685. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134686. */
  134687. invertNormalMapX: boolean;
  134688. /**
  134689. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134690. */
  134691. invertNormalMapY: boolean;
  134692. /**
  134693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134694. */
  134695. twoSidedLighting: boolean;
  134696. /**
  134697. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134698. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134699. */
  134700. useAlphaFresnel: boolean;
  134701. /**
  134702. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134703. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134704. */
  134705. useLinearAlphaFresnel: boolean;
  134706. /**
  134707. * Let user defines the brdf lookup texture used for IBL.
  134708. * A default 8bit version is embedded but you could point at :
  134709. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134710. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134711. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134712. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134713. */
  134714. environmentBRDFTexture: Nullable<BaseTexture>;
  134715. /**
  134716. * Force normal to face away from face.
  134717. */
  134718. forceNormalForward: boolean;
  134719. /**
  134720. * Enables specular anti aliasing in the PBR shader.
  134721. * It will both interacts on the Geometry for analytical and IBL lighting.
  134722. * It also prefilter the roughness map based on the bump values.
  134723. */
  134724. enableSpecularAntiAliasing: boolean;
  134725. /**
  134726. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134727. * makes the reflect vector face the model (under horizon).
  134728. */
  134729. useHorizonOcclusion: boolean;
  134730. /**
  134731. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134732. * too much the area relying on ambient texture to define their ambient occlusion.
  134733. */
  134734. useRadianceOcclusion: boolean;
  134735. /**
  134736. * If set to true, no lighting calculations will be applied.
  134737. */
  134738. unlit: boolean;
  134739. /**
  134740. * Gets the image processing configuration used either in this material.
  134741. */
  134742. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134743. /**
  134744. * Sets the Default image processing configuration used either in the this material.
  134745. *
  134746. * If sets to null, the scene one is in use.
  134747. */
  134748. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134749. /**
  134750. * Gets wether the color curves effect is enabled.
  134751. */
  134752. get cameraColorCurvesEnabled(): boolean;
  134753. /**
  134754. * Sets wether the color curves effect is enabled.
  134755. */
  134756. set cameraColorCurvesEnabled(value: boolean);
  134757. /**
  134758. * Gets wether the color grading effect is enabled.
  134759. */
  134760. get cameraColorGradingEnabled(): boolean;
  134761. /**
  134762. * Gets wether the color grading effect is enabled.
  134763. */
  134764. set cameraColorGradingEnabled(value: boolean);
  134765. /**
  134766. * Gets wether tonemapping is enabled or not.
  134767. */
  134768. get cameraToneMappingEnabled(): boolean;
  134769. /**
  134770. * Sets wether tonemapping is enabled or not
  134771. */
  134772. set cameraToneMappingEnabled(value: boolean);
  134773. /**
  134774. * The camera exposure used on this material.
  134775. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134776. * This corresponds to a photographic exposure.
  134777. */
  134778. get cameraExposure(): number;
  134779. /**
  134780. * The camera exposure used on this material.
  134781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134782. * This corresponds to a photographic exposure.
  134783. */
  134784. set cameraExposure(value: number);
  134785. /**
  134786. * Gets The camera contrast used on this material.
  134787. */
  134788. get cameraContrast(): number;
  134789. /**
  134790. * Sets The camera contrast used on this material.
  134791. */
  134792. set cameraContrast(value: number);
  134793. /**
  134794. * Gets the Color Grading 2D Lookup Texture.
  134795. */
  134796. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134797. /**
  134798. * Sets the Color Grading 2D Lookup Texture.
  134799. */
  134800. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134801. /**
  134802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134804. * 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;
  134805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134806. */
  134807. get cameraColorCurves(): Nullable<ColorCurves>;
  134808. /**
  134809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134811. * 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;
  134812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134813. */
  134814. set cameraColorCurves(value: Nullable<ColorCurves>);
  134815. /**
  134816. * Instantiates a new PBRMaterial instance.
  134817. *
  134818. * @param name The material name
  134819. * @param scene The scene the material will be use in.
  134820. */
  134821. constructor(name: string, scene: Scene);
  134822. /**
  134823. * Returns the name of this material class.
  134824. */
  134825. getClassName(): string;
  134826. /**
  134827. * Makes a duplicate of the current material.
  134828. * @param name - name to use for the new material.
  134829. */
  134830. clone(name: string): PBRMaterial;
  134831. /**
  134832. * Serializes this PBR Material.
  134833. * @returns - An object with the serialized material.
  134834. */
  134835. serialize(): any;
  134836. /**
  134837. * Parses a PBR Material from a serialized object.
  134838. * @param source - Serialized object.
  134839. * @param scene - BJS scene instance.
  134840. * @param rootUrl - url for the scene object
  134841. * @returns - PBRMaterial
  134842. */
  134843. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134844. }
  134845. }
  134846. declare module BABYLON {
  134847. /**
  134848. * Direct draw surface info
  134849. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134850. */
  134851. export interface DDSInfo {
  134852. /**
  134853. * Width of the texture
  134854. */
  134855. width: number;
  134856. /**
  134857. * Width of the texture
  134858. */
  134859. height: number;
  134860. /**
  134861. * Number of Mipmaps for the texture
  134862. * @see https://en.wikipedia.org/wiki/Mipmap
  134863. */
  134864. mipmapCount: number;
  134865. /**
  134866. * If the textures format is a known fourCC format
  134867. * @see https://www.fourcc.org/
  134868. */
  134869. isFourCC: boolean;
  134870. /**
  134871. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134872. */
  134873. isRGB: boolean;
  134874. /**
  134875. * If the texture is a lumincance format
  134876. */
  134877. isLuminance: boolean;
  134878. /**
  134879. * If this is a cube texture
  134880. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134881. */
  134882. isCube: boolean;
  134883. /**
  134884. * If the texture is a compressed format eg. FOURCC_DXT1
  134885. */
  134886. isCompressed: boolean;
  134887. /**
  134888. * The dxgiFormat of the texture
  134889. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134890. */
  134891. dxgiFormat: number;
  134892. /**
  134893. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134894. */
  134895. textureType: number;
  134896. /**
  134897. * Sphericle polynomial created for the dds texture
  134898. */
  134899. sphericalPolynomial?: SphericalPolynomial;
  134900. }
  134901. /**
  134902. * Class used to provide DDS decompression tools
  134903. */
  134904. export class DDSTools {
  134905. /**
  134906. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134907. */
  134908. static StoreLODInAlphaChannel: boolean;
  134909. /**
  134910. * Gets DDS information from an array buffer
  134911. * @param data defines the array buffer view to read data from
  134912. * @returns the DDS information
  134913. */
  134914. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134915. private static _FloatView;
  134916. private static _Int32View;
  134917. private static _ToHalfFloat;
  134918. private static _FromHalfFloat;
  134919. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134920. private static _GetHalfFloatRGBAArrayBuffer;
  134921. private static _GetFloatRGBAArrayBuffer;
  134922. private static _GetFloatAsUIntRGBAArrayBuffer;
  134923. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134924. private static _GetRGBAArrayBuffer;
  134925. private static _ExtractLongWordOrder;
  134926. private static _GetRGBArrayBuffer;
  134927. private static _GetLuminanceArrayBuffer;
  134928. /**
  134929. * Uploads DDS Levels to a Babylon Texture
  134930. * @hidden
  134931. */
  134932. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134933. }
  134934. interface ThinEngine {
  134935. /**
  134936. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134937. * @param rootUrl defines the url where the file to load is located
  134938. * @param scene defines the current scene
  134939. * @param lodScale defines scale to apply to the mip map selection
  134940. * @param lodOffset defines offset to apply to the mip map selection
  134941. * @param onLoad defines an optional callback raised when the texture is loaded
  134942. * @param onError defines an optional callback raised if there is an issue to load the texture
  134943. * @param format defines the format of the data
  134944. * @param forcedExtension defines the extension to use to pick the right loader
  134945. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134946. * @returns the cube texture as an InternalTexture
  134947. */
  134948. 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;
  134949. }
  134950. }
  134951. declare module BABYLON {
  134952. /**
  134953. * Implementation of the DDS Texture Loader.
  134954. * @hidden
  134955. */
  134956. export class _DDSTextureLoader implements IInternalTextureLoader {
  134957. /**
  134958. * Defines wether the loader supports cascade loading the different faces.
  134959. */
  134960. readonly supportCascades: boolean;
  134961. /**
  134962. * This returns if the loader support the current file information.
  134963. * @param extension defines the file extension of the file being loaded
  134964. * @returns true if the loader can load the specified file
  134965. */
  134966. canLoad(extension: string): boolean;
  134967. /**
  134968. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134969. * @param data contains the texture data
  134970. * @param texture defines the BabylonJS internal texture
  134971. * @param createPolynomials will be true if polynomials have been requested
  134972. * @param onLoad defines the callback to trigger once the texture is ready
  134973. * @param onError defines the callback to trigger in case of error
  134974. */
  134975. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134976. /**
  134977. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134978. * @param data contains the texture data
  134979. * @param texture defines the BabylonJS internal texture
  134980. * @param callback defines the method to call once ready to upload
  134981. */
  134982. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134983. }
  134984. }
  134985. declare module BABYLON {
  134986. /**
  134987. * Implementation of the ENV Texture Loader.
  134988. * @hidden
  134989. */
  134990. export class _ENVTextureLoader implements IInternalTextureLoader {
  134991. /**
  134992. * Defines wether the loader supports cascade loading the different faces.
  134993. */
  134994. readonly supportCascades: boolean;
  134995. /**
  134996. * This returns if the loader support the current file information.
  134997. * @param extension defines the file extension of the file being loaded
  134998. * @returns true if the loader can load the specified file
  134999. */
  135000. canLoad(extension: string): boolean;
  135001. /**
  135002. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135003. * @param data contains the texture data
  135004. * @param texture defines the BabylonJS internal texture
  135005. * @param createPolynomials will be true if polynomials have been requested
  135006. * @param onLoad defines the callback to trigger once the texture is ready
  135007. * @param onError defines the callback to trigger in case of error
  135008. */
  135009. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135010. /**
  135011. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135012. * @param data contains the texture data
  135013. * @param texture defines the BabylonJS internal texture
  135014. * @param callback defines the method to call once ready to upload
  135015. */
  135016. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135017. }
  135018. }
  135019. declare module BABYLON {
  135020. /**
  135021. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  135022. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  135023. */
  135024. export class KhronosTextureContainer {
  135025. /** contents of the KTX container file */
  135026. data: ArrayBufferView;
  135027. private static HEADER_LEN;
  135028. private static COMPRESSED_2D;
  135029. private static COMPRESSED_3D;
  135030. private static TEX_2D;
  135031. private static TEX_3D;
  135032. /**
  135033. * Gets the openGL type
  135034. */
  135035. glType: number;
  135036. /**
  135037. * Gets the openGL type size
  135038. */
  135039. glTypeSize: number;
  135040. /**
  135041. * Gets the openGL format
  135042. */
  135043. glFormat: number;
  135044. /**
  135045. * Gets the openGL internal format
  135046. */
  135047. glInternalFormat: number;
  135048. /**
  135049. * Gets the base internal format
  135050. */
  135051. glBaseInternalFormat: number;
  135052. /**
  135053. * Gets image width in pixel
  135054. */
  135055. pixelWidth: number;
  135056. /**
  135057. * Gets image height in pixel
  135058. */
  135059. pixelHeight: number;
  135060. /**
  135061. * Gets image depth in pixels
  135062. */
  135063. pixelDepth: number;
  135064. /**
  135065. * Gets the number of array elements
  135066. */
  135067. numberOfArrayElements: number;
  135068. /**
  135069. * Gets the number of faces
  135070. */
  135071. numberOfFaces: number;
  135072. /**
  135073. * Gets the number of mipmap levels
  135074. */
  135075. numberOfMipmapLevels: number;
  135076. /**
  135077. * Gets the bytes of key value data
  135078. */
  135079. bytesOfKeyValueData: number;
  135080. /**
  135081. * Gets the load type
  135082. */
  135083. loadType: number;
  135084. /**
  135085. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  135086. */
  135087. isInvalid: boolean;
  135088. /**
  135089. * Creates a new KhronosTextureContainer
  135090. * @param data contents of the KTX container file
  135091. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  135092. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  135093. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  135094. */
  135095. constructor(
  135096. /** contents of the KTX container file */
  135097. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  135098. /**
  135099. * Uploads KTX content to a Babylon Texture.
  135100. * It is assumed that the texture has already been created & is currently bound
  135101. * @hidden
  135102. */
  135103. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  135104. private _upload2DCompressedLevels;
  135105. /**
  135106. * Checks if the given data starts with a KTX file identifier.
  135107. * @param data the data to check
  135108. * @returns true if the data is a KTX file or false otherwise
  135109. */
  135110. static IsValid(data: ArrayBufferView): boolean;
  135111. }
  135112. }
  135113. declare module BABYLON {
  135114. /**
  135115. * Class for loading KTX2 files
  135116. * !!! Experimental Extension Subject to Changes !!!
  135117. * @hidden
  135118. */
  135119. export class KhronosTextureContainer2 {
  135120. private static _ModulePromise;
  135121. private static _TranscodeFormat;
  135122. constructor(engine: ThinEngine);
  135123. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  135124. private _determineTranscodeFormat;
  135125. /**
  135126. * Checks if the given data starts with a KTX2 file identifier.
  135127. * @param data the data to check
  135128. * @returns true if the data is a KTX2 file or false otherwise
  135129. */
  135130. static IsValid(data: ArrayBufferView): boolean;
  135131. }
  135132. }
  135133. declare module BABYLON {
  135134. /**
  135135. * Implementation of the KTX Texture Loader.
  135136. * @hidden
  135137. */
  135138. export class _KTXTextureLoader implements IInternalTextureLoader {
  135139. /**
  135140. * Defines wether the loader supports cascade loading the different faces.
  135141. */
  135142. readonly supportCascades: boolean;
  135143. /**
  135144. * This returns if the loader support the current file information.
  135145. * @param extension defines the file extension of the file being loaded
  135146. * @param mimeType defines the optional mime type of the file being loaded
  135147. * @returns true if the loader can load the specified file
  135148. */
  135149. canLoad(extension: string, mimeType?: string): boolean;
  135150. /**
  135151. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135152. * @param data contains the texture data
  135153. * @param texture defines the BabylonJS internal texture
  135154. * @param createPolynomials will be true if polynomials have been requested
  135155. * @param onLoad defines the callback to trigger once the texture is ready
  135156. * @param onError defines the callback to trigger in case of error
  135157. */
  135158. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135159. /**
  135160. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135161. * @param data contains the texture data
  135162. * @param texture defines the BabylonJS internal texture
  135163. * @param callback defines the method to call once ready to upload
  135164. */
  135165. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  135166. }
  135167. }
  135168. declare module BABYLON {
  135169. /** @hidden */
  135170. export var _forceSceneHelpersToBundle: boolean;
  135171. interface Scene {
  135172. /**
  135173. * Creates a default light for the scene.
  135174. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  135175. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  135176. */
  135177. createDefaultLight(replace?: boolean): void;
  135178. /**
  135179. * Creates a default camera for the scene.
  135180. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  135181. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135182. * @param replace has default false, when true replaces the active camera in the scene
  135183. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  135184. */
  135185. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135186. /**
  135187. * Creates a default camera and a default light.
  135188. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  135189. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135190. * @param replace has the default false, when true replaces the active camera/light in the scene
  135191. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  135192. */
  135193. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135194. /**
  135195. * Creates a new sky box
  135196. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  135197. * @param environmentTexture defines the texture to use as environment texture
  135198. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  135199. * @param scale defines the overall scale of the skybox
  135200. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  135201. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  135202. * @returns a new mesh holding the sky box
  135203. */
  135204. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  135205. /**
  135206. * Creates a new environment
  135207. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  135208. * @param options defines the options you can use to configure the environment
  135209. * @returns the new EnvironmentHelper
  135210. */
  135211. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  135212. /**
  135213. * Creates a new VREXperienceHelper
  135214. * @see https://doc.babylonjs.com/how_to/webvr_helper
  135215. * @param webVROptions defines the options used to create the new VREXperienceHelper
  135216. * @returns a new VREXperienceHelper
  135217. */
  135218. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  135219. /**
  135220. * Creates a new WebXRDefaultExperience
  135221. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  135222. * @param options experience options
  135223. * @returns a promise for a new WebXRDefaultExperience
  135224. */
  135225. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135226. }
  135227. }
  135228. declare module BABYLON {
  135229. /**
  135230. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  135231. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  135232. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  135233. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135234. */
  135235. export class VideoDome extends TransformNode {
  135236. /**
  135237. * Define the video source as a Monoscopic panoramic 360 video.
  135238. */
  135239. static readonly MODE_MONOSCOPIC: number;
  135240. /**
  135241. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135242. */
  135243. static readonly MODE_TOPBOTTOM: number;
  135244. /**
  135245. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135246. */
  135247. static readonly MODE_SIDEBYSIDE: number;
  135248. private _halfDome;
  135249. private _useDirectMapping;
  135250. /**
  135251. * The video texture being displayed on the sphere
  135252. */
  135253. protected _videoTexture: VideoTexture;
  135254. /**
  135255. * Gets the video texture being displayed on the sphere
  135256. */
  135257. get videoTexture(): VideoTexture;
  135258. /**
  135259. * The skybox material
  135260. */
  135261. protected _material: BackgroundMaterial;
  135262. /**
  135263. * The surface used for the video dome
  135264. */
  135265. protected _mesh: Mesh;
  135266. /**
  135267. * Gets the mesh used for the video dome.
  135268. */
  135269. get mesh(): Mesh;
  135270. /**
  135271. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  135272. */
  135273. private _halfDomeMask;
  135274. /**
  135275. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135276. * Also see the options.resolution property.
  135277. */
  135278. get fovMultiplier(): number;
  135279. set fovMultiplier(value: number);
  135280. private _videoMode;
  135281. /**
  135282. * Gets or set the current video mode for the video. It can be:
  135283. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  135284. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135285. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135286. */
  135287. get videoMode(): number;
  135288. set videoMode(value: number);
  135289. /**
  135290. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  135291. *
  135292. */
  135293. get halfDome(): boolean;
  135294. /**
  135295. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135296. */
  135297. set halfDome(enabled: boolean);
  135298. /**
  135299. * Oberserver used in Stereoscopic VR Mode.
  135300. */
  135301. private _onBeforeCameraRenderObserver;
  135302. /**
  135303. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  135304. * @param name Element's name, child elements will append suffixes for their own names.
  135305. * @param urlsOrVideo defines the url(s) or the video element to use
  135306. * @param options An object containing optional or exposed sub element properties
  135307. */
  135308. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  135309. resolution?: number;
  135310. clickToPlay?: boolean;
  135311. autoPlay?: boolean;
  135312. loop?: boolean;
  135313. size?: number;
  135314. poster?: string;
  135315. faceForward?: boolean;
  135316. useDirectMapping?: boolean;
  135317. halfDomeMode?: boolean;
  135318. }, scene: Scene);
  135319. private _changeVideoMode;
  135320. /**
  135321. * Releases resources associated with this node.
  135322. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135323. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135324. */
  135325. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135326. }
  135327. }
  135328. declare module BABYLON {
  135329. /**
  135330. * This class can be used to get instrumentation data from a Babylon engine
  135331. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135332. */
  135333. export class EngineInstrumentation implements IDisposable {
  135334. /**
  135335. * Define the instrumented engine.
  135336. */
  135337. engine: Engine;
  135338. private _captureGPUFrameTime;
  135339. private _gpuFrameTimeToken;
  135340. private _gpuFrameTime;
  135341. private _captureShaderCompilationTime;
  135342. private _shaderCompilationTime;
  135343. private _onBeginFrameObserver;
  135344. private _onEndFrameObserver;
  135345. private _onBeforeShaderCompilationObserver;
  135346. private _onAfterShaderCompilationObserver;
  135347. /**
  135348. * Gets the perf counter used for GPU frame time
  135349. */
  135350. get gpuFrameTimeCounter(): PerfCounter;
  135351. /**
  135352. * Gets the GPU frame time capture status
  135353. */
  135354. get captureGPUFrameTime(): boolean;
  135355. /**
  135356. * Enable or disable the GPU frame time capture
  135357. */
  135358. set captureGPUFrameTime(value: boolean);
  135359. /**
  135360. * Gets the perf counter used for shader compilation time
  135361. */
  135362. get shaderCompilationTimeCounter(): PerfCounter;
  135363. /**
  135364. * Gets the shader compilation time capture status
  135365. */
  135366. get captureShaderCompilationTime(): boolean;
  135367. /**
  135368. * Enable or disable the shader compilation time capture
  135369. */
  135370. set captureShaderCompilationTime(value: boolean);
  135371. /**
  135372. * Instantiates a new engine instrumentation.
  135373. * This class can be used to get instrumentation data from a Babylon engine
  135374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135375. * @param engine Defines the engine to instrument
  135376. */
  135377. constructor(
  135378. /**
  135379. * Define the instrumented engine.
  135380. */
  135381. engine: Engine);
  135382. /**
  135383. * Dispose and release associated resources.
  135384. */
  135385. dispose(): void;
  135386. }
  135387. }
  135388. declare module BABYLON {
  135389. /**
  135390. * This class can be used to get instrumentation data from a Babylon engine
  135391. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135392. */
  135393. export class SceneInstrumentation implements IDisposable {
  135394. /**
  135395. * Defines the scene to instrument
  135396. */
  135397. scene: Scene;
  135398. private _captureActiveMeshesEvaluationTime;
  135399. private _activeMeshesEvaluationTime;
  135400. private _captureRenderTargetsRenderTime;
  135401. private _renderTargetsRenderTime;
  135402. private _captureFrameTime;
  135403. private _frameTime;
  135404. private _captureRenderTime;
  135405. private _renderTime;
  135406. private _captureInterFrameTime;
  135407. private _interFrameTime;
  135408. private _captureParticlesRenderTime;
  135409. private _particlesRenderTime;
  135410. private _captureSpritesRenderTime;
  135411. private _spritesRenderTime;
  135412. private _capturePhysicsTime;
  135413. private _physicsTime;
  135414. private _captureAnimationsTime;
  135415. private _animationsTime;
  135416. private _captureCameraRenderTime;
  135417. private _cameraRenderTime;
  135418. private _onBeforeActiveMeshesEvaluationObserver;
  135419. private _onAfterActiveMeshesEvaluationObserver;
  135420. private _onBeforeRenderTargetsRenderObserver;
  135421. private _onAfterRenderTargetsRenderObserver;
  135422. private _onAfterRenderObserver;
  135423. private _onBeforeDrawPhaseObserver;
  135424. private _onAfterDrawPhaseObserver;
  135425. private _onBeforeAnimationsObserver;
  135426. private _onBeforeParticlesRenderingObserver;
  135427. private _onAfterParticlesRenderingObserver;
  135428. private _onBeforeSpritesRenderingObserver;
  135429. private _onAfterSpritesRenderingObserver;
  135430. private _onBeforePhysicsObserver;
  135431. private _onAfterPhysicsObserver;
  135432. private _onAfterAnimationsObserver;
  135433. private _onBeforeCameraRenderObserver;
  135434. private _onAfterCameraRenderObserver;
  135435. /**
  135436. * Gets the perf counter used for active meshes evaluation time
  135437. */
  135438. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135439. /**
  135440. * Gets the active meshes evaluation time capture status
  135441. */
  135442. get captureActiveMeshesEvaluationTime(): boolean;
  135443. /**
  135444. * Enable or disable the active meshes evaluation time capture
  135445. */
  135446. set captureActiveMeshesEvaluationTime(value: boolean);
  135447. /**
  135448. * Gets the perf counter used for render targets render time
  135449. */
  135450. get renderTargetsRenderTimeCounter(): PerfCounter;
  135451. /**
  135452. * Gets the render targets render time capture status
  135453. */
  135454. get captureRenderTargetsRenderTime(): boolean;
  135455. /**
  135456. * Enable or disable the render targets render time capture
  135457. */
  135458. set captureRenderTargetsRenderTime(value: boolean);
  135459. /**
  135460. * Gets the perf counter used for particles render time
  135461. */
  135462. get particlesRenderTimeCounter(): PerfCounter;
  135463. /**
  135464. * Gets the particles render time capture status
  135465. */
  135466. get captureParticlesRenderTime(): boolean;
  135467. /**
  135468. * Enable or disable the particles render time capture
  135469. */
  135470. set captureParticlesRenderTime(value: boolean);
  135471. /**
  135472. * Gets the perf counter used for sprites render time
  135473. */
  135474. get spritesRenderTimeCounter(): PerfCounter;
  135475. /**
  135476. * Gets the sprites render time capture status
  135477. */
  135478. get captureSpritesRenderTime(): boolean;
  135479. /**
  135480. * Enable or disable the sprites render time capture
  135481. */
  135482. set captureSpritesRenderTime(value: boolean);
  135483. /**
  135484. * Gets the perf counter used for physics time
  135485. */
  135486. get physicsTimeCounter(): PerfCounter;
  135487. /**
  135488. * Gets the physics time capture status
  135489. */
  135490. get capturePhysicsTime(): boolean;
  135491. /**
  135492. * Enable or disable the physics time capture
  135493. */
  135494. set capturePhysicsTime(value: boolean);
  135495. /**
  135496. * Gets the perf counter used for animations time
  135497. */
  135498. get animationsTimeCounter(): PerfCounter;
  135499. /**
  135500. * Gets the animations time capture status
  135501. */
  135502. get captureAnimationsTime(): boolean;
  135503. /**
  135504. * Enable or disable the animations time capture
  135505. */
  135506. set captureAnimationsTime(value: boolean);
  135507. /**
  135508. * Gets the perf counter used for frame time capture
  135509. */
  135510. get frameTimeCounter(): PerfCounter;
  135511. /**
  135512. * Gets the frame time capture status
  135513. */
  135514. get captureFrameTime(): boolean;
  135515. /**
  135516. * Enable or disable the frame time capture
  135517. */
  135518. set captureFrameTime(value: boolean);
  135519. /**
  135520. * Gets the perf counter used for inter-frames time capture
  135521. */
  135522. get interFrameTimeCounter(): PerfCounter;
  135523. /**
  135524. * Gets the inter-frames time capture status
  135525. */
  135526. get captureInterFrameTime(): boolean;
  135527. /**
  135528. * Enable or disable the inter-frames time capture
  135529. */
  135530. set captureInterFrameTime(value: boolean);
  135531. /**
  135532. * Gets the perf counter used for render time capture
  135533. */
  135534. get renderTimeCounter(): PerfCounter;
  135535. /**
  135536. * Gets the render time capture status
  135537. */
  135538. get captureRenderTime(): boolean;
  135539. /**
  135540. * Enable or disable the render time capture
  135541. */
  135542. set captureRenderTime(value: boolean);
  135543. /**
  135544. * Gets the perf counter used for camera render time capture
  135545. */
  135546. get cameraRenderTimeCounter(): PerfCounter;
  135547. /**
  135548. * Gets the camera render time capture status
  135549. */
  135550. get captureCameraRenderTime(): boolean;
  135551. /**
  135552. * Enable or disable the camera render time capture
  135553. */
  135554. set captureCameraRenderTime(value: boolean);
  135555. /**
  135556. * Gets the perf counter used for draw calls
  135557. */
  135558. get drawCallsCounter(): PerfCounter;
  135559. /**
  135560. * Instantiates a new scene instrumentation.
  135561. * This class can be used to get instrumentation data from a Babylon engine
  135562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135563. * @param scene Defines the scene to instrument
  135564. */
  135565. constructor(
  135566. /**
  135567. * Defines the scene to instrument
  135568. */
  135569. scene: Scene);
  135570. /**
  135571. * Dispose and release associated resources.
  135572. */
  135573. dispose(): void;
  135574. }
  135575. }
  135576. declare module BABYLON {
  135577. /** @hidden */
  135578. export var glowMapGenerationPixelShader: {
  135579. name: string;
  135580. shader: string;
  135581. };
  135582. }
  135583. declare module BABYLON {
  135584. /** @hidden */
  135585. export var glowMapGenerationVertexShader: {
  135586. name: string;
  135587. shader: string;
  135588. };
  135589. }
  135590. declare module BABYLON {
  135591. /**
  135592. * Effect layer options. This helps customizing the behaviour
  135593. * of the effect layer.
  135594. */
  135595. export interface IEffectLayerOptions {
  135596. /**
  135597. * Multiplication factor apply to the canvas size to compute the render target size
  135598. * used to generated the objects (the smaller the faster).
  135599. */
  135600. mainTextureRatio: number;
  135601. /**
  135602. * Enforces a fixed size texture to ensure effect stability across devices.
  135603. */
  135604. mainTextureFixedSize?: number;
  135605. /**
  135606. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135607. */
  135608. alphaBlendingMode: number;
  135609. /**
  135610. * The camera attached to the layer.
  135611. */
  135612. camera: Nullable<Camera>;
  135613. /**
  135614. * The rendering group to draw the layer in.
  135615. */
  135616. renderingGroupId: number;
  135617. }
  135618. /**
  135619. * The effect layer Helps adding post process effect blended with the main pass.
  135620. *
  135621. * This can be for instance use to generate glow or higlight effects on the scene.
  135622. *
  135623. * The effect layer class can not be used directly and is intented to inherited from to be
  135624. * customized per effects.
  135625. */
  135626. export abstract class EffectLayer {
  135627. private _vertexBuffers;
  135628. private _indexBuffer;
  135629. private _cachedDefines;
  135630. private _effectLayerMapGenerationEffect;
  135631. private _effectLayerOptions;
  135632. private _mergeEffect;
  135633. protected _scene: Scene;
  135634. protected _engine: Engine;
  135635. protected _maxSize: number;
  135636. protected _mainTextureDesiredSize: ISize;
  135637. protected _mainTexture: RenderTargetTexture;
  135638. protected _shouldRender: boolean;
  135639. protected _postProcesses: PostProcess[];
  135640. protected _textures: BaseTexture[];
  135641. protected _emissiveTextureAndColor: {
  135642. texture: Nullable<BaseTexture>;
  135643. color: Color4;
  135644. };
  135645. /**
  135646. * The name of the layer
  135647. */
  135648. name: string;
  135649. /**
  135650. * The clear color of the texture used to generate the glow map.
  135651. */
  135652. neutralColor: Color4;
  135653. /**
  135654. * Specifies whether the highlight layer is enabled or not.
  135655. */
  135656. isEnabled: boolean;
  135657. /**
  135658. * Gets the camera attached to the layer.
  135659. */
  135660. get camera(): Nullable<Camera>;
  135661. /**
  135662. * Gets the rendering group id the layer should render in.
  135663. */
  135664. get renderingGroupId(): number;
  135665. set renderingGroupId(renderingGroupId: number);
  135666. /**
  135667. * An event triggered when the effect layer has been disposed.
  135668. */
  135669. onDisposeObservable: Observable<EffectLayer>;
  135670. /**
  135671. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135672. */
  135673. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135674. /**
  135675. * An event triggered when the generated texture is being merged in the scene.
  135676. */
  135677. onBeforeComposeObservable: Observable<EffectLayer>;
  135678. /**
  135679. * An event triggered when the mesh is rendered into the effect render target.
  135680. */
  135681. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135682. /**
  135683. * An event triggered after the mesh has been rendered into the effect render target.
  135684. */
  135685. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135686. /**
  135687. * An event triggered when the generated texture has been merged in the scene.
  135688. */
  135689. onAfterComposeObservable: Observable<EffectLayer>;
  135690. /**
  135691. * An event triggered when the efffect layer changes its size.
  135692. */
  135693. onSizeChangedObservable: Observable<EffectLayer>;
  135694. /** @hidden */
  135695. static _SceneComponentInitialization: (scene: Scene) => void;
  135696. /**
  135697. * Instantiates a new effect Layer and references it in the scene.
  135698. * @param name The name of the layer
  135699. * @param scene The scene to use the layer in
  135700. */
  135701. constructor(
  135702. /** The Friendly of the effect in the scene */
  135703. name: string, scene: Scene);
  135704. /**
  135705. * Get the effect name of the layer.
  135706. * @return The effect name
  135707. */
  135708. abstract getEffectName(): string;
  135709. /**
  135710. * Checks for the readiness of the element composing the layer.
  135711. * @param subMesh the mesh to check for
  135712. * @param useInstances specify whether or not to use instances to render the mesh
  135713. * @return true if ready otherwise, false
  135714. */
  135715. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135716. /**
  135717. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135718. * @returns true if the effect requires stencil during the main canvas render pass.
  135719. */
  135720. abstract needStencil(): boolean;
  135721. /**
  135722. * Create the merge effect. This is the shader use to blit the information back
  135723. * to the main canvas at the end of the scene rendering.
  135724. * @returns The effect containing the shader used to merge the effect on the main canvas
  135725. */
  135726. protected abstract _createMergeEffect(): Effect;
  135727. /**
  135728. * Creates the render target textures and post processes used in the effect layer.
  135729. */
  135730. protected abstract _createTextureAndPostProcesses(): void;
  135731. /**
  135732. * Implementation specific of rendering the generating effect on the main canvas.
  135733. * @param effect The effect used to render through
  135734. */
  135735. protected abstract _internalRender(effect: Effect): void;
  135736. /**
  135737. * Sets the required values for both the emissive texture and and the main color.
  135738. */
  135739. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135740. /**
  135741. * Free any resources and references associated to a mesh.
  135742. * Internal use
  135743. * @param mesh The mesh to free.
  135744. */
  135745. abstract _disposeMesh(mesh: Mesh): void;
  135746. /**
  135747. * Serializes this layer (Glow or Highlight for example)
  135748. * @returns a serialized layer object
  135749. */
  135750. abstract serialize?(): any;
  135751. /**
  135752. * Initializes the effect layer with the required options.
  135753. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135754. */
  135755. protected _init(options: Partial<IEffectLayerOptions>): void;
  135756. /**
  135757. * Generates the index buffer of the full screen quad blending to the main canvas.
  135758. */
  135759. private _generateIndexBuffer;
  135760. /**
  135761. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135762. */
  135763. private _generateVertexBuffer;
  135764. /**
  135765. * Sets the main texture desired size which is the closest power of two
  135766. * of the engine canvas size.
  135767. */
  135768. private _setMainTextureSize;
  135769. /**
  135770. * Creates the main texture for the effect layer.
  135771. */
  135772. protected _createMainTexture(): void;
  135773. /**
  135774. * Adds specific effects defines.
  135775. * @param defines The defines to add specifics to.
  135776. */
  135777. protected _addCustomEffectDefines(defines: string[]): void;
  135778. /**
  135779. * Checks for the readiness of the element composing the layer.
  135780. * @param subMesh the mesh to check for
  135781. * @param useInstances specify whether or not to use instances to render the mesh
  135782. * @param emissiveTexture the associated emissive texture used to generate the glow
  135783. * @return true if ready otherwise, false
  135784. */
  135785. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135786. /**
  135787. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135788. */
  135789. render(): void;
  135790. /**
  135791. * Determine if a given mesh will be used in the current effect.
  135792. * @param mesh mesh to test
  135793. * @returns true if the mesh will be used
  135794. */
  135795. hasMesh(mesh: AbstractMesh): boolean;
  135796. /**
  135797. * Returns true if the layer contains information to display, otherwise false.
  135798. * @returns true if the glow layer should be rendered
  135799. */
  135800. shouldRender(): boolean;
  135801. /**
  135802. * Returns true if the mesh should render, otherwise false.
  135803. * @param mesh The mesh to render
  135804. * @returns true if it should render otherwise false
  135805. */
  135806. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135807. /**
  135808. * Returns true if the mesh can be rendered, otherwise false.
  135809. * @param mesh The mesh to render
  135810. * @param material The material used on the mesh
  135811. * @returns true if it can be rendered otherwise false
  135812. */
  135813. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135814. /**
  135815. * Returns true if the mesh should render, otherwise false.
  135816. * @param mesh The mesh to render
  135817. * @returns true if it should render otherwise false
  135818. */
  135819. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135820. /**
  135821. * Renders the submesh passed in parameter to the generation map.
  135822. */
  135823. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135824. /**
  135825. * Defines whether the current material of the mesh should be use to render the effect.
  135826. * @param mesh defines the current mesh to render
  135827. */
  135828. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135829. /**
  135830. * Rebuild the required buffers.
  135831. * @hidden Internal use only.
  135832. */
  135833. _rebuild(): void;
  135834. /**
  135835. * Dispose only the render target textures and post process.
  135836. */
  135837. private _disposeTextureAndPostProcesses;
  135838. /**
  135839. * Dispose the highlight layer and free resources.
  135840. */
  135841. dispose(): void;
  135842. /**
  135843. * Gets the class name of the effect layer
  135844. * @returns the string with the class name of the effect layer
  135845. */
  135846. getClassName(): string;
  135847. /**
  135848. * Creates an effect layer from parsed effect layer data
  135849. * @param parsedEffectLayer defines effect layer data
  135850. * @param scene defines the current scene
  135851. * @param rootUrl defines the root URL containing the effect layer information
  135852. * @returns a parsed effect Layer
  135853. */
  135854. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135855. }
  135856. }
  135857. declare module BABYLON {
  135858. interface AbstractScene {
  135859. /**
  135860. * The list of effect layers (highlights/glow) added to the scene
  135861. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135862. * @see https://doc.babylonjs.com/how_to/glow_layer
  135863. */
  135864. effectLayers: Array<EffectLayer>;
  135865. /**
  135866. * Removes the given effect layer from this scene.
  135867. * @param toRemove defines the effect layer to remove
  135868. * @returns the index of the removed effect layer
  135869. */
  135870. removeEffectLayer(toRemove: EffectLayer): number;
  135871. /**
  135872. * Adds the given effect layer to this scene
  135873. * @param newEffectLayer defines the effect layer to add
  135874. */
  135875. addEffectLayer(newEffectLayer: EffectLayer): void;
  135876. }
  135877. /**
  135878. * Defines the layer scene component responsible to manage any effect layers
  135879. * in a given scene.
  135880. */
  135881. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135882. /**
  135883. * The component name helpfull to identify the component in the list of scene components.
  135884. */
  135885. readonly name: string;
  135886. /**
  135887. * The scene the component belongs to.
  135888. */
  135889. scene: Scene;
  135890. private _engine;
  135891. private _renderEffects;
  135892. private _needStencil;
  135893. private _previousStencilState;
  135894. /**
  135895. * Creates a new instance of the component for the given scene
  135896. * @param scene Defines the scene to register the component in
  135897. */
  135898. constructor(scene: Scene);
  135899. /**
  135900. * Registers the component in a given scene
  135901. */
  135902. register(): void;
  135903. /**
  135904. * Rebuilds the elements related to this component in case of
  135905. * context lost for instance.
  135906. */
  135907. rebuild(): void;
  135908. /**
  135909. * Serializes the component data to the specified json object
  135910. * @param serializationObject The object to serialize to
  135911. */
  135912. serialize(serializationObject: any): void;
  135913. /**
  135914. * Adds all the elements from the container to the scene
  135915. * @param container the container holding the elements
  135916. */
  135917. addFromContainer(container: AbstractScene): void;
  135918. /**
  135919. * Removes all the elements in the container from the scene
  135920. * @param container contains the elements to remove
  135921. * @param dispose if the removed element should be disposed (default: false)
  135922. */
  135923. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135924. /**
  135925. * Disposes the component and the associated ressources.
  135926. */
  135927. dispose(): void;
  135928. private _isReadyForMesh;
  135929. private _renderMainTexture;
  135930. private _setStencil;
  135931. private _setStencilBack;
  135932. private _draw;
  135933. private _drawCamera;
  135934. private _drawRenderingGroup;
  135935. }
  135936. }
  135937. declare module BABYLON {
  135938. /** @hidden */
  135939. export var glowMapMergePixelShader: {
  135940. name: string;
  135941. shader: string;
  135942. };
  135943. }
  135944. declare module BABYLON {
  135945. /** @hidden */
  135946. export var glowMapMergeVertexShader: {
  135947. name: string;
  135948. shader: string;
  135949. };
  135950. }
  135951. declare module BABYLON {
  135952. interface AbstractScene {
  135953. /**
  135954. * Return a the first highlight layer of the scene with a given name.
  135955. * @param name The name of the highlight layer to look for.
  135956. * @return The highlight layer if found otherwise null.
  135957. */
  135958. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135959. }
  135960. /**
  135961. * Glow layer options. This helps customizing the behaviour
  135962. * of the glow layer.
  135963. */
  135964. export interface IGlowLayerOptions {
  135965. /**
  135966. * Multiplication factor apply to the canvas size to compute the render target size
  135967. * used to generated the glowing objects (the smaller the faster).
  135968. */
  135969. mainTextureRatio: number;
  135970. /**
  135971. * Enforces a fixed size texture to ensure resize independant blur.
  135972. */
  135973. mainTextureFixedSize?: number;
  135974. /**
  135975. * How big is the kernel of the blur texture.
  135976. */
  135977. blurKernelSize: number;
  135978. /**
  135979. * The camera attached to the layer.
  135980. */
  135981. camera: Nullable<Camera>;
  135982. /**
  135983. * Enable MSAA by chosing the number of samples.
  135984. */
  135985. mainTextureSamples?: number;
  135986. /**
  135987. * The rendering group to draw the layer in.
  135988. */
  135989. renderingGroupId: number;
  135990. }
  135991. /**
  135992. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135993. *
  135994. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135995. *
  135996. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135997. */
  135998. export class GlowLayer extends EffectLayer {
  135999. /**
  136000. * Effect Name of the layer.
  136001. */
  136002. static readonly EffectName: string;
  136003. /**
  136004. * The default blur kernel size used for the glow.
  136005. */
  136006. static DefaultBlurKernelSize: number;
  136007. /**
  136008. * The default texture size ratio used for the glow.
  136009. */
  136010. static DefaultTextureRatio: number;
  136011. /**
  136012. * Sets the kernel size of the blur.
  136013. */
  136014. set blurKernelSize(value: number);
  136015. /**
  136016. * Gets the kernel size of the blur.
  136017. */
  136018. get blurKernelSize(): number;
  136019. /**
  136020. * Sets the glow intensity.
  136021. */
  136022. set intensity(value: number);
  136023. /**
  136024. * Gets the glow intensity.
  136025. */
  136026. get intensity(): number;
  136027. private _options;
  136028. private _intensity;
  136029. private _horizontalBlurPostprocess1;
  136030. private _verticalBlurPostprocess1;
  136031. private _horizontalBlurPostprocess2;
  136032. private _verticalBlurPostprocess2;
  136033. private _blurTexture1;
  136034. private _blurTexture2;
  136035. private _postProcesses1;
  136036. private _postProcesses2;
  136037. private _includedOnlyMeshes;
  136038. private _excludedMeshes;
  136039. private _meshesUsingTheirOwnMaterials;
  136040. /**
  136041. * Callback used to let the user override the color selection on a per mesh basis
  136042. */
  136043. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  136044. /**
  136045. * Callback used to let the user override the texture selection on a per mesh basis
  136046. */
  136047. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  136048. /**
  136049. * Instantiates a new glow Layer and references it to the scene.
  136050. * @param name The name of the layer
  136051. * @param scene The scene to use the layer in
  136052. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  136053. */
  136054. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  136055. /**
  136056. * Get the effect name of the layer.
  136057. * @return The effect name
  136058. */
  136059. getEffectName(): string;
  136060. /**
  136061. * Create the merge effect. This is the shader use to blit the information back
  136062. * to the main canvas at the end of the scene rendering.
  136063. */
  136064. protected _createMergeEffect(): Effect;
  136065. /**
  136066. * Creates the render target textures and post processes used in the glow layer.
  136067. */
  136068. protected _createTextureAndPostProcesses(): void;
  136069. /**
  136070. * Checks for the readiness of the element composing the layer.
  136071. * @param subMesh the mesh to check for
  136072. * @param useInstances specify wether or not to use instances to render the mesh
  136073. * @param emissiveTexture the associated emissive texture used to generate the glow
  136074. * @return true if ready otherwise, false
  136075. */
  136076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136077. /**
  136078. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136079. */
  136080. needStencil(): boolean;
  136081. /**
  136082. * Returns true if the mesh can be rendered, otherwise false.
  136083. * @param mesh The mesh to render
  136084. * @param material The material used on the mesh
  136085. * @returns true if it can be rendered otherwise false
  136086. */
  136087. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136088. /**
  136089. * Implementation specific of rendering the generating effect on the main canvas.
  136090. * @param effect The effect used to render through
  136091. */
  136092. protected _internalRender(effect: Effect): void;
  136093. /**
  136094. * Sets the required values for both the emissive texture and and the main color.
  136095. */
  136096. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136097. /**
  136098. * Returns true if the mesh should render, otherwise false.
  136099. * @param mesh The mesh to render
  136100. * @returns true if it should render otherwise false
  136101. */
  136102. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136103. /**
  136104. * Adds specific effects defines.
  136105. * @param defines The defines to add specifics to.
  136106. */
  136107. protected _addCustomEffectDefines(defines: string[]): void;
  136108. /**
  136109. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  136110. * @param mesh The mesh to exclude from the glow layer
  136111. */
  136112. addExcludedMesh(mesh: Mesh): void;
  136113. /**
  136114. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  136115. * @param mesh The mesh to remove
  136116. */
  136117. removeExcludedMesh(mesh: Mesh): void;
  136118. /**
  136119. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  136120. * @param mesh The mesh to include in the glow layer
  136121. */
  136122. addIncludedOnlyMesh(mesh: Mesh): void;
  136123. /**
  136124. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  136125. * @param mesh The mesh to remove
  136126. */
  136127. removeIncludedOnlyMesh(mesh: Mesh): void;
  136128. /**
  136129. * Determine if a given mesh will be used in the glow layer
  136130. * @param mesh The mesh to test
  136131. * @returns true if the mesh will be highlighted by the current glow layer
  136132. */
  136133. hasMesh(mesh: AbstractMesh): boolean;
  136134. /**
  136135. * Defines whether the current material of the mesh should be use to render the effect.
  136136. * @param mesh defines the current mesh to render
  136137. */
  136138. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136139. /**
  136140. * Add a mesh to be rendered through its own material and not with emissive only.
  136141. * @param mesh The mesh for which we need to use its material
  136142. */
  136143. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  136144. /**
  136145. * Remove a mesh from being rendered through its own material and not with emissive only.
  136146. * @param mesh The mesh for which we need to not use its material
  136147. */
  136148. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  136149. /**
  136150. * Free any resources and references associated to a mesh.
  136151. * Internal use
  136152. * @param mesh The mesh to free.
  136153. * @hidden
  136154. */
  136155. _disposeMesh(mesh: Mesh): void;
  136156. /**
  136157. * Gets the class name of the effect layer
  136158. * @returns the string with the class name of the effect layer
  136159. */
  136160. getClassName(): string;
  136161. /**
  136162. * Serializes this glow layer
  136163. * @returns a serialized glow layer object
  136164. */
  136165. serialize(): any;
  136166. /**
  136167. * Creates a Glow Layer from parsed glow layer data
  136168. * @param parsedGlowLayer defines glow layer data
  136169. * @param scene defines the current scene
  136170. * @param rootUrl defines the root URL containing the glow layer information
  136171. * @returns a parsed Glow Layer
  136172. */
  136173. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  136174. }
  136175. }
  136176. declare module BABYLON {
  136177. /** @hidden */
  136178. export var glowBlurPostProcessPixelShader: {
  136179. name: string;
  136180. shader: string;
  136181. };
  136182. }
  136183. declare module BABYLON {
  136184. interface AbstractScene {
  136185. /**
  136186. * Return a the first highlight layer of the scene with a given name.
  136187. * @param name The name of the highlight layer to look for.
  136188. * @return The highlight layer if found otherwise null.
  136189. */
  136190. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  136191. }
  136192. /**
  136193. * Highlight layer options. This helps customizing the behaviour
  136194. * of the highlight layer.
  136195. */
  136196. export interface IHighlightLayerOptions {
  136197. /**
  136198. * Multiplication factor apply to the canvas size to compute the render target size
  136199. * used to generated the glowing objects (the smaller the faster).
  136200. */
  136201. mainTextureRatio: number;
  136202. /**
  136203. * Enforces a fixed size texture to ensure resize independant blur.
  136204. */
  136205. mainTextureFixedSize?: number;
  136206. /**
  136207. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  136208. * of the picture to blur (the smaller the faster).
  136209. */
  136210. blurTextureSizeRatio: number;
  136211. /**
  136212. * How big in texel of the blur texture is the vertical blur.
  136213. */
  136214. blurVerticalSize: number;
  136215. /**
  136216. * How big in texel of the blur texture is the horizontal blur.
  136217. */
  136218. blurHorizontalSize: number;
  136219. /**
  136220. * Alpha blending mode used to apply the blur. Default is combine.
  136221. */
  136222. alphaBlendingMode: number;
  136223. /**
  136224. * The camera attached to the layer.
  136225. */
  136226. camera: Nullable<Camera>;
  136227. /**
  136228. * Should we display highlight as a solid stroke?
  136229. */
  136230. isStroke?: boolean;
  136231. /**
  136232. * The rendering group to draw the layer in.
  136233. */
  136234. renderingGroupId: number;
  136235. }
  136236. /**
  136237. * The highlight layer Helps adding a glow effect around a mesh.
  136238. *
  136239. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  136240. * glowy meshes to your scene.
  136241. *
  136242. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  136243. */
  136244. export class HighlightLayer extends EffectLayer {
  136245. name: string;
  136246. /**
  136247. * Effect Name of the highlight layer.
  136248. */
  136249. static readonly EffectName: string;
  136250. /**
  136251. * The neutral color used during the preparation of the glow effect.
  136252. * This is black by default as the blend operation is a blend operation.
  136253. */
  136254. static NeutralColor: Color4;
  136255. /**
  136256. * Stencil value used for glowing meshes.
  136257. */
  136258. static GlowingMeshStencilReference: number;
  136259. /**
  136260. * Stencil value used for the other meshes in the scene.
  136261. */
  136262. static NormalMeshStencilReference: number;
  136263. /**
  136264. * Specifies whether or not the inner glow is ACTIVE in the layer.
  136265. */
  136266. innerGlow: boolean;
  136267. /**
  136268. * Specifies whether or not the outer glow is ACTIVE in the layer.
  136269. */
  136270. outerGlow: boolean;
  136271. /**
  136272. * Specifies the horizontal size of the blur.
  136273. */
  136274. set blurHorizontalSize(value: number);
  136275. /**
  136276. * Specifies the vertical size of the blur.
  136277. */
  136278. set blurVerticalSize(value: number);
  136279. /**
  136280. * Gets the horizontal size of the blur.
  136281. */
  136282. get blurHorizontalSize(): number;
  136283. /**
  136284. * Gets the vertical size of the blur.
  136285. */
  136286. get blurVerticalSize(): number;
  136287. /**
  136288. * An event triggered when the highlight layer is being blurred.
  136289. */
  136290. onBeforeBlurObservable: Observable<HighlightLayer>;
  136291. /**
  136292. * An event triggered when the highlight layer has been blurred.
  136293. */
  136294. onAfterBlurObservable: Observable<HighlightLayer>;
  136295. private _instanceGlowingMeshStencilReference;
  136296. private _options;
  136297. private _downSamplePostprocess;
  136298. private _horizontalBlurPostprocess;
  136299. private _verticalBlurPostprocess;
  136300. private _blurTexture;
  136301. private _meshes;
  136302. private _excludedMeshes;
  136303. /**
  136304. * Instantiates a new highlight Layer and references it to the scene..
  136305. * @param name The name of the layer
  136306. * @param scene The scene to use the layer in
  136307. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  136308. */
  136309. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  136310. /**
  136311. * Get the effect name of the layer.
  136312. * @return The effect name
  136313. */
  136314. getEffectName(): string;
  136315. /**
  136316. * Create the merge effect. This is the shader use to blit the information back
  136317. * to the main canvas at the end of the scene rendering.
  136318. */
  136319. protected _createMergeEffect(): Effect;
  136320. /**
  136321. * Creates the render target textures and post processes used in the highlight layer.
  136322. */
  136323. protected _createTextureAndPostProcesses(): void;
  136324. /**
  136325. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  136326. */
  136327. needStencil(): boolean;
  136328. /**
  136329. * Checks for the readiness of the element composing the layer.
  136330. * @param subMesh the mesh to check for
  136331. * @param useInstances specify wether or not to use instances to render the mesh
  136332. * @param emissiveTexture the associated emissive texture used to generate the glow
  136333. * @return true if ready otherwise, false
  136334. */
  136335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136336. /**
  136337. * Implementation specific of rendering the generating effect on the main canvas.
  136338. * @param effect The effect used to render through
  136339. */
  136340. protected _internalRender(effect: Effect): void;
  136341. /**
  136342. * Returns true if the layer contains information to display, otherwise false.
  136343. */
  136344. shouldRender(): boolean;
  136345. /**
  136346. * Returns true if the mesh should render, otherwise false.
  136347. * @param mesh The mesh to render
  136348. * @returns true if it should render otherwise false
  136349. */
  136350. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136351. /**
  136352. * Returns true if the mesh can be rendered, otherwise false.
  136353. * @param mesh The mesh to render
  136354. * @param material The material used on the mesh
  136355. * @returns true if it can be rendered otherwise false
  136356. */
  136357. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136358. /**
  136359. * Adds specific effects defines.
  136360. * @param defines The defines to add specifics to.
  136361. */
  136362. protected _addCustomEffectDefines(defines: string[]): void;
  136363. /**
  136364. * Sets the required values for both the emissive texture and and the main color.
  136365. */
  136366. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136367. /**
  136368. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136369. * @param mesh The mesh to exclude from the highlight layer
  136370. */
  136371. addExcludedMesh(mesh: Mesh): void;
  136372. /**
  136373. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136374. * @param mesh The mesh to highlight
  136375. */
  136376. removeExcludedMesh(mesh: Mesh): void;
  136377. /**
  136378. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136379. * @param mesh mesh to test
  136380. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136381. */
  136382. hasMesh(mesh: AbstractMesh): boolean;
  136383. /**
  136384. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136385. * @param mesh The mesh to highlight
  136386. * @param color The color of the highlight
  136387. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136388. */
  136389. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136390. /**
  136391. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136392. * @param mesh The mesh to highlight
  136393. */
  136394. removeMesh(mesh: Mesh): void;
  136395. /**
  136396. * Remove all the meshes currently referenced in the highlight layer
  136397. */
  136398. removeAllMeshes(): void;
  136399. /**
  136400. * Force the stencil to the normal expected value for none glowing parts
  136401. */
  136402. private _defaultStencilReference;
  136403. /**
  136404. * Free any resources and references associated to a mesh.
  136405. * Internal use
  136406. * @param mesh The mesh to free.
  136407. * @hidden
  136408. */
  136409. _disposeMesh(mesh: Mesh): void;
  136410. /**
  136411. * Dispose the highlight layer and free resources.
  136412. */
  136413. dispose(): void;
  136414. /**
  136415. * Gets the class name of the effect layer
  136416. * @returns the string with the class name of the effect layer
  136417. */
  136418. getClassName(): string;
  136419. /**
  136420. * Serializes this Highlight layer
  136421. * @returns a serialized Highlight layer object
  136422. */
  136423. serialize(): any;
  136424. /**
  136425. * Creates a Highlight layer from parsed Highlight layer data
  136426. * @param parsedHightlightLayer defines the Highlight layer data
  136427. * @param scene defines the current scene
  136428. * @param rootUrl defines the root URL containing the Highlight layer information
  136429. * @returns a parsed Highlight layer
  136430. */
  136431. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136432. }
  136433. }
  136434. declare module BABYLON {
  136435. interface AbstractScene {
  136436. /**
  136437. * The list of layers (background and foreground) of the scene
  136438. */
  136439. layers: Array<Layer>;
  136440. }
  136441. /**
  136442. * Defines the layer scene component responsible to manage any layers
  136443. * in a given scene.
  136444. */
  136445. export class LayerSceneComponent implements ISceneComponent {
  136446. /**
  136447. * The component name helpfull to identify the component in the list of scene components.
  136448. */
  136449. readonly name: string;
  136450. /**
  136451. * The scene the component belongs to.
  136452. */
  136453. scene: Scene;
  136454. private _engine;
  136455. /**
  136456. * Creates a new instance of the component for the given scene
  136457. * @param scene Defines the scene to register the component in
  136458. */
  136459. constructor(scene: Scene);
  136460. /**
  136461. * Registers the component in a given scene
  136462. */
  136463. register(): void;
  136464. /**
  136465. * Rebuilds the elements related to this component in case of
  136466. * context lost for instance.
  136467. */
  136468. rebuild(): void;
  136469. /**
  136470. * Disposes the component and the associated ressources.
  136471. */
  136472. dispose(): void;
  136473. private _draw;
  136474. private _drawCameraPredicate;
  136475. private _drawCameraBackground;
  136476. private _drawCameraForeground;
  136477. private _drawRenderTargetPredicate;
  136478. private _drawRenderTargetBackground;
  136479. private _drawRenderTargetForeground;
  136480. /**
  136481. * Adds all the elements from the container to the scene
  136482. * @param container the container holding the elements
  136483. */
  136484. addFromContainer(container: AbstractScene): void;
  136485. /**
  136486. * Removes all the elements in the container from the scene
  136487. * @param container contains the elements to remove
  136488. * @param dispose if the removed element should be disposed (default: false)
  136489. */
  136490. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136491. }
  136492. }
  136493. declare module BABYLON {
  136494. /** @hidden */
  136495. export var layerPixelShader: {
  136496. name: string;
  136497. shader: string;
  136498. };
  136499. }
  136500. declare module BABYLON {
  136501. /** @hidden */
  136502. export var layerVertexShader: {
  136503. name: string;
  136504. shader: string;
  136505. };
  136506. }
  136507. declare module BABYLON {
  136508. /**
  136509. * This represents a full screen 2d layer.
  136510. * This can be useful to display a picture in the background of your scene for instance.
  136511. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136512. */
  136513. export class Layer {
  136514. /**
  136515. * Define the name of the layer.
  136516. */
  136517. name: string;
  136518. /**
  136519. * Define the texture the layer should display.
  136520. */
  136521. texture: Nullable<Texture>;
  136522. /**
  136523. * Is the layer in background or foreground.
  136524. */
  136525. isBackground: boolean;
  136526. /**
  136527. * Define the color of the layer (instead of texture).
  136528. */
  136529. color: Color4;
  136530. /**
  136531. * Define the scale of the layer in order to zoom in out of the texture.
  136532. */
  136533. scale: Vector2;
  136534. /**
  136535. * Define an offset for the layer in order to shift the texture.
  136536. */
  136537. offset: Vector2;
  136538. /**
  136539. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136540. */
  136541. alphaBlendingMode: number;
  136542. /**
  136543. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136544. * Alpha test will not mix with the background color in case of transparency.
  136545. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136546. */
  136547. alphaTest: boolean;
  136548. /**
  136549. * Define a mask to restrict the layer to only some of the scene cameras.
  136550. */
  136551. layerMask: number;
  136552. /**
  136553. * Define the list of render target the layer is visible into.
  136554. */
  136555. renderTargetTextures: RenderTargetTexture[];
  136556. /**
  136557. * Define if the layer is only used in renderTarget or if it also
  136558. * renders in the main frame buffer of the canvas.
  136559. */
  136560. renderOnlyInRenderTargetTextures: boolean;
  136561. private _scene;
  136562. private _vertexBuffers;
  136563. private _indexBuffer;
  136564. private _effect;
  136565. private _previousDefines;
  136566. /**
  136567. * An event triggered when the layer is disposed.
  136568. */
  136569. onDisposeObservable: Observable<Layer>;
  136570. private _onDisposeObserver;
  136571. /**
  136572. * Back compatibility with callback before the onDisposeObservable existed.
  136573. * The set callback will be triggered when the layer has been disposed.
  136574. */
  136575. set onDispose(callback: () => void);
  136576. /**
  136577. * An event triggered before rendering the scene
  136578. */
  136579. onBeforeRenderObservable: Observable<Layer>;
  136580. private _onBeforeRenderObserver;
  136581. /**
  136582. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136583. * The set callback will be triggered just before rendering the layer.
  136584. */
  136585. set onBeforeRender(callback: () => void);
  136586. /**
  136587. * An event triggered after rendering the scene
  136588. */
  136589. onAfterRenderObservable: Observable<Layer>;
  136590. private _onAfterRenderObserver;
  136591. /**
  136592. * Back compatibility with callback before the onAfterRenderObservable existed.
  136593. * The set callback will be triggered just after rendering the layer.
  136594. */
  136595. set onAfterRender(callback: () => void);
  136596. /**
  136597. * Instantiates a new layer.
  136598. * This represents a full screen 2d layer.
  136599. * This can be useful to display a picture in the background of your scene for instance.
  136600. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136601. * @param name Define the name of the layer in the scene
  136602. * @param imgUrl Define the url of the texture to display in the layer
  136603. * @param scene Define the scene the layer belongs to
  136604. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136605. * @param color Defines a color for the layer
  136606. */
  136607. constructor(
  136608. /**
  136609. * Define the name of the layer.
  136610. */
  136611. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136612. private _createIndexBuffer;
  136613. /** @hidden */
  136614. _rebuild(): void;
  136615. /**
  136616. * Renders the layer in the scene.
  136617. */
  136618. render(): void;
  136619. /**
  136620. * Disposes and releases the associated ressources.
  136621. */
  136622. dispose(): void;
  136623. }
  136624. }
  136625. declare module BABYLON {
  136626. /** @hidden */
  136627. export var lensFlarePixelShader: {
  136628. name: string;
  136629. shader: string;
  136630. };
  136631. }
  136632. declare module BABYLON {
  136633. /** @hidden */
  136634. export var lensFlareVertexShader: {
  136635. name: string;
  136636. shader: string;
  136637. };
  136638. }
  136639. declare module BABYLON {
  136640. /**
  136641. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136642. * It is usually composed of several `lensFlare`.
  136643. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136644. */
  136645. export class LensFlareSystem {
  136646. /**
  136647. * Define the name of the lens flare system
  136648. */
  136649. name: string;
  136650. /**
  136651. * List of lens flares used in this system.
  136652. */
  136653. lensFlares: LensFlare[];
  136654. /**
  136655. * Define a limit from the border the lens flare can be visible.
  136656. */
  136657. borderLimit: number;
  136658. /**
  136659. * Define a viewport border we do not want to see the lens flare in.
  136660. */
  136661. viewportBorder: number;
  136662. /**
  136663. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136664. */
  136665. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136666. /**
  136667. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136668. */
  136669. layerMask: number;
  136670. /**
  136671. * Define the id of the lens flare system in the scene.
  136672. * (equal to name by default)
  136673. */
  136674. id: string;
  136675. private _scene;
  136676. private _emitter;
  136677. private _vertexBuffers;
  136678. private _indexBuffer;
  136679. private _effect;
  136680. private _positionX;
  136681. private _positionY;
  136682. private _isEnabled;
  136683. /** @hidden */
  136684. static _SceneComponentInitialization: (scene: Scene) => void;
  136685. /**
  136686. * Instantiates a lens flare system.
  136687. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136688. * It is usually composed of several `lensFlare`.
  136689. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136690. * @param name Define the name of the lens flare system in the scene
  136691. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136692. * @param scene Define the scene the lens flare system belongs to
  136693. */
  136694. constructor(
  136695. /**
  136696. * Define the name of the lens flare system
  136697. */
  136698. name: string, emitter: any, scene: Scene);
  136699. /**
  136700. * Define if the lens flare system is enabled.
  136701. */
  136702. get isEnabled(): boolean;
  136703. set isEnabled(value: boolean);
  136704. /**
  136705. * Get the scene the effects belongs to.
  136706. * @returns the scene holding the lens flare system
  136707. */
  136708. getScene(): Scene;
  136709. /**
  136710. * Get the emitter of the lens flare system.
  136711. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136712. * @returns the emitter of the lens flare system
  136713. */
  136714. getEmitter(): any;
  136715. /**
  136716. * Set the emitter of the lens flare system.
  136717. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136718. * @param newEmitter Define the new emitter of the system
  136719. */
  136720. setEmitter(newEmitter: any): void;
  136721. /**
  136722. * Get the lens flare system emitter position.
  136723. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136724. * @returns the position
  136725. */
  136726. getEmitterPosition(): Vector3;
  136727. /**
  136728. * @hidden
  136729. */
  136730. computeEffectivePosition(globalViewport: Viewport): boolean;
  136731. /** @hidden */
  136732. _isVisible(): boolean;
  136733. /**
  136734. * @hidden
  136735. */
  136736. render(): boolean;
  136737. /**
  136738. * Dispose and release the lens flare with its associated resources.
  136739. */
  136740. dispose(): void;
  136741. /**
  136742. * Parse a lens flare system from a JSON repressentation
  136743. * @param parsedLensFlareSystem Define the JSON to parse
  136744. * @param scene Define the scene the parsed system should be instantiated in
  136745. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136746. * @returns the parsed system
  136747. */
  136748. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136749. /**
  136750. * Serialize the current Lens Flare System into a JSON representation.
  136751. * @returns the serialized JSON
  136752. */
  136753. serialize(): any;
  136754. }
  136755. }
  136756. declare module BABYLON {
  136757. /**
  136758. * This represents one of the lens effect in a `lensFlareSystem`.
  136759. * It controls one of the indiviual texture used in the effect.
  136760. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136761. */
  136762. export class LensFlare {
  136763. /**
  136764. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136765. */
  136766. size: number;
  136767. /**
  136768. * 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.
  136769. */
  136770. position: number;
  136771. /**
  136772. * Define the lens color.
  136773. */
  136774. color: Color3;
  136775. /**
  136776. * Define the lens texture.
  136777. */
  136778. texture: Nullable<Texture>;
  136779. /**
  136780. * Define the alpha mode to render this particular lens.
  136781. */
  136782. alphaMode: number;
  136783. private _system;
  136784. /**
  136785. * Creates a new Lens Flare.
  136786. * This represents one of the lens effect in a `lensFlareSystem`.
  136787. * It controls one of the indiviual texture used in the effect.
  136788. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136789. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136790. * @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.
  136791. * @param color Define the lens color
  136792. * @param imgUrl Define the lens texture url
  136793. * @param system Define the `lensFlareSystem` this flare is part of
  136794. * @returns The newly created Lens Flare
  136795. */
  136796. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136797. /**
  136798. * Instantiates a new Lens Flare.
  136799. * This represents one of the lens effect in a `lensFlareSystem`.
  136800. * It controls one of the indiviual texture used in the effect.
  136801. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136802. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136803. * @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.
  136804. * @param color Define the lens color
  136805. * @param imgUrl Define the lens texture url
  136806. * @param system Define the `lensFlareSystem` this flare is part of
  136807. */
  136808. constructor(
  136809. /**
  136810. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136811. */
  136812. size: number,
  136813. /**
  136814. * 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.
  136815. */
  136816. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136817. /**
  136818. * Dispose and release the lens flare with its associated resources.
  136819. */
  136820. dispose(): void;
  136821. }
  136822. }
  136823. declare module BABYLON {
  136824. interface AbstractScene {
  136825. /**
  136826. * The list of lens flare system added to the scene
  136827. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136828. */
  136829. lensFlareSystems: Array<LensFlareSystem>;
  136830. /**
  136831. * Removes the given lens flare system from this scene.
  136832. * @param toRemove The lens flare system to remove
  136833. * @returns The index of the removed lens flare system
  136834. */
  136835. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136836. /**
  136837. * Adds the given lens flare system to this scene
  136838. * @param newLensFlareSystem The lens flare system to add
  136839. */
  136840. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136841. /**
  136842. * Gets a lens flare system using its name
  136843. * @param name defines the name to look for
  136844. * @returns the lens flare system or null if not found
  136845. */
  136846. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136847. /**
  136848. * Gets a lens flare system using its id
  136849. * @param id defines the id to look for
  136850. * @returns the lens flare system or null if not found
  136851. */
  136852. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136853. }
  136854. /**
  136855. * Defines the lens flare scene component responsible to manage any lens flares
  136856. * in a given scene.
  136857. */
  136858. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136859. /**
  136860. * The component name helpfull to identify the component in the list of scene components.
  136861. */
  136862. readonly name: string;
  136863. /**
  136864. * The scene the component belongs to.
  136865. */
  136866. scene: Scene;
  136867. /**
  136868. * Creates a new instance of the component for the given scene
  136869. * @param scene Defines the scene to register the component in
  136870. */
  136871. constructor(scene: Scene);
  136872. /**
  136873. * Registers the component in a given scene
  136874. */
  136875. register(): void;
  136876. /**
  136877. * Rebuilds the elements related to this component in case of
  136878. * context lost for instance.
  136879. */
  136880. rebuild(): void;
  136881. /**
  136882. * Adds all the elements from the container to the scene
  136883. * @param container the container holding the elements
  136884. */
  136885. addFromContainer(container: AbstractScene): void;
  136886. /**
  136887. * Removes all the elements in the container from the scene
  136888. * @param container contains the elements to remove
  136889. * @param dispose if the removed element should be disposed (default: false)
  136890. */
  136891. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136892. /**
  136893. * Serializes the component data to the specified json object
  136894. * @param serializationObject The object to serialize to
  136895. */
  136896. serialize(serializationObject: any): void;
  136897. /**
  136898. * Disposes the component and the associated ressources.
  136899. */
  136900. dispose(): void;
  136901. private _draw;
  136902. }
  136903. }
  136904. declare module BABYLON {
  136905. /** @hidden */
  136906. export var depthPixelShader: {
  136907. name: string;
  136908. shader: string;
  136909. };
  136910. }
  136911. declare module BABYLON {
  136912. /** @hidden */
  136913. export var depthVertexShader: {
  136914. name: string;
  136915. shader: string;
  136916. };
  136917. }
  136918. declare module BABYLON {
  136919. /**
  136920. * This represents a depth renderer in Babylon.
  136921. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136922. */
  136923. export class DepthRenderer {
  136924. private _scene;
  136925. private _depthMap;
  136926. private _effect;
  136927. private readonly _storeNonLinearDepth;
  136928. private readonly _clearColor;
  136929. /** Get if the depth renderer is using packed depth or not */
  136930. readonly isPacked: boolean;
  136931. private _cachedDefines;
  136932. private _camera;
  136933. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136934. enabled: boolean;
  136935. /**
  136936. * Specifiess that the depth renderer will only be used within
  136937. * the camera it is created for.
  136938. * This can help forcing its rendering during the camera processing.
  136939. */
  136940. useOnlyInActiveCamera: boolean;
  136941. /** @hidden */
  136942. static _SceneComponentInitialization: (scene: Scene) => void;
  136943. /**
  136944. * Instantiates a depth renderer
  136945. * @param scene The scene the renderer belongs to
  136946. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136947. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136948. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136949. */
  136950. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136951. /**
  136952. * Creates the depth rendering effect and checks if the effect is ready.
  136953. * @param subMesh The submesh to be used to render the depth map of
  136954. * @param useInstances If multiple world instances should be used
  136955. * @returns if the depth renderer is ready to render the depth map
  136956. */
  136957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136958. /**
  136959. * Gets the texture which the depth map will be written to.
  136960. * @returns The depth map texture
  136961. */
  136962. getDepthMap(): RenderTargetTexture;
  136963. /**
  136964. * Disposes of the depth renderer.
  136965. */
  136966. dispose(): void;
  136967. }
  136968. }
  136969. declare module BABYLON {
  136970. /** @hidden */
  136971. export var minmaxReduxPixelShader: {
  136972. name: string;
  136973. shader: string;
  136974. };
  136975. }
  136976. declare module BABYLON {
  136977. /**
  136978. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136979. * and maximum values from all values of the texture.
  136980. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136981. * The source values are read from the red channel of the texture.
  136982. */
  136983. export class MinMaxReducer {
  136984. /**
  136985. * Observable triggered when the computation has been performed
  136986. */
  136987. onAfterReductionPerformed: Observable<{
  136988. min: number;
  136989. max: number;
  136990. }>;
  136991. protected _camera: Camera;
  136992. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136993. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136994. protected _postProcessManager: PostProcessManager;
  136995. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136996. protected _forceFullscreenViewport: boolean;
  136997. /**
  136998. * Creates a min/max reducer
  136999. * @param camera The camera to use for the post processes
  137000. */
  137001. constructor(camera: Camera);
  137002. /**
  137003. * Gets the texture used to read the values from.
  137004. */
  137005. get sourceTexture(): Nullable<RenderTargetTexture>;
  137006. /**
  137007. * Sets the source texture to read the values from.
  137008. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  137009. * because in such textures '1' value must not be taken into account to compute the maximum
  137010. * as this value is used to clear the texture.
  137011. * Note that the computation is not activated by calling this function, you must call activate() for that!
  137012. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  137013. * @param depthRedux Indicates if the texture is a depth texture or not
  137014. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  137015. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137016. */
  137017. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137018. /**
  137019. * Defines the refresh rate of the computation.
  137020. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137021. */
  137022. get refreshRate(): number;
  137023. set refreshRate(value: number);
  137024. protected _activated: boolean;
  137025. /**
  137026. * Gets the activation status of the reducer
  137027. */
  137028. get activated(): boolean;
  137029. /**
  137030. * Activates the reduction computation.
  137031. * When activated, the observers registered in onAfterReductionPerformed are
  137032. * called after the compuation is performed
  137033. */
  137034. activate(): void;
  137035. /**
  137036. * Deactivates the reduction computation.
  137037. */
  137038. deactivate(): void;
  137039. /**
  137040. * Disposes the min/max reducer
  137041. * @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.
  137042. */
  137043. dispose(disposeAll?: boolean): void;
  137044. }
  137045. }
  137046. declare module BABYLON {
  137047. /**
  137048. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  137049. */
  137050. export class DepthReducer extends MinMaxReducer {
  137051. private _depthRenderer;
  137052. private _depthRendererId;
  137053. /**
  137054. * Gets the depth renderer used for the computation.
  137055. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  137056. */
  137057. get depthRenderer(): Nullable<DepthRenderer>;
  137058. /**
  137059. * Creates a depth reducer
  137060. * @param camera The camera used to render the depth texture
  137061. */
  137062. constructor(camera: Camera);
  137063. /**
  137064. * Sets the depth renderer to use to generate the depth map
  137065. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  137066. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  137067. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137068. */
  137069. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  137070. /** @hidden */
  137071. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137072. /**
  137073. * Activates the reduction computation.
  137074. * When activated, the observers registered in onAfterReductionPerformed are
  137075. * called after the compuation is performed
  137076. */
  137077. activate(): void;
  137078. /**
  137079. * Deactivates the reduction computation.
  137080. */
  137081. deactivate(): void;
  137082. /**
  137083. * Disposes the depth reducer
  137084. * @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.
  137085. */
  137086. dispose(disposeAll?: boolean): void;
  137087. }
  137088. }
  137089. declare module BABYLON {
  137090. /**
  137091. * A CSM implementation allowing casting shadows on large scenes.
  137092. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137093. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  137094. */
  137095. export class CascadedShadowGenerator extends ShadowGenerator {
  137096. private static readonly frustumCornersNDCSpace;
  137097. /**
  137098. * Name of the CSM class
  137099. */
  137100. static CLASSNAME: string;
  137101. /**
  137102. * Defines the default number of cascades used by the CSM.
  137103. */
  137104. static readonly DEFAULT_CASCADES_COUNT: number;
  137105. /**
  137106. * Defines the minimum number of cascades used by the CSM.
  137107. */
  137108. static readonly MIN_CASCADES_COUNT: number;
  137109. /**
  137110. * Defines the maximum number of cascades used by the CSM.
  137111. */
  137112. static readonly MAX_CASCADES_COUNT: number;
  137113. protected _validateFilter(filter: number): number;
  137114. /**
  137115. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  137116. */
  137117. penumbraDarkness: number;
  137118. private _numCascades;
  137119. /**
  137120. * Gets or set the number of cascades used by the CSM.
  137121. */
  137122. get numCascades(): number;
  137123. set numCascades(value: number);
  137124. /**
  137125. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  137126. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  137127. */
  137128. stabilizeCascades: boolean;
  137129. private _freezeShadowCastersBoundingInfo;
  137130. private _freezeShadowCastersBoundingInfoObservable;
  137131. /**
  137132. * Enables or disables the shadow casters bounding info computation.
  137133. * If your shadow casters don't move, you can disable this feature.
  137134. * If it is enabled, the bounding box computation is done every frame.
  137135. */
  137136. get freezeShadowCastersBoundingInfo(): boolean;
  137137. set freezeShadowCastersBoundingInfo(freeze: boolean);
  137138. private _scbiMin;
  137139. private _scbiMax;
  137140. protected _computeShadowCastersBoundingInfo(): void;
  137141. protected _shadowCastersBoundingInfo: BoundingInfo;
  137142. /**
  137143. * Gets or sets the shadow casters bounding info.
  137144. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  137145. * so that the system won't overwrite the bounds you provide
  137146. */
  137147. get shadowCastersBoundingInfo(): BoundingInfo;
  137148. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  137149. protected _breaksAreDirty: boolean;
  137150. protected _minDistance: number;
  137151. protected _maxDistance: number;
  137152. /**
  137153. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  137154. *
  137155. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  137156. * If you don't know these values, simply leave them to their defaults and don't call this function.
  137157. * @param min minimal distance for the breaks (default to 0.)
  137158. * @param max maximal distance for the breaks (default to 1.)
  137159. */
  137160. setMinMaxDistance(min: number, max: number): void;
  137161. /** Gets the minimal distance used in the cascade break computation */
  137162. get minDistance(): number;
  137163. /** Gets the maximal distance used in the cascade break computation */
  137164. get maxDistance(): number;
  137165. /**
  137166. * Gets the class name of that object
  137167. * @returns "CascadedShadowGenerator"
  137168. */
  137169. getClassName(): string;
  137170. private _cascadeMinExtents;
  137171. private _cascadeMaxExtents;
  137172. /**
  137173. * Gets a cascade minimum extents
  137174. * @param cascadeIndex index of the cascade
  137175. * @returns the minimum cascade extents
  137176. */
  137177. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  137178. /**
  137179. * Gets a cascade maximum extents
  137180. * @param cascadeIndex index of the cascade
  137181. * @returns the maximum cascade extents
  137182. */
  137183. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  137184. private _cascades;
  137185. private _currentLayer;
  137186. private _viewSpaceFrustumsZ;
  137187. private _viewMatrices;
  137188. private _projectionMatrices;
  137189. private _transformMatrices;
  137190. private _transformMatricesAsArray;
  137191. private _frustumLengths;
  137192. private _lightSizeUVCorrection;
  137193. private _depthCorrection;
  137194. private _frustumCornersWorldSpace;
  137195. private _frustumCenter;
  137196. private _shadowCameraPos;
  137197. private _shadowMaxZ;
  137198. /**
  137199. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  137200. * It defaults to camera.maxZ
  137201. */
  137202. get shadowMaxZ(): number;
  137203. /**
  137204. * Sets the shadow max z distance.
  137205. */
  137206. set shadowMaxZ(value: number);
  137207. protected _debug: boolean;
  137208. /**
  137209. * Gets or sets the debug flag.
  137210. * When enabled, the cascades are materialized by different colors on the screen.
  137211. */
  137212. get debug(): boolean;
  137213. set debug(dbg: boolean);
  137214. private _depthClamp;
  137215. /**
  137216. * Gets or sets the depth clamping value.
  137217. *
  137218. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  137219. * to account for the shadow casters far away.
  137220. *
  137221. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  137222. */
  137223. get depthClamp(): boolean;
  137224. set depthClamp(value: boolean);
  137225. private _cascadeBlendPercentage;
  137226. /**
  137227. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  137228. * It defaults to 0.1 (10% blending).
  137229. */
  137230. get cascadeBlendPercentage(): number;
  137231. set cascadeBlendPercentage(value: number);
  137232. private _lambda;
  137233. /**
  137234. * Gets or set the lambda parameter.
  137235. * This parameter is used to split the camera frustum and create the cascades.
  137236. * 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.
  137237. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  137238. */
  137239. get lambda(): number;
  137240. set lambda(value: number);
  137241. /**
  137242. * Gets the view matrix corresponding to a given cascade
  137243. * @param cascadeNum cascade to retrieve the view matrix from
  137244. * @returns the cascade view matrix
  137245. */
  137246. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  137247. /**
  137248. * Gets the projection matrix corresponding to a given cascade
  137249. * @param cascadeNum cascade to retrieve the projection matrix from
  137250. * @returns the cascade projection matrix
  137251. */
  137252. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  137253. /**
  137254. * Gets the transformation matrix corresponding to a given cascade
  137255. * @param cascadeNum cascade to retrieve the transformation matrix from
  137256. * @returns the cascade transformation matrix
  137257. */
  137258. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  137259. private _depthRenderer;
  137260. /**
  137261. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  137262. *
  137263. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  137264. *
  137265. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  137266. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  137267. * @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
  137268. */
  137269. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  137270. private _depthReducer;
  137271. private _autoCalcDepthBounds;
  137272. /**
  137273. * Gets or sets the autoCalcDepthBounds property.
  137274. *
  137275. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  137276. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  137277. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  137278. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  137279. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  137280. */
  137281. get autoCalcDepthBounds(): boolean;
  137282. set autoCalcDepthBounds(value: boolean);
  137283. /**
  137284. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  137285. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137286. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  137287. * for setting the refresh rate on the renderer yourself!
  137288. */
  137289. get autoCalcDepthBoundsRefreshRate(): number;
  137290. set autoCalcDepthBoundsRefreshRate(value: number);
  137291. /**
  137292. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  137293. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  137294. * you change the camera near/far planes!
  137295. */
  137296. splitFrustum(): void;
  137297. private _splitFrustum;
  137298. private _computeMatrices;
  137299. private _computeFrustumInWorldSpace;
  137300. private _computeCascadeFrustum;
  137301. /**
  137302. * Support test.
  137303. */
  137304. static get IsSupported(): boolean;
  137305. /** @hidden */
  137306. static _SceneComponentInitialization: (scene: Scene) => void;
  137307. /**
  137308. * Creates a Cascaded Shadow Generator object.
  137309. * A ShadowGenerator is the required tool to use the shadows.
  137310. * Each directional light casting shadows needs to use its own ShadowGenerator.
  137311. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137312. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  137313. * @param light The directional light object generating the shadows.
  137314. * @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.
  137315. */
  137316. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  137317. protected _initializeGenerator(): void;
  137318. protected _createTargetRenderTexture(): void;
  137319. protected _initializeShadowMap(): void;
  137320. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  137321. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  137322. /**
  137323. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  137324. * @param defines Defines of the material we want to update
  137325. * @param lightIndex Index of the light in the enabled light list of the material
  137326. */
  137327. prepareDefines(defines: any, lightIndex: number): void;
  137328. /**
  137329. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  137330. * defined in the generator but impacting the effect).
  137331. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  137332. * @param effect The effect we are binfing the information for
  137333. */
  137334. bindShadowLight(lightIndex: string, effect: Effect): void;
  137335. /**
  137336. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  137337. * (eq to view projection * shadow projection matrices)
  137338. * @returns The transform matrix used to create the shadow map
  137339. */
  137340. getTransformMatrix(): Matrix;
  137341. /**
  137342. * Disposes the ShadowGenerator.
  137343. * Returns nothing.
  137344. */
  137345. dispose(): void;
  137346. /**
  137347. * Serializes the shadow generator setup to a json object.
  137348. * @returns The serialized JSON object
  137349. */
  137350. serialize(): any;
  137351. /**
  137352. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137353. * @param parsedShadowGenerator The JSON object to parse
  137354. * @param scene The scene to create the shadow map for
  137355. * @returns The parsed shadow generator
  137356. */
  137357. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137358. }
  137359. }
  137360. declare module BABYLON {
  137361. /**
  137362. * Defines the shadow generator component responsible to manage any shadow generators
  137363. * in a given scene.
  137364. */
  137365. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137366. /**
  137367. * The component name helpfull to identify the component in the list of scene components.
  137368. */
  137369. readonly name: string;
  137370. /**
  137371. * The scene the component belongs to.
  137372. */
  137373. scene: Scene;
  137374. /**
  137375. * Creates a new instance of the component for the given scene
  137376. * @param scene Defines the scene to register the component in
  137377. */
  137378. constructor(scene: Scene);
  137379. /**
  137380. * Registers the component in a given scene
  137381. */
  137382. register(): void;
  137383. /**
  137384. * Rebuilds the elements related to this component in case of
  137385. * context lost for instance.
  137386. */
  137387. rebuild(): void;
  137388. /**
  137389. * Serializes the component data to the specified json object
  137390. * @param serializationObject The object to serialize to
  137391. */
  137392. serialize(serializationObject: any): void;
  137393. /**
  137394. * Adds all the elements from the container to the scene
  137395. * @param container the container holding the elements
  137396. */
  137397. addFromContainer(container: AbstractScene): void;
  137398. /**
  137399. * Removes all the elements in the container from the scene
  137400. * @param container contains the elements to remove
  137401. * @param dispose if the removed element should be disposed (default: false)
  137402. */
  137403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137404. /**
  137405. * Rebuilds the elements related to this component in case of
  137406. * context lost for instance.
  137407. */
  137408. dispose(): void;
  137409. private _gatherRenderTargets;
  137410. }
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. * A point light is a light defined by an unique point in world space.
  137415. * The light is emitted in every direction from this point.
  137416. * A good example of a point light is a standard light bulb.
  137417. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137418. */
  137419. export class PointLight extends ShadowLight {
  137420. private _shadowAngle;
  137421. /**
  137422. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137423. * This specifies what angle the shadow will use to be created.
  137424. *
  137425. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137426. */
  137427. get shadowAngle(): number;
  137428. /**
  137429. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137430. * This specifies what angle the shadow will use to be created.
  137431. *
  137432. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137433. */
  137434. set shadowAngle(value: number);
  137435. /**
  137436. * Gets the direction if it has been set.
  137437. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137438. */
  137439. get direction(): Vector3;
  137440. /**
  137441. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137442. */
  137443. set direction(value: Vector3);
  137444. /**
  137445. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137446. * A PointLight emits the light in every direction.
  137447. * It can cast shadows.
  137448. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137449. * ```javascript
  137450. * var pointLight = new PointLight("pl", camera.position, scene);
  137451. * ```
  137452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137453. * @param name The light friendly name
  137454. * @param position The position of the point light in the scene
  137455. * @param scene The scene the lights belongs to
  137456. */
  137457. constructor(name: string, position: Vector3, scene: Scene);
  137458. /**
  137459. * Returns the string "PointLight"
  137460. * @returns the class name
  137461. */
  137462. getClassName(): string;
  137463. /**
  137464. * Returns the integer 0.
  137465. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137466. */
  137467. getTypeID(): number;
  137468. /**
  137469. * Specifies wether or not the shadowmap should be a cube texture.
  137470. * @returns true if the shadowmap needs to be a cube texture.
  137471. */
  137472. needCube(): boolean;
  137473. /**
  137474. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137475. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137476. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137477. */
  137478. getShadowDirection(faceIndex?: number): Vector3;
  137479. /**
  137480. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137481. * - fov = PI / 2
  137482. * - aspect ratio : 1.0
  137483. * - z-near and far equal to the active camera minZ and maxZ.
  137484. * Returns the PointLight.
  137485. */
  137486. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137487. protected _buildUniformLayout(): void;
  137488. /**
  137489. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137490. * @param effect The effect to update
  137491. * @param lightIndex The index of the light in the effect to update
  137492. * @returns The point light
  137493. */
  137494. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137495. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137496. /**
  137497. * Prepares the list of defines specific to the light type.
  137498. * @param defines the list of defines
  137499. * @param lightIndex defines the index of the light for the effect
  137500. */
  137501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137502. }
  137503. }
  137504. declare module BABYLON {
  137505. /**
  137506. * Header information of HDR texture files.
  137507. */
  137508. export interface HDRInfo {
  137509. /**
  137510. * The height of the texture in pixels.
  137511. */
  137512. height: number;
  137513. /**
  137514. * The width of the texture in pixels.
  137515. */
  137516. width: number;
  137517. /**
  137518. * The index of the beginning of the data in the binary file.
  137519. */
  137520. dataPosition: number;
  137521. }
  137522. /**
  137523. * This groups tools to convert HDR texture to native colors array.
  137524. */
  137525. export class HDRTools {
  137526. private static Ldexp;
  137527. private static Rgbe2float;
  137528. private static readStringLine;
  137529. /**
  137530. * Reads header information from an RGBE texture stored in a native array.
  137531. * More information on this format are available here:
  137532. * https://en.wikipedia.org/wiki/RGBE_image_format
  137533. *
  137534. * @param uint8array The binary file stored in native array.
  137535. * @return The header information.
  137536. */
  137537. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137538. /**
  137539. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137540. * This RGBE texture needs to store the information as a panorama.
  137541. *
  137542. * More information on this format are available here:
  137543. * https://en.wikipedia.org/wiki/RGBE_image_format
  137544. *
  137545. * @param buffer The binary file stored in an array buffer.
  137546. * @param size The expected size of the extracted cubemap.
  137547. * @return The Cube Map information.
  137548. */
  137549. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137550. /**
  137551. * Returns the pixels data extracted from an RGBE texture.
  137552. * This pixels will be stored left to right up to down in the R G B order in one array.
  137553. *
  137554. * More information on this format are available here:
  137555. * https://en.wikipedia.org/wiki/RGBE_image_format
  137556. *
  137557. * @param uint8array The binary file stored in an array buffer.
  137558. * @param hdrInfo The header information of the file.
  137559. * @return The pixels data in RGB right to left up to down order.
  137560. */
  137561. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137562. private static RGBE_ReadPixels_RLE;
  137563. }
  137564. }
  137565. declare module BABYLON {
  137566. /**
  137567. * Effect Render Options
  137568. */
  137569. export interface IEffectRendererOptions {
  137570. /**
  137571. * Defines the vertices positions.
  137572. */
  137573. positions?: number[];
  137574. /**
  137575. * Defines the indices.
  137576. */
  137577. indices?: number[];
  137578. }
  137579. /**
  137580. * Helper class to render one or more effects.
  137581. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137582. */
  137583. export class EffectRenderer {
  137584. private engine;
  137585. private static _DefaultOptions;
  137586. private _vertexBuffers;
  137587. private _indexBuffer;
  137588. private _fullscreenViewport;
  137589. /**
  137590. * Creates an effect renderer
  137591. * @param engine the engine to use for rendering
  137592. * @param options defines the options of the effect renderer
  137593. */
  137594. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137595. /**
  137596. * Sets the current viewport in normalized coordinates 0-1
  137597. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137598. */
  137599. setViewport(viewport?: Viewport): void;
  137600. /**
  137601. * Binds the embedded attributes buffer to the effect.
  137602. * @param effect Defines the effect to bind the attributes for
  137603. */
  137604. bindBuffers(effect: Effect): void;
  137605. /**
  137606. * Sets the current effect wrapper to use during draw.
  137607. * The effect needs to be ready before calling this api.
  137608. * This also sets the default full screen position attribute.
  137609. * @param effectWrapper Defines the effect to draw with
  137610. */
  137611. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137612. /**
  137613. * Restores engine states
  137614. */
  137615. restoreStates(): void;
  137616. /**
  137617. * Draws a full screen quad.
  137618. */
  137619. draw(): void;
  137620. private isRenderTargetTexture;
  137621. /**
  137622. * renders one or more effects to a specified texture
  137623. * @param effectWrapper the effect to renderer
  137624. * @param outputTexture texture to draw to, if null it will render to the screen.
  137625. */
  137626. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137627. /**
  137628. * Disposes of the effect renderer
  137629. */
  137630. dispose(): void;
  137631. }
  137632. /**
  137633. * Options to create an EffectWrapper
  137634. */
  137635. interface EffectWrapperCreationOptions {
  137636. /**
  137637. * Engine to use to create the effect
  137638. */
  137639. engine: ThinEngine;
  137640. /**
  137641. * Fragment shader for the effect
  137642. */
  137643. fragmentShader: string;
  137644. /**
  137645. * Use the shader store instead of direct source code
  137646. */
  137647. useShaderStore?: boolean;
  137648. /**
  137649. * Vertex shader for the effect
  137650. */
  137651. vertexShader?: string;
  137652. /**
  137653. * Attributes to use in the shader
  137654. */
  137655. attributeNames?: Array<string>;
  137656. /**
  137657. * Uniforms to use in the shader
  137658. */
  137659. uniformNames?: Array<string>;
  137660. /**
  137661. * Texture sampler names to use in the shader
  137662. */
  137663. samplerNames?: Array<string>;
  137664. /**
  137665. * Defines to use in the shader
  137666. */
  137667. defines?: Array<string>;
  137668. /**
  137669. * Callback when effect is compiled
  137670. */
  137671. onCompiled?: Nullable<(effect: Effect) => void>;
  137672. /**
  137673. * The friendly name of the effect displayed in Spector.
  137674. */
  137675. name?: string;
  137676. }
  137677. /**
  137678. * Wraps an effect to be used for rendering
  137679. */
  137680. export class EffectWrapper {
  137681. /**
  137682. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137683. */
  137684. onApplyObservable: Observable<{}>;
  137685. /**
  137686. * The underlying effect
  137687. */
  137688. effect: Effect;
  137689. /**
  137690. * Creates an effect to be renderer
  137691. * @param creationOptions options to create the effect
  137692. */
  137693. constructor(creationOptions: EffectWrapperCreationOptions);
  137694. /**
  137695. * Disposes of the effect wrapper
  137696. */
  137697. dispose(): void;
  137698. }
  137699. }
  137700. declare module BABYLON {
  137701. /** @hidden */
  137702. export var hdrFilteringVertexShader: {
  137703. name: string;
  137704. shader: string;
  137705. };
  137706. }
  137707. declare module BABYLON {
  137708. /** @hidden */
  137709. export var hdrFilteringPixelShader: {
  137710. name: string;
  137711. shader: string;
  137712. };
  137713. }
  137714. declare module BABYLON {
  137715. /**
  137716. * Options for texture filtering
  137717. */
  137718. interface IHDRFilteringOptions {
  137719. /**
  137720. * Scales pixel intensity for the input HDR map.
  137721. */
  137722. hdrScale?: number;
  137723. /**
  137724. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137725. */
  137726. quality?: number;
  137727. }
  137728. /**
  137729. * Filters HDR maps to get correct renderings of PBR reflections
  137730. */
  137731. export class HDRFiltering {
  137732. private _engine;
  137733. private _effectRenderer;
  137734. private _effectWrapper;
  137735. private _lodGenerationOffset;
  137736. private _lodGenerationScale;
  137737. /**
  137738. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137739. * you care about baking speed.
  137740. */
  137741. quality: number;
  137742. /**
  137743. * Scales pixel intensity for the input HDR map.
  137744. */
  137745. hdrScale: number;
  137746. /**
  137747. * Instantiates HDR filter for reflection maps
  137748. *
  137749. * @param engine Thin engine
  137750. * @param options Options
  137751. */
  137752. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137753. private _createRenderTarget;
  137754. private _prefilterInternal;
  137755. private _createEffect;
  137756. /**
  137757. * Get a value indicating if the filter is ready to be used
  137758. * @param texture Texture to filter
  137759. * @returns true if the filter is ready
  137760. */
  137761. isReady(texture: BaseTexture): boolean;
  137762. /**
  137763. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137764. * Prefiltering will be invoked at the end of next rendering pass.
  137765. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137766. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137767. * @param texture Texture to filter
  137768. * @param onFinished Callback when filtering is done
  137769. * @return Promise called when prefiltering is done
  137770. */
  137771. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137772. }
  137773. }
  137774. declare module BABYLON {
  137775. /**
  137776. * This represents a texture coming from an HDR input.
  137777. *
  137778. * The only supported format is currently panorama picture stored in RGBE format.
  137779. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137780. */
  137781. export class HDRCubeTexture extends BaseTexture {
  137782. private static _facesMapping;
  137783. private _generateHarmonics;
  137784. private _noMipmap;
  137785. private _prefilterOnLoad;
  137786. private _textureMatrix;
  137787. private _size;
  137788. private _onLoad;
  137789. private _onError;
  137790. /**
  137791. * The texture URL.
  137792. */
  137793. url: string;
  137794. /**
  137795. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137796. */
  137797. coordinatesMode: number;
  137798. protected _isBlocking: boolean;
  137799. /**
  137800. * Sets wether or not the texture is blocking during loading.
  137801. */
  137802. set isBlocking(value: boolean);
  137803. /**
  137804. * Gets wether or not the texture is blocking during loading.
  137805. */
  137806. get isBlocking(): boolean;
  137807. protected _rotationY: number;
  137808. /**
  137809. * Sets texture matrix rotation angle around Y axis in radians.
  137810. */
  137811. set rotationY(value: number);
  137812. /**
  137813. * Gets texture matrix rotation angle around Y axis radians.
  137814. */
  137815. get rotationY(): number;
  137816. /**
  137817. * Gets or sets the center of the bounding box associated with the cube texture
  137818. * It must define where the camera used to render the texture was set
  137819. */
  137820. boundingBoxPosition: Vector3;
  137821. private _boundingBoxSize;
  137822. /**
  137823. * Gets or sets the size of the bounding box associated with the cube texture
  137824. * When defined, the cubemap will switch to local mode
  137825. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137826. * @example https://www.babylonjs-playground.com/#RNASML
  137827. */
  137828. set boundingBoxSize(value: Vector3);
  137829. get boundingBoxSize(): Vector3;
  137830. /**
  137831. * Instantiates an HDRTexture from the following parameters.
  137832. *
  137833. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137834. * @param sceneOrEngine The scene or engine the texture will be used in
  137835. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137836. * @param noMipmap Forces to not generate the mipmap if true
  137837. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137838. * @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)
  137839. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137840. */
  137841. 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>);
  137842. /**
  137843. * Get the current class name of the texture useful for serialization or dynamic coding.
  137844. * @returns "HDRCubeTexture"
  137845. */
  137846. getClassName(): string;
  137847. /**
  137848. * Occurs when the file is raw .hdr file.
  137849. */
  137850. private loadTexture;
  137851. clone(): HDRCubeTexture;
  137852. delayLoad(): void;
  137853. /**
  137854. * Get the texture reflection matrix used to rotate/transform the reflection.
  137855. * @returns the reflection matrix
  137856. */
  137857. getReflectionTextureMatrix(): Matrix;
  137858. /**
  137859. * Set the texture reflection matrix used to rotate/transform the reflection.
  137860. * @param value Define the reflection matrix to set
  137861. */
  137862. setReflectionTextureMatrix(value: Matrix): void;
  137863. /**
  137864. * Parses a JSON representation of an HDR Texture in order to create the texture
  137865. * @param parsedTexture Define the JSON representation
  137866. * @param scene Define the scene the texture should be created in
  137867. * @param rootUrl Define the root url in case we need to load relative dependencies
  137868. * @returns the newly created texture after parsing
  137869. */
  137870. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137871. serialize(): any;
  137872. }
  137873. }
  137874. declare module BABYLON {
  137875. /**
  137876. * Class used to control physics engine
  137877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137878. */
  137879. export class PhysicsEngine implements IPhysicsEngine {
  137880. private _physicsPlugin;
  137881. /**
  137882. * Global value used to control the smallest number supported by the simulation
  137883. */
  137884. static Epsilon: number;
  137885. private _impostors;
  137886. private _joints;
  137887. private _subTimeStep;
  137888. /**
  137889. * Gets the gravity vector used by the simulation
  137890. */
  137891. gravity: Vector3;
  137892. /**
  137893. * Factory used to create the default physics plugin.
  137894. * @returns The default physics plugin
  137895. */
  137896. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137897. /**
  137898. * Creates a new Physics Engine
  137899. * @param gravity defines the gravity vector used by the simulation
  137900. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137901. */
  137902. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137903. /**
  137904. * Sets the gravity vector used by the simulation
  137905. * @param gravity defines the gravity vector to use
  137906. */
  137907. setGravity(gravity: Vector3): void;
  137908. /**
  137909. * Set the time step of the physics engine.
  137910. * Default is 1/60.
  137911. * To slow it down, enter 1/600 for example.
  137912. * To speed it up, 1/30
  137913. * @param newTimeStep defines the new timestep to apply to this world.
  137914. */
  137915. setTimeStep(newTimeStep?: number): void;
  137916. /**
  137917. * Get the time step of the physics engine.
  137918. * @returns the current time step
  137919. */
  137920. getTimeStep(): number;
  137921. /**
  137922. * Set the sub time step of the physics engine.
  137923. * Default is 0 meaning there is no sub steps
  137924. * To increase physics resolution precision, set a small value (like 1 ms)
  137925. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137926. */
  137927. setSubTimeStep(subTimeStep?: number): void;
  137928. /**
  137929. * Get the sub time step of the physics engine.
  137930. * @returns the current sub time step
  137931. */
  137932. getSubTimeStep(): number;
  137933. /**
  137934. * Release all resources
  137935. */
  137936. dispose(): void;
  137937. /**
  137938. * Gets the name of the current physics plugin
  137939. * @returns the name of the plugin
  137940. */
  137941. getPhysicsPluginName(): string;
  137942. /**
  137943. * Adding a new impostor for the impostor tracking.
  137944. * This will be done by the impostor itself.
  137945. * @param impostor the impostor to add
  137946. */
  137947. addImpostor(impostor: PhysicsImpostor): void;
  137948. /**
  137949. * Remove an impostor from the engine.
  137950. * This impostor and its mesh will not longer be updated by the physics engine.
  137951. * @param impostor the impostor to remove
  137952. */
  137953. removeImpostor(impostor: PhysicsImpostor): void;
  137954. /**
  137955. * Add a joint to the physics engine
  137956. * @param mainImpostor defines the main impostor to which the joint is added.
  137957. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137958. * @param joint defines the joint that will connect both impostors.
  137959. */
  137960. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137961. /**
  137962. * Removes a joint from the simulation
  137963. * @param mainImpostor defines the impostor used with the joint
  137964. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137965. * @param joint defines the joint to remove
  137966. */
  137967. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137968. /**
  137969. * Called by the scene. No need to call it.
  137970. * @param delta defines the timespam between frames
  137971. */
  137972. _step(delta: number): void;
  137973. /**
  137974. * Gets the current plugin used to run the simulation
  137975. * @returns current plugin
  137976. */
  137977. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137978. /**
  137979. * Gets the list of physic impostors
  137980. * @returns an array of PhysicsImpostor
  137981. */
  137982. getImpostors(): Array<PhysicsImpostor>;
  137983. /**
  137984. * Gets the impostor for a physics enabled object
  137985. * @param object defines the object impersonated by the impostor
  137986. * @returns the PhysicsImpostor or null if not found
  137987. */
  137988. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137989. /**
  137990. * Gets the impostor for a physics body object
  137991. * @param body defines physics body used by the impostor
  137992. * @returns the PhysicsImpostor or null if not found
  137993. */
  137994. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137995. /**
  137996. * Does a raycast in the physics world
  137997. * @param from when should the ray start?
  137998. * @param to when should the ray end?
  137999. * @returns PhysicsRaycastResult
  138000. */
  138001. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138002. }
  138003. }
  138004. declare module BABYLON {
  138005. /** @hidden */
  138006. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  138007. private _useDeltaForWorldStep;
  138008. world: any;
  138009. name: string;
  138010. private _physicsMaterials;
  138011. private _fixedTimeStep;
  138012. private _cannonRaycastResult;
  138013. private _raycastResult;
  138014. private _physicsBodysToRemoveAfterStep;
  138015. private _firstFrame;
  138016. BJSCANNON: any;
  138017. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  138018. setGravity(gravity: Vector3): void;
  138019. setTimeStep(timeStep: number): void;
  138020. getTimeStep(): number;
  138021. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138022. private _removeMarkedPhysicsBodiesFromWorld;
  138023. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138025. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138026. private _processChildMeshes;
  138027. removePhysicsBody(impostor: PhysicsImpostor): void;
  138028. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138029. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138030. private _addMaterial;
  138031. private _checkWithEpsilon;
  138032. private _createShape;
  138033. private _createHeightmap;
  138034. private _minus90X;
  138035. private _plus90X;
  138036. private _tmpPosition;
  138037. private _tmpDeltaPosition;
  138038. private _tmpUnityRotation;
  138039. private _updatePhysicsBodyTransformation;
  138040. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138041. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138042. isSupported(): boolean;
  138043. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138044. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138045. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138046. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138047. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138048. getBodyMass(impostor: PhysicsImpostor): number;
  138049. getBodyFriction(impostor: PhysicsImpostor): number;
  138050. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138051. getBodyRestitution(impostor: PhysicsImpostor): number;
  138052. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138053. sleepBody(impostor: PhysicsImpostor): void;
  138054. wakeUpBody(impostor: PhysicsImpostor): void;
  138055. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  138056. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138058. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138059. getRadius(impostor: PhysicsImpostor): number;
  138060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138061. dispose(): void;
  138062. private _extendNamespace;
  138063. /**
  138064. * Does a raycast in the physics world
  138065. * @param from when should the ray start?
  138066. * @param to when should the ray end?
  138067. * @returns PhysicsRaycastResult
  138068. */
  138069. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138070. }
  138071. }
  138072. declare module BABYLON {
  138073. /** @hidden */
  138074. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  138075. private _useDeltaForWorldStep;
  138076. world: any;
  138077. name: string;
  138078. BJSOIMO: any;
  138079. private _raycastResult;
  138080. private _fixedTimeStep;
  138081. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  138082. setGravity(gravity: Vector3): void;
  138083. setTimeStep(timeStep: number): void;
  138084. getTimeStep(): number;
  138085. private _tmpImpostorsArray;
  138086. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138087. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138088. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138090. private _tmpPositionVector;
  138091. removePhysicsBody(impostor: PhysicsImpostor): void;
  138092. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138094. isSupported(): boolean;
  138095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138096. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138102. getBodyMass(impostor: PhysicsImpostor): number;
  138103. getBodyFriction(impostor: PhysicsImpostor): number;
  138104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138105. getBodyRestitution(impostor: PhysicsImpostor): number;
  138106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138107. sleepBody(impostor: PhysicsImpostor): void;
  138108. wakeUpBody(impostor: PhysicsImpostor): void;
  138109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138110. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  138111. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  138112. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138113. getRadius(impostor: PhysicsImpostor): number;
  138114. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138115. dispose(): void;
  138116. /**
  138117. * Does a raycast in the physics world
  138118. * @param from when should the ray start?
  138119. * @param to when should the ray end?
  138120. * @returns PhysicsRaycastResult
  138121. */
  138122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138123. }
  138124. }
  138125. declare module BABYLON {
  138126. /**
  138127. * Class containing static functions to help procedurally build meshes
  138128. */
  138129. export class RibbonBuilder {
  138130. /**
  138131. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138132. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138133. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138134. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138135. * * 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
  138136. * * 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
  138137. * * 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
  138138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138141. * * 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
  138142. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138143. * * 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
  138144. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138146. * @param name defines the name of the mesh
  138147. * @param options defines the options used to create the mesh
  138148. * @param scene defines the hosting scene
  138149. * @returns the ribbon mesh
  138150. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138152. */
  138153. static CreateRibbon(name: string, options: {
  138154. pathArray: Vector3[][];
  138155. closeArray?: boolean;
  138156. closePath?: boolean;
  138157. offset?: number;
  138158. updatable?: boolean;
  138159. sideOrientation?: number;
  138160. frontUVs?: Vector4;
  138161. backUVs?: Vector4;
  138162. instance?: Mesh;
  138163. invertUV?: boolean;
  138164. uvs?: Vector2[];
  138165. colors?: Color4[];
  138166. }, scene?: Nullable<Scene>): Mesh;
  138167. }
  138168. }
  138169. declare module BABYLON {
  138170. /**
  138171. * Class containing static functions to help procedurally build meshes
  138172. */
  138173. export class ShapeBuilder {
  138174. /**
  138175. * 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.
  138176. * * 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.
  138177. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138178. * * 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.
  138179. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  138180. * * 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
  138181. * * 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
  138182. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  138183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  138186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138187. * @param name defines the name of the mesh
  138188. * @param options defines the options used to create the mesh
  138189. * @param scene defines the hosting scene
  138190. * @returns the extruded shape mesh
  138191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138193. */
  138194. static ExtrudeShape(name: string, options: {
  138195. shape: Vector3[];
  138196. path: Vector3[];
  138197. scale?: number;
  138198. rotation?: number;
  138199. cap?: number;
  138200. updatable?: boolean;
  138201. sideOrientation?: number;
  138202. frontUVs?: Vector4;
  138203. backUVs?: Vector4;
  138204. instance?: Mesh;
  138205. invertUV?: boolean;
  138206. }, scene?: Nullable<Scene>): Mesh;
  138207. /**
  138208. * Creates an custom extruded shape mesh.
  138209. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  138210. * * 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.
  138211. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138212. * * 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
  138213. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  138214. * * 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
  138215. * * It must returns a float value that will be the scale value applied to the shape on each path point
  138216. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  138217. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  138218. * * 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
  138219. * * 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
  138220. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  138221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138225. * @param name defines the name of the mesh
  138226. * @param options defines the options used to create the mesh
  138227. * @param scene defines the hosting scene
  138228. * @returns the custom extruded shape mesh
  138229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  138230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138232. */
  138233. static ExtrudeShapeCustom(name: string, options: {
  138234. shape: Vector3[];
  138235. path: Vector3[];
  138236. scaleFunction?: any;
  138237. rotationFunction?: any;
  138238. ribbonCloseArray?: boolean;
  138239. ribbonClosePath?: boolean;
  138240. cap?: number;
  138241. updatable?: boolean;
  138242. sideOrientation?: number;
  138243. frontUVs?: Vector4;
  138244. backUVs?: Vector4;
  138245. instance?: Mesh;
  138246. invertUV?: boolean;
  138247. }, scene?: Nullable<Scene>): Mesh;
  138248. private static _ExtrudeShapeGeneric;
  138249. }
  138250. }
  138251. declare module BABYLON {
  138252. /**
  138253. * AmmoJS Physics plugin
  138254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138255. * @see https://github.com/kripken/ammo.js/
  138256. */
  138257. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  138258. private _useDeltaForWorldStep;
  138259. /**
  138260. * Reference to the Ammo library
  138261. */
  138262. bjsAMMO: any;
  138263. /**
  138264. * Created ammoJS world which physics bodies are added to
  138265. */
  138266. world: any;
  138267. /**
  138268. * Name of the plugin
  138269. */
  138270. name: string;
  138271. private _timeStep;
  138272. private _fixedTimeStep;
  138273. private _maxSteps;
  138274. private _tmpQuaternion;
  138275. private _tmpAmmoTransform;
  138276. private _tmpAmmoQuaternion;
  138277. private _tmpAmmoConcreteContactResultCallback;
  138278. private _collisionConfiguration;
  138279. private _dispatcher;
  138280. private _overlappingPairCache;
  138281. private _solver;
  138282. private _softBodySolver;
  138283. private _tmpAmmoVectorA;
  138284. private _tmpAmmoVectorB;
  138285. private _tmpAmmoVectorC;
  138286. private _tmpAmmoVectorD;
  138287. private _tmpContactCallbackResult;
  138288. private _tmpAmmoVectorRCA;
  138289. private _tmpAmmoVectorRCB;
  138290. private _raycastResult;
  138291. private static readonly DISABLE_COLLISION_FLAG;
  138292. private static readonly KINEMATIC_FLAG;
  138293. private static readonly DISABLE_DEACTIVATION_FLAG;
  138294. /**
  138295. * Initializes the ammoJS plugin
  138296. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  138297. * @param ammoInjection can be used to inject your own ammo reference
  138298. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  138299. */
  138300. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  138301. /**
  138302. * Sets the gravity of the physics world (m/(s^2))
  138303. * @param gravity Gravity to set
  138304. */
  138305. setGravity(gravity: Vector3): void;
  138306. /**
  138307. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  138308. * @param timeStep timestep to use in seconds
  138309. */
  138310. setTimeStep(timeStep: number): void;
  138311. /**
  138312. * 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)
  138313. * @param fixedTimeStep fixedTimeStep to use in seconds
  138314. */
  138315. setFixedTimeStep(fixedTimeStep: number): void;
  138316. /**
  138317. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  138318. * @param maxSteps the maximum number of steps by the physics engine per frame
  138319. */
  138320. setMaxSteps(maxSteps: number): void;
  138321. /**
  138322. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  138323. * @returns the current timestep in seconds
  138324. */
  138325. getTimeStep(): number;
  138326. /**
  138327. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  138328. */
  138329. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  138330. private _isImpostorInContact;
  138331. private _isImpostorPairInContact;
  138332. private _stepSimulation;
  138333. /**
  138334. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  138335. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  138336. * After the step the babylon meshes are set to the position of the physics imposters
  138337. * @param delta amount of time to step forward
  138338. * @param impostors array of imposters to update before/after the step
  138339. */
  138340. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138341. /**
  138342. * Update babylon mesh to match physics world object
  138343. * @param impostor imposter to match
  138344. */
  138345. private _afterSoftStep;
  138346. /**
  138347. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138348. * @param impostor imposter to match
  138349. */
  138350. private _ropeStep;
  138351. /**
  138352. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138353. * @param impostor imposter to match
  138354. */
  138355. private _softbodyOrClothStep;
  138356. private _tmpMatrix;
  138357. /**
  138358. * Applies an impulse on the imposter
  138359. * @param impostor imposter to apply impulse to
  138360. * @param force amount of force to be applied to the imposter
  138361. * @param contactPoint the location to apply the impulse on the imposter
  138362. */
  138363. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138364. /**
  138365. * Applies a force on the imposter
  138366. * @param impostor imposter to apply force
  138367. * @param force amount of force to be applied to the imposter
  138368. * @param contactPoint the location to apply the force on the imposter
  138369. */
  138370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138371. /**
  138372. * Creates a physics body using the plugin
  138373. * @param impostor the imposter to create the physics body on
  138374. */
  138375. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138376. /**
  138377. * Removes the physics body from the imposter and disposes of the body's memory
  138378. * @param impostor imposter to remove the physics body from
  138379. */
  138380. removePhysicsBody(impostor: PhysicsImpostor): void;
  138381. /**
  138382. * Generates a joint
  138383. * @param impostorJoint the imposter joint to create the joint with
  138384. */
  138385. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138386. /**
  138387. * Removes a joint
  138388. * @param impostorJoint the imposter joint to remove the joint from
  138389. */
  138390. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138391. private _addMeshVerts;
  138392. /**
  138393. * Initialise the soft body vertices to match its object's (mesh) vertices
  138394. * Softbody vertices (nodes) are in world space and to match this
  138395. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138396. * @param impostor to create the softbody for
  138397. */
  138398. private _softVertexData;
  138399. /**
  138400. * Create an impostor's soft body
  138401. * @param impostor to create the softbody for
  138402. */
  138403. private _createSoftbody;
  138404. /**
  138405. * Create cloth for an impostor
  138406. * @param impostor to create the softbody for
  138407. */
  138408. private _createCloth;
  138409. /**
  138410. * Create rope for an impostor
  138411. * @param impostor to create the softbody for
  138412. */
  138413. private _createRope;
  138414. /**
  138415. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138416. * @param impostor to create the custom physics shape for
  138417. */
  138418. private _createCustom;
  138419. private _addHullVerts;
  138420. private _createShape;
  138421. /**
  138422. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138423. * @param impostor imposter containing the physics body and babylon object
  138424. */
  138425. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138426. /**
  138427. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138428. * @param impostor imposter containing the physics body and babylon object
  138429. * @param newPosition new position
  138430. * @param newRotation new rotation
  138431. */
  138432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138433. /**
  138434. * If this plugin is supported
  138435. * @returns true if its supported
  138436. */
  138437. isSupported(): boolean;
  138438. /**
  138439. * Sets the linear velocity of the physics body
  138440. * @param impostor imposter to set the velocity on
  138441. * @param velocity velocity to set
  138442. */
  138443. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138444. /**
  138445. * Sets the angular velocity of the physics body
  138446. * @param impostor imposter to set the velocity on
  138447. * @param velocity velocity to set
  138448. */
  138449. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138450. /**
  138451. * gets the linear velocity
  138452. * @param impostor imposter to get linear velocity from
  138453. * @returns linear velocity
  138454. */
  138455. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138456. /**
  138457. * gets the angular velocity
  138458. * @param impostor imposter to get angular velocity from
  138459. * @returns angular velocity
  138460. */
  138461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138462. /**
  138463. * Sets the mass of physics body
  138464. * @param impostor imposter to set the mass on
  138465. * @param mass mass to set
  138466. */
  138467. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138468. /**
  138469. * Gets the mass of the physics body
  138470. * @param impostor imposter to get the mass from
  138471. * @returns mass
  138472. */
  138473. getBodyMass(impostor: PhysicsImpostor): number;
  138474. /**
  138475. * Gets friction of the impostor
  138476. * @param impostor impostor to get friction from
  138477. * @returns friction value
  138478. */
  138479. getBodyFriction(impostor: PhysicsImpostor): number;
  138480. /**
  138481. * Sets friction of the impostor
  138482. * @param impostor impostor to set friction on
  138483. * @param friction friction value
  138484. */
  138485. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138486. /**
  138487. * Gets restitution of the impostor
  138488. * @param impostor impostor to get restitution from
  138489. * @returns restitution value
  138490. */
  138491. getBodyRestitution(impostor: PhysicsImpostor): number;
  138492. /**
  138493. * Sets resitution of the impostor
  138494. * @param impostor impostor to set resitution on
  138495. * @param restitution resitution value
  138496. */
  138497. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138498. /**
  138499. * Gets pressure inside the impostor
  138500. * @param impostor impostor to get pressure from
  138501. * @returns pressure value
  138502. */
  138503. getBodyPressure(impostor: PhysicsImpostor): number;
  138504. /**
  138505. * Sets pressure inside a soft body impostor
  138506. * Cloth and rope must remain 0 pressure
  138507. * @param impostor impostor to set pressure on
  138508. * @param pressure pressure value
  138509. */
  138510. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138511. /**
  138512. * Gets stiffness of the impostor
  138513. * @param impostor impostor to get stiffness from
  138514. * @returns pressure value
  138515. */
  138516. getBodyStiffness(impostor: PhysicsImpostor): number;
  138517. /**
  138518. * Sets stiffness of the impostor
  138519. * @param impostor impostor to set stiffness on
  138520. * @param stiffness stiffness value from 0 to 1
  138521. */
  138522. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138523. /**
  138524. * Gets velocityIterations of the impostor
  138525. * @param impostor impostor to get velocity iterations from
  138526. * @returns velocityIterations value
  138527. */
  138528. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138529. /**
  138530. * Sets velocityIterations of the impostor
  138531. * @param impostor impostor to set velocity iterations on
  138532. * @param velocityIterations velocityIterations value
  138533. */
  138534. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138535. /**
  138536. * Gets positionIterations of the impostor
  138537. * @param impostor impostor to get position iterations from
  138538. * @returns positionIterations value
  138539. */
  138540. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138541. /**
  138542. * Sets positionIterations of the impostor
  138543. * @param impostor impostor to set position on
  138544. * @param positionIterations positionIterations value
  138545. */
  138546. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138547. /**
  138548. * Append an anchor to a cloth object
  138549. * @param impostor is the cloth impostor to add anchor to
  138550. * @param otherImpostor is the rigid impostor to anchor to
  138551. * @param width ratio across width from 0 to 1
  138552. * @param height ratio up height from 0 to 1
  138553. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138554. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138555. */
  138556. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138557. /**
  138558. * Append an hook to a rope object
  138559. * @param impostor is the rope impostor to add hook to
  138560. * @param otherImpostor is the rigid impostor to hook to
  138561. * @param length ratio along the rope from 0 to 1
  138562. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138563. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138564. */
  138565. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138566. /**
  138567. * Sleeps the physics body and stops it from being active
  138568. * @param impostor impostor to sleep
  138569. */
  138570. sleepBody(impostor: PhysicsImpostor): void;
  138571. /**
  138572. * Activates the physics body
  138573. * @param impostor impostor to activate
  138574. */
  138575. wakeUpBody(impostor: PhysicsImpostor): void;
  138576. /**
  138577. * Updates the distance parameters of the joint
  138578. * @param joint joint to update
  138579. * @param maxDistance maximum distance of the joint
  138580. * @param minDistance minimum distance of the joint
  138581. */
  138582. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138583. /**
  138584. * Sets a motor on the joint
  138585. * @param joint joint to set motor on
  138586. * @param speed speed of the motor
  138587. * @param maxForce maximum force of the motor
  138588. * @param motorIndex index of the motor
  138589. */
  138590. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138591. /**
  138592. * Sets the motors limit
  138593. * @param joint joint to set limit on
  138594. * @param upperLimit upper limit
  138595. * @param lowerLimit lower limit
  138596. */
  138597. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138598. /**
  138599. * Syncs the position and rotation of a mesh with the impostor
  138600. * @param mesh mesh to sync
  138601. * @param impostor impostor to update the mesh with
  138602. */
  138603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138604. /**
  138605. * Gets the radius of the impostor
  138606. * @param impostor impostor to get radius from
  138607. * @returns the radius
  138608. */
  138609. getRadius(impostor: PhysicsImpostor): number;
  138610. /**
  138611. * Gets the box size of the impostor
  138612. * @param impostor impostor to get box size from
  138613. * @param result the resulting box size
  138614. */
  138615. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138616. /**
  138617. * Disposes of the impostor
  138618. */
  138619. dispose(): void;
  138620. /**
  138621. * Does a raycast in the physics world
  138622. * @param from when should the ray start?
  138623. * @param to when should the ray end?
  138624. * @returns PhysicsRaycastResult
  138625. */
  138626. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138627. }
  138628. }
  138629. declare module BABYLON {
  138630. interface AbstractScene {
  138631. /**
  138632. * The list of reflection probes added to the scene
  138633. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138634. */
  138635. reflectionProbes: Array<ReflectionProbe>;
  138636. /**
  138637. * Removes the given reflection probe from this scene.
  138638. * @param toRemove The reflection probe to remove
  138639. * @returns The index of the removed reflection probe
  138640. */
  138641. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138642. /**
  138643. * Adds the given reflection probe to this scene.
  138644. * @param newReflectionProbe The reflection probe to add
  138645. */
  138646. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138647. }
  138648. /**
  138649. * Class used to generate realtime reflection / refraction cube textures
  138650. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138651. */
  138652. export class ReflectionProbe {
  138653. /** defines the name of the probe */
  138654. name: string;
  138655. private _scene;
  138656. private _renderTargetTexture;
  138657. private _projectionMatrix;
  138658. private _viewMatrix;
  138659. private _target;
  138660. private _add;
  138661. private _attachedMesh;
  138662. private _invertYAxis;
  138663. /** Gets or sets probe position (center of the cube map) */
  138664. position: Vector3;
  138665. /**
  138666. * Creates a new reflection probe
  138667. * @param name defines the name of the probe
  138668. * @param size defines the texture resolution (for each face)
  138669. * @param scene defines the hosting scene
  138670. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138671. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138672. */
  138673. constructor(
  138674. /** defines the name of the probe */
  138675. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138676. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138677. get samples(): number;
  138678. set samples(value: number);
  138679. /** Gets or sets the refresh rate to use (on every frame by default) */
  138680. get refreshRate(): number;
  138681. set refreshRate(value: number);
  138682. /**
  138683. * Gets the hosting scene
  138684. * @returns a Scene
  138685. */
  138686. getScene(): Scene;
  138687. /** Gets the internal CubeTexture used to render to */
  138688. get cubeTexture(): RenderTargetTexture;
  138689. /** Gets the list of meshes to render */
  138690. get renderList(): Nullable<AbstractMesh[]>;
  138691. /**
  138692. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138693. * @param mesh defines the mesh to attach to
  138694. */
  138695. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138696. /**
  138697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138698. * @param renderingGroupId The rendering group id corresponding to its index
  138699. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138700. */
  138701. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138702. /**
  138703. * Clean all associated resources
  138704. */
  138705. dispose(): void;
  138706. /**
  138707. * Converts the reflection probe information to a readable string for debug purpose.
  138708. * @param fullDetails Supports for multiple levels of logging within scene loading
  138709. * @returns the human readable reflection probe info
  138710. */
  138711. toString(fullDetails?: boolean): string;
  138712. /**
  138713. * Get the class name of the relfection probe.
  138714. * @returns "ReflectionProbe"
  138715. */
  138716. getClassName(): string;
  138717. /**
  138718. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138719. * @returns The JSON representation of the texture
  138720. */
  138721. serialize(): any;
  138722. /**
  138723. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138724. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138725. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138726. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138727. * @returns The parsed reflection probe if successful
  138728. */
  138729. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138730. }
  138731. }
  138732. declare module BABYLON {
  138733. /** @hidden */
  138734. export var _BabylonLoaderRegistered: boolean;
  138735. /**
  138736. * Helps setting up some configuration for the babylon file loader.
  138737. */
  138738. export class BabylonFileLoaderConfiguration {
  138739. /**
  138740. * The loader does not allow injecting custom physix engine into the plugins.
  138741. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138742. * So you could set this variable to your engine import to make it work.
  138743. */
  138744. static LoaderInjectedPhysicsEngine: any;
  138745. }
  138746. }
  138747. declare module BABYLON {
  138748. /**
  138749. * The Physically based simple base material of BJS.
  138750. *
  138751. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138752. * It is used as the base class for both the specGloss and metalRough conventions.
  138753. */
  138754. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138755. /**
  138756. * Number of Simultaneous lights allowed on the material.
  138757. */
  138758. maxSimultaneousLights: number;
  138759. /**
  138760. * If sets to true, disables all the lights affecting the material.
  138761. */
  138762. disableLighting: boolean;
  138763. /**
  138764. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138765. */
  138766. environmentTexture: BaseTexture;
  138767. /**
  138768. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138769. */
  138770. invertNormalMapX: boolean;
  138771. /**
  138772. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138773. */
  138774. invertNormalMapY: boolean;
  138775. /**
  138776. * Normal map used in the model.
  138777. */
  138778. normalTexture: BaseTexture;
  138779. /**
  138780. * Emissivie color used to self-illuminate the model.
  138781. */
  138782. emissiveColor: Color3;
  138783. /**
  138784. * Emissivie texture used to self-illuminate the model.
  138785. */
  138786. emissiveTexture: BaseTexture;
  138787. /**
  138788. * Occlusion Channel Strenght.
  138789. */
  138790. occlusionStrength: number;
  138791. /**
  138792. * Occlusion Texture of the material (adding extra occlusion effects).
  138793. */
  138794. occlusionTexture: BaseTexture;
  138795. /**
  138796. * Defines the alpha limits in alpha test mode.
  138797. */
  138798. alphaCutOff: number;
  138799. /**
  138800. * Gets the current double sided mode.
  138801. */
  138802. get doubleSided(): boolean;
  138803. /**
  138804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138805. */
  138806. set doubleSided(value: boolean);
  138807. /**
  138808. * Stores the pre-calculated light information of a mesh in a texture.
  138809. */
  138810. lightmapTexture: BaseTexture;
  138811. /**
  138812. * If true, the light map contains occlusion information instead of lighting info.
  138813. */
  138814. useLightmapAsShadowmap: boolean;
  138815. /**
  138816. * Instantiates a new PBRMaterial instance.
  138817. *
  138818. * @param name The material name
  138819. * @param scene The scene the material will be use in.
  138820. */
  138821. constructor(name: string, scene: Scene);
  138822. getClassName(): string;
  138823. }
  138824. }
  138825. declare module BABYLON {
  138826. /**
  138827. * The PBR material of BJS following the metal roughness convention.
  138828. *
  138829. * This fits to the PBR convention in the GLTF definition:
  138830. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138831. */
  138832. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138833. /**
  138834. * The base color has two different interpretations depending on the value of metalness.
  138835. * When the material is a metal, the base color is the specific measured reflectance value
  138836. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138837. * of the material.
  138838. */
  138839. baseColor: Color3;
  138840. /**
  138841. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138842. * well as opacity information in the alpha channel.
  138843. */
  138844. baseTexture: BaseTexture;
  138845. /**
  138846. * Specifies the metallic scalar value of the material.
  138847. * Can also be used to scale the metalness values of the metallic texture.
  138848. */
  138849. metallic: number;
  138850. /**
  138851. * Specifies the roughness scalar value of the material.
  138852. * Can also be used to scale the roughness values of the metallic texture.
  138853. */
  138854. roughness: number;
  138855. /**
  138856. * Texture containing both the metallic value in the B channel and the
  138857. * roughness value in the G channel to keep better precision.
  138858. */
  138859. metallicRoughnessTexture: BaseTexture;
  138860. /**
  138861. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138862. *
  138863. * @param name The material name
  138864. * @param scene The scene the material will be use in.
  138865. */
  138866. constructor(name: string, scene: Scene);
  138867. /**
  138868. * Return the currrent class name of the material.
  138869. */
  138870. getClassName(): string;
  138871. /**
  138872. * Makes a duplicate of the current material.
  138873. * @param name - name to use for the new material.
  138874. */
  138875. clone(name: string): PBRMetallicRoughnessMaterial;
  138876. /**
  138877. * Serialize the material to a parsable JSON object.
  138878. */
  138879. serialize(): any;
  138880. /**
  138881. * Parses a JSON object correponding to the serialize function.
  138882. */
  138883. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138884. }
  138885. }
  138886. declare module BABYLON {
  138887. /**
  138888. * The PBR material of BJS following the specular glossiness convention.
  138889. *
  138890. * This fits to the PBR convention in the GLTF definition:
  138891. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138892. */
  138893. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138894. /**
  138895. * Specifies the diffuse color of the material.
  138896. */
  138897. diffuseColor: Color3;
  138898. /**
  138899. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138900. * channel.
  138901. */
  138902. diffuseTexture: BaseTexture;
  138903. /**
  138904. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138905. */
  138906. specularColor: Color3;
  138907. /**
  138908. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138909. */
  138910. glossiness: number;
  138911. /**
  138912. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138913. */
  138914. specularGlossinessTexture: BaseTexture;
  138915. /**
  138916. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138917. *
  138918. * @param name The material name
  138919. * @param scene The scene the material will be use in.
  138920. */
  138921. constructor(name: string, scene: Scene);
  138922. /**
  138923. * Return the currrent class name of the material.
  138924. */
  138925. getClassName(): string;
  138926. /**
  138927. * Makes a duplicate of the current material.
  138928. * @param name - name to use for the new material.
  138929. */
  138930. clone(name: string): PBRSpecularGlossinessMaterial;
  138931. /**
  138932. * Serialize the material to a parsable JSON object.
  138933. */
  138934. serialize(): any;
  138935. /**
  138936. * Parses a JSON object correponding to the serialize function.
  138937. */
  138938. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138939. }
  138940. }
  138941. declare module BABYLON {
  138942. /**
  138943. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138944. * It can help converting any input color in a desired output one. This can then be used to create effects
  138945. * from sepia, black and white to sixties or futuristic rendering...
  138946. *
  138947. * The only supported format is currently 3dl.
  138948. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138949. */
  138950. export class ColorGradingTexture extends BaseTexture {
  138951. /**
  138952. * The texture URL.
  138953. */
  138954. url: string;
  138955. /**
  138956. * Empty line regex stored for GC.
  138957. */
  138958. private static _noneEmptyLineRegex;
  138959. private _textureMatrix;
  138960. private _onLoad;
  138961. /**
  138962. * Instantiates a ColorGradingTexture from the following parameters.
  138963. *
  138964. * @param url The location of the color gradind data (currently only supporting 3dl)
  138965. * @param sceneOrEngine The scene or engine the texture will be used in
  138966. * @param onLoad defines a callback triggered when the texture has been loaded
  138967. */
  138968. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138969. /**
  138970. * Fires the onload event from the constructor if requested.
  138971. */
  138972. private _triggerOnLoad;
  138973. /**
  138974. * Returns the texture matrix used in most of the material.
  138975. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138976. */
  138977. getTextureMatrix(): Matrix;
  138978. /**
  138979. * Occurs when the file being loaded is a .3dl LUT file.
  138980. */
  138981. private load3dlTexture;
  138982. /**
  138983. * Starts the loading process of the texture.
  138984. */
  138985. private loadTexture;
  138986. /**
  138987. * Clones the color gradind texture.
  138988. */
  138989. clone(): ColorGradingTexture;
  138990. /**
  138991. * Called during delayed load for textures.
  138992. */
  138993. delayLoad(): void;
  138994. /**
  138995. * Parses a color grading texture serialized by Babylon.
  138996. * @param parsedTexture The texture information being parsedTexture
  138997. * @param scene The scene to load the texture in
  138998. * @param rootUrl The root url of the data assets to load
  138999. * @return A color gradind texture
  139000. */
  139001. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139002. /**
  139003. * Serializes the LUT texture to json format.
  139004. */
  139005. serialize(): any;
  139006. }
  139007. }
  139008. declare module BABYLON {
  139009. /**
  139010. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139011. */
  139012. export class EquiRectangularCubeTexture extends BaseTexture {
  139013. /** The six faces of the cube. */
  139014. private static _FacesMapping;
  139015. private _noMipmap;
  139016. private _onLoad;
  139017. private _onError;
  139018. /** The size of the cubemap. */
  139019. private _size;
  139020. /** The buffer of the image. */
  139021. private _buffer;
  139022. /** The width of the input image. */
  139023. private _width;
  139024. /** The height of the input image. */
  139025. private _height;
  139026. /** The URL to the image. */
  139027. url: string;
  139028. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139029. coordinatesMode: number;
  139030. /**
  139031. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139032. * @param url The location of the image
  139033. * @param scene The scene the texture will be used in
  139034. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139035. * @param noMipmap Forces to not generate the mipmap if true
  139036. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139037. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139038. * @param onLoad — defines a callback called when texture is loaded
  139039. * @param onError — defines a callback called if there is an error
  139040. */
  139041. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139042. /**
  139043. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139044. */
  139045. private loadImage;
  139046. /**
  139047. * Convert the image buffer into a cubemap and create a CubeTexture.
  139048. */
  139049. private loadTexture;
  139050. /**
  139051. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139052. * @param buffer The ArrayBuffer that should be converted.
  139053. * @returns The buffer as Float32Array.
  139054. */
  139055. private getFloat32ArrayFromArrayBuffer;
  139056. /**
  139057. * Get the current class name of the texture useful for serialization or dynamic coding.
  139058. * @returns "EquiRectangularCubeTexture"
  139059. */
  139060. getClassName(): string;
  139061. /**
  139062. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139063. * @returns A clone of the current EquiRectangularCubeTexture.
  139064. */
  139065. clone(): EquiRectangularCubeTexture;
  139066. }
  139067. }
  139068. declare module BABYLON {
  139069. /**
  139070. * Defines the options related to the creation of an HtmlElementTexture
  139071. */
  139072. export interface IHtmlElementTextureOptions {
  139073. /**
  139074. * Defines wether mip maps should be created or not.
  139075. */
  139076. generateMipMaps?: boolean;
  139077. /**
  139078. * Defines the sampling mode of the texture.
  139079. */
  139080. samplingMode?: number;
  139081. /**
  139082. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139083. */
  139084. engine: Nullable<ThinEngine>;
  139085. /**
  139086. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139087. */
  139088. scene: Nullable<Scene>;
  139089. }
  139090. /**
  139091. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  139092. * To be as efficient as possible depending on your constraints nothing aside the first upload
  139093. * is automatically managed.
  139094. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  139095. * in your application.
  139096. *
  139097. * As the update is not automatic, you need to call them manually.
  139098. */
  139099. export class HtmlElementTexture extends BaseTexture {
  139100. /**
  139101. * The texture URL.
  139102. */
  139103. element: HTMLVideoElement | HTMLCanvasElement;
  139104. private static readonly DefaultOptions;
  139105. private _textureMatrix;
  139106. private _isVideo;
  139107. private _generateMipMaps;
  139108. private _samplingMode;
  139109. /**
  139110. * Instantiates a HtmlElementTexture from the following parameters.
  139111. *
  139112. * @param name Defines the name of the texture
  139113. * @param element Defines the video or canvas the texture is filled with
  139114. * @param options Defines the other none mandatory texture creation options
  139115. */
  139116. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  139117. private _createInternalTexture;
  139118. /**
  139119. * Returns the texture matrix used in most of the material.
  139120. */
  139121. getTextureMatrix(): Matrix;
  139122. /**
  139123. * Updates the content of the texture.
  139124. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  139125. */
  139126. update(invertY?: Nullable<boolean>): void;
  139127. }
  139128. }
  139129. declare module BABYLON {
  139130. /**
  139131. * Based on jsTGALoader - Javascript loader for TGA file
  139132. * By Vincent Thibault
  139133. * @see http://blog.robrowser.com/javascript-tga-loader.html
  139134. */
  139135. export class TGATools {
  139136. private static _TYPE_INDEXED;
  139137. private static _TYPE_RGB;
  139138. private static _TYPE_GREY;
  139139. private static _TYPE_RLE_INDEXED;
  139140. private static _TYPE_RLE_RGB;
  139141. private static _TYPE_RLE_GREY;
  139142. private static _ORIGIN_MASK;
  139143. private static _ORIGIN_SHIFT;
  139144. private static _ORIGIN_BL;
  139145. private static _ORIGIN_BR;
  139146. private static _ORIGIN_UL;
  139147. private static _ORIGIN_UR;
  139148. /**
  139149. * Gets the header of a TGA file
  139150. * @param data defines the TGA data
  139151. * @returns the header
  139152. */
  139153. static GetTGAHeader(data: Uint8Array): any;
  139154. /**
  139155. * Uploads TGA content to a Babylon Texture
  139156. * @hidden
  139157. */
  139158. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  139159. /** @hidden */
  139160. 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;
  139161. /** @hidden */
  139162. 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;
  139163. /** @hidden */
  139164. 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;
  139165. /** @hidden */
  139166. 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;
  139167. /** @hidden */
  139168. 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;
  139169. /** @hidden */
  139170. 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;
  139171. }
  139172. }
  139173. declare module BABYLON {
  139174. /**
  139175. * Implementation of the TGA Texture Loader.
  139176. * @hidden
  139177. */
  139178. export class _TGATextureLoader implements IInternalTextureLoader {
  139179. /**
  139180. * Defines wether the loader supports cascade loading the different faces.
  139181. */
  139182. readonly supportCascades: boolean;
  139183. /**
  139184. * This returns if the loader support the current file information.
  139185. * @param extension defines the file extension of the file being loaded
  139186. * @returns true if the loader can load the specified file
  139187. */
  139188. canLoad(extension: string): boolean;
  139189. /**
  139190. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139191. * @param data contains the texture data
  139192. * @param texture defines the BabylonJS internal texture
  139193. * @param createPolynomials will be true if polynomials have been requested
  139194. * @param onLoad defines the callback to trigger once the texture is ready
  139195. * @param onError defines the callback to trigger in case of error
  139196. */
  139197. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139198. /**
  139199. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139200. * @param data contains the texture data
  139201. * @param texture defines the BabylonJS internal texture
  139202. * @param callback defines the method to call once ready to upload
  139203. */
  139204. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139205. }
  139206. }
  139207. declare module BABYLON {
  139208. /**
  139209. * Info about the .basis files
  139210. */
  139211. class BasisFileInfo {
  139212. /**
  139213. * If the file has alpha
  139214. */
  139215. hasAlpha: boolean;
  139216. /**
  139217. * Info about each image of the basis file
  139218. */
  139219. images: Array<{
  139220. levels: Array<{
  139221. width: number;
  139222. height: number;
  139223. transcodedPixels: ArrayBufferView;
  139224. }>;
  139225. }>;
  139226. }
  139227. /**
  139228. * Result of transcoding a basis file
  139229. */
  139230. class TranscodeResult {
  139231. /**
  139232. * Info about the .basis file
  139233. */
  139234. fileInfo: BasisFileInfo;
  139235. /**
  139236. * Format to use when loading the file
  139237. */
  139238. format: number;
  139239. }
  139240. /**
  139241. * Configuration options for the Basis transcoder
  139242. */
  139243. export class BasisTranscodeConfiguration {
  139244. /**
  139245. * Supported compression formats used to determine the supported output format of the transcoder
  139246. */
  139247. supportedCompressionFormats?: {
  139248. /**
  139249. * etc1 compression format
  139250. */
  139251. etc1?: boolean;
  139252. /**
  139253. * s3tc compression format
  139254. */
  139255. s3tc?: boolean;
  139256. /**
  139257. * pvrtc compression format
  139258. */
  139259. pvrtc?: boolean;
  139260. /**
  139261. * etc2 compression format
  139262. */
  139263. etc2?: boolean;
  139264. };
  139265. /**
  139266. * If mipmap levels should be loaded for transcoded images (Default: true)
  139267. */
  139268. loadMipmapLevels?: boolean;
  139269. /**
  139270. * Index of a single image to load (Default: all images)
  139271. */
  139272. loadSingleImage?: number;
  139273. }
  139274. /**
  139275. * Used to load .Basis files
  139276. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  139277. */
  139278. export class BasisTools {
  139279. private static _IgnoreSupportedFormats;
  139280. /**
  139281. * URL to use when loading the basis transcoder
  139282. */
  139283. static JSModuleURL: string;
  139284. /**
  139285. * URL to use when loading the wasm module for the transcoder
  139286. */
  139287. static WasmModuleURL: string;
  139288. /**
  139289. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  139290. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  139291. * @returns internal format corresponding to the Basis format
  139292. */
  139293. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  139294. private static _WorkerPromise;
  139295. private static _Worker;
  139296. private static _actionId;
  139297. private static _CreateWorkerAsync;
  139298. /**
  139299. * Transcodes a loaded image file to compressed pixel data
  139300. * @param data image data to transcode
  139301. * @param config configuration options for the transcoding
  139302. * @returns a promise resulting in the transcoded image
  139303. */
  139304. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  139305. /**
  139306. * Loads a texture from the transcode result
  139307. * @param texture texture load to
  139308. * @param transcodeResult the result of transcoding the basis file to load from
  139309. */
  139310. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  139311. }
  139312. }
  139313. declare module BABYLON {
  139314. /**
  139315. * Loader for .basis file format
  139316. */
  139317. export class _BasisTextureLoader implements IInternalTextureLoader {
  139318. /**
  139319. * Defines whether the loader supports cascade loading the different faces.
  139320. */
  139321. readonly supportCascades: boolean;
  139322. /**
  139323. * This returns if the loader support the current file information.
  139324. * @param extension defines the file extension of the file being loaded
  139325. * @returns true if the loader can load the specified file
  139326. */
  139327. canLoad(extension: string): boolean;
  139328. /**
  139329. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139330. * @param data contains the texture data
  139331. * @param texture defines the BabylonJS internal texture
  139332. * @param createPolynomials will be true if polynomials have been requested
  139333. * @param onLoad defines the callback to trigger once the texture is ready
  139334. * @param onError defines the callback to trigger in case of error
  139335. */
  139336. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139337. /**
  139338. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139339. * @param data contains the texture data
  139340. * @param texture defines the BabylonJS internal texture
  139341. * @param callback defines the method to call once ready to upload
  139342. */
  139343. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139344. }
  139345. }
  139346. declare module BABYLON {
  139347. /**
  139348. * Defines the basic options interface of a TexturePacker Frame
  139349. */
  139350. export interface ITexturePackerFrame {
  139351. /**
  139352. * The frame ID
  139353. */
  139354. id: number;
  139355. /**
  139356. * The frames Scale
  139357. */
  139358. scale: Vector2;
  139359. /**
  139360. * The Frames offset
  139361. */
  139362. offset: Vector2;
  139363. }
  139364. /**
  139365. * This is a support class for frame Data on texture packer sets.
  139366. */
  139367. export class TexturePackerFrame implements ITexturePackerFrame {
  139368. /**
  139369. * The frame ID
  139370. */
  139371. id: number;
  139372. /**
  139373. * The frames Scale
  139374. */
  139375. scale: Vector2;
  139376. /**
  139377. * The Frames offset
  139378. */
  139379. offset: Vector2;
  139380. /**
  139381. * Initializes a texture package frame.
  139382. * @param id The numerical frame identifier
  139383. * @param scale Scalar Vector2 for UV frame
  139384. * @param offset Vector2 for the frame position in UV units.
  139385. * @returns TexturePackerFrame
  139386. */
  139387. constructor(id: number, scale: Vector2, offset: Vector2);
  139388. }
  139389. }
  139390. declare module BABYLON {
  139391. /**
  139392. * Defines the basic options interface of a TexturePacker
  139393. */
  139394. export interface ITexturePackerOptions {
  139395. /**
  139396. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139397. */
  139398. map?: string[];
  139399. /**
  139400. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139401. */
  139402. uvsIn?: string;
  139403. /**
  139404. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139405. */
  139406. uvsOut?: string;
  139407. /**
  139408. * number representing the layout style. Defaults to LAYOUT_STRIP
  139409. */
  139410. layout?: number;
  139411. /**
  139412. * number of columns if using custom column count layout(2). This defaults to 4.
  139413. */
  139414. colnum?: number;
  139415. /**
  139416. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139417. */
  139418. updateInputMeshes?: boolean;
  139419. /**
  139420. * boolean flag to dispose all the source textures. Defaults to true.
  139421. */
  139422. disposeSources?: boolean;
  139423. /**
  139424. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139425. */
  139426. fillBlanks?: boolean;
  139427. /**
  139428. * string value representing the context fill style color. Defaults to 'black'.
  139429. */
  139430. customFillColor?: string;
  139431. /**
  139432. * Width and Height Value of each Frame in the TexturePacker Sets
  139433. */
  139434. frameSize?: number;
  139435. /**
  139436. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139437. */
  139438. paddingRatio?: number;
  139439. /**
  139440. * Number that declares the fill method for the padding gutter.
  139441. */
  139442. paddingMode?: number;
  139443. /**
  139444. * If in SUBUV_COLOR padding mode what color to use.
  139445. */
  139446. paddingColor?: Color3 | Color4;
  139447. }
  139448. /**
  139449. * Defines the basic interface of a TexturePacker JSON File
  139450. */
  139451. export interface ITexturePackerJSON {
  139452. /**
  139453. * The frame ID
  139454. */
  139455. name: string;
  139456. /**
  139457. * The base64 channel data
  139458. */
  139459. sets: any;
  139460. /**
  139461. * The options of the Packer
  139462. */
  139463. options: ITexturePackerOptions;
  139464. /**
  139465. * The frame data of the Packer
  139466. */
  139467. frames: Array<number>;
  139468. }
  139469. /**
  139470. * This is a support class that generates a series of packed texture sets.
  139471. * @see https://doc.babylonjs.com/babylon101/materials
  139472. */
  139473. export class TexturePacker {
  139474. /** Packer Layout Constant 0 */
  139475. static readonly LAYOUT_STRIP: number;
  139476. /** Packer Layout Constant 1 */
  139477. static readonly LAYOUT_POWER2: number;
  139478. /** Packer Layout Constant 2 */
  139479. static readonly LAYOUT_COLNUM: number;
  139480. /** Packer Layout Constant 0 */
  139481. static readonly SUBUV_WRAP: number;
  139482. /** Packer Layout Constant 1 */
  139483. static readonly SUBUV_EXTEND: number;
  139484. /** Packer Layout Constant 2 */
  139485. static readonly SUBUV_COLOR: number;
  139486. /** The Name of the Texture Package */
  139487. name: string;
  139488. /** The scene scope of the TexturePacker */
  139489. scene: Scene;
  139490. /** The Meshes to target */
  139491. meshes: AbstractMesh[];
  139492. /** Arguments passed with the Constructor */
  139493. options: ITexturePackerOptions;
  139494. /** The promise that is started upon initialization */
  139495. promise: Nullable<Promise<TexturePacker | string>>;
  139496. /** The Container object for the channel sets that are generated */
  139497. sets: object;
  139498. /** The Container array for the frames that are generated */
  139499. frames: TexturePackerFrame[];
  139500. /** The expected number of textures the system is parsing. */
  139501. private _expecting;
  139502. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139503. private _paddingValue;
  139504. /**
  139505. * Initializes a texture package series from an array of meshes or a single mesh.
  139506. * @param name The name of the package
  139507. * @param meshes The target meshes to compose the package from
  139508. * @param options The arguments that texture packer should follow while building.
  139509. * @param scene The scene which the textures are scoped to.
  139510. * @returns TexturePacker
  139511. */
  139512. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139513. /**
  139514. * Starts the package process
  139515. * @param resolve The promises resolution function
  139516. * @returns TexturePacker
  139517. */
  139518. private _createFrames;
  139519. /**
  139520. * Calculates the Size of the Channel Sets
  139521. * @returns Vector2
  139522. */
  139523. private _calculateSize;
  139524. /**
  139525. * Calculates the UV data for the frames.
  139526. * @param baseSize the base frameSize
  139527. * @param padding the base frame padding
  139528. * @param dtSize size of the Dynamic Texture for that channel
  139529. * @param dtUnits is 1/dtSize
  139530. * @param update flag to update the input meshes
  139531. */
  139532. private _calculateMeshUVFrames;
  139533. /**
  139534. * Calculates the frames Offset.
  139535. * @param index of the frame
  139536. * @returns Vector2
  139537. */
  139538. private _getFrameOffset;
  139539. /**
  139540. * Updates a Mesh to the frame data
  139541. * @param mesh that is the target
  139542. * @param frameID or the frame index
  139543. */
  139544. private _updateMeshUV;
  139545. /**
  139546. * Updates a Meshes materials to use the texture packer channels
  139547. * @param m is the mesh to target
  139548. * @param force all channels on the packer to be set.
  139549. */
  139550. private _updateTextureReferences;
  139551. /**
  139552. * Public method to set a Mesh to a frame
  139553. * @param m that is the target
  139554. * @param frameID or the frame index
  139555. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139556. */
  139557. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139558. /**
  139559. * Starts the async promise to compile the texture packer.
  139560. * @returns Promise<void>
  139561. */
  139562. processAsync(): Promise<void>;
  139563. /**
  139564. * Disposes all textures associated with this packer
  139565. */
  139566. dispose(): void;
  139567. /**
  139568. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139569. * @param imageType is the image type to use.
  139570. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139571. */
  139572. download(imageType?: string, quality?: number): void;
  139573. /**
  139574. * Public method to load a texturePacker JSON file.
  139575. * @param data of the JSON file in string format.
  139576. */
  139577. updateFromJSON(data: string): void;
  139578. }
  139579. }
  139580. declare module BABYLON {
  139581. /**
  139582. * 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.
  139583. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139584. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139585. */
  139586. export class CustomProceduralTexture extends ProceduralTexture {
  139587. private _animate;
  139588. private _time;
  139589. private _config;
  139590. private _texturePath;
  139591. /**
  139592. * Instantiates a new Custom Procedural Texture.
  139593. * 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.
  139594. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139595. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139596. * @param name Define the name of the texture
  139597. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139598. * @param size Define the size of the texture to create
  139599. * @param scene Define the scene the texture belongs to
  139600. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139601. * @param generateMipMaps Define if the texture should creates mip maps or not
  139602. */
  139603. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139604. private _loadJson;
  139605. /**
  139606. * Is the texture ready to be used ? (rendered at least once)
  139607. * @returns true if ready, otherwise, false.
  139608. */
  139609. isReady(): boolean;
  139610. /**
  139611. * Render the texture to its associated render target.
  139612. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139613. */
  139614. render(useCameraPostProcess?: boolean): void;
  139615. /**
  139616. * Update the list of dependant textures samplers in the shader.
  139617. */
  139618. updateTextures(): void;
  139619. /**
  139620. * Update the uniform values of the procedural texture in the shader.
  139621. */
  139622. updateShaderUniforms(): void;
  139623. /**
  139624. * Define if the texture animates or not.
  139625. */
  139626. get animate(): boolean;
  139627. set animate(value: boolean);
  139628. }
  139629. }
  139630. declare module BABYLON {
  139631. /** @hidden */
  139632. export var noisePixelShader: {
  139633. name: string;
  139634. shader: string;
  139635. };
  139636. }
  139637. declare module BABYLON {
  139638. /**
  139639. * Class used to generate noise procedural textures
  139640. */
  139641. export class NoiseProceduralTexture extends ProceduralTexture {
  139642. private _time;
  139643. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139644. brightness: number;
  139645. /** Defines the number of octaves to process */
  139646. octaves: number;
  139647. /** Defines the level of persistence (0.8 by default) */
  139648. persistence: number;
  139649. /** Gets or sets animation speed factor (default is 1) */
  139650. animationSpeedFactor: number;
  139651. /**
  139652. * Creates a new NoiseProceduralTexture
  139653. * @param name defines the name fo the texture
  139654. * @param size defines the size of the texture (default is 256)
  139655. * @param scene defines the hosting scene
  139656. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139657. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139658. */
  139659. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139660. private _updateShaderUniforms;
  139661. protected _getDefines(): string;
  139662. /** Generate the current state of the procedural texture */
  139663. render(useCameraPostProcess?: boolean): void;
  139664. /**
  139665. * Serializes this noise procedural texture
  139666. * @returns a serialized noise procedural texture object
  139667. */
  139668. serialize(): any;
  139669. /**
  139670. * Clone the texture.
  139671. * @returns the cloned texture
  139672. */
  139673. clone(): NoiseProceduralTexture;
  139674. /**
  139675. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139676. * @param parsedTexture defines parsed texture data
  139677. * @param scene defines the current scene
  139678. * @param rootUrl defines the root URL containing noise procedural texture information
  139679. * @returns a parsed NoiseProceduralTexture
  139680. */
  139681. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139682. }
  139683. }
  139684. declare module BABYLON {
  139685. /**
  139686. * Raw cube texture where the raw buffers are passed in
  139687. */
  139688. export class RawCubeTexture extends CubeTexture {
  139689. /**
  139690. * Creates a cube texture where the raw buffers are passed in.
  139691. * @param scene defines the scene the texture is attached to
  139692. * @param data defines the array of data to use to create each face
  139693. * @param size defines the size of the textures
  139694. * @param format defines the format of the data
  139695. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139696. * @param generateMipMaps defines if the engine should generate the mip levels
  139697. * @param invertY defines if data must be stored with Y axis inverted
  139698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139699. * @param compression defines the compression used (null by default)
  139700. */
  139701. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139702. /**
  139703. * Updates the raw cube texture.
  139704. * @param data defines the data to store
  139705. * @param format defines the data format
  139706. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139707. * @param invertY defines if data must be stored with Y axis inverted
  139708. * @param compression defines the compression used (null by default)
  139709. * @param level defines which level of the texture to update
  139710. */
  139711. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139712. /**
  139713. * Updates a raw cube texture with RGBD encoded data.
  139714. * @param data defines the array of data [mipmap][face] to use to create each face
  139715. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139718. * @returns a promsie that resolves when the operation is complete
  139719. */
  139720. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139721. /**
  139722. * Clones the raw cube texture.
  139723. * @return a new cube texture
  139724. */
  139725. clone(): CubeTexture;
  139726. /** @hidden */
  139727. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139728. }
  139729. }
  139730. declare module BABYLON {
  139731. /**
  139732. * Class used to store 2D array textures containing user data
  139733. */
  139734. export class RawTexture2DArray extends Texture {
  139735. /** Gets or sets the texture format to use */
  139736. format: number;
  139737. /**
  139738. * Create a new RawTexture2DArray
  139739. * @param data defines the data of the texture
  139740. * @param width defines the width of the texture
  139741. * @param height defines the height of the texture
  139742. * @param depth defines the number of layers of the texture
  139743. * @param format defines the texture format to use
  139744. * @param scene defines the hosting scene
  139745. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139746. * @param invertY defines if texture must be stored with Y axis inverted
  139747. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139749. */
  139750. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139751. /** Gets or sets the texture format to use */
  139752. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139753. /**
  139754. * Update the texture with new data
  139755. * @param data defines the data to store in the texture
  139756. */
  139757. update(data: ArrayBufferView): void;
  139758. }
  139759. }
  139760. declare module BABYLON {
  139761. /**
  139762. * Class used to store 3D textures containing user data
  139763. */
  139764. export class RawTexture3D extends Texture {
  139765. /** Gets or sets the texture format to use */
  139766. format: number;
  139767. /**
  139768. * Create a new RawTexture3D
  139769. * @param data defines the data of the texture
  139770. * @param width defines the width of the texture
  139771. * @param height defines the height of the texture
  139772. * @param depth defines the depth of the texture
  139773. * @param format defines the texture format to use
  139774. * @param scene defines the hosting scene
  139775. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139776. * @param invertY defines if texture must be stored with Y axis inverted
  139777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139778. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139779. */
  139780. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139781. /** Gets or sets the texture format to use */
  139782. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139783. /**
  139784. * Update the texture with new data
  139785. * @param data defines the data to store in the texture
  139786. */
  139787. update(data: ArrayBufferView): void;
  139788. }
  139789. }
  139790. declare module BABYLON {
  139791. /**
  139792. * Creates a refraction texture used by refraction channel of the standard material.
  139793. * It is like a mirror but to see through a material.
  139794. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139795. */
  139796. export class RefractionTexture extends RenderTargetTexture {
  139797. /**
  139798. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139799. * 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.
  139800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139801. */
  139802. refractionPlane: Plane;
  139803. /**
  139804. * Define how deep under the surface we should see.
  139805. */
  139806. depth: number;
  139807. /**
  139808. * Creates a refraction texture used by refraction channel of the standard material.
  139809. * It is like a mirror but to see through a material.
  139810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139811. * @param name Define the texture name
  139812. * @param size Define the size of the underlying texture
  139813. * @param scene Define the scene the refraction belongs to
  139814. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139815. */
  139816. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139817. /**
  139818. * Clone the refraction texture.
  139819. * @returns the cloned texture
  139820. */
  139821. clone(): RefractionTexture;
  139822. /**
  139823. * Serialize the texture to a JSON representation you could use in Parse later on
  139824. * @returns the serialized JSON representation
  139825. */
  139826. serialize(): any;
  139827. }
  139828. }
  139829. declare module BABYLON {
  139830. /**
  139831. * Block used to add support for vertex skinning (bones)
  139832. */
  139833. export class BonesBlock extends NodeMaterialBlock {
  139834. /**
  139835. * Creates a new BonesBlock
  139836. * @param name defines the block name
  139837. */
  139838. constructor(name: string);
  139839. /**
  139840. * Initialize the block and prepare the context for build
  139841. * @param state defines the state that will be used for the build
  139842. */
  139843. initialize(state: NodeMaterialBuildState): void;
  139844. /**
  139845. * Gets the current class name
  139846. * @returns the class name
  139847. */
  139848. getClassName(): string;
  139849. /**
  139850. * Gets the matrix indices input component
  139851. */
  139852. get matricesIndices(): NodeMaterialConnectionPoint;
  139853. /**
  139854. * Gets the matrix weights input component
  139855. */
  139856. get matricesWeights(): NodeMaterialConnectionPoint;
  139857. /**
  139858. * Gets the extra matrix indices input component
  139859. */
  139860. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139861. /**
  139862. * Gets the extra matrix weights input component
  139863. */
  139864. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139865. /**
  139866. * Gets the world input component
  139867. */
  139868. get world(): NodeMaterialConnectionPoint;
  139869. /**
  139870. * Gets the output component
  139871. */
  139872. get output(): NodeMaterialConnectionPoint;
  139873. autoConfigure(material: NodeMaterial): void;
  139874. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139877. protected _buildBlock(state: NodeMaterialBuildState): this;
  139878. }
  139879. }
  139880. declare module BABYLON {
  139881. /**
  139882. * Block used to add support for instances
  139883. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139884. */
  139885. export class InstancesBlock extends NodeMaterialBlock {
  139886. /**
  139887. * Creates a new InstancesBlock
  139888. * @param name defines the block name
  139889. */
  139890. constructor(name: string);
  139891. /**
  139892. * Gets the current class name
  139893. * @returns the class name
  139894. */
  139895. getClassName(): string;
  139896. /**
  139897. * Gets the first world row input component
  139898. */
  139899. get world0(): NodeMaterialConnectionPoint;
  139900. /**
  139901. * Gets the second world row input component
  139902. */
  139903. get world1(): NodeMaterialConnectionPoint;
  139904. /**
  139905. * Gets the third world row input component
  139906. */
  139907. get world2(): NodeMaterialConnectionPoint;
  139908. /**
  139909. * Gets the forth world row input component
  139910. */
  139911. get world3(): NodeMaterialConnectionPoint;
  139912. /**
  139913. * Gets the world input component
  139914. */
  139915. get world(): NodeMaterialConnectionPoint;
  139916. /**
  139917. * Gets the output component
  139918. */
  139919. get output(): NodeMaterialConnectionPoint;
  139920. /**
  139921. * Gets the isntanceID component
  139922. */
  139923. get instanceID(): NodeMaterialConnectionPoint;
  139924. autoConfigure(material: NodeMaterial): void;
  139925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139926. protected _buildBlock(state: NodeMaterialBuildState): this;
  139927. }
  139928. }
  139929. declare module BABYLON {
  139930. /**
  139931. * Block used to add morph targets support to vertex shader
  139932. */
  139933. export class MorphTargetsBlock extends NodeMaterialBlock {
  139934. private _repeatableContentAnchor;
  139935. /**
  139936. * Create a new MorphTargetsBlock
  139937. * @param name defines the block name
  139938. */
  139939. constructor(name: string);
  139940. /**
  139941. * Gets the current class name
  139942. * @returns the class name
  139943. */
  139944. getClassName(): string;
  139945. /**
  139946. * Gets the position input component
  139947. */
  139948. get position(): NodeMaterialConnectionPoint;
  139949. /**
  139950. * Gets the normal input component
  139951. */
  139952. get normal(): NodeMaterialConnectionPoint;
  139953. /**
  139954. * Gets the tangent input component
  139955. */
  139956. get tangent(): NodeMaterialConnectionPoint;
  139957. /**
  139958. * Gets the tangent input component
  139959. */
  139960. get uv(): NodeMaterialConnectionPoint;
  139961. /**
  139962. * Gets the position output component
  139963. */
  139964. get positionOutput(): NodeMaterialConnectionPoint;
  139965. /**
  139966. * Gets the normal output component
  139967. */
  139968. get normalOutput(): NodeMaterialConnectionPoint;
  139969. /**
  139970. * Gets the tangent output component
  139971. */
  139972. get tangentOutput(): NodeMaterialConnectionPoint;
  139973. /**
  139974. * Gets the tangent output component
  139975. */
  139976. get uvOutput(): NodeMaterialConnectionPoint;
  139977. initialize(state: NodeMaterialBuildState): void;
  139978. autoConfigure(material: NodeMaterial): void;
  139979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139981. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139982. protected _buildBlock(state: NodeMaterialBuildState): this;
  139983. }
  139984. }
  139985. declare module BABYLON {
  139986. /**
  139987. * Block used to get data information from a light
  139988. */
  139989. export class LightInformationBlock extends NodeMaterialBlock {
  139990. private _lightDataUniformName;
  139991. private _lightColorUniformName;
  139992. private _lightTypeDefineName;
  139993. /**
  139994. * Gets or sets the light associated with this block
  139995. */
  139996. light: Nullable<Light>;
  139997. /**
  139998. * Creates a new LightInformationBlock
  139999. * @param name defines the block name
  140000. */
  140001. constructor(name: string);
  140002. /**
  140003. * Gets the current class name
  140004. * @returns the class name
  140005. */
  140006. getClassName(): string;
  140007. /**
  140008. * Gets the world position input component
  140009. */
  140010. get worldPosition(): NodeMaterialConnectionPoint;
  140011. /**
  140012. * Gets the direction output component
  140013. */
  140014. get direction(): NodeMaterialConnectionPoint;
  140015. /**
  140016. * Gets the direction output component
  140017. */
  140018. get color(): NodeMaterialConnectionPoint;
  140019. /**
  140020. * Gets the direction output component
  140021. */
  140022. get intensity(): NodeMaterialConnectionPoint;
  140023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140025. protected _buildBlock(state: NodeMaterialBuildState): this;
  140026. serialize(): any;
  140027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140028. }
  140029. }
  140030. declare module BABYLON {
  140031. /**
  140032. * Block used to add image processing support to fragment shader
  140033. */
  140034. export class ImageProcessingBlock extends NodeMaterialBlock {
  140035. /**
  140036. * Create a new ImageProcessingBlock
  140037. * @param name defines the block name
  140038. */
  140039. constructor(name: string);
  140040. /**
  140041. * Gets the current class name
  140042. * @returns the class name
  140043. */
  140044. getClassName(): string;
  140045. /**
  140046. * Gets the color input component
  140047. */
  140048. get color(): NodeMaterialConnectionPoint;
  140049. /**
  140050. * Gets the output component
  140051. */
  140052. get output(): NodeMaterialConnectionPoint;
  140053. /**
  140054. * Initialize the block and prepare the context for build
  140055. * @param state defines the state that will be used for the build
  140056. */
  140057. initialize(state: NodeMaterialBuildState): void;
  140058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140061. protected _buildBlock(state: NodeMaterialBuildState): this;
  140062. }
  140063. }
  140064. declare module BABYLON {
  140065. /**
  140066. * Block used to pertub normals based on a normal map
  140067. */
  140068. export class PerturbNormalBlock extends NodeMaterialBlock {
  140069. private _tangentSpaceParameterName;
  140070. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140071. invertX: boolean;
  140072. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140073. invertY: boolean;
  140074. /**
  140075. * Create a new PerturbNormalBlock
  140076. * @param name defines the block name
  140077. */
  140078. constructor(name: string);
  140079. /**
  140080. * Gets the current class name
  140081. * @returns the class name
  140082. */
  140083. getClassName(): string;
  140084. /**
  140085. * Gets the world position input component
  140086. */
  140087. get worldPosition(): NodeMaterialConnectionPoint;
  140088. /**
  140089. * Gets the world normal input component
  140090. */
  140091. get worldNormal(): NodeMaterialConnectionPoint;
  140092. /**
  140093. * Gets the world tangent input component
  140094. */
  140095. get worldTangent(): NodeMaterialConnectionPoint;
  140096. /**
  140097. * Gets the uv input component
  140098. */
  140099. get uv(): NodeMaterialConnectionPoint;
  140100. /**
  140101. * Gets the normal map color input component
  140102. */
  140103. get normalMapColor(): NodeMaterialConnectionPoint;
  140104. /**
  140105. * Gets the strength input component
  140106. */
  140107. get strength(): NodeMaterialConnectionPoint;
  140108. /**
  140109. * Gets the output component
  140110. */
  140111. get output(): NodeMaterialConnectionPoint;
  140112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140114. autoConfigure(material: NodeMaterial): void;
  140115. protected _buildBlock(state: NodeMaterialBuildState): this;
  140116. protected _dumpPropertiesCode(): string;
  140117. serialize(): any;
  140118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140119. }
  140120. }
  140121. declare module BABYLON {
  140122. /**
  140123. * Block used to discard a pixel if a value is smaller than a cutoff
  140124. */
  140125. export class DiscardBlock extends NodeMaterialBlock {
  140126. /**
  140127. * Create a new DiscardBlock
  140128. * @param name defines the block name
  140129. */
  140130. constructor(name: string);
  140131. /**
  140132. * Gets the current class name
  140133. * @returns the class name
  140134. */
  140135. getClassName(): string;
  140136. /**
  140137. * Gets the color input component
  140138. */
  140139. get value(): NodeMaterialConnectionPoint;
  140140. /**
  140141. * Gets the cutoff input component
  140142. */
  140143. get cutoff(): NodeMaterialConnectionPoint;
  140144. protected _buildBlock(state: NodeMaterialBuildState): this;
  140145. }
  140146. }
  140147. declare module BABYLON {
  140148. /**
  140149. * Block used to test if the fragment shader is front facing
  140150. */
  140151. export class FrontFacingBlock extends NodeMaterialBlock {
  140152. /**
  140153. * Creates a new FrontFacingBlock
  140154. * @param name defines the block name
  140155. */
  140156. constructor(name: string);
  140157. /**
  140158. * Gets the current class name
  140159. * @returns the class name
  140160. */
  140161. getClassName(): string;
  140162. /**
  140163. * Gets the output component
  140164. */
  140165. get output(): NodeMaterialConnectionPoint;
  140166. protected _buildBlock(state: NodeMaterialBuildState): this;
  140167. }
  140168. }
  140169. declare module BABYLON {
  140170. /**
  140171. * Block used to get the derivative value on x and y of a given input
  140172. */
  140173. export class DerivativeBlock extends NodeMaterialBlock {
  140174. /**
  140175. * Create a new DerivativeBlock
  140176. * @param name defines the block name
  140177. */
  140178. constructor(name: string);
  140179. /**
  140180. * Gets the current class name
  140181. * @returns the class name
  140182. */
  140183. getClassName(): string;
  140184. /**
  140185. * Gets the input component
  140186. */
  140187. get input(): NodeMaterialConnectionPoint;
  140188. /**
  140189. * Gets the derivative output on x
  140190. */
  140191. get dx(): NodeMaterialConnectionPoint;
  140192. /**
  140193. * Gets the derivative output on y
  140194. */
  140195. get dy(): NodeMaterialConnectionPoint;
  140196. protected _buildBlock(state: NodeMaterialBuildState): this;
  140197. }
  140198. }
  140199. declare module BABYLON {
  140200. /**
  140201. * Block used to make gl_FragCoord available
  140202. */
  140203. export class FragCoordBlock extends NodeMaterialBlock {
  140204. /**
  140205. * Creates a new FragCoordBlock
  140206. * @param name defines the block name
  140207. */
  140208. constructor(name: string);
  140209. /**
  140210. * Gets the current class name
  140211. * @returns the class name
  140212. */
  140213. getClassName(): string;
  140214. /**
  140215. * Gets the xy component
  140216. */
  140217. get xy(): NodeMaterialConnectionPoint;
  140218. /**
  140219. * Gets the xyz component
  140220. */
  140221. get xyz(): NodeMaterialConnectionPoint;
  140222. /**
  140223. * Gets the xyzw component
  140224. */
  140225. get xyzw(): NodeMaterialConnectionPoint;
  140226. /**
  140227. * Gets the x component
  140228. */
  140229. get x(): NodeMaterialConnectionPoint;
  140230. /**
  140231. * Gets the y component
  140232. */
  140233. get y(): NodeMaterialConnectionPoint;
  140234. /**
  140235. * Gets the z component
  140236. */
  140237. get z(): NodeMaterialConnectionPoint;
  140238. /**
  140239. * Gets the w component
  140240. */
  140241. get output(): NodeMaterialConnectionPoint;
  140242. protected writeOutputs(state: NodeMaterialBuildState): string;
  140243. protected _buildBlock(state: NodeMaterialBuildState): this;
  140244. }
  140245. }
  140246. declare module BABYLON {
  140247. /**
  140248. * Block used to get the screen sizes
  140249. */
  140250. export class ScreenSizeBlock extends NodeMaterialBlock {
  140251. private _varName;
  140252. private _scene;
  140253. /**
  140254. * Creates a new ScreenSizeBlock
  140255. * @param name defines the block name
  140256. */
  140257. constructor(name: string);
  140258. /**
  140259. * Gets the current class name
  140260. * @returns the class name
  140261. */
  140262. getClassName(): string;
  140263. /**
  140264. * Gets the xy component
  140265. */
  140266. get xy(): NodeMaterialConnectionPoint;
  140267. /**
  140268. * Gets the x component
  140269. */
  140270. get x(): NodeMaterialConnectionPoint;
  140271. /**
  140272. * Gets the y component
  140273. */
  140274. get y(): NodeMaterialConnectionPoint;
  140275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140276. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  140277. protected _buildBlock(state: NodeMaterialBuildState): this;
  140278. }
  140279. }
  140280. declare module BABYLON {
  140281. /**
  140282. * Block used to add support for scene fog
  140283. */
  140284. export class FogBlock extends NodeMaterialBlock {
  140285. private _fogDistanceName;
  140286. private _fogParameters;
  140287. /**
  140288. * Create a new FogBlock
  140289. * @param name defines the block name
  140290. */
  140291. constructor(name: string);
  140292. /**
  140293. * Gets the current class name
  140294. * @returns the class name
  140295. */
  140296. getClassName(): string;
  140297. /**
  140298. * Gets the world position input component
  140299. */
  140300. get worldPosition(): NodeMaterialConnectionPoint;
  140301. /**
  140302. * Gets the view input component
  140303. */
  140304. get view(): NodeMaterialConnectionPoint;
  140305. /**
  140306. * Gets the color input component
  140307. */
  140308. get input(): NodeMaterialConnectionPoint;
  140309. /**
  140310. * Gets the fog color input component
  140311. */
  140312. get fogColor(): NodeMaterialConnectionPoint;
  140313. /**
  140314. * Gets the output component
  140315. */
  140316. get output(): NodeMaterialConnectionPoint;
  140317. autoConfigure(material: NodeMaterial): void;
  140318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140320. protected _buildBlock(state: NodeMaterialBuildState): this;
  140321. }
  140322. }
  140323. declare module BABYLON {
  140324. /**
  140325. * Block used to add light in the fragment shader
  140326. */
  140327. export class LightBlock extends NodeMaterialBlock {
  140328. private _lightId;
  140329. /**
  140330. * Gets or sets the light associated with this block
  140331. */
  140332. light: Nullable<Light>;
  140333. /**
  140334. * Create a new LightBlock
  140335. * @param name defines the block name
  140336. */
  140337. constructor(name: string);
  140338. /**
  140339. * Gets the current class name
  140340. * @returns the class name
  140341. */
  140342. getClassName(): string;
  140343. /**
  140344. * Gets the world position input component
  140345. */
  140346. get worldPosition(): NodeMaterialConnectionPoint;
  140347. /**
  140348. * Gets the world normal input component
  140349. */
  140350. get worldNormal(): NodeMaterialConnectionPoint;
  140351. /**
  140352. * Gets the camera (or eye) position component
  140353. */
  140354. get cameraPosition(): NodeMaterialConnectionPoint;
  140355. /**
  140356. * Gets the glossiness component
  140357. */
  140358. get glossiness(): NodeMaterialConnectionPoint;
  140359. /**
  140360. * Gets the glossinness power component
  140361. */
  140362. get glossPower(): NodeMaterialConnectionPoint;
  140363. /**
  140364. * Gets the diffuse color component
  140365. */
  140366. get diffuseColor(): NodeMaterialConnectionPoint;
  140367. /**
  140368. * Gets the specular color component
  140369. */
  140370. get specularColor(): NodeMaterialConnectionPoint;
  140371. /**
  140372. * Gets the diffuse output component
  140373. */
  140374. get diffuseOutput(): NodeMaterialConnectionPoint;
  140375. /**
  140376. * Gets the specular output component
  140377. */
  140378. get specularOutput(): NodeMaterialConnectionPoint;
  140379. /**
  140380. * Gets the shadow output component
  140381. */
  140382. get shadow(): NodeMaterialConnectionPoint;
  140383. autoConfigure(material: NodeMaterial): void;
  140384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140385. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140387. private _injectVertexCode;
  140388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140389. serialize(): any;
  140390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140391. }
  140392. }
  140393. declare module BABYLON {
  140394. /**
  140395. * Block used to read a reflection texture from a sampler
  140396. */
  140397. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140398. /**
  140399. * Create a new ReflectionTextureBlock
  140400. * @param name defines the block name
  140401. */
  140402. constructor(name: string);
  140403. /**
  140404. * Gets the current class name
  140405. * @returns the class name
  140406. */
  140407. getClassName(): string;
  140408. /**
  140409. * Gets the world position input component
  140410. */
  140411. get position(): NodeMaterialConnectionPoint;
  140412. /**
  140413. * Gets the world position input component
  140414. */
  140415. get worldPosition(): NodeMaterialConnectionPoint;
  140416. /**
  140417. * Gets the world normal input component
  140418. */
  140419. get worldNormal(): NodeMaterialConnectionPoint;
  140420. /**
  140421. * Gets the world input component
  140422. */
  140423. get world(): NodeMaterialConnectionPoint;
  140424. /**
  140425. * Gets the camera (or eye) position component
  140426. */
  140427. get cameraPosition(): NodeMaterialConnectionPoint;
  140428. /**
  140429. * Gets the view input component
  140430. */
  140431. get view(): NodeMaterialConnectionPoint;
  140432. /**
  140433. * Gets the rgb output component
  140434. */
  140435. get rgb(): NodeMaterialConnectionPoint;
  140436. /**
  140437. * Gets the rgba output component
  140438. */
  140439. get rgba(): NodeMaterialConnectionPoint;
  140440. /**
  140441. * Gets the r output component
  140442. */
  140443. get r(): NodeMaterialConnectionPoint;
  140444. /**
  140445. * Gets the g output component
  140446. */
  140447. get g(): NodeMaterialConnectionPoint;
  140448. /**
  140449. * Gets the b output component
  140450. */
  140451. get b(): NodeMaterialConnectionPoint;
  140452. /**
  140453. * Gets the a output component
  140454. */
  140455. get a(): NodeMaterialConnectionPoint;
  140456. autoConfigure(material: NodeMaterial): void;
  140457. protected _buildBlock(state: NodeMaterialBuildState): this;
  140458. }
  140459. }
  140460. declare module BABYLON {
  140461. /**
  140462. * Block used to add 2 vectors
  140463. */
  140464. export class AddBlock extends NodeMaterialBlock {
  140465. /**
  140466. * Creates a new AddBlock
  140467. * @param name defines the block name
  140468. */
  140469. constructor(name: string);
  140470. /**
  140471. * Gets the current class name
  140472. * @returns the class name
  140473. */
  140474. getClassName(): string;
  140475. /**
  140476. * Gets the left operand input component
  140477. */
  140478. get left(): NodeMaterialConnectionPoint;
  140479. /**
  140480. * Gets the right operand input component
  140481. */
  140482. get right(): NodeMaterialConnectionPoint;
  140483. /**
  140484. * Gets the output component
  140485. */
  140486. get output(): NodeMaterialConnectionPoint;
  140487. protected _buildBlock(state: NodeMaterialBuildState): this;
  140488. }
  140489. }
  140490. declare module BABYLON {
  140491. /**
  140492. * Block used to scale a vector by a float
  140493. */
  140494. export class ScaleBlock extends NodeMaterialBlock {
  140495. /**
  140496. * Creates a new ScaleBlock
  140497. * @param name defines the block name
  140498. */
  140499. constructor(name: string);
  140500. /**
  140501. * Gets the current class name
  140502. * @returns the class name
  140503. */
  140504. getClassName(): string;
  140505. /**
  140506. * Gets the input component
  140507. */
  140508. get input(): NodeMaterialConnectionPoint;
  140509. /**
  140510. * Gets the factor input component
  140511. */
  140512. get factor(): NodeMaterialConnectionPoint;
  140513. /**
  140514. * Gets the output component
  140515. */
  140516. get output(): NodeMaterialConnectionPoint;
  140517. protected _buildBlock(state: NodeMaterialBuildState): this;
  140518. }
  140519. }
  140520. declare module BABYLON {
  140521. /**
  140522. * Block used to clamp a float
  140523. */
  140524. export class ClampBlock extends NodeMaterialBlock {
  140525. /** Gets or sets the minimum range */
  140526. minimum: number;
  140527. /** Gets or sets the maximum range */
  140528. maximum: number;
  140529. /**
  140530. * Creates a new ClampBlock
  140531. * @param name defines the block name
  140532. */
  140533. constructor(name: string);
  140534. /**
  140535. * Gets the current class name
  140536. * @returns the class name
  140537. */
  140538. getClassName(): string;
  140539. /**
  140540. * Gets the value input component
  140541. */
  140542. get value(): NodeMaterialConnectionPoint;
  140543. /**
  140544. * Gets the output component
  140545. */
  140546. get output(): NodeMaterialConnectionPoint;
  140547. protected _buildBlock(state: NodeMaterialBuildState): this;
  140548. protected _dumpPropertiesCode(): string;
  140549. serialize(): any;
  140550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140551. }
  140552. }
  140553. declare module BABYLON {
  140554. /**
  140555. * Block used to apply a cross product between 2 vectors
  140556. */
  140557. export class CrossBlock extends NodeMaterialBlock {
  140558. /**
  140559. * Creates a new CrossBlock
  140560. * @param name defines the block name
  140561. */
  140562. constructor(name: string);
  140563. /**
  140564. * Gets the current class name
  140565. * @returns the class name
  140566. */
  140567. getClassName(): string;
  140568. /**
  140569. * Gets the left operand input component
  140570. */
  140571. get left(): NodeMaterialConnectionPoint;
  140572. /**
  140573. * Gets the right operand input component
  140574. */
  140575. get right(): NodeMaterialConnectionPoint;
  140576. /**
  140577. * Gets the output component
  140578. */
  140579. get output(): NodeMaterialConnectionPoint;
  140580. protected _buildBlock(state: NodeMaterialBuildState): this;
  140581. }
  140582. }
  140583. declare module BABYLON {
  140584. /**
  140585. * Block used to apply a dot product between 2 vectors
  140586. */
  140587. export class DotBlock extends NodeMaterialBlock {
  140588. /**
  140589. * Creates a new DotBlock
  140590. * @param name defines the block name
  140591. */
  140592. constructor(name: string);
  140593. /**
  140594. * Gets the current class name
  140595. * @returns the class name
  140596. */
  140597. getClassName(): string;
  140598. /**
  140599. * Gets the left operand input component
  140600. */
  140601. get left(): NodeMaterialConnectionPoint;
  140602. /**
  140603. * Gets the right operand input component
  140604. */
  140605. get right(): NodeMaterialConnectionPoint;
  140606. /**
  140607. * Gets the output component
  140608. */
  140609. get output(): NodeMaterialConnectionPoint;
  140610. protected _buildBlock(state: NodeMaterialBuildState): this;
  140611. }
  140612. }
  140613. declare module BABYLON {
  140614. /**
  140615. * Block used to normalize a vector
  140616. */
  140617. export class NormalizeBlock extends NodeMaterialBlock {
  140618. /**
  140619. * Creates a new NormalizeBlock
  140620. * @param name defines the block name
  140621. */
  140622. constructor(name: string);
  140623. /**
  140624. * Gets the current class name
  140625. * @returns the class name
  140626. */
  140627. getClassName(): string;
  140628. /**
  140629. * Gets the input component
  140630. */
  140631. get input(): NodeMaterialConnectionPoint;
  140632. /**
  140633. * Gets the output component
  140634. */
  140635. get output(): NodeMaterialConnectionPoint;
  140636. protected _buildBlock(state: NodeMaterialBuildState): this;
  140637. }
  140638. }
  140639. declare module BABYLON {
  140640. /**
  140641. * Operations supported by the Trigonometry block
  140642. */
  140643. export enum TrigonometryBlockOperations {
  140644. /** Cos */
  140645. Cos = 0,
  140646. /** Sin */
  140647. Sin = 1,
  140648. /** Abs */
  140649. Abs = 2,
  140650. /** Exp */
  140651. Exp = 3,
  140652. /** Exp2 */
  140653. Exp2 = 4,
  140654. /** Round */
  140655. Round = 5,
  140656. /** Floor */
  140657. Floor = 6,
  140658. /** Ceiling */
  140659. Ceiling = 7,
  140660. /** Square root */
  140661. Sqrt = 8,
  140662. /** Log */
  140663. Log = 9,
  140664. /** Tangent */
  140665. Tan = 10,
  140666. /** Arc tangent */
  140667. ArcTan = 11,
  140668. /** Arc cosinus */
  140669. ArcCos = 12,
  140670. /** Arc sinus */
  140671. ArcSin = 13,
  140672. /** Fraction */
  140673. Fract = 14,
  140674. /** Sign */
  140675. Sign = 15,
  140676. /** To radians (from degrees) */
  140677. Radians = 16,
  140678. /** To degrees (from radians) */
  140679. Degrees = 17
  140680. }
  140681. /**
  140682. * Block used to apply trigonometry operation to floats
  140683. */
  140684. export class TrigonometryBlock extends NodeMaterialBlock {
  140685. /**
  140686. * Gets or sets the operation applied by the block
  140687. */
  140688. operation: TrigonometryBlockOperations;
  140689. /**
  140690. * Creates a new TrigonometryBlock
  140691. * @param name defines the block name
  140692. */
  140693. constructor(name: string);
  140694. /**
  140695. * Gets the current class name
  140696. * @returns the class name
  140697. */
  140698. getClassName(): string;
  140699. /**
  140700. * Gets the input component
  140701. */
  140702. get input(): NodeMaterialConnectionPoint;
  140703. /**
  140704. * Gets the output component
  140705. */
  140706. get output(): NodeMaterialConnectionPoint;
  140707. protected _buildBlock(state: NodeMaterialBuildState): this;
  140708. serialize(): any;
  140709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140710. protected _dumpPropertiesCode(): string;
  140711. }
  140712. }
  140713. declare module BABYLON {
  140714. /**
  140715. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140716. */
  140717. export class ColorMergerBlock extends NodeMaterialBlock {
  140718. /**
  140719. * Create a new ColorMergerBlock
  140720. * @param name defines the block name
  140721. */
  140722. constructor(name: string);
  140723. /**
  140724. * Gets the current class name
  140725. * @returns the class name
  140726. */
  140727. getClassName(): string;
  140728. /**
  140729. * Gets the rgb component (input)
  140730. */
  140731. get rgbIn(): NodeMaterialConnectionPoint;
  140732. /**
  140733. * Gets the r component (input)
  140734. */
  140735. get r(): NodeMaterialConnectionPoint;
  140736. /**
  140737. * Gets the g component (input)
  140738. */
  140739. get g(): NodeMaterialConnectionPoint;
  140740. /**
  140741. * Gets the b component (input)
  140742. */
  140743. get b(): NodeMaterialConnectionPoint;
  140744. /**
  140745. * Gets the a component (input)
  140746. */
  140747. get a(): NodeMaterialConnectionPoint;
  140748. /**
  140749. * Gets the rgba component (output)
  140750. */
  140751. get rgba(): NodeMaterialConnectionPoint;
  140752. /**
  140753. * Gets the rgb component (output)
  140754. */
  140755. get rgbOut(): NodeMaterialConnectionPoint;
  140756. /**
  140757. * Gets the rgb component (output)
  140758. * @deprecated Please use rgbOut instead.
  140759. */
  140760. get rgb(): NodeMaterialConnectionPoint;
  140761. protected _buildBlock(state: NodeMaterialBuildState): this;
  140762. }
  140763. }
  140764. declare module BABYLON {
  140765. /**
  140766. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140767. */
  140768. export class VectorSplitterBlock extends NodeMaterialBlock {
  140769. /**
  140770. * Create a new VectorSplitterBlock
  140771. * @param name defines the block name
  140772. */
  140773. constructor(name: string);
  140774. /**
  140775. * Gets the current class name
  140776. * @returns the class name
  140777. */
  140778. getClassName(): string;
  140779. /**
  140780. * Gets the xyzw component (input)
  140781. */
  140782. get xyzw(): NodeMaterialConnectionPoint;
  140783. /**
  140784. * Gets the xyz component (input)
  140785. */
  140786. get xyzIn(): NodeMaterialConnectionPoint;
  140787. /**
  140788. * Gets the xy component (input)
  140789. */
  140790. get xyIn(): NodeMaterialConnectionPoint;
  140791. /**
  140792. * Gets the xyz component (output)
  140793. */
  140794. get xyzOut(): NodeMaterialConnectionPoint;
  140795. /**
  140796. * Gets the xy component (output)
  140797. */
  140798. get xyOut(): NodeMaterialConnectionPoint;
  140799. /**
  140800. * Gets the x component (output)
  140801. */
  140802. get x(): NodeMaterialConnectionPoint;
  140803. /**
  140804. * Gets the y component (output)
  140805. */
  140806. get y(): NodeMaterialConnectionPoint;
  140807. /**
  140808. * Gets the z component (output)
  140809. */
  140810. get z(): NodeMaterialConnectionPoint;
  140811. /**
  140812. * Gets the w component (output)
  140813. */
  140814. get w(): NodeMaterialConnectionPoint;
  140815. protected _inputRename(name: string): string;
  140816. protected _outputRename(name: string): string;
  140817. protected _buildBlock(state: NodeMaterialBuildState): this;
  140818. }
  140819. }
  140820. declare module BABYLON {
  140821. /**
  140822. * Block used to lerp between 2 values
  140823. */
  140824. export class LerpBlock extends NodeMaterialBlock {
  140825. /**
  140826. * Creates a new LerpBlock
  140827. * @param name defines the block name
  140828. */
  140829. constructor(name: string);
  140830. /**
  140831. * Gets the current class name
  140832. * @returns the class name
  140833. */
  140834. getClassName(): string;
  140835. /**
  140836. * Gets the left operand input component
  140837. */
  140838. get left(): NodeMaterialConnectionPoint;
  140839. /**
  140840. * Gets the right operand input component
  140841. */
  140842. get right(): NodeMaterialConnectionPoint;
  140843. /**
  140844. * Gets the gradient operand input component
  140845. */
  140846. get gradient(): NodeMaterialConnectionPoint;
  140847. /**
  140848. * Gets the output component
  140849. */
  140850. get output(): NodeMaterialConnectionPoint;
  140851. protected _buildBlock(state: NodeMaterialBuildState): this;
  140852. }
  140853. }
  140854. declare module BABYLON {
  140855. /**
  140856. * Block used to divide 2 vectors
  140857. */
  140858. export class DivideBlock extends NodeMaterialBlock {
  140859. /**
  140860. * Creates a new DivideBlock
  140861. * @param name defines the block name
  140862. */
  140863. constructor(name: string);
  140864. /**
  140865. * Gets the current class name
  140866. * @returns the class name
  140867. */
  140868. getClassName(): string;
  140869. /**
  140870. * Gets the left operand input component
  140871. */
  140872. get left(): NodeMaterialConnectionPoint;
  140873. /**
  140874. * Gets the right operand input component
  140875. */
  140876. get right(): NodeMaterialConnectionPoint;
  140877. /**
  140878. * Gets the output component
  140879. */
  140880. get output(): NodeMaterialConnectionPoint;
  140881. protected _buildBlock(state: NodeMaterialBuildState): this;
  140882. }
  140883. }
  140884. declare module BABYLON {
  140885. /**
  140886. * Block used to subtract 2 vectors
  140887. */
  140888. export class SubtractBlock extends NodeMaterialBlock {
  140889. /**
  140890. * Creates a new SubtractBlock
  140891. * @param name defines the block name
  140892. */
  140893. constructor(name: string);
  140894. /**
  140895. * Gets the current class name
  140896. * @returns the class name
  140897. */
  140898. getClassName(): string;
  140899. /**
  140900. * Gets the left operand input component
  140901. */
  140902. get left(): NodeMaterialConnectionPoint;
  140903. /**
  140904. * Gets the right operand input component
  140905. */
  140906. get right(): NodeMaterialConnectionPoint;
  140907. /**
  140908. * Gets the output component
  140909. */
  140910. get output(): NodeMaterialConnectionPoint;
  140911. protected _buildBlock(state: NodeMaterialBuildState): this;
  140912. }
  140913. }
  140914. declare module BABYLON {
  140915. /**
  140916. * Block used to step a value
  140917. */
  140918. export class StepBlock extends NodeMaterialBlock {
  140919. /**
  140920. * Creates a new StepBlock
  140921. * @param name defines the block name
  140922. */
  140923. constructor(name: string);
  140924. /**
  140925. * Gets the current class name
  140926. * @returns the class name
  140927. */
  140928. getClassName(): string;
  140929. /**
  140930. * Gets the value operand input component
  140931. */
  140932. get value(): NodeMaterialConnectionPoint;
  140933. /**
  140934. * Gets the edge operand input component
  140935. */
  140936. get edge(): NodeMaterialConnectionPoint;
  140937. /**
  140938. * Gets the output component
  140939. */
  140940. get output(): NodeMaterialConnectionPoint;
  140941. protected _buildBlock(state: NodeMaterialBuildState): this;
  140942. }
  140943. }
  140944. declare module BABYLON {
  140945. /**
  140946. * Block used to get the opposite (1 - x) of a value
  140947. */
  140948. export class OneMinusBlock extends NodeMaterialBlock {
  140949. /**
  140950. * Creates a new OneMinusBlock
  140951. * @param name defines the block name
  140952. */
  140953. constructor(name: string);
  140954. /**
  140955. * Gets the current class name
  140956. * @returns the class name
  140957. */
  140958. getClassName(): string;
  140959. /**
  140960. * Gets the input component
  140961. */
  140962. get input(): NodeMaterialConnectionPoint;
  140963. /**
  140964. * Gets the output component
  140965. */
  140966. get output(): NodeMaterialConnectionPoint;
  140967. protected _buildBlock(state: NodeMaterialBuildState): this;
  140968. }
  140969. }
  140970. declare module BABYLON {
  140971. /**
  140972. * Block used to get the view direction
  140973. */
  140974. export class ViewDirectionBlock extends NodeMaterialBlock {
  140975. /**
  140976. * Creates a new ViewDirectionBlock
  140977. * @param name defines the block name
  140978. */
  140979. constructor(name: string);
  140980. /**
  140981. * Gets the current class name
  140982. * @returns the class name
  140983. */
  140984. getClassName(): string;
  140985. /**
  140986. * Gets the world position component
  140987. */
  140988. get worldPosition(): NodeMaterialConnectionPoint;
  140989. /**
  140990. * Gets the camera position component
  140991. */
  140992. get cameraPosition(): NodeMaterialConnectionPoint;
  140993. /**
  140994. * Gets the output component
  140995. */
  140996. get output(): NodeMaterialConnectionPoint;
  140997. autoConfigure(material: NodeMaterial): void;
  140998. protected _buildBlock(state: NodeMaterialBuildState): this;
  140999. }
  141000. }
  141001. declare module BABYLON {
  141002. /**
  141003. * Block used to compute fresnel value
  141004. */
  141005. export class FresnelBlock extends NodeMaterialBlock {
  141006. /**
  141007. * Create a new FresnelBlock
  141008. * @param name defines the block name
  141009. */
  141010. constructor(name: string);
  141011. /**
  141012. * Gets the current class name
  141013. * @returns the class name
  141014. */
  141015. getClassName(): string;
  141016. /**
  141017. * Gets the world normal input component
  141018. */
  141019. get worldNormal(): NodeMaterialConnectionPoint;
  141020. /**
  141021. * Gets the view direction input component
  141022. */
  141023. get viewDirection(): NodeMaterialConnectionPoint;
  141024. /**
  141025. * Gets the bias input component
  141026. */
  141027. get bias(): NodeMaterialConnectionPoint;
  141028. /**
  141029. * Gets the camera (or eye) position component
  141030. */
  141031. get power(): NodeMaterialConnectionPoint;
  141032. /**
  141033. * Gets the fresnel output component
  141034. */
  141035. get fresnel(): NodeMaterialConnectionPoint;
  141036. autoConfigure(material: NodeMaterial): void;
  141037. protected _buildBlock(state: NodeMaterialBuildState): this;
  141038. }
  141039. }
  141040. declare module BABYLON {
  141041. /**
  141042. * Block used to get the max of 2 values
  141043. */
  141044. export class MaxBlock extends NodeMaterialBlock {
  141045. /**
  141046. * Creates a new MaxBlock
  141047. * @param name defines the block name
  141048. */
  141049. constructor(name: string);
  141050. /**
  141051. * Gets the current class name
  141052. * @returns the class name
  141053. */
  141054. getClassName(): string;
  141055. /**
  141056. * Gets the left operand input component
  141057. */
  141058. get left(): NodeMaterialConnectionPoint;
  141059. /**
  141060. * Gets the right operand input component
  141061. */
  141062. get right(): NodeMaterialConnectionPoint;
  141063. /**
  141064. * Gets the output component
  141065. */
  141066. get output(): NodeMaterialConnectionPoint;
  141067. protected _buildBlock(state: NodeMaterialBuildState): this;
  141068. }
  141069. }
  141070. declare module BABYLON {
  141071. /**
  141072. * Block used to get the min of 2 values
  141073. */
  141074. export class MinBlock extends NodeMaterialBlock {
  141075. /**
  141076. * Creates a new MinBlock
  141077. * @param name defines the block name
  141078. */
  141079. constructor(name: string);
  141080. /**
  141081. * Gets the current class name
  141082. * @returns the class name
  141083. */
  141084. getClassName(): string;
  141085. /**
  141086. * Gets the left operand input component
  141087. */
  141088. get left(): NodeMaterialConnectionPoint;
  141089. /**
  141090. * Gets the right operand input component
  141091. */
  141092. get right(): NodeMaterialConnectionPoint;
  141093. /**
  141094. * Gets the output component
  141095. */
  141096. get output(): NodeMaterialConnectionPoint;
  141097. protected _buildBlock(state: NodeMaterialBuildState): this;
  141098. }
  141099. }
  141100. declare module BABYLON {
  141101. /**
  141102. * Block used to get the distance between 2 values
  141103. */
  141104. export class DistanceBlock extends NodeMaterialBlock {
  141105. /**
  141106. * Creates a new DistanceBlock
  141107. * @param name defines the block name
  141108. */
  141109. constructor(name: string);
  141110. /**
  141111. * Gets the current class name
  141112. * @returns the class name
  141113. */
  141114. getClassName(): string;
  141115. /**
  141116. * Gets the left operand input component
  141117. */
  141118. get left(): NodeMaterialConnectionPoint;
  141119. /**
  141120. * Gets the right operand input component
  141121. */
  141122. get right(): NodeMaterialConnectionPoint;
  141123. /**
  141124. * Gets the output component
  141125. */
  141126. get output(): NodeMaterialConnectionPoint;
  141127. protected _buildBlock(state: NodeMaterialBuildState): this;
  141128. }
  141129. }
  141130. declare module BABYLON {
  141131. /**
  141132. * Block used to get the length of a vector
  141133. */
  141134. export class LengthBlock extends NodeMaterialBlock {
  141135. /**
  141136. * Creates a new LengthBlock
  141137. * @param name defines the block name
  141138. */
  141139. constructor(name: string);
  141140. /**
  141141. * Gets the current class name
  141142. * @returns the class name
  141143. */
  141144. getClassName(): string;
  141145. /**
  141146. * Gets the value input component
  141147. */
  141148. get value(): NodeMaterialConnectionPoint;
  141149. /**
  141150. * Gets the output component
  141151. */
  141152. get output(): NodeMaterialConnectionPoint;
  141153. protected _buildBlock(state: NodeMaterialBuildState): this;
  141154. }
  141155. }
  141156. declare module BABYLON {
  141157. /**
  141158. * Block used to get negative version of a value (i.e. x * -1)
  141159. */
  141160. export class NegateBlock extends NodeMaterialBlock {
  141161. /**
  141162. * Creates a new NegateBlock
  141163. * @param name defines the block name
  141164. */
  141165. constructor(name: string);
  141166. /**
  141167. * Gets the current class name
  141168. * @returns the class name
  141169. */
  141170. getClassName(): string;
  141171. /**
  141172. * Gets the value input component
  141173. */
  141174. get value(): NodeMaterialConnectionPoint;
  141175. /**
  141176. * Gets the output component
  141177. */
  141178. get output(): NodeMaterialConnectionPoint;
  141179. protected _buildBlock(state: NodeMaterialBuildState): this;
  141180. }
  141181. }
  141182. declare module BABYLON {
  141183. /**
  141184. * Block used to get the value of the first parameter raised to the power of the second
  141185. */
  141186. export class PowBlock extends NodeMaterialBlock {
  141187. /**
  141188. * Creates a new PowBlock
  141189. * @param name defines the block name
  141190. */
  141191. constructor(name: string);
  141192. /**
  141193. * Gets the current class name
  141194. * @returns the class name
  141195. */
  141196. getClassName(): string;
  141197. /**
  141198. * Gets the value operand input component
  141199. */
  141200. get value(): NodeMaterialConnectionPoint;
  141201. /**
  141202. * Gets the power operand input component
  141203. */
  141204. get power(): NodeMaterialConnectionPoint;
  141205. /**
  141206. * Gets the output component
  141207. */
  141208. get output(): NodeMaterialConnectionPoint;
  141209. protected _buildBlock(state: NodeMaterialBuildState): this;
  141210. }
  141211. }
  141212. declare module BABYLON {
  141213. /**
  141214. * Block used to get a random number
  141215. */
  141216. export class RandomNumberBlock extends NodeMaterialBlock {
  141217. /**
  141218. * Creates a new RandomNumberBlock
  141219. * @param name defines the block name
  141220. */
  141221. constructor(name: string);
  141222. /**
  141223. * Gets the current class name
  141224. * @returns the class name
  141225. */
  141226. getClassName(): string;
  141227. /**
  141228. * Gets the seed input component
  141229. */
  141230. get seed(): NodeMaterialConnectionPoint;
  141231. /**
  141232. * Gets the output component
  141233. */
  141234. get output(): NodeMaterialConnectionPoint;
  141235. protected _buildBlock(state: NodeMaterialBuildState): this;
  141236. }
  141237. }
  141238. declare module BABYLON {
  141239. /**
  141240. * Block used to compute arc tangent of 2 values
  141241. */
  141242. export class ArcTan2Block extends NodeMaterialBlock {
  141243. /**
  141244. * Creates a new ArcTan2Block
  141245. * @param name defines the block name
  141246. */
  141247. constructor(name: string);
  141248. /**
  141249. * Gets the current class name
  141250. * @returns the class name
  141251. */
  141252. getClassName(): string;
  141253. /**
  141254. * Gets the x operand input component
  141255. */
  141256. get x(): NodeMaterialConnectionPoint;
  141257. /**
  141258. * Gets the y operand input component
  141259. */
  141260. get y(): NodeMaterialConnectionPoint;
  141261. /**
  141262. * Gets the output component
  141263. */
  141264. get output(): NodeMaterialConnectionPoint;
  141265. protected _buildBlock(state: NodeMaterialBuildState): this;
  141266. }
  141267. }
  141268. declare module BABYLON {
  141269. /**
  141270. * Block used to smooth step a value
  141271. */
  141272. export class SmoothStepBlock extends NodeMaterialBlock {
  141273. /**
  141274. * Creates a new SmoothStepBlock
  141275. * @param name defines the block name
  141276. */
  141277. constructor(name: string);
  141278. /**
  141279. * Gets the current class name
  141280. * @returns the class name
  141281. */
  141282. getClassName(): string;
  141283. /**
  141284. * Gets the value operand input component
  141285. */
  141286. get value(): NodeMaterialConnectionPoint;
  141287. /**
  141288. * Gets the first edge operand input component
  141289. */
  141290. get edge0(): NodeMaterialConnectionPoint;
  141291. /**
  141292. * Gets the second edge operand input component
  141293. */
  141294. get edge1(): NodeMaterialConnectionPoint;
  141295. /**
  141296. * Gets the output component
  141297. */
  141298. get output(): NodeMaterialConnectionPoint;
  141299. protected _buildBlock(state: NodeMaterialBuildState): this;
  141300. }
  141301. }
  141302. declare module BABYLON {
  141303. /**
  141304. * Block used to get the reciprocal (1 / x) of a value
  141305. */
  141306. export class ReciprocalBlock extends NodeMaterialBlock {
  141307. /**
  141308. * Creates a new ReciprocalBlock
  141309. * @param name defines the block name
  141310. */
  141311. constructor(name: string);
  141312. /**
  141313. * Gets the current class name
  141314. * @returns the class name
  141315. */
  141316. getClassName(): string;
  141317. /**
  141318. * Gets the input component
  141319. */
  141320. get input(): NodeMaterialConnectionPoint;
  141321. /**
  141322. * Gets the output component
  141323. */
  141324. get output(): NodeMaterialConnectionPoint;
  141325. protected _buildBlock(state: NodeMaterialBuildState): this;
  141326. }
  141327. }
  141328. declare module BABYLON {
  141329. /**
  141330. * Block used to replace a color by another one
  141331. */
  141332. export class ReplaceColorBlock extends NodeMaterialBlock {
  141333. /**
  141334. * Creates a new ReplaceColorBlock
  141335. * @param name defines the block name
  141336. */
  141337. constructor(name: string);
  141338. /**
  141339. * Gets the current class name
  141340. * @returns the class name
  141341. */
  141342. getClassName(): string;
  141343. /**
  141344. * Gets the value input component
  141345. */
  141346. get value(): NodeMaterialConnectionPoint;
  141347. /**
  141348. * Gets the reference input component
  141349. */
  141350. get reference(): NodeMaterialConnectionPoint;
  141351. /**
  141352. * Gets the distance input component
  141353. */
  141354. get distance(): NodeMaterialConnectionPoint;
  141355. /**
  141356. * Gets the replacement input component
  141357. */
  141358. get replacement(): NodeMaterialConnectionPoint;
  141359. /**
  141360. * Gets the output component
  141361. */
  141362. get output(): NodeMaterialConnectionPoint;
  141363. protected _buildBlock(state: NodeMaterialBuildState): this;
  141364. }
  141365. }
  141366. declare module BABYLON {
  141367. /**
  141368. * Block used to posterize a value
  141369. * @see https://en.wikipedia.org/wiki/Posterization
  141370. */
  141371. export class PosterizeBlock extends NodeMaterialBlock {
  141372. /**
  141373. * Creates a new PosterizeBlock
  141374. * @param name defines the block name
  141375. */
  141376. constructor(name: string);
  141377. /**
  141378. * Gets the current class name
  141379. * @returns the class name
  141380. */
  141381. getClassName(): string;
  141382. /**
  141383. * Gets the value input component
  141384. */
  141385. get value(): NodeMaterialConnectionPoint;
  141386. /**
  141387. * Gets the steps input component
  141388. */
  141389. get steps(): NodeMaterialConnectionPoint;
  141390. /**
  141391. * Gets the output component
  141392. */
  141393. get output(): NodeMaterialConnectionPoint;
  141394. protected _buildBlock(state: NodeMaterialBuildState): this;
  141395. }
  141396. }
  141397. declare module BABYLON {
  141398. /**
  141399. * Operations supported by the Wave block
  141400. */
  141401. export enum WaveBlockKind {
  141402. /** SawTooth */
  141403. SawTooth = 0,
  141404. /** Square */
  141405. Square = 1,
  141406. /** Triangle */
  141407. Triangle = 2
  141408. }
  141409. /**
  141410. * Block used to apply wave operation to floats
  141411. */
  141412. export class WaveBlock extends NodeMaterialBlock {
  141413. /**
  141414. * Gets or sets the kibnd of wave to be applied by the block
  141415. */
  141416. kind: WaveBlockKind;
  141417. /**
  141418. * Creates a new WaveBlock
  141419. * @param name defines the block name
  141420. */
  141421. constructor(name: string);
  141422. /**
  141423. * Gets the current class name
  141424. * @returns the class name
  141425. */
  141426. getClassName(): string;
  141427. /**
  141428. * Gets the input component
  141429. */
  141430. get input(): NodeMaterialConnectionPoint;
  141431. /**
  141432. * Gets the output component
  141433. */
  141434. get output(): NodeMaterialConnectionPoint;
  141435. protected _buildBlock(state: NodeMaterialBuildState): this;
  141436. serialize(): any;
  141437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141438. }
  141439. }
  141440. declare module BABYLON {
  141441. /**
  141442. * Class used to store a color step for the GradientBlock
  141443. */
  141444. export class GradientBlockColorStep {
  141445. /**
  141446. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141447. */
  141448. step: number;
  141449. /**
  141450. * Gets or sets the color associated with this step
  141451. */
  141452. color: Color3;
  141453. /**
  141454. * Creates a new GradientBlockColorStep
  141455. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141456. * @param color defines the color associated with this step
  141457. */
  141458. constructor(
  141459. /**
  141460. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141461. */
  141462. step: number,
  141463. /**
  141464. * Gets or sets the color associated with this step
  141465. */
  141466. color: Color3);
  141467. }
  141468. /**
  141469. * Block used to return a color from a gradient based on an input value between 0 and 1
  141470. */
  141471. export class GradientBlock extends NodeMaterialBlock {
  141472. /**
  141473. * Gets or sets the list of color steps
  141474. */
  141475. colorSteps: GradientBlockColorStep[];
  141476. /**
  141477. * Creates a new GradientBlock
  141478. * @param name defines the block name
  141479. */
  141480. constructor(name: string);
  141481. /**
  141482. * Gets the current class name
  141483. * @returns the class name
  141484. */
  141485. getClassName(): string;
  141486. /**
  141487. * Gets the gradient input component
  141488. */
  141489. get gradient(): NodeMaterialConnectionPoint;
  141490. /**
  141491. * Gets the output component
  141492. */
  141493. get output(): NodeMaterialConnectionPoint;
  141494. private _writeColorConstant;
  141495. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141496. serialize(): any;
  141497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141498. protected _dumpPropertiesCode(): string;
  141499. }
  141500. }
  141501. declare module BABYLON {
  141502. /**
  141503. * Block used to normalize lerp between 2 values
  141504. */
  141505. export class NLerpBlock extends NodeMaterialBlock {
  141506. /**
  141507. * Creates a new NLerpBlock
  141508. * @param name defines the block name
  141509. */
  141510. constructor(name: string);
  141511. /**
  141512. * Gets the current class name
  141513. * @returns the class name
  141514. */
  141515. getClassName(): string;
  141516. /**
  141517. * Gets the left operand input component
  141518. */
  141519. get left(): NodeMaterialConnectionPoint;
  141520. /**
  141521. * Gets the right operand input component
  141522. */
  141523. get right(): NodeMaterialConnectionPoint;
  141524. /**
  141525. * Gets the gradient operand input component
  141526. */
  141527. get gradient(): NodeMaterialConnectionPoint;
  141528. /**
  141529. * Gets the output component
  141530. */
  141531. get output(): NodeMaterialConnectionPoint;
  141532. protected _buildBlock(state: NodeMaterialBuildState): this;
  141533. }
  141534. }
  141535. declare module BABYLON {
  141536. /**
  141537. * block used to Generate a Worley Noise 3D Noise Pattern
  141538. */
  141539. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141540. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141541. manhattanDistance: boolean;
  141542. /**
  141543. * Creates a new WorleyNoise3DBlock
  141544. * @param name defines the block name
  141545. */
  141546. constructor(name: string);
  141547. /**
  141548. * Gets the current class name
  141549. * @returns the class name
  141550. */
  141551. getClassName(): string;
  141552. /**
  141553. * Gets the seed input component
  141554. */
  141555. get seed(): NodeMaterialConnectionPoint;
  141556. /**
  141557. * Gets the jitter input component
  141558. */
  141559. get jitter(): NodeMaterialConnectionPoint;
  141560. /**
  141561. * Gets the output component
  141562. */
  141563. get output(): NodeMaterialConnectionPoint;
  141564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141565. /**
  141566. * Exposes the properties to the UI?
  141567. */
  141568. protected _dumpPropertiesCode(): string;
  141569. /**
  141570. * Exposes the properties to the Seralize?
  141571. */
  141572. serialize(): any;
  141573. /**
  141574. * Exposes the properties to the deseralize?
  141575. */
  141576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141577. }
  141578. }
  141579. declare module BABYLON {
  141580. /**
  141581. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141582. */
  141583. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141584. /**
  141585. * Creates a new SimplexPerlin3DBlock
  141586. * @param name defines the block name
  141587. */
  141588. constructor(name: string);
  141589. /**
  141590. * Gets the current class name
  141591. * @returns the class name
  141592. */
  141593. getClassName(): string;
  141594. /**
  141595. * Gets the seed operand input component
  141596. */
  141597. get seed(): NodeMaterialConnectionPoint;
  141598. /**
  141599. * Gets the output component
  141600. */
  141601. get output(): NodeMaterialConnectionPoint;
  141602. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141603. }
  141604. }
  141605. declare module BABYLON {
  141606. /**
  141607. * Block used to blend normals
  141608. */
  141609. export class NormalBlendBlock extends NodeMaterialBlock {
  141610. /**
  141611. * Creates a new NormalBlendBlock
  141612. * @param name defines the block name
  141613. */
  141614. constructor(name: string);
  141615. /**
  141616. * Gets the current class name
  141617. * @returns the class name
  141618. */
  141619. getClassName(): string;
  141620. /**
  141621. * Gets the first input component
  141622. */
  141623. get normalMap0(): NodeMaterialConnectionPoint;
  141624. /**
  141625. * Gets the second input component
  141626. */
  141627. get normalMap1(): NodeMaterialConnectionPoint;
  141628. /**
  141629. * Gets the output component
  141630. */
  141631. get output(): NodeMaterialConnectionPoint;
  141632. protected _buildBlock(state: NodeMaterialBuildState): this;
  141633. }
  141634. }
  141635. declare module BABYLON {
  141636. /**
  141637. * Block used to rotate a 2d vector by a given angle
  141638. */
  141639. export class Rotate2dBlock extends NodeMaterialBlock {
  141640. /**
  141641. * Creates a new Rotate2dBlock
  141642. * @param name defines the block name
  141643. */
  141644. constructor(name: string);
  141645. /**
  141646. * Gets the current class name
  141647. * @returns the class name
  141648. */
  141649. getClassName(): string;
  141650. /**
  141651. * Gets the input vector
  141652. */
  141653. get input(): NodeMaterialConnectionPoint;
  141654. /**
  141655. * Gets the input angle
  141656. */
  141657. get angle(): NodeMaterialConnectionPoint;
  141658. /**
  141659. * Gets the output component
  141660. */
  141661. get output(): NodeMaterialConnectionPoint;
  141662. autoConfigure(material: NodeMaterial): void;
  141663. protected _buildBlock(state: NodeMaterialBuildState): this;
  141664. }
  141665. }
  141666. declare module BABYLON {
  141667. /**
  141668. * Block used to get the reflected vector from a direction and a normal
  141669. */
  141670. export class ReflectBlock extends NodeMaterialBlock {
  141671. /**
  141672. * Creates a new ReflectBlock
  141673. * @param name defines the block name
  141674. */
  141675. constructor(name: string);
  141676. /**
  141677. * Gets the current class name
  141678. * @returns the class name
  141679. */
  141680. getClassName(): string;
  141681. /**
  141682. * Gets the incident component
  141683. */
  141684. get incident(): NodeMaterialConnectionPoint;
  141685. /**
  141686. * Gets the normal component
  141687. */
  141688. get normal(): NodeMaterialConnectionPoint;
  141689. /**
  141690. * Gets the output component
  141691. */
  141692. get output(): NodeMaterialConnectionPoint;
  141693. protected _buildBlock(state: NodeMaterialBuildState): this;
  141694. }
  141695. }
  141696. declare module BABYLON {
  141697. /**
  141698. * Block used to get the refracted vector from a direction and a normal
  141699. */
  141700. export class RefractBlock extends NodeMaterialBlock {
  141701. /**
  141702. * Creates a new RefractBlock
  141703. * @param name defines the block name
  141704. */
  141705. constructor(name: string);
  141706. /**
  141707. * Gets the current class name
  141708. * @returns the class name
  141709. */
  141710. getClassName(): string;
  141711. /**
  141712. * Gets the incident component
  141713. */
  141714. get incident(): NodeMaterialConnectionPoint;
  141715. /**
  141716. * Gets the normal component
  141717. */
  141718. get normal(): NodeMaterialConnectionPoint;
  141719. /**
  141720. * Gets the index of refraction component
  141721. */
  141722. get ior(): NodeMaterialConnectionPoint;
  141723. /**
  141724. * Gets the output component
  141725. */
  141726. get output(): NodeMaterialConnectionPoint;
  141727. protected _buildBlock(state: NodeMaterialBuildState): this;
  141728. }
  141729. }
  141730. declare module BABYLON {
  141731. /**
  141732. * Block used to desaturate a color
  141733. */
  141734. export class DesaturateBlock extends NodeMaterialBlock {
  141735. /**
  141736. * Creates a new DesaturateBlock
  141737. * @param name defines the block name
  141738. */
  141739. constructor(name: string);
  141740. /**
  141741. * Gets the current class name
  141742. * @returns the class name
  141743. */
  141744. getClassName(): string;
  141745. /**
  141746. * Gets the color operand input component
  141747. */
  141748. get color(): NodeMaterialConnectionPoint;
  141749. /**
  141750. * Gets the level operand input component
  141751. */
  141752. get level(): NodeMaterialConnectionPoint;
  141753. /**
  141754. * Gets the output component
  141755. */
  141756. get output(): NodeMaterialConnectionPoint;
  141757. protected _buildBlock(state: NodeMaterialBuildState): this;
  141758. }
  141759. }
  141760. declare module BABYLON {
  141761. /**
  141762. * Block used to implement the ambient occlusion module of the PBR material
  141763. */
  141764. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141765. /**
  141766. * Create a new AmbientOcclusionBlock
  141767. * @param name defines the block name
  141768. */
  141769. constructor(name: string);
  141770. /**
  141771. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141772. */
  141773. useAmbientInGrayScale: boolean;
  141774. /**
  141775. * Initialize the block and prepare the context for build
  141776. * @param state defines the state that will be used for the build
  141777. */
  141778. initialize(state: NodeMaterialBuildState): void;
  141779. /**
  141780. * Gets the current class name
  141781. * @returns the class name
  141782. */
  141783. getClassName(): string;
  141784. /**
  141785. * Gets the texture input component
  141786. */
  141787. get texture(): NodeMaterialConnectionPoint;
  141788. /**
  141789. * Gets the texture intensity component
  141790. */
  141791. get intensity(): NodeMaterialConnectionPoint;
  141792. /**
  141793. * Gets the direct light intensity input component
  141794. */
  141795. get directLightIntensity(): NodeMaterialConnectionPoint;
  141796. /**
  141797. * Gets the ambient occlusion object output component
  141798. */
  141799. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141800. /**
  141801. * Gets the main code of the block (fragment side)
  141802. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141803. * @returns the shader code
  141804. */
  141805. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141807. protected _buildBlock(state: NodeMaterialBuildState): this;
  141808. protected _dumpPropertiesCode(): string;
  141809. serialize(): any;
  141810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141811. }
  141812. }
  141813. declare module BABYLON {
  141814. /**
  141815. * Block used to implement the reflection module of the PBR material
  141816. */
  141817. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141818. /** @hidden */
  141819. _defineLODReflectionAlpha: string;
  141820. /** @hidden */
  141821. _defineLinearSpecularReflection: string;
  141822. private _vEnvironmentIrradianceName;
  141823. /** @hidden */
  141824. _vReflectionMicrosurfaceInfosName: string;
  141825. /** @hidden */
  141826. _vReflectionInfosName: string;
  141827. /** @hidden */
  141828. _vReflectionFilteringInfoName: string;
  141829. private _scene;
  141830. /**
  141831. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141832. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141833. * It's less burden on the user side in the editor part.
  141834. */
  141835. /** @hidden */
  141836. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141837. /** @hidden */
  141838. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141839. /** @hidden */
  141840. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141841. /**
  141842. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141843. * diffuse part of the IBL.
  141844. */
  141845. useSphericalHarmonics: boolean;
  141846. /**
  141847. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141848. */
  141849. forceIrradianceInFragment: boolean;
  141850. /**
  141851. * Create a new ReflectionBlock
  141852. * @param name defines the block name
  141853. */
  141854. constructor(name: string);
  141855. /**
  141856. * Gets the current class name
  141857. * @returns the class name
  141858. */
  141859. getClassName(): string;
  141860. /**
  141861. * Gets the position input component
  141862. */
  141863. get position(): NodeMaterialConnectionPoint;
  141864. /**
  141865. * Gets the world position input component
  141866. */
  141867. get worldPosition(): NodeMaterialConnectionPoint;
  141868. /**
  141869. * Gets the world normal input component
  141870. */
  141871. get worldNormal(): NodeMaterialConnectionPoint;
  141872. /**
  141873. * Gets the world input component
  141874. */
  141875. get world(): NodeMaterialConnectionPoint;
  141876. /**
  141877. * Gets the camera (or eye) position component
  141878. */
  141879. get cameraPosition(): NodeMaterialConnectionPoint;
  141880. /**
  141881. * Gets the view input component
  141882. */
  141883. get view(): NodeMaterialConnectionPoint;
  141884. /**
  141885. * Gets the color input component
  141886. */
  141887. get color(): NodeMaterialConnectionPoint;
  141888. /**
  141889. * Gets the reflection object output component
  141890. */
  141891. get reflection(): NodeMaterialConnectionPoint;
  141892. /**
  141893. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141894. */
  141895. get hasTexture(): boolean;
  141896. /**
  141897. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141898. */
  141899. get reflectionColor(): string;
  141900. protected _getTexture(): Nullable<BaseTexture>;
  141901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141903. /**
  141904. * Gets the code to inject in the vertex shader
  141905. * @param state current state of the node material building
  141906. * @returns the shader code
  141907. */
  141908. handleVertexSide(state: NodeMaterialBuildState): string;
  141909. /**
  141910. * Gets the main code of the block (fragment side)
  141911. * @param state current state of the node material building
  141912. * @param normalVarName name of the existing variable corresponding to the normal
  141913. * @returns the shader code
  141914. */
  141915. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141916. protected _buildBlock(state: NodeMaterialBuildState): this;
  141917. protected _dumpPropertiesCode(): string;
  141918. serialize(): any;
  141919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141920. }
  141921. }
  141922. declare module BABYLON {
  141923. /**
  141924. * Block used to implement the sheen module of the PBR material
  141925. */
  141926. export class SheenBlock extends NodeMaterialBlock {
  141927. /**
  141928. * Create a new SheenBlock
  141929. * @param name defines the block name
  141930. */
  141931. constructor(name: string);
  141932. /**
  141933. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141934. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141935. * making it easier to setup and tweak the effect
  141936. */
  141937. albedoScaling: boolean;
  141938. /**
  141939. * Defines if the sheen is linked to the sheen color.
  141940. */
  141941. linkSheenWithAlbedo: boolean;
  141942. /**
  141943. * Initialize the block and prepare the context for build
  141944. * @param state defines the state that will be used for the build
  141945. */
  141946. initialize(state: NodeMaterialBuildState): void;
  141947. /**
  141948. * Gets the current class name
  141949. * @returns the class name
  141950. */
  141951. getClassName(): string;
  141952. /**
  141953. * Gets the intensity input component
  141954. */
  141955. get intensity(): NodeMaterialConnectionPoint;
  141956. /**
  141957. * Gets the color input component
  141958. */
  141959. get color(): NodeMaterialConnectionPoint;
  141960. /**
  141961. * Gets the roughness input component
  141962. */
  141963. get roughness(): NodeMaterialConnectionPoint;
  141964. /**
  141965. * Gets the sheen object output component
  141966. */
  141967. get sheen(): NodeMaterialConnectionPoint;
  141968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141969. /**
  141970. * Gets the main code of the block (fragment side)
  141971. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141972. * @returns the shader code
  141973. */
  141974. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141975. protected _buildBlock(state: NodeMaterialBuildState): this;
  141976. protected _dumpPropertiesCode(): string;
  141977. serialize(): any;
  141978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141979. }
  141980. }
  141981. declare module BABYLON {
  141982. /**
  141983. * Block used to implement the reflectivity module of the PBR material
  141984. */
  141985. export class ReflectivityBlock extends NodeMaterialBlock {
  141986. private _metallicReflectanceColor;
  141987. private _metallicF0Factor;
  141988. /** @hidden */
  141989. _vMetallicReflectanceFactorsName: string;
  141990. /**
  141991. * The property below is set by the main PBR block prior to calling methods of this class.
  141992. */
  141993. /** @hidden */
  141994. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141995. /**
  141996. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141997. */
  141998. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141999. /**
  142000. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142001. */
  142002. useMetallnessFromMetallicTextureBlue: boolean;
  142003. /**
  142004. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142005. */
  142006. useRoughnessFromMetallicTextureAlpha: boolean;
  142007. /**
  142008. * Specifies if the metallic texture contains the roughness information in its green channel.
  142009. */
  142010. useRoughnessFromMetallicTextureGreen: boolean;
  142011. /**
  142012. * Create a new ReflectivityBlock
  142013. * @param name defines the block name
  142014. */
  142015. constructor(name: string);
  142016. /**
  142017. * Initialize the block and prepare the context for build
  142018. * @param state defines the state that will be used for the build
  142019. */
  142020. initialize(state: NodeMaterialBuildState): void;
  142021. /**
  142022. * Gets the current class name
  142023. * @returns the class name
  142024. */
  142025. getClassName(): string;
  142026. /**
  142027. * Gets the metallic input component
  142028. */
  142029. get metallic(): NodeMaterialConnectionPoint;
  142030. /**
  142031. * Gets the roughness input component
  142032. */
  142033. get roughness(): NodeMaterialConnectionPoint;
  142034. /**
  142035. * Gets the texture input component
  142036. */
  142037. get texture(): NodeMaterialConnectionPoint;
  142038. /**
  142039. * Gets the reflectivity object output component
  142040. */
  142041. get reflectivity(): NodeMaterialConnectionPoint;
  142042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142043. /**
  142044. * Gets the main code of the block (fragment side)
  142045. * @param state current state of the node material building
  142046. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142047. * @returns the shader code
  142048. */
  142049. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142051. protected _buildBlock(state: NodeMaterialBuildState): this;
  142052. protected _dumpPropertiesCode(): string;
  142053. serialize(): any;
  142054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142055. }
  142056. }
  142057. declare module BABYLON {
  142058. /**
  142059. * Block used to implement the anisotropy module of the PBR material
  142060. */
  142061. export class AnisotropyBlock extends NodeMaterialBlock {
  142062. /**
  142063. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142064. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142065. * It's less burden on the user side in the editor part.
  142066. */
  142067. /** @hidden */
  142068. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142069. /** @hidden */
  142070. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142071. /**
  142072. * Create a new AnisotropyBlock
  142073. * @param name defines the block name
  142074. */
  142075. constructor(name: string);
  142076. /**
  142077. * Initialize the block and prepare the context for build
  142078. * @param state defines the state that will be used for the build
  142079. */
  142080. initialize(state: NodeMaterialBuildState): void;
  142081. /**
  142082. * Gets the current class name
  142083. * @returns the class name
  142084. */
  142085. getClassName(): string;
  142086. /**
  142087. * Gets the intensity input component
  142088. */
  142089. get intensity(): NodeMaterialConnectionPoint;
  142090. /**
  142091. * Gets the direction input component
  142092. */
  142093. get direction(): NodeMaterialConnectionPoint;
  142094. /**
  142095. * Gets the texture input component
  142096. */
  142097. get texture(): NodeMaterialConnectionPoint;
  142098. /**
  142099. * Gets the uv input component
  142100. */
  142101. get uv(): NodeMaterialConnectionPoint;
  142102. /**
  142103. * Gets the worldTangent input component
  142104. */
  142105. get worldTangent(): NodeMaterialConnectionPoint;
  142106. /**
  142107. * Gets the anisotropy object output component
  142108. */
  142109. get anisotropy(): NodeMaterialConnectionPoint;
  142110. private _generateTBNSpace;
  142111. /**
  142112. * Gets the main code of the block (fragment side)
  142113. * @param state current state of the node material building
  142114. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142115. * @returns the shader code
  142116. */
  142117. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  142118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142119. protected _buildBlock(state: NodeMaterialBuildState): this;
  142120. }
  142121. }
  142122. declare module BABYLON {
  142123. /**
  142124. * Block used to implement the clear coat module of the PBR material
  142125. */
  142126. export class ClearCoatBlock extends NodeMaterialBlock {
  142127. private _scene;
  142128. /**
  142129. * Create a new ClearCoatBlock
  142130. * @param name defines the block name
  142131. */
  142132. constructor(name: string);
  142133. /**
  142134. * Initialize the block and prepare the context for build
  142135. * @param state defines the state that will be used for the build
  142136. */
  142137. initialize(state: NodeMaterialBuildState): void;
  142138. /**
  142139. * Gets the current class name
  142140. * @returns the class name
  142141. */
  142142. getClassName(): string;
  142143. /**
  142144. * Gets the intensity input component
  142145. */
  142146. get intensity(): NodeMaterialConnectionPoint;
  142147. /**
  142148. * Gets the roughness input component
  142149. */
  142150. get roughness(): NodeMaterialConnectionPoint;
  142151. /**
  142152. * Gets the ior input component
  142153. */
  142154. get ior(): NodeMaterialConnectionPoint;
  142155. /**
  142156. * Gets the texture input component
  142157. */
  142158. get texture(): NodeMaterialConnectionPoint;
  142159. /**
  142160. * Gets the bump texture input component
  142161. */
  142162. get bumpTexture(): NodeMaterialConnectionPoint;
  142163. /**
  142164. * Gets the uv input component
  142165. */
  142166. get uv(): NodeMaterialConnectionPoint;
  142167. /**
  142168. * Gets the tint color input component
  142169. */
  142170. get tintColor(): NodeMaterialConnectionPoint;
  142171. /**
  142172. * Gets the tint "at distance" input component
  142173. */
  142174. get tintAtDistance(): NodeMaterialConnectionPoint;
  142175. /**
  142176. * Gets the tint thickness input component
  142177. */
  142178. get tintThickness(): NodeMaterialConnectionPoint;
  142179. /**
  142180. * Gets the world tangent input component
  142181. */
  142182. get worldTangent(): NodeMaterialConnectionPoint;
  142183. /**
  142184. * Gets the clear coat object output component
  142185. */
  142186. get clearcoat(): NodeMaterialConnectionPoint;
  142187. autoConfigure(material: NodeMaterial): void;
  142188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142190. private _generateTBNSpace;
  142191. /**
  142192. * Gets the main code of the block (fragment side)
  142193. * @param state current state of the node material building
  142194. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  142195. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142196. * @param worldPosVarName name of the variable holding the world position
  142197. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142198. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  142199. * @param worldNormalVarName name of the variable holding the world normal
  142200. * @returns the shader code
  142201. */
  142202. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  142203. protected _buildBlock(state: NodeMaterialBuildState): this;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * Block used to implement the sub surface module of the PBR material
  142209. */
  142210. export class SubSurfaceBlock extends NodeMaterialBlock {
  142211. /**
  142212. * Create a new SubSurfaceBlock
  142213. * @param name defines the block name
  142214. */
  142215. constructor(name: string);
  142216. /**
  142217. * Stores the intensity of the different subsurface effects in the thickness texture.
  142218. * * the green channel is the translucency intensity.
  142219. * * the blue channel is the scattering intensity.
  142220. * * the alpha channel is the refraction intensity.
  142221. */
  142222. useMaskFromThicknessTexture: boolean;
  142223. /**
  142224. * Initialize the block and prepare the context for build
  142225. * @param state defines the state that will be used for the build
  142226. */
  142227. initialize(state: NodeMaterialBuildState): void;
  142228. /**
  142229. * Gets the current class name
  142230. * @returns the class name
  142231. */
  142232. getClassName(): string;
  142233. /**
  142234. * Gets the min thickness input component
  142235. */
  142236. get minThickness(): NodeMaterialConnectionPoint;
  142237. /**
  142238. * Gets the max thickness input component
  142239. */
  142240. get maxThickness(): NodeMaterialConnectionPoint;
  142241. /**
  142242. * Gets the thickness texture component
  142243. */
  142244. get thicknessTexture(): NodeMaterialConnectionPoint;
  142245. /**
  142246. * Gets the tint color input component
  142247. */
  142248. get tintColor(): NodeMaterialConnectionPoint;
  142249. /**
  142250. * Gets the translucency intensity input component
  142251. */
  142252. get translucencyIntensity(): NodeMaterialConnectionPoint;
  142253. /**
  142254. * Gets the translucency diffusion distance input component
  142255. */
  142256. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  142257. /**
  142258. * Gets the refraction object parameters
  142259. */
  142260. get refraction(): NodeMaterialConnectionPoint;
  142261. /**
  142262. * Gets the sub surface object output component
  142263. */
  142264. get subsurface(): NodeMaterialConnectionPoint;
  142265. autoConfigure(material: NodeMaterial): void;
  142266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142267. /**
  142268. * Gets the main code of the block (fragment side)
  142269. * @param state current state of the node material building
  142270. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  142271. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142272. * @param worldPosVarName name of the variable holding the world position
  142273. * @returns the shader code
  142274. */
  142275. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  142276. protected _buildBlock(state: NodeMaterialBuildState): this;
  142277. }
  142278. }
  142279. declare module BABYLON {
  142280. /**
  142281. * Block used to implement the PBR metallic/roughness model
  142282. */
  142283. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  142284. /**
  142285. * Gets or sets the light associated with this block
  142286. */
  142287. light: Nullable<Light>;
  142288. private _lightId;
  142289. private _scene;
  142290. private _environmentBRDFTexture;
  142291. private _environmentBrdfSamplerName;
  142292. private _vNormalWName;
  142293. private _invertNormalName;
  142294. /**
  142295. * Create a new ReflectionBlock
  142296. * @param name defines the block name
  142297. */
  142298. constructor(name: string);
  142299. /**
  142300. * Intensity of the direct lights e.g. the four lights available in your scene.
  142301. * This impacts both the direct diffuse and specular highlights.
  142302. */
  142303. directIntensity: number;
  142304. /**
  142305. * Intensity of the environment e.g. how much the environment will light the object
  142306. * either through harmonics for rough material or through the refelction for shiny ones.
  142307. */
  142308. environmentIntensity: number;
  142309. /**
  142310. * This is a special control allowing the reduction of the specular highlights coming from the
  142311. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  142312. */
  142313. specularIntensity: number;
  142314. /**
  142315. * Defines the falloff type used in this material.
  142316. * It by default is Physical.
  142317. */
  142318. lightFalloff: number;
  142319. /**
  142320. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  142321. */
  142322. useAlphaFromAlbedoTexture: boolean;
  142323. /**
  142324. * Specifies that alpha test should be used
  142325. */
  142326. useAlphaTest: boolean;
  142327. /**
  142328. * Defines the alpha limits in alpha test mode.
  142329. */
  142330. alphaTestCutoff: number;
  142331. /**
  142332. * Specifies that alpha blending should be used
  142333. */
  142334. useAlphaBlending: boolean;
  142335. /**
  142336. * Defines if the alpha value should be determined via the rgb values.
  142337. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142338. */
  142339. opacityRGB: boolean;
  142340. /**
  142341. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142342. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142343. */
  142344. useRadianceOverAlpha: boolean;
  142345. /**
  142346. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142347. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142348. */
  142349. useSpecularOverAlpha: boolean;
  142350. /**
  142351. * Enables specular anti aliasing in the PBR shader.
  142352. * It will both interacts on the Geometry for analytical and IBL lighting.
  142353. * It also prefilter the roughness map based on the bump values.
  142354. */
  142355. enableSpecularAntiAliasing: boolean;
  142356. /**
  142357. * Enables realtime filtering on the texture.
  142358. */
  142359. realTimeFiltering: boolean;
  142360. /**
  142361. * Quality switch for realtime filtering
  142362. */
  142363. realTimeFilteringQuality: number;
  142364. /**
  142365. * Defines if the material uses energy conservation.
  142366. */
  142367. useEnergyConservation: boolean;
  142368. /**
  142369. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142370. * too much the area relying on ambient texture to define their ambient occlusion.
  142371. */
  142372. useRadianceOcclusion: boolean;
  142373. /**
  142374. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142375. * makes the reflect vector face the model (under horizon).
  142376. */
  142377. useHorizonOcclusion: boolean;
  142378. /**
  142379. * If set to true, no lighting calculations will be applied.
  142380. */
  142381. unlit: boolean;
  142382. /**
  142383. * Force normal to face away from face.
  142384. */
  142385. forceNormalForward: boolean;
  142386. /**
  142387. * Defines the material debug mode.
  142388. * It helps seeing only some components of the material while troubleshooting.
  142389. */
  142390. debugMode: number;
  142391. /**
  142392. * Specify from where on screen the debug mode should start.
  142393. * The value goes from -1 (full screen) to 1 (not visible)
  142394. * It helps with side by side comparison against the final render
  142395. * This defaults to 0
  142396. */
  142397. debugLimit: number;
  142398. /**
  142399. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142400. * You can use the factor to better multiply the final value.
  142401. */
  142402. debugFactor: number;
  142403. /**
  142404. * Initialize the block and prepare the context for build
  142405. * @param state defines the state that will be used for the build
  142406. */
  142407. initialize(state: NodeMaterialBuildState): void;
  142408. /**
  142409. * Gets the current class name
  142410. * @returns the class name
  142411. */
  142412. getClassName(): string;
  142413. /**
  142414. * Gets the world position input component
  142415. */
  142416. get worldPosition(): NodeMaterialConnectionPoint;
  142417. /**
  142418. * Gets the world normal input component
  142419. */
  142420. get worldNormal(): NodeMaterialConnectionPoint;
  142421. /**
  142422. * Gets the perturbed normal input component
  142423. */
  142424. get perturbedNormal(): NodeMaterialConnectionPoint;
  142425. /**
  142426. * Gets the camera position input component
  142427. */
  142428. get cameraPosition(): NodeMaterialConnectionPoint;
  142429. /**
  142430. * Gets the base color input component
  142431. */
  142432. get baseColor(): NodeMaterialConnectionPoint;
  142433. /**
  142434. * Gets the opacity texture input component
  142435. */
  142436. get opacityTexture(): NodeMaterialConnectionPoint;
  142437. /**
  142438. * Gets the ambient color input component
  142439. */
  142440. get ambientColor(): NodeMaterialConnectionPoint;
  142441. /**
  142442. * Gets the reflectivity object parameters
  142443. */
  142444. get reflectivity(): NodeMaterialConnectionPoint;
  142445. /**
  142446. * Gets the ambient occlusion object parameters
  142447. */
  142448. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142449. /**
  142450. * Gets the reflection object parameters
  142451. */
  142452. get reflection(): NodeMaterialConnectionPoint;
  142453. /**
  142454. * Gets the sheen object parameters
  142455. */
  142456. get sheen(): NodeMaterialConnectionPoint;
  142457. /**
  142458. * Gets the clear coat object parameters
  142459. */
  142460. get clearcoat(): NodeMaterialConnectionPoint;
  142461. /**
  142462. * Gets the sub surface object parameters
  142463. */
  142464. get subsurface(): NodeMaterialConnectionPoint;
  142465. /**
  142466. * Gets the anisotropy object parameters
  142467. */
  142468. get anisotropy(): NodeMaterialConnectionPoint;
  142469. /**
  142470. * Gets the ambient output component
  142471. */
  142472. get ambient(): NodeMaterialConnectionPoint;
  142473. /**
  142474. * Gets the diffuse output component
  142475. */
  142476. get diffuse(): NodeMaterialConnectionPoint;
  142477. /**
  142478. * Gets the specular output component
  142479. */
  142480. get specular(): NodeMaterialConnectionPoint;
  142481. /**
  142482. * Gets the sheen output component
  142483. */
  142484. get sheenDir(): NodeMaterialConnectionPoint;
  142485. /**
  142486. * Gets the clear coat output component
  142487. */
  142488. get clearcoatDir(): NodeMaterialConnectionPoint;
  142489. /**
  142490. * Gets the indirect diffuse output component
  142491. */
  142492. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142493. /**
  142494. * Gets the indirect specular output component
  142495. */
  142496. get specularIndirect(): NodeMaterialConnectionPoint;
  142497. /**
  142498. * Gets the indirect sheen output component
  142499. */
  142500. get sheenIndirect(): NodeMaterialConnectionPoint;
  142501. /**
  142502. * Gets the indirect clear coat output component
  142503. */
  142504. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142505. /**
  142506. * Gets the refraction output component
  142507. */
  142508. get refraction(): NodeMaterialConnectionPoint;
  142509. /**
  142510. * Gets the global lighting output component
  142511. */
  142512. get lighting(): NodeMaterialConnectionPoint;
  142513. /**
  142514. * Gets the shadow output component
  142515. */
  142516. get shadow(): NodeMaterialConnectionPoint;
  142517. /**
  142518. * Gets the alpha output component
  142519. */
  142520. get alpha(): NodeMaterialConnectionPoint;
  142521. autoConfigure(material: NodeMaterial): void;
  142522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142523. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142525. private _injectVertexCode;
  142526. /**
  142527. * Gets the code corresponding to the albedo/opacity module
  142528. * @returns the shader code
  142529. */
  142530. getAlbedoOpacityCode(): string;
  142531. protected _buildBlock(state: NodeMaterialBuildState): this;
  142532. protected _dumpPropertiesCode(): string;
  142533. serialize(): any;
  142534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142535. }
  142536. }
  142537. declare module BABYLON {
  142538. /**
  142539. * Block used to compute value of one parameter modulo another
  142540. */
  142541. export class ModBlock extends NodeMaterialBlock {
  142542. /**
  142543. * Creates a new ModBlock
  142544. * @param name defines the block name
  142545. */
  142546. constructor(name: string);
  142547. /**
  142548. * Gets the current class name
  142549. * @returns the class name
  142550. */
  142551. getClassName(): string;
  142552. /**
  142553. * Gets the left operand input component
  142554. */
  142555. get left(): NodeMaterialConnectionPoint;
  142556. /**
  142557. * Gets the right operand input component
  142558. */
  142559. get right(): NodeMaterialConnectionPoint;
  142560. /**
  142561. * Gets the output component
  142562. */
  142563. get output(): NodeMaterialConnectionPoint;
  142564. protected _buildBlock(state: NodeMaterialBuildState): this;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /**
  142569. * Helper class to push actions to a pool of workers.
  142570. */
  142571. export class WorkerPool implements IDisposable {
  142572. private _workerInfos;
  142573. private _pendingActions;
  142574. /**
  142575. * Constructor
  142576. * @param workers Array of workers to use for actions
  142577. */
  142578. constructor(workers: Array<Worker>);
  142579. /**
  142580. * Terminates all workers and clears any pending actions.
  142581. */
  142582. dispose(): void;
  142583. /**
  142584. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142585. * pended until a worker has completed its action.
  142586. * @param action The action to perform. Call onComplete when the action is complete.
  142587. */
  142588. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142589. private _execute;
  142590. }
  142591. }
  142592. declare module BABYLON {
  142593. /**
  142594. * Configuration for Draco compression
  142595. */
  142596. export interface IDracoCompressionConfiguration {
  142597. /**
  142598. * Configuration for the decoder.
  142599. */
  142600. decoder: {
  142601. /**
  142602. * The url to the WebAssembly module.
  142603. */
  142604. wasmUrl?: string;
  142605. /**
  142606. * The url to the WebAssembly binary.
  142607. */
  142608. wasmBinaryUrl?: string;
  142609. /**
  142610. * The url to the fallback JavaScript module.
  142611. */
  142612. fallbackUrl?: string;
  142613. };
  142614. }
  142615. /**
  142616. * Draco compression (https://google.github.io/draco/)
  142617. *
  142618. * This class wraps the Draco module.
  142619. *
  142620. * **Encoder**
  142621. *
  142622. * The encoder is not currently implemented.
  142623. *
  142624. * **Decoder**
  142625. *
  142626. * 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.
  142627. *
  142628. * To update the configuration, use the following code:
  142629. * ```javascript
  142630. * DracoCompression.Configuration = {
  142631. * decoder: {
  142632. * wasmUrl: "<url to the WebAssembly library>",
  142633. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142634. * fallbackUrl: "<url to the fallback JavaScript library>",
  142635. * }
  142636. * };
  142637. * ```
  142638. *
  142639. * 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.
  142640. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142641. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142642. *
  142643. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142644. * ```javascript
  142645. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142646. * ```
  142647. *
  142648. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142649. */
  142650. export class DracoCompression implements IDisposable {
  142651. private _workerPoolPromise?;
  142652. private _decoderModulePromise?;
  142653. /**
  142654. * The configuration. Defaults to the following urls:
  142655. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142656. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142657. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142658. */
  142659. static Configuration: IDracoCompressionConfiguration;
  142660. /**
  142661. * Returns true if the decoder configuration is available.
  142662. */
  142663. static get DecoderAvailable(): boolean;
  142664. /**
  142665. * Default number of workers to create when creating the draco compression object.
  142666. */
  142667. static DefaultNumWorkers: number;
  142668. private static GetDefaultNumWorkers;
  142669. private static _Default;
  142670. /**
  142671. * Default instance for the draco compression object.
  142672. */
  142673. static get Default(): DracoCompression;
  142674. /**
  142675. * Constructor
  142676. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142677. */
  142678. constructor(numWorkers?: number);
  142679. /**
  142680. * Stop all async operations and release resources.
  142681. */
  142682. dispose(): void;
  142683. /**
  142684. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142685. * @returns a promise that resolves when ready
  142686. */
  142687. whenReadyAsync(): Promise<void>;
  142688. /**
  142689. * Decode Draco compressed mesh data to vertex data.
  142690. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142691. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142692. * @returns A promise that resolves with the decoded vertex data
  142693. */
  142694. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142695. [kind: string]: number;
  142696. }): Promise<VertexData>;
  142697. }
  142698. }
  142699. declare module BABYLON {
  142700. /**
  142701. * Class for building Constructive Solid Geometry
  142702. */
  142703. export class CSG {
  142704. private polygons;
  142705. /**
  142706. * The world matrix
  142707. */
  142708. matrix: Matrix;
  142709. /**
  142710. * Stores the position
  142711. */
  142712. position: Vector3;
  142713. /**
  142714. * Stores the rotation
  142715. */
  142716. rotation: Vector3;
  142717. /**
  142718. * Stores the rotation quaternion
  142719. */
  142720. rotationQuaternion: Nullable<Quaternion>;
  142721. /**
  142722. * Stores the scaling vector
  142723. */
  142724. scaling: Vector3;
  142725. /**
  142726. * Convert the Mesh to CSG
  142727. * @param mesh The Mesh to convert to CSG
  142728. * @returns A new CSG from the Mesh
  142729. */
  142730. static FromMesh(mesh: Mesh): CSG;
  142731. /**
  142732. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142733. * @param polygons Polygons used to construct a CSG solid
  142734. */
  142735. private static FromPolygons;
  142736. /**
  142737. * Clones, or makes a deep copy, of the CSG
  142738. * @returns A new CSG
  142739. */
  142740. clone(): CSG;
  142741. /**
  142742. * Unions this CSG with another CSG
  142743. * @param csg The CSG to union against this CSG
  142744. * @returns The unioned CSG
  142745. */
  142746. union(csg: CSG): CSG;
  142747. /**
  142748. * Unions this CSG with another CSG in place
  142749. * @param csg The CSG to union against this CSG
  142750. */
  142751. unionInPlace(csg: CSG): void;
  142752. /**
  142753. * Subtracts this CSG with another CSG
  142754. * @param csg The CSG to subtract against this CSG
  142755. * @returns A new CSG
  142756. */
  142757. subtract(csg: CSG): CSG;
  142758. /**
  142759. * Subtracts this CSG with another CSG in place
  142760. * @param csg The CSG to subtact against this CSG
  142761. */
  142762. subtractInPlace(csg: CSG): void;
  142763. /**
  142764. * Intersect this CSG with another CSG
  142765. * @param csg The CSG to intersect against this CSG
  142766. * @returns A new CSG
  142767. */
  142768. intersect(csg: CSG): CSG;
  142769. /**
  142770. * Intersects this CSG with another CSG in place
  142771. * @param csg The CSG to intersect against this CSG
  142772. */
  142773. intersectInPlace(csg: CSG): void;
  142774. /**
  142775. * Return a new CSG solid with solid and empty space switched. This solid is
  142776. * not modified.
  142777. * @returns A new CSG solid with solid and empty space switched
  142778. */
  142779. inverse(): CSG;
  142780. /**
  142781. * Inverses the CSG in place
  142782. */
  142783. inverseInPlace(): void;
  142784. /**
  142785. * This is used to keep meshes transformations so they can be restored
  142786. * when we build back a Babylon Mesh
  142787. * NB : All CSG operations are performed in world coordinates
  142788. * @param csg The CSG to copy the transform attributes from
  142789. * @returns This CSG
  142790. */
  142791. copyTransformAttributes(csg: CSG): CSG;
  142792. /**
  142793. * Build Raw mesh from CSG
  142794. * Coordinates here are in world space
  142795. * @param name The name of the mesh geometry
  142796. * @param scene The Scene
  142797. * @param keepSubMeshes Specifies if the submeshes should be kept
  142798. * @returns A new Mesh
  142799. */
  142800. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142801. /**
  142802. * Build Mesh from CSG taking material and transforms into account
  142803. * @param name The name of the Mesh
  142804. * @param material The material of the Mesh
  142805. * @param scene The Scene
  142806. * @param keepSubMeshes Specifies if submeshes should be kept
  142807. * @returns The new Mesh
  142808. */
  142809. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142810. }
  142811. }
  142812. declare module BABYLON {
  142813. /**
  142814. * Class used to create a trail following a mesh
  142815. */
  142816. export class TrailMesh extends Mesh {
  142817. private _generator;
  142818. private _autoStart;
  142819. private _running;
  142820. private _diameter;
  142821. private _length;
  142822. private _sectionPolygonPointsCount;
  142823. private _sectionVectors;
  142824. private _sectionNormalVectors;
  142825. private _beforeRenderObserver;
  142826. /**
  142827. * @constructor
  142828. * @param name The value used by scene.getMeshByName() to do a lookup.
  142829. * @param generator The mesh or transform node to generate a trail.
  142830. * @param scene The scene to add this mesh to.
  142831. * @param diameter Diameter of trailing mesh. Default is 1.
  142832. * @param length Length of trailing mesh. Default is 60.
  142833. * @param autoStart Automatically start trailing mesh. Default true.
  142834. */
  142835. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142836. /**
  142837. * "TrailMesh"
  142838. * @returns "TrailMesh"
  142839. */
  142840. getClassName(): string;
  142841. private _createMesh;
  142842. /**
  142843. * Start trailing mesh.
  142844. */
  142845. start(): void;
  142846. /**
  142847. * Stop trailing mesh.
  142848. */
  142849. stop(): void;
  142850. /**
  142851. * Update trailing mesh geometry.
  142852. */
  142853. update(): void;
  142854. /**
  142855. * Returns a new TrailMesh object.
  142856. * @param name is a string, the name given to the new mesh
  142857. * @param newGenerator use new generator object for cloned trail mesh
  142858. * @returns a new mesh
  142859. */
  142860. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142861. /**
  142862. * Serializes this trail mesh
  142863. * @param serializationObject object to write serialization to
  142864. */
  142865. serialize(serializationObject: any): void;
  142866. /**
  142867. * Parses a serialized trail mesh
  142868. * @param parsedMesh the serialized mesh
  142869. * @param scene the scene to create the trail mesh in
  142870. * @returns the created trail mesh
  142871. */
  142872. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142873. }
  142874. }
  142875. declare module BABYLON {
  142876. /**
  142877. * Class containing static functions to help procedurally build meshes
  142878. */
  142879. export class TiledBoxBuilder {
  142880. /**
  142881. * Creates a box mesh
  142882. * 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)
  142883. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142887. * @param name defines the name of the mesh
  142888. * @param options defines the options used to create the mesh
  142889. * @param scene defines the hosting scene
  142890. * @returns the box mesh
  142891. */
  142892. static CreateTiledBox(name: string, options: {
  142893. pattern?: number;
  142894. width?: number;
  142895. height?: number;
  142896. depth?: number;
  142897. tileSize?: number;
  142898. tileWidth?: number;
  142899. tileHeight?: number;
  142900. alignHorizontal?: number;
  142901. alignVertical?: number;
  142902. faceUV?: Vector4[];
  142903. faceColors?: Color4[];
  142904. sideOrientation?: number;
  142905. updatable?: boolean;
  142906. }, scene?: Nullable<Scene>): Mesh;
  142907. }
  142908. }
  142909. declare module BABYLON {
  142910. /**
  142911. * Class containing static functions to help procedurally build meshes
  142912. */
  142913. export class TorusKnotBuilder {
  142914. /**
  142915. * Creates a torus knot mesh
  142916. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142917. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142918. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142919. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142923. * @param name defines the name of the mesh
  142924. * @param options defines the options used to create the mesh
  142925. * @param scene defines the hosting scene
  142926. * @returns the torus knot mesh
  142927. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142928. */
  142929. static CreateTorusKnot(name: string, options: {
  142930. radius?: number;
  142931. tube?: number;
  142932. radialSegments?: number;
  142933. tubularSegments?: number;
  142934. p?: number;
  142935. q?: number;
  142936. updatable?: boolean;
  142937. sideOrientation?: number;
  142938. frontUVs?: Vector4;
  142939. backUVs?: Vector4;
  142940. }, scene: any): Mesh;
  142941. }
  142942. }
  142943. declare module BABYLON {
  142944. /**
  142945. * Polygon
  142946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142947. */
  142948. export class Polygon {
  142949. /**
  142950. * Creates a rectangle
  142951. * @param xmin bottom X coord
  142952. * @param ymin bottom Y coord
  142953. * @param xmax top X coord
  142954. * @param ymax top Y coord
  142955. * @returns points that make the resulting rectation
  142956. */
  142957. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142958. /**
  142959. * Creates a circle
  142960. * @param radius radius of circle
  142961. * @param cx scale in x
  142962. * @param cy scale in y
  142963. * @param numberOfSides number of sides that make up the circle
  142964. * @returns points that make the resulting circle
  142965. */
  142966. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142967. /**
  142968. * Creates a polygon from input string
  142969. * @param input Input polygon data
  142970. * @returns the parsed points
  142971. */
  142972. static Parse(input: string): Vector2[];
  142973. /**
  142974. * Starts building a polygon from x and y coordinates
  142975. * @param x x coordinate
  142976. * @param y y coordinate
  142977. * @returns the started path2
  142978. */
  142979. static StartingAt(x: number, y: number): Path2;
  142980. }
  142981. /**
  142982. * Builds a polygon
  142983. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142984. */
  142985. export class PolygonMeshBuilder {
  142986. private _points;
  142987. private _outlinepoints;
  142988. private _holes;
  142989. private _name;
  142990. private _scene;
  142991. private _epoints;
  142992. private _eholes;
  142993. private _addToepoint;
  142994. /**
  142995. * Babylon reference to the earcut plugin.
  142996. */
  142997. bjsEarcut: any;
  142998. /**
  142999. * Creates a PolygonMeshBuilder
  143000. * @param name name of the builder
  143001. * @param contours Path of the polygon
  143002. * @param scene scene to add to when creating the mesh
  143003. * @param earcutInjection can be used to inject your own earcut reference
  143004. */
  143005. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143006. /**
  143007. * Adds a whole within the polygon
  143008. * @param hole Array of points defining the hole
  143009. * @returns this
  143010. */
  143011. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143012. /**
  143013. * Creates the polygon
  143014. * @param updatable If the mesh should be updatable
  143015. * @param depth The depth of the mesh created
  143016. * @returns the created mesh
  143017. */
  143018. build(updatable?: boolean, depth?: number): Mesh;
  143019. /**
  143020. * Creates the polygon
  143021. * @param depth The depth of the mesh created
  143022. * @returns the created VertexData
  143023. */
  143024. buildVertexData(depth?: number): VertexData;
  143025. /**
  143026. * Adds a side to the polygon
  143027. * @param positions points that make the polygon
  143028. * @param normals normals of the polygon
  143029. * @param uvs uvs of the polygon
  143030. * @param indices indices of the polygon
  143031. * @param bounds bounds of the polygon
  143032. * @param points points of the polygon
  143033. * @param depth depth of the polygon
  143034. * @param flip flip of the polygon
  143035. */
  143036. private addSide;
  143037. }
  143038. }
  143039. declare module BABYLON {
  143040. /**
  143041. * Class containing static functions to help procedurally build meshes
  143042. */
  143043. export class PolygonBuilder {
  143044. /**
  143045. * Creates a polygon mesh
  143046. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143047. * * 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
  143048. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143051. * * Remember you can only change the shape positions, not their number when updating a polygon
  143052. * @param name defines the name of the mesh
  143053. * @param options defines the options used to create the mesh
  143054. * @param scene defines the hosting scene
  143055. * @param earcutInjection can be used to inject your own earcut reference
  143056. * @returns the polygon mesh
  143057. */
  143058. static CreatePolygon(name: string, options: {
  143059. shape: Vector3[];
  143060. holes?: Vector3[][];
  143061. depth?: number;
  143062. faceUV?: Vector4[];
  143063. faceColors?: Color4[];
  143064. updatable?: boolean;
  143065. sideOrientation?: number;
  143066. frontUVs?: Vector4;
  143067. backUVs?: Vector4;
  143068. wrap?: boolean;
  143069. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143070. /**
  143071. * Creates an extruded polygon mesh, with depth in the Y direction.
  143072. * * 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)
  143073. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143074. * @param name defines the name of the mesh
  143075. * @param options defines the options used to create the mesh
  143076. * @param scene defines the hosting scene
  143077. * @param earcutInjection can be used to inject your own earcut reference
  143078. * @returns the polygon mesh
  143079. */
  143080. static ExtrudePolygon(name: string, options: {
  143081. shape: Vector3[];
  143082. holes?: Vector3[][];
  143083. depth?: number;
  143084. faceUV?: Vector4[];
  143085. faceColors?: Color4[];
  143086. updatable?: boolean;
  143087. sideOrientation?: number;
  143088. frontUVs?: Vector4;
  143089. backUVs?: Vector4;
  143090. wrap?: boolean;
  143091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143092. }
  143093. }
  143094. declare module BABYLON {
  143095. /**
  143096. * Class containing static functions to help procedurally build meshes
  143097. */
  143098. export class LatheBuilder {
  143099. /**
  143100. * Creates lathe mesh.
  143101. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143102. * * 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
  143103. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143104. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143105. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143106. * * 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
  143107. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143108. * * 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
  143109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143111. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143113. * @param name defines the name of the mesh
  143114. * @param options defines the options used to create the mesh
  143115. * @param scene defines the hosting scene
  143116. * @returns the lathe mesh
  143117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143118. */
  143119. static CreateLathe(name: string, options: {
  143120. shape: Vector3[];
  143121. radius?: number;
  143122. tessellation?: number;
  143123. clip?: number;
  143124. arc?: number;
  143125. closed?: boolean;
  143126. updatable?: boolean;
  143127. sideOrientation?: number;
  143128. frontUVs?: Vector4;
  143129. backUVs?: Vector4;
  143130. cap?: number;
  143131. invertUV?: boolean;
  143132. }, scene?: Nullable<Scene>): Mesh;
  143133. }
  143134. }
  143135. declare module BABYLON {
  143136. /**
  143137. * Class containing static functions to help procedurally build meshes
  143138. */
  143139. export class TiledPlaneBuilder {
  143140. /**
  143141. * Creates a tiled plane mesh
  143142. * * The parameter `pattern` will, depending on value, do nothing or
  143143. * * * flip (reflect about central vertical) alternate tiles across and up
  143144. * * * flip every tile on alternate rows
  143145. * * * rotate (180 degs) alternate tiles across and up
  143146. * * * rotate every tile on alternate rows
  143147. * * * flip and rotate alternate tiles across and up
  143148. * * * flip and rotate every tile on alternate rows
  143149. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  143150. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  143151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143153. * * 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)
  143154. * * 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)
  143155. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143156. * @param name defines the name of the mesh
  143157. * @param options defines the options used to create the mesh
  143158. * @param scene defines the hosting scene
  143159. * @returns the box mesh
  143160. */
  143161. static CreateTiledPlane(name: string, options: {
  143162. pattern?: number;
  143163. tileSize?: number;
  143164. tileWidth?: number;
  143165. tileHeight?: number;
  143166. size?: number;
  143167. width?: number;
  143168. height?: number;
  143169. alignHorizontal?: number;
  143170. alignVertical?: number;
  143171. sideOrientation?: number;
  143172. frontUVs?: Vector4;
  143173. backUVs?: Vector4;
  143174. updatable?: boolean;
  143175. }, scene?: Nullable<Scene>): Mesh;
  143176. }
  143177. }
  143178. declare module BABYLON {
  143179. /**
  143180. * Class containing static functions to help procedurally build meshes
  143181. */
  143182. export class TubeBuilder {
  143183. /**
  143184. * Creates a tube mesh.
  143185. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143186. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143187. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143188. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143189. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143190. * * 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)
  143191. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143192. * * 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
  143193. * * 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
  143194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143198. * @param name defines the name of the mesh
  143199. * @param options defines the options used to create the mesh
  143200. * @param scene defines the hosting scene
  143201. * @returns the tube mesh
  143202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143203. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143204. */
  143205. static CreateTube(name: string, options: {
  143206. path: Vector3[];
  143207. radius?: number;
  143208. tessellation?: number;
  143209. radiusFunction?: {
  143210. (i: number, distance: number): number;
  143211. };
  143212. cap?: number;
  143213. arc?: number;
  143214. updatable?: boolean;
  143215. sideOrientation?: number;
  143216. frontUVs?: Vector4;
  143217. backUVs?: Vector4;
  143218. instance?: Mesh;
  143219. invertUV?: boolean;
  143220. }, scene?: Nullable<Scene>): Mesh;
  143221. }
  143222. }
  143223. declare module BABYLON {
  143224. /**
  143225. * Class containing static functions to help procedurally build meshes
  143226. */
  143227. export class IcoSphereBuilder {
  143228. /**
  143229. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143230. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143231. * * 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`)
  143232. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143233. * * 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
  143234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143237. * @param name defines the name of the mesh
  143238. * @param options defines the options used to create the mesh
  143239. * @param scene defines the hosting scene
  143240. * @returns the icosahedron mesh
  143241. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143242. */
  143243. static CreateIcoSphere(name: string, options: {
  143244. radius?: number;
  143245. radiusX?: number;
  143246. radiusY?: number;
  143247. radiusZ?: number;
  143248. flat?: boolean;
  143249. subdivisions?: number;
  143250. sideOrientation?: number;
  143251. frontUVs?: Vector4;
  143252. backUVs?: Vector4;
  143253. updatable?: boolean;
  143254. }, scene?: Nullable<Scene>): Mesh;
  143255. }
  143256. }
  143257. declare module BABYLON {
  143258. /**
  143259. * Class containing static functions to help procedurally build meshes
  143260. */
  143261. export class DecalBuilder {
  143262. /**
  143263. * Creates a decal mesh.
  143264. * 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
  143265. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143266. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143267. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143268. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143269. * @param name defines the name of the mesh
  143270. * @param sourceMesh defines the mesh where the decal must be applied
  143271. * @param options defines the options used to create the mesh
  143272. * @param scene defines the hosting scene
  143273. * @returns the decal mesh
  143274. * @see https://doc.babylonjs.com/how_to/decals
  143275. */
  143276. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143277. position?: Vector3;
  143278. normal?: Vector3;
  143279. size?: Vector3;
  143280. angle?: number;
  143281. }): Mesh;
  143282. }
  143283. }
  143284. declare module BABYLON {
  143285. /**
  143286. * Class containing static functions to help procedurally build meshes
  143287. */
  143288. export class MeshBuilder {
  143289. /**
  143290. * Creates a box mesh
  143291. * * The parameter `size` sets the size (float) of each box side (default 1)
  143292. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  143293. * * 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)
  143294. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143298. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143299. * @param name defines the name of the mesh
  143300. * @param options defines the options used to create the mesh
  143301. * @param scene defines the hosting scene
  143302. * @returns the box mesh
  143303. */
  143304. static CreateBox(name: string, options: {
  143305. size?: number;
  143306. width?: number;
  143307. height?: number;
  143308. depth?: number;
  143309. faceUV?: Vector4[];
  143310. faceColors?: Color4[];
  143311. sideOrientation?: number;
  143312. frontUVs?: Vector4;
  143313. backUVs?: Vector4;
  143314. wrap?: boolean;
  143315. topBaseAt?: number;
  143316. bottomBaseAt?: number;
  143317. updatable?: boolean;
  143318. }, scene?: Nullable<Scene>): Mesh;
  143319. /**
  143320. * Creates a tiled box mesh
  143321. * * faceTiles sets the pattern, tile size and number of tiles for a face
  143322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143323. * @param name defines the name of the mesh
  143324. * @param options defines the options used to create the mesh
  143325. * @param scene defines the hosting scene
  143326. * @returns the tiled box mesh
  143327. */
  143328. static CreateTiledBox(name: string, options: {
  143329. pattern?: number;
  143330. size?: number;
  143331. width?: number;
  143332. height?: number;
  143333. depth: number;
  143334. tileSize?: number;
  143335. tileWidth?: number;
  143336. tileHeight?: number;
  143337. faceUV?: Vector4[];
  143338. faceColors?: Color4[];
  143339. alignHorizontal?: number;
  143340. alignVertical?: number;
  143341. sideOrientation?: number;
  143342. updatable?: boolean;
  143343. }, scene?: Nullable<Scene>): Mesh;
  143344. /**
  143345. * Creates a sphere mesh
  143346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143347. * * 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`)
  143348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143349. * * 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
  143350. * * 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)
  143351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143354. * @param name defines the name of the mesh
  143355. * @param options defines the options used to create the mesh
  143356. * @param scene defines the hosting scene
  143357. * @returns the sphere mesh
  143358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143359. */
  143360. static CreateSphere(name: string, options: {
  143361. segments?: number;
  143362. diameter?: number;
  143363. diameterX?: number;
  143364. diameterY?: number;
  143365. diameterZ?: number;
  143366. arc?: number;
  143367. slice?: number;
  143368. sideOrientation?: number;
  143369. frontUVs?: Vector4;
  143370. backUVs?: Vector4;
  143371. updatable?: boolean;
  143372. }, scene?: Nullable<Scene>): Mesh;
  143373. /**
  143374. * Creates a plane polygonal mesh. By default, this is a disc
  143375. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143376. * * 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
  143377. * * 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
  143378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143381. * @param name defines the name of the mesh
  143382. * @param options defines the options used to create the mesh
  143383. * @param scene defines the hosting scene
  143384. * @returns the plane polygonal mesh
  143385. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143386. */
  143387. static CreateDisc(name: string, options: {
  143388. radius?: number;
  143389. tessellation?: number;
  143390. arc?: number;
  143391. updatable?: boolean;
  143392. sideOrientation?: number;
  143393. frontUVs?: Vector4;
  143394. backUVs?: Vector4;
  143395. }, scene?: Nullable<Scene>): Mesh;
  143396. /**
  143397. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143398. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143399. * * 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`)
  143400. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143401. * * 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
  143402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143405. * @param name defines the name of the mesh
  143406. * @param options defines the options used to create the mesh
  143407. * @param scene defines the hosting scene
  143408. * @returns the icosahedron mesh
  143409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143410. */
  143411. static CreateIcoSphere(name: string, options: {
  143412. radius?: number;
  143413. radiusX?: number;
  143414. radiusY?: number;
  143415. radiusZ?: number;
  143416. flat?: boolean;
  143417. subdivisions?: number;
  143418. sideOrientation?: number;
  143419. frontUVs?: Vector4;
  143420. backUVs?: Vector4;
  143421. updatable?: boolean;
  143422. }, scene?: Nullable<Scene>): Mesh;
  143423. /**
  143424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143428. * * 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
  143429. * * 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
  143430. * * 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
  143431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143434. * * 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
  143435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143436. * * 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
  143437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143439. * @param name defines the name of the mesh
  143440. * @param options defines the options used to create the mesh
  143441. * @param scene defines the hosting scene
  143442. * @returns the ribbon mesh
  143443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143445. */
  143446. static CreateRibbon(name: string, options: {
  143447. pathArray: Vector3[][];
  143448. closeArray?: boolean;
  143449. closePath?: boolean;
  143450. offset?: number;
  143451. updatable?: boolean;
  143452. sideOrientation?: number;
  143453. frontUVs?: Vector4;
  143454. backUVs?: Vector4;
  143455. instance?: Mesh;
  143456. invertUV?: boolean;
  143457. uvs?: Vector2[];
  143458. colors?: Color4[];
  143459. }, scene?: Nullable<Scene>): Mesh;
  143460. /**
  143461. * Creates a cylinder or a cone mesh
  143462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143464. * * 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.
  143465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143469. * * 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).
  143470. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143471. * * 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).
  143472. * * 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
  143473. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143474. * * 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
  143475. * * 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.
  143476. * * If `enclose` is false, a ring surface is one element.
  143477. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143478. * * 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
  143479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143482. * @param name defines the name of the mesh
  143483. * @param options defines the options used to create the mesh
  143484. * @param scene defines the hosting scene
  143485. * @returns the cylinder mesh
  143486. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143487. */
  143488. static CreateCylinder(name: string, options: {
  143489. height?: number;
  143490. diameterTop?: number;
  143491. diameterBottom?: number;
  143492. diameter?: number;
  143493. tessellation?: number;
  143494. subdivisions?: number;
  143495. arc?: number;
  143496. faceColors?: Color4[];
  143497. faceUV?: Vector4[];
  143498. updatable?: boolean;
  143499. hasRings?: boolean;
  143500. enclose?: boolean;
  143501. cap?: number;
  143502. sideOrientation?: number;
  143503. frontUVs?: Vector4;
  143504. backUVs?: Vector4;
  143505. }, scene?: Nullable<Scene>): Mesh;
  143506. /**
  143507. * Creates a torus mesh
  143508. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143509. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143510. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143514. * @param name defines the name of the mesh
  143515. * @param options defines the options used to create the mesh
  143516. * @param scene defines the hosting scene
  143517. * @returns the torus mesh
  143518. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143519. */
  143520. static CreateTorus(name: string, options: {
  143521. diameter?: number;
  143522. thickness?: number;
  143523. tessellation?: number;
  143524. updatable?: boolean;
  143525. sideOrientation?: number;
  143526. frontUVs?: Vector4;
  143527. backUVs?: Vector4;
  143528. }, scene?: Nullable<Scene>): Mesh;
  143529. /**
  143530. * Creates a torus knot mesh
  143531. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143532. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143533. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143534. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143538. * @param name defines the name of the mesh
  143539. * @param options defines the options used to create the mesh
  143540. * @param scene defines the hosting scene
  143541. * @returns the torus knot mesh
  143542. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143543. */
  143544. static CreateTorusKnot(name: string, options: {
  143545. radius?: number;
  143546. tube?: number;
  143547. radialSegments?: number;
  143548. tubularSegments?: number;
  143549. p?: number;
  143550. q?: number;
  143551. updatable?: boolean;
  143552. sideOrientation?: number;
  143553. frontUVs?: Vector4;
  143554. backUVs?: Vector4;
  143555. }, scene?: Nullable<Scene>): Mesh;
  143556. /**
  143557. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143558. * * 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
  143559. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143560. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143561. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143562. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143563. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143564. * * 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
  143565. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143568. * @param name defines the name of the new line system
  143569. * @param options defines the options used to create the line system
  143570. * @param scene defines the hosting scene
  143571. * @returns a new line system mesh
  143572. */
  143573. static CreateLineSystem(name: string, options: {
  143574. lines: Vector3[][];
  143575. updatable?: boolean;
  143576. instance?: Nullable<LinesMesh>;
  143577. colors?: Nullable<Color4[][]>;
  143578. useVertexAlpha?: boolean;
  143579. }, scene: Nullable<Scene>): LinesMesh;
  143580. /**
  143581. * Creates a line mesh
  143582. * 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
  143583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143584. * * The parameter `points` is an array successive Vector3
  143585. * * 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
  143586. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143587. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143588. * * When updating an instance, remember that only point positions can change, not the number of points
  143589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143591. * @param name defines the name of the new line system
  143592. * @param options defines the options used to create the line system
  143593. * @param scene defines the hosting scene
  143594. * @returns a new line mesh
  143595. */
  143596. static CreateLines(name: string, options: {
  143597. points: Vector3[];
  143598. updatable?: boolean;
  143599. instance?: Nullable<LinesMesh>;
  143600. colors?: Color4[];
  143601. useVertexAlpha?: boolean;
  143602. }, scene?: Nullable<Scene>): LinesMesh;
  143603. /**
  143604. * Creates a dashed line mesh
  143605. * * 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
  143606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143607. * * The parameter `points` is an array successive Vector3
  143608. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143609. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143610. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143611. * * 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
  143612. * * When updating an instance, remember that only point positions can change, not the number of points
  143613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143614. * @param name defines the name of the mesh
  143615. * @param options defines the options used to create the mesh
  143616. * @param scene defines the hosting scene
  143617. * @returns the dashed line mesh
  143618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143619. */
  143620. static CreateDashedLines(name: string, options: {
  143621. points: Vector3[];
  143622. dashSize?: number;
  143623. gapSize?: number;
  143624. dashNb?: number;
  143625. updatable?: boolean;
  143626. instance?: LinesMesh;
  143627. }, scene?: Nullable<Scene>): LinesMesh;
  143628. /**
  143629. * 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.
  143630. * * 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.
  143631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143632. * * 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.
  143633. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143634. * * 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
  143635. * * 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
  143636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143641. * @param name defines the name of the mesh
  143642. * @param options defines the options used to create the mesh
  143643. * @param scene defines the hosting scene
  143644. * @returns the extruded shape mesh
  143645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143647. */
  143648. static ExtrudeShape(name: string, options: {
  143649. shape: Vector3[];
  143650. path: Vector3[];
  143651. scale?: number;
  143652. rotation?: number;
  143653. cap?: number;
  143654. updatable?: boolean;
  143655. sideOrientation?: number;
  143656. frontUVs?: Vector4;
  143657. backUVs?: Vector4;
  143658. instance?: Mesh;
  143659. invertUV?: boolean;
  143660. }, scene?: Nullable<Scene>): Mesh;
  143661. /**
  143662. * Creates an custom extruded shape mesh.
  143663. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143664. * * 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.
  143665. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143666. * * 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
  143667. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143668. * * 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
  143669. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143670. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143671. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143672. * * 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
  143673. * * 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
  143674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143679. * @param name defines the name of the mesh
  143680. * @param options defines the options used to create the mesh
  143681. * @param scene defines the hosting scene
  143682. * @returns the custom extruded shape mesh
  143683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143686. */
  143687. static ExtrudeShapeCustom(name: string, options: {
  143688. shape: Vector3[];
  143689. path: Vector3[];
  143690. scaleFunction?: any;
  143691. rotationFunction?: any;
  143692. ribbonCloseArray?: boolean;
  143693. ribbonClosePath?: boolean;
  143694. cap?: number;
  143695. updatable?: boolean;
  143696. sideOrientation?: number;
  143697. frontUVs?: Vector4;
  143698. backUVs?: Vector4;
  143699. instance?: Mesh;
  143700. invertUV?: boolean;
  143701. }, scene?: Nullable<Scene>): Mesh;
  143702. /**
  143703. * Creates lathe mesh.
  143704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143705. * * 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
  143706. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143707. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143708. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143709. * * 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
  143710. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143711. * * 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
  143712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143716. * @param name defines the name of the mesh
  143717. * @param options defines the options used to create the mesh
  143718. * @param scene defines the hosting scene
  143719. * @returns the lathe mesh
  143720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143721. */
  143722. static CreateLathe(name: string, options: {
  143723. shape: Vector3[];
  143724. radius?: number;
  143725. tessellation?: number;
  143726. clip?: number;
  143727. arc?: number;
  143728. closed?: boolean;
  143729. updatable?: boolean;
  143730. sideOrientation?: number;
  143731. frontUVs?: Vector4;
  143732. backUVs?: Vector4;
  143733. cap?: number;
  143734. invertUV?: boolean;
  143735. }, scene?: Nullable<Scene>): Mesh;
  143736. /**
  143737. * Creates a tiled plane mesh
  143738. * * You can set a limited pattern arrangement with the tiles
  143739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143742. * @param name defines the name of the mesh
  143743. * @param options defines the options used to create the mesh
  143744. * @param scene defines the hosting scene
  143745. * @returns the plane mesh
  143746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143747. */
  143748. static CreateTiledPlane(name: string, options: {
  143749. pattern?: number;
  143750. tileSize?: number;
  143751. tileWidth?: number;
  143752. tileHeight?: number;
  143753. size?: number;
  143754. width?: number;
  143755. height?: number;
  143756. alignHorizontal?: number;
  143757. alignVertical?: number;
  143758. sideOrientation?: number;
  143759. frontUVs?: Vector4;
  143760. backUVs?: Vector4;
  143761. updatable?: boolean;
  143762. }, scene?: Nullable<Scene>): Mesh;
  143763. /**
  143764. * Creates a plane mesh
  143765. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143766. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143767. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143771. * @param name defines the name of the mesh
  143772. * @param options defines the options used to create the mesh
  143773. * @param scene defines the hosting scene
  143774. * @returns the plane mesh
  143775. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143776. */
  143777. static CreatePlane(name: string, options: {
  143778. size?: number;
  143779. width?: number;
  143780. height?: number;
  143781. sideOrientation?: number;
  143782. frontUVs?: Vector4;
  143783. backUVs?: Vector4;
  143784. updatable?: boolean;
  143785. sourcePlane?: Plane;
  143786. }, scene?: Nullable<Scene>): Mesh;
  143787. /**
  143788. * Creates a ground mesh
  143789. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143790. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143792. * @param name defines the name of the mesh
  143793. * @param options defines the options used to create the mesh
  143794. * @param scene defines the hosting scene
  143795. * @returns the ground mesh
  143796. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143797. */
  143798. static CreateGround(name: string, options: {
  143799. width?: number;
  143800. height?: number;
  143801. subdivisions?: number;
  143802. subdivisionsX?: number;
  143803. subdivisionsY?: number;
  143804. updatable?: boolean;
  143805. }, scene?: Nullable<Scene>): Mesh;
  143806. /**
  143807. * Creates a tiled ground mesh
  143808. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143809. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143810. * * 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
  143811. * * 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
  143812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143813. * @param name defines the name of the mesh
  143814. * @param options defines the options used to create the mesh
  143815. * @param scene defines the hosting scene
  143816. * @returns the tiled ground mesh
  143817. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143818. */
  143819. static CreateTiledGround(name: string, options: {
  143820. xmin: number;
  143821. zmin: number;
  143822. xmax: number;
  143823. zmax: number;
  143824. subdivisions?: {
  143825. w: number;
  143826. h: number;
  143827. };
  143828. precision?: {
  143829. w: number;
  143830. h: number;
  143831. };
  143832. updatable?: boolean;
  143833. }, scene?: Nullable<Scene>): Mesh;
  143834. /**
  143835. * Creates a ground mesh from a height map
  143836. * * The parameter `url` sets the URL of the height map image resource.
  143837. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143838. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143839. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143840. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143841. * * 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.
  143842. * * 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).
  143843. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143845. * @param name defines the name of the mesh
  143846. * @param url defines the url to the height map
  143847. * @param options defines the options used to create the mesh
  143848. * @param scene defines the hosting scene
  143849. * @returns the ground mesh
  143850. * @see https://doc.babylonjs.com/babylon101/height_map
  143851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143852. */
  143853. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143854. width?: number;
  143855. height?: number;
  143856. subdivisions?: number;
  143857. minHeight?: number;
  143858. maxHeight?: number;
  143859. colorFilter?: Color3;
  143860. alphaFilter?: number;
  143861. updatable?: boolean;
  143862. onReady?: (mesh: GroundMesh) => void;
  143863. }, scene?: Nullable<Scene>): GroundMesh;
  143864. /**
  143865. * Creates a polygon mesh
  143866. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143867. * * 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
  143868. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143871. * * Remember you can only change the shape positions, not their number when updating a polygon
  143872. * @param name defines the name of the mesh
  143873. * @param options defines the options used to create the mesh
  143874. * @param scene defines the hosting scene
  143875. * @param earcutInjection can be used to inject your own earcut reference
  143876. * @returns the polygon mesh
  143877. */
  143878. static CreatePolygon(name: string, options: {
  143879. shape: Vector3[];
  143880. holes?: Vector3[][];
  143881. depth?: number;
  143882. faceUV?: Vector4[];
  143883. faceColors?: Color4[];
  143884. updatable?: boolean;
  143885. sideOrientation?: number;
  143886. frontUVs?: Vector4;
  143887. backUVs?: Vector4;
  143888. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143889. /**
  143890. * Creates an extruded polygon mesh, with depth in the Y direction.
  143891. * * 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)
  143892. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143893. * @param name defines the name of the mesh
  143894. * @param options defines the options used to create the mesh
  143895. * @param scene defines the hosting scene
  143896. * @param earcutInjection can be used to inject your own earcut reference
  143897. * @returns the polygon mesh
  143898. */
  143899. static ExtrudePolygon(name: string, options: {
  143900. shape: Vector3[];
  143901. holes?: Vector3[][];
  143902. depth?: number;
  143903. faceUV?: Vector4[];
  143904. faceColors?: Color4[];
  143905. updatable?: boolean;
  143906. sideOrientation?: number;
  143907. frontUVs?: Vector4;
  143908. backUVs?: Vector4;
  143909. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143910. /**
  143911. * Creates a tube mesh.
  143912. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143913. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143914. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143915. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143916. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143917. * * 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)
  143918. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143919. * * 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
  143920. * * 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
  143921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143925. * @param name defines the name of the mesh
  143926. * @param options defines the options used to create the mesh
  143927. * @param scene defines the hosting scene
  143928. * @returns the tube mesh
  143929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143930. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143931. */
  143932. static CreateTube(name: string, options: {
  143933. path: Vector3[];
  143934. radius?: number;
  143935. tessellation?: number;
  143936. radiusFunction?: {
  143937. (i: number, distance: number): number;
  143938. };
  143939. cap?: number;
  143940. arc?: number;
  143941. updatable?: boolean;
  143942. sideOrientation?: number;
  143943. frontUVs?: Vector4;
  143944. backUVs?: Vector4;
  143945. instance?: Mesh;
  143946. invertUV?: boolean;
  143947. }, scene?: Nullable<Scene>): Mesh;
  143948. /**
  143949. * Creates a polyhedron mesh
  143950. * * 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
  143951. * * The parameter `size` (positive float, default 1) sets the polygon size
  143952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143953. * * 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`
  143954. * * 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
  143955. * * 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)`)
  143956. * * 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
  143957. * * 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
  143958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143961. * @param name defines the name of the mesh
  143962. * @param options defines the options used to create the mesh
  143963. * @param scene defines the hosting scene
  143964. * @returns the polyhedron mesh
  143965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143966. */
  143967. static CreatePolyhedron(name: string, options: {
  143968. type?: number;
  143969. size?: number;
  143970. sizeX?: number;
  143971. sizeY?: number;
  143972. sizeZ?: number;
  143973. custom?: any;
  143974. faceUV?: Vector4[];
  143975. faceColors?: Color4[];
  143976. flat?: boolean;
  143977. updatable?: boolean;
  143978. sideOrientation?: number;
  143979. frontUVs?: Vector4;
  143980. backUVs?: Vector4;
  143981. }, scene?: Nullable<Scene>): Mesh;
  143982. /**
  143983. * Creates a decal mesh.
  143984. * 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
  143985. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143986. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143987. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143988. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143989. * @param name defines the name of the mesh
  143990. * @param sourceMesh defines the mesh where the decal must be applied
  143991. * @param options defines the options used to create the mesh
  143992. * @param scene defines the hosting scene
  143993. * @returns the decal mesh
  143994. * @see https://doc.babylonjs.com/how_to/decals
  143995. */
  143996. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143997. position?: Vector3;
  143998. normal?: Vector3;
  143999. size?: Vector3;
  144000. angle?: number;
  144001. }): Mesh;
  144002. }
  144003. }
  144004. declare module BABYLON {
  144005. /**
  144006. * A simplifier interface for future simplification implementations
  144007. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144008. */
  144009. export interface ISimplifier {
  144010. /**
  144011. * Simplification of a given mesh according to the given settings.
  144012. * Since this requires computation, it is assumed that the function runs async.
  144013. * @param settings The settings of the simplification, including quality and distance
  144014. * @param successCallback A callback that will be called after the mesh was simplified.
  144015. * @param errorCallback in case of an error, this callback will be called. optional.
  144016. */
  144017. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144018. }
  144019. /**
  144020. * Expected simplification settings.
  144021. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144022. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144023. */
  144024. export interface ISimplificationSettings {
  144025. /**
  144026. * Gets or sets the expected quality
  144027. */
  144028. quality: number;
  144029. /**
  144030. * Gets or sets the distance when this optimized version should be used
  144031. */
  144032. distance: number;
  144033. /**
  144034. * Gets an already optimized mesh
  144035. */
  144036. optimizeMesh?: boolean;
  144037. }
  144038. /**
  144039. * Class used to specify simplification options
  144040. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144041. */
  144042. export class SimplificationSettings implements ISimplificationSettings {
  144043. /** expected quality */
  144044. quality: number;
  144045. /** distance when this optimized version should be used */
  144046. distance: number;
  144047. /** already optimized mesh */
  144048. optimizeMesh?: boolean | undefined;
  144049. /**
  144050. * Creates a SimplificationSettings
  144051. * @param quality expected quality
  144052. * @param distance distance when this optimized version should be used
  144053. * @param optimizeMesh already optimized mesh
  144054. */
  144055. constructor(
  144056. /** expected quality */
  144057. quality: number,
  144058. /** distance when this optimized version should be used */
  144059. distance: number,
  144060. /** already optimized mesh */
  144061. optimizeMesh?: boolean | undefined);
  144062. }
  144063. /**
  144064. * Interface used to define a simplification task
  144065. */
  144066. export interface ISimplificationTask {
  144067. /**
  144068. * Array of settings
  144069. */
  144070. settings: Array<ISimplificationSettings>;
  144071. /**
  144072. * Simplification type
  144073. */
  144074. simplificationType: SimplificationType;
  144075. /**
  144076. * Mesh to simplify
  144077. */
  144078. mesh: Mesh;
  144079. /**
  144080. * Callback called on success
  144081. */
  144082. successCallback?: () => void;
  144083. /**
  144084. * Defines if parallel processing can be used
  144085. */
  144086. parallelProcessing: boolean;
  144087. }
  144088. /**
  144089. * Queue used to order the simplification tasks
  144090. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144091. */
  144092. export class SimplificationQueue {
  144093. private _simplificationArray;
  144094. /**
  144095. * Gets a boolean indicating that the process is still running
  144096. */
  144097. running: boolean;
  144098. /**
  144099. * Creates a new queue
  144100. */
  144101. constructor();
  144102. /**
  144103. * Adds a new simplification task
  144104. * @param task defines a task to add
  144105. */
  144106. addTask(task: ISimplificationTask): void;
  144107. /**
  144108. * Execute next task
  144109. */
  144110. executeNext(): void;
  144111. /**
  144112. * Execute a simplification task
  144113. * @param task defines the task to run
  144114. */
  144115. runSimplification(task: ISimplificationTask): void;
  144116. private getSimplifier;
  144117. }
  144118. /**
  144119. * The implemented types of simplification
  144120. * At the moment only Quadratic Error Decimation is implemented
  144121. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144122. */
  144123. export enum SimplificationType {
  144124. /** Quadratic error decimation */
  144125. QUADRATIC = 0
  144126. }
  144127. /**
  144128. * An implementation of the Quadratic Error simplification algorithm.
  144129. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  144130. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  144131. * @author RaananW
  144132. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144133. */
  144134. export class QuadraticErrorSimplification implements ISimplifier {
  144135. private _mesh;
  144136. private triangles;
  144137. private vertices;
  144138. private references;
  144139. private _reconstructedMesh;
  144140. /** Gets or sets the number pf sync interations */
  144141. syncIterations: number;
  144142. /** Gets or sets the aggressiveness of the simplifier */
  144143. aggressiveness: number;
  144144. /** Gets or sets the number of allowed iterations for decimation */
  144145. decimationIterations: number;
  144146. /** Gets or sets the espilon to use for bounding box computation */
  144147. boundingBoxEpsilon: number;
  144148. /**
  144149. * Creates a new QuadraticErrorSimplification
  144150. * @param _mesh defines the target mesh
  144151. */
  144152. constructor(_mesh: Mesh);
  144153. /**
  144154. * Simplification of a given mesh according to the given settings.
  144155. * Since this requires computation, it is assumed that the function runs async.
  144156. * @param settings The settings of the simplification, including quality and distance
  144157. * @param successCallback A callback that will be called after the mesh was simplified.
  144158. */
  144159. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  144160. private runDecimation;
  144161. private initWithMesh;
  144162. private init;
  144163. private reconstructMesh;
  144164. private initDecimatedMesh;
  144165. private isFlipped;
  144166. private updateTriangles;
  144167. private identifyBorder;
  144168. private updateMesh;
  144169. private vertexError;
  144170. private calculateError;
  144171. }
  144172. }
  144173. declare module BABYLON {
  144174. interface Scene {
  144175. /** @hidden (Backing field) */
  144176. _simplificationQueue: SimplificationQueue;
  144177. /**
  144178. * Gets or sets the simplification queue attached to the scene
  144179. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144180. */
  144181. simplificationQueue: SimplificationQueue;
  144182. }
  144183. interface Mesh {
  144184. /**
  144185. * Simplify the mesh according to the given array of settings.
  144186. * Function will return immediately and will simplify async
  144187. * @param settings a collection of simplification settings
  144188. * @param parallelProcessing should all levels calculate parallel or one after the other
  144189. * @param simplificationType the type of simplification to run
  144190. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  144191. * @returns the current mesh
  144192. */
  144193. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  144194. }
  144195. /**
  144196. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  144197. * created in a scene
  144198. */
  144199. export class SimplicationQueueSceneComponent implements ISceneComponent {
  144200. /**
  144201. * The component name helpfull to identify the component in the list of scene components.
  144202. */
  144203. readonly name: string;
  144204. /**
  144205. * The scene the component belongs to.
  144206. */
  144207. scene: Scene;
  144208. /**
  144209. * Creates a new instance of the component for the given scene
  144210. * @param scene Defines the scene to register the component in
  144211. */
  144212. constructor(scene: Scene);
  144213. /**
  144214. * Registers the component in a given scene
  144215. */
  144216. register(): void;
  144217. /**
  144218. * Rebuilds the elements related to this component in case of
  144219. * context lost for instance.
  144220. */
  144221. rebuild(): void;
  144222. /**
  144223. * Disposes the component and the associated ressources
  144224. */
  144225. dispose(): void;
  144226. private _beforeCameraUpdate;
  144227. }
  144228. }
  144229. declare module BABYLON {
  144230. interface Mesh {
  144231. /**
  144232. * Creates a new thin instance
  144233. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  144234. * @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
  144235. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  144236. */
  144237. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  144238. /**
  144239. * Adds the transformation (matrix) of the current mesh as a thin instance
  144240. * @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
  144241. * @returns the thin instance index number
  144242. */
  144243. thinInstanceAddSelf(refresh: boolean): number;
  144244. /**
  144245. * Registers a custom attribute to be used with thin instances
  144246. * @param kind name of the attribute
  144247. * @param stride size in floats of the attribute
  144248. */
  144249. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  144250. /**
  144251. * Sets the matrix of a thin instance
  144252. * @param index index of the thin instance
  144253. * @param matrix matrix to set
  144254. * @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
  144255. */
  144256. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  144257. /**
  144258. * Sets the value of a custom attribute for a thin instance
  144259. * @param kind name of the attribute
  144260. * @param index index of the thin instance
  144261. * @param value value to set
  144262. * @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
  144263. */
  144264. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  144265. /**
  144266. * 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.
  144267. */
  144268. thinInstanceCount: number;
  144269. /**
  144270. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  144271. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  144272. * @param buffer buffer to set
  144273. * @param stride size in floats of each value of the buffer
  144274. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  144275. */
  144276. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  144277. /**
  144278. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  144279. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  144280. */
  144281. thinInstanceBufferUpdated(kind: string): void;
  144282. /**
  144283. * Refreshes the bounding info, taking into account all the thin instances defined
  144284. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  144285. */
  144286. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  144287. /** @hidden */
  144288. _thinInstanceInitializeUserStorage(): void;
  144289. /** @hidden */
  144290. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  144291. /** @hidden */
  144292. _userThinInstanceBuffersStorage: {
  144293. data: {
  144294. [key: string]: Float32Array;
  144295. };
  144296. sizes: {
  144297. [key: string]: number;
  144298. };
  144299. vertexBuffers: {
  144300. [key: string]: Nullable<VertexBuffer>;
  144301. };
  144302. strides: {
  144303. [key: string]: number;
  144304. };
  144305. };
  144306. }
  144307. }
  144308. declare module BABYLON {
  144309. /**
  144310. * Navigation plugin interface to add navigation constrained by a navigation mesh
  144311. */
  144312. export interface INavigationEnginePlugin {
  144313. /**
  144314. * plugin name
  144315. */
  144316. name: string;
  144317. /**
  144318. * Creates a navigation mesh
  144319. * @param meshes array of all the geometry used to compute the navigatio mesh
  144320. * @param parameters bunch of parameters used to filter geometry
  144321. */
  144322. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144323. /**
  144324. * Create a navigation mesh debug mesh
  144325. * @param scene is where the mesh will be added
  144326. * @returns debug display mesh
  144327. */
  144328. createDebugNavMesh(scene: Scene): Mesh;
  144329. /**
  144330. * Get a navigation mesh constrained position, closest to the parameter position
  144331. * @param position world position
  144332. * @returns the closest point to position constrained by the navigation mesh
  144333. */
  144334. getClosestPoint(position: Vector3): Vector3;
  144335. /**
  144336. * Get a navigation mesh constrained position, closest to the parameter position
  144337. * @param position world position
  144338. * @param result output the closest point to position constrained by the navigation mesh
  144339. */
  144340. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144341. /**
  144342. * Get a navigation mesh constrained position, within a particular radius
  144343. * @param position world position
  144344. * @param maxRadius the maximum distance to the constrained world position
  144345. * @returns the closest point to position constrained by the navigation mesh
  144346. */
  144347. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144348. /**
  144349. * Get a navigation mesh constrained position, within a particular radius
  144350. * @param position world position
  144351. * @param maxRadius the maximum distance to the constrained world position
  144352. * @param result output the closest point to position constrained by the navigation mesh
  144353. */
  144354. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144355. /**
  144356. * Compute the final position from a segment made of destination-position
  144357. * @param position world position
  144358. * @param destination world position
  144359. * @returns the resulting point along the navmesh
  144360. */
  144361. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144362. /**
  144363. * Compute the final position from a segment made of destination-position
  144364. * @param position world position
  144365. * @param destination world position
  144366. * @param result output the resulting point along the navmesh
  144367. */
  144368. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144369. /**
  144370. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144371. * @param start world position
  144372. * @param end world position
  144373. * @returns array containing world position composing the path
  144374. */
  144375. computePath(start: Vector3, end: Vector3): Vector3[];
  144376. /**
  144377. * If this plugin is supported
  144378. * @returns true if plugin is supported
  144379. */
  144380. isSupported(): boolean;
  144381. /**
  144382. * Create a new Crowd so you can add agents
  144383. * @param maxAgents the maximum agent count in the crowd
  144384. * @param maxAgentRadius the maximum radius an agent can have
  144385. * @param scene to attach the crowd to
  144386. * @returns the crowd you can add agents to
  144387. */
  144388. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144389. /**
  144390. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144391. * The queries will try to find a solution within those bounds
  144392. * default is (1,1,1)
  144393. * @param extent x,y,z value that define the extent around the queries point of reference
  144394. */
  144395. setDefaultQueryExtent(extent: Vector3): void;
  144396. /**
  144397. * Get the Bounding box extent specified by setDefaultQueryExtent
  144398. * @returns the box extent values
  144399. */
  144400. getDefaultQueryExtent(): Vector3;
  144401. /**
  144402. * build the navmesh from a previously saved state using getNavmeshData
  144403. * @param data the Uint8Array returned by getNavmeshData
  144404. */
  144405. buildFromNavmeshData(data: Uint8Array): void;
  144406. /**
  144407. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144408. * @returns data the Uint8Array that can be saved and reused
  144409. */
  144410. getNavmeshData(): Uint8Array;
  144411. /**
  144412. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144413. * @param result output the box extent values
  144414. */
  144415. getDefaultQueryExtentToRef(result: Vector3): void;
  144416. /**
  144417. * Release all resources
  144418. */
  144419. dispose(): void;
  144420. }
  144421. /**
  144422. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144423. */
  144424. export interface ICrowd {
  144425. /**
  144426. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144427. * You can attach anything to that node. The node position is updated in the scene update tick.
  144428. * @param pos world position that will be constrained by the navigation mesh
  144429. * @param parameters agent parameters
  144430. * @param transform hooked to the agent that will be update by the scene
  144431. * @returns agent index
  144432. */
  144433. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144434. /**
  144435. * Returns the agent position in world space
  144436. * @param index agent index returned by addAgent
  144437. * @returns world space position
  144438. */
  144439. getAgentPosition(index: number): Vector3;
  144440. /**
  144441. * Gets the agent position result in world space
  144442. * @param index agent index returned by addAgent
  144443. * @param result output world space position
  144444. */
  144445. getAgentPositionToRef(index: number, result: Vector3): void;
  144446. /**
  144447. * Gets the agent velocity in world space
  144448. * @param index agent index returned by addAgent
  144449. * @returns world space velocity
  144450. */
  144451. getAgentVelocity(index: number): Vector3;
  144452. /**
  144453. * Gets the agent velocity result in world space
  144454. * @param index agent index returned by addAgent
  144455. * @param result output world space velocity
  144456. */
  144457. getAgentVelocityToRef(index: number, result: Vector3): void;
  144458. /**
  144459. * remove a particular agent previously created
  144460. * @param index agent index returned by addAgent
  144461. */
  144462. removeAgent(index: number): void;
  144463. /**
  144464. * get the list of all agents attached to this crowd
  144465. * @returns list of agent indices
  144466. */
  144467. getAgents(): number[];
  144468. /**
  144469. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144470. * @param deltaTime in seconds
  144471. */
  144472. update(deltaTime: number): void;
  144473. /**
  144474. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144475. * @param index agent index returned by addAgent
  144476. * @param destination targeted world position
  144477. */
  144478. agentGoto(index: number, destination: Vector3): void;
  144479. /**
  144480. * Teleport the agent to a new position
  144481. * @param index agent index returned by addAgent
  144482. * @param destination targeted world position
  144483. */
  144484. agentTeleport(index: number, destination: Vector3): void;
  144485. /**
  144486. * Update agent parameters
  144487. * @param index agent index returned by addAgent
  144488. * @param parameters agent parameters
  144489. */
  144490. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144491. /**
  144492. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144493. * The queries will try to find a solution within those bounds
  144494. * default is (1,1,1)
  144495. * @param extent x,y,z value that define the extent around the queries point of reference
  144496. */
  144497. setDefaultQueryExtent(extent: Vector3): void;
  144498. /**
  144499. * Get the Bounding box extent specified by setDefaultQueryExtent
  144500. * @returns the box extent values
  144501. */
  144502. getDefaultQueryExtent(): Vector3;
  144503. /**
  144504. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144505. * @param result output the box extent values
  144506. */
  144507. getDefaultQueryExtentToRef(result: Vector3): void;
  144508. /**
  144509. * Release all resources
  144510. */
  144511. dispose(): void;
  144512. }
  144513. /**
  144514. * Configures an agent
  144515. */
  144516. export interface IAgentParameters {
  144517. /**
  144518. * Agent radius. [Limit: >= 0]
  144519. */
  144520. radius: number;
  144521. /**
  144522. * Agent height. [Limit: > 0]
  144523. */
  144524. height: number;
  144525. /**
  144526. * Maximum allowed acceleration. [Limit: >= 0]
  144527. */
  144528. maxAcceleration: number;
  144529. /**
  144530. * Maximum allowed speed. [Limit: >= 0]
  144531. */
  144532. maxSpeed: number;
  144533. /**
  144534. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144535. */
  144536. collisionQueryRange: number;
  144537. /**
  144538. * The path visibility optimization range. [Limit: > 0]
  144539. */
  144540. pathOptimizationRange: number;
  144541. /**
  144542. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144543. */
  144544. separationWeight: number;
  144545. }
  144546. /**
  144547. * Configures the navigation mesh creation
  144548. */
  144549. export interface INavMeshParameters {
  144550. /**
  144551. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144552. */
  144553. cs: number;
  144554. /**
  144555. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144556. */
  144557. ch: number;
  144558. /**
  144559. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144560. */
  144561. walkableSlopeAngle: number;
  144562. /**
  144563. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144564. * be considered walkable. [Limit: >= 3] [Units: vx]
  144565. */
  144566. walkableHeight: number;
  144567. /**
  144568. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144569. */
  144570. walkableClimb: number;
  144571. /**
  144572. * The distance to erode/shrink the walkable area of the heightfield away from
  144573. * obstructions. [Limit: >=0] [Units: vx]
  144574. */
  144575. walkableRadius: number;
  144576. /**
  144577. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144578. */
  144579. maxEdgeLen: number;
  144580. /**
  144581. * The maximum distance a simplfied contour's border edges should deviate
  144582. * the original raw contour. [Limit: >=0] [Units: vx]
  144583. */
  144584. maxSimplificationError: number;
  144585. /**
  144586. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144587. */
  144588. minRegionArea: number;
  144589. /**
  144590. * Any regions with a span count smaller than this value will, if possible,
  144591. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144592. */
  144593. mergeRegionArea: number;
  144594. /**
  144595. * The maximum number of vertices allowed for polygons generated during the
  144596. * contour to polygon conversion process. [Limit: >= 3]
  144597. */
  144598. maxVertsPerPoly: number;
  144599. /**
  144600. * Sets the sampling distance to use when generating the detail mesh.
  144601. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144602. */
  144603. detailSampleDist: number;
  144604. /**
  144605. * The maximum distance the detail mesh surface should deviate from heightfield
  144606. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144607. */
  144608. detailSampleMaxError: number;
  144609. }
  144610. }
  144611. declare module BABYLON {
  144612. /**
  144613. * RecastJS navigation plugin
  144614. */
  144615. export class RecastJSPlugin implements INavigationEnginePlugin {
  144616. /**
  144617. * Reference to the Recast library
  144618. */
  144619. bjsRECAST: any;
  144620. /**
  144621. * plugin name
  144622. */
  144623. name: string;
  144624. /**
  144625. * the first navmesh created. We might extend this to support multiple navmeshes
  144626. */
  144627. navMesh: any;
  144628. /**
  144629. * Initializes the recastJS plugin
  144630. * @param recastInjection can be used to inject your own recast reference
  144631. */
  144632. constructor(recastInjection?: any);
  144633. /**
  144634. * Creates a navigation mesh
  144635. * @param meshes array of all the geometry used to compute the navigatio mesh
  144636. * @param parameters bunch of parameters used to filter geometry
  144637. */
  144638. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144639. /**
  144640. * Create a navigation mesh debug mesh
  144641. * @param scene is where the mesh will be added
  144642. * @returns debug display mesh
  144643. */
  144644. createDebugNavMesh(scene: Scene): Mesh;
  144645. /**
  144646. * Get a navigation mesh constrained position, closest to the parameter position
  144647. * @param position world position
  144648. * @returns the closest point to position constrained by the navigation mesh
  144649. */
  144650. getClosestPoint(position: Vector3): Vector3;
  144651. /**
  144652. * Get a navigation mesh constrained position, closest to the parameter position
  144653. * @param position world position
  144654. * @param result output the closest point to position constrained by the navigation mesh
  144655. */
  144656. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144657. /**
  144658. * Get a navigation mesh constrained position, within a particular radius
  144659. * @param position world position
  144660. * @param maxRadius the maximum distance to the constrained world position
  144661. * @returns the closest point to position constrained by the navigation mesh
  144662. */
  144663. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144664. /**
  144665. * Get a navigation mesh constrained position, within a particular radius
  144666. * @param position world position
  144667. * @param maxRadius the maximum distance to the constrained world position
  144668. * @param result output the closest point to position constrained by the navigation mesh
  144669. */
  144670. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144671. /**
  144672. * Compute the final position from a segment made of destination-position
  144673. * @param position world position
  144674. * @param destination world position
  144675. * @returns the resulting point along the navmesh
  144676. */
  144677. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144678. /**
  144679. * Compute the final position from a segment made of destination-position
  144680. * @param position world position
  144681. * @param destination world position
  144682. * @param result output the resulting point along the navmesh
  144683. */
  144684. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144685. /**
  144686. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144687. * @param start world position
  144688. * @param end world position
  144689. * @returns array containing world position composing the path
  144690. */
  144691. computePath(start: Vector3, end: Vector3): Vector3[];
  144692. /**
  144693. * Create a new Crowd so you can add agents
  144694. * @param maxAgents the maximum agent count in the crowd
  144695. * @param maxAgentRadius the maximum radius an agent can have
  144696. * @param scene to attach the crowd to
  144697. * @returns the crowd you can add agents to
  144698. */
  144699. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144700. /**
  144701. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144702. * The queries will try to find a solution within those bounds
  144703. * default is (1,1,1)
  144704. * @param extent x,y,z value that define the extent around the queries point of reference
  144705. */
  144706. setDefaultQueryExtent(extent: Vector3): void;
  144707. /**
  144708. * Get the Bounding box extent specified by setDefaultQueryExtent
  144709. * @returns the box extent values
  144710. */
  144711. getDefaultQueryExtent(): Vector3;
  144712. /**
  144713. * build the navmesh from a previously saved state using getNavmeshData
  144714. * @param data the Uint8Array returned by getNavmeshData
  144715. */
  144716. buildFromNavmeshData(data: Uint8Array): void;
  144717. /**
  144718. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144719. * @returns data the Uint8Array that can be saved and reused
  144720. */
  144721. getNavmeshData(): Uint8Array;
  144722. /**
  144723. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144724. * @param result output the box extent values
  144725. */
  144726. getDefaultQueryExtentToRef(result: Vector3): void;
  144727. /**
  144728. * Disposes
  144729. */
  144730. dispose(): void;
  144731. /**
  144732. * If this plugin is supported
  144733. * @returns true if plugin is supported
  144734. */
  144735. isSupported(): boolean;
  144736. }
  144737. /**
  144738. * Recast detour crowd implementation
  144739. */
  144740. export class RecastJSCrowd implements ICrowd {
  144741. /**
  144742. * Recast/detour plugin
  144743. */
  144744. bjsRECASTPlugin: RecastJSPlugin;
  144745. /**
  144746. * Link to the detour crowd
  144747. */
  144748. recastCrowd: any;
  144749. /**
  144750. * One transform per agent
  144751. */
  144752. transforms: TransformNode[];
  144753. /**
  144754. * All agents created
  144755. */
  144756. agents: number[];
  144757. /**
  144758. * Link to the scene is kept to unregister the crowd from the scene
  144759. */
  144760. private _scene;
  144761. /**
  144762. * Observer for crowd updates
  144763. */
  144764. private _onBeforeAnimationsObserver;
  144765. /**
  144766. * Constructor
  144767. * @param plugin recastJS plugin
  144768. * @param maxAgents the maximum agent count in the crowd
  144769. * @param maxAgentRadius the maximum radius an agent can have
  144770. * @param scene to attach the crowd to
  144771. * @returns the crowd you can add agents to
  144772. */
  144773. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144774. /**
  144775. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144776. * You can attach anything to that node. The node position is updated in the scene update tick.
  144777. * @param pos world position that will be constrained by the navigation mesh
  144778. * @param parameters agent parameters
  144779. * @param transform hooked to the agent that will be update by the scene
  144780. * @returns agent index
  144781. */
  144782. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144783. /**
  144784. * Returns the agent position in world space
  144785. * @param index agent index returned by addAgent
  144786. * @returns world space position
  144787. */
  144788. getAgentPosition(index: number): Vector3;
  144789. /**
  144790. * Returns the agent position result in world space
  144791. * @param index agent index returned by addAgent
  144792. * @param result output world space position
  144793. */
  144794. getAgentPositionToRef(index: number, result: Vector3): void;
  144795. /**
  144796. * Returns the agent velocity in world space
  144797. * @param index agent index returned by addAgent
  144798. * @returns world space velocity
  144799. */
  144800. getAgentVelocity(index: number): Vector3;
  144801. /**
  144802. * Returns the agent velocity result in world space
  144803. * @param index agent index returned by addAgent
  144804. * @param result output world space velocity
  144805. */
  144806. getAgentVelocityToRef(index: number, result: Vector3): void;
  144807. /**
  144808. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144809. * @param index agent index returned by addAgent
  144810. * @param destination targeted world position
  144811. */
  144812. agentGoto(index: number, destination: Vector3): void;
  144813. /**
  144814. * Teleport the agent to a new position
  144815. * @param index agent index returned by addAgent
  144816. * @param destination targeted world position
  144817. */
  144818. agentTeleport(index: number, destination: Vector3): void;
  144819. /**
  144820. * Update agent parameters
  144821. * @param index agent index returned by addAgent
  144822. * @param parameters agent parameters
  144823. */
  144824. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144825. /**
  144826. * remove a particular agent previously created
  144827. * @param index agent index returned by addAgent
  144828. */
  144829. removeAgent(index: number): void;
  144830. /**
  144831. * get the list of all agents attached to this crowd
  144832. * @returns list of agent indices
  144833. */
  144834. getAgents(): number[];
  144835. /**
  144836. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144837. * @param deltaTime in seconds
  144838. */
  144839. update(deltaTime: number): void;
  144840. /**
  144841. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144842. * The queries will try to find a solution within those bounds
  144843. * default is (1,1,1)
  144844. * @param extent x,y,z value that define the extent around the queries point of reference
  144845. */
  144846. setDefaultQueryExtent(extent: Vector3): void;
  144847. /**
  144848. * Get the Bounding box extent specified by setDefaultQueryExtent
  144849. * @returns the box extent values
  144850. */
  144851. getDefaultQueryExtent(): Vector3;
  144852. /**
  144853. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144854. * @param result output the box extent values
  144855. */
  144856. getDefaultQueryExtentToRef(result: Vector3): void;
  144857. /**
  144858. * Release all resources
  144859. */
  144860. dispose(): void;
  144861. }
  144862. }
  144863. declare module BABYLON {
  144864. /**
  144865. * Class used to enable access to IndexedDB
  144866. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144867. */
  144868. export class Database implements IOfflineProvider {
  144869. private _callbackManifestChecked;
  144870. private _currentSceneUrl;
  144871. private _db;
  144872. private _enableSceneOffline;
  144873. private _enableTexturesOffline;
  144874. private _manifestVersionFound;
  144875. private _mustUpdateRessources;
  144876. private _hasReachedQuota;
  144877. private _isSupported;
  144878. private _idbFactory;
  144879. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144880. private static IsUASupportingBlobStorage;
  144881. /**
  144882. * Gets a boolean indicating if Database storate is enabled (off by default)
  144883. */
  144884. static IDBStorageEnabled: boolean;
  144885. /**
  144886. * Gets a boolean indicating if scene must be saved in the database
  144887. */
  144888. get enableSceneOffline(): boolean;
  144889. /**
  144890. * Gets a boolean indicating if textures must be saved in the database
  144891. */
  144892. get enableTexturesOffline(): boolean;
  144893. /**
  144894. * Creates a new Database
  144895. * @param urlToScene defines the url to load the scene
  144896. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144897. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144898. */
  144899. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144900. private static _ParseURL;
  144901. private static _ReturnFullUrlLocation;
  144902. private _checkManifestFile;
  144903. /**
  144904. * Open the database and make it available
  144905. * @param successCallback defines the callback to call on success
  144906. * @param errorCallback defines the callback to call on error
  144907. */
  144908. open(successCallback: () => void, errorCallback: () => void): void;
  144909. /**
  144910. * Loads an image from the database
  144911. * @param url defines the url to load from
  144912. * @param image defines the target DOM image
  144913. */
  144914. loadImage(url: string, image: HTMLImageElement): void;
  144915. private _loadImageFromDBAsync;
  144916. private _saveImageIntoDBAsync;
  144917. private _checkVersionFromDB;
  144918. private _loadVersionFromDBAsync;
  144919. private _saveVersionIntoDBAsync;
  144920. /**
  144921. * Loads a file from database
  144922. * @param url defines the URL to load from
  144923. * @param sceneLoaded defines a callback to call on success
  144924. * @param progressCallBack defines a callback to call when progress changed
  144925. * @param errorCallback defines a callback to call on error
  144926. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144927. */
  144928. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144929. private _loadFileAsync;
  144930. private _saveFileAsync;
  144931. /**
  144932. * Validates if xhr data is correct
  144933. * @param xhr defines the request to validate
  144934. * @param dataType defines the expected data type
  144935. * @returns true if data is correct
  144936. */
  144937. private static _ValidateXHRData;
  144938. }
  144939. }
  144940. declare module BABYLON {
  144941. /** @hidden */
  144942. export var gpuUpdateParticlesPixelShader: {
  144943. name: string;
  144944. shader: string;
  144945. };
  144946. }
  144947. declare module BABYLON {
  144948. /** @hidden */
  144949. export var gpuUpdateParticlesVertexShader: {
  144950. name: string;
  144951. shader: string;
  144952. };
  144953. }
  144954. declare module BABYLON {
  144955. /** @hidden */
  144956. export var clipPlaneFragmentDeclaration2: {
  144957. name: string;
  144958. shader: string;
  144959. };
  144960. }
  144961. declare module BABYLON {
  144962. /** @hidden */
  144963. export var gpuRenderParticlesPixelShader: {
  144964. name: string;
  144965. shader: string;
  144966. };
  144967. }
  144968. declare module BABYLON {
  144969. /** @hidden */
  144970. export var clipPlaneVertexDeclaration2: {
  144971. name: string;
  144972. shader: string;
  144973. };
  144974. }
  144975. declare module BABYLON {
  144976. /** @hidden */
  144977. export var gpuRenderParticlesVertexShader: {
  144978. name: string;
  144979. shader: string;
  144980. };
  144981. }
  144982. declare module BABYLON {
  144983. /**
  144984. * This represents a GPU particle system in Babylon
  144985. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144986. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144987. */
  144988. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144989. /**
  144990. * The layer mask we are rendering the particles through.
  144991. */
  144992. layerMask: number;
  144993. private _capacity;
  144994. private _activeCount;
  144995. private _currentActiveCount;
  144996. private _accumulatedCount;
  144997. private _renderEffect;
  144998. private _updateEffect;
  144999. private _buffer0;
  145000. private _buffer1;
  145001. private _spriteBuffer;
  145002. private _updateVAO;
  145003. private _renderVAO;
  145004. private _targetIndex;
  145005. private _sourceBuffer;
  145006. private _targetBuffer;
  145007. private _engine;
  145008. private _currentRenderId;
  145009. private _started;
  145010. private _stopped;
  145011. private _timeDelta;
  145012. private _randomTexture;
  145013. private _randomTexture2;
  145014. private _attributesStrideSize;
  145015. private _updateEffectOptions;
  145016. private _randomTextureSize;
  145017. private _actualFrame;
  145018. private _customEffect;
  145019. private readonly _rawTextureWidth;
  145020. /**
  145021. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145022. */
  145023. static get IsSupported(): boolean;
  145024. /**
  145025. * An event triggered when the system is disposed.
  145026. */
  145027. onDisposeObservable: Observable<IParticleSystem>;
  145028. /**
  145029. * Gets the maximum number of particles active at the same time.
  145030. * @returns The max number of active particles.
  145031. */
  145032. getCapacity(): number;
  145033. /**
  145034. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145035. * to override the particles.
  145036. */
  145037. forceDepthWrite: boolean;
  145038. /**
  145039. * Gets or set the number of active particles
  145040. */
  145041. get activeParticleCount(): number;
  145042. set activeParticleCount(value: number);
  145043. private _preWarmDone;
  145044. /**
  145045. * Specifies if the particles are updated in emitter local space or world space.
  145046. */
  145047. isLocal: boolean;
  145048. /**
  145049. * Is this system ready to be used/rendered
  145050. * @return true if the system is ready
  145051. */
  145052. isReady(): boolean;
  145053. /**
  145054. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145055. * @returns True if it has been started, otherwise false.
  145056. */
  145057. isStarted(): boolean;
  145058. /**
  145059. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145060. * @returns True if it has been stopped, otherwise false.
  145061. */
  145062. isStopped(): boolean;
  145063. /**
  145064. * Gets a boolean indicating that the system is stopping
  145065. * @returns true if the system is currently stopping
  145066. */
  145067. isStopping(): boolean;
  145068. /**
  145069. * Gets the number of particles active at the same time.
  145070. * @returns The number of active particles.
  145071. */
  145072. getActiveCount(): number;
  145073. /**
  145074. * Starts the particle system and begins to emit
  145075. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145076. */
  145077. start(delay?: number): void;
  145078. /**
  145079. * Stops the particle system.
  145080. */
  145081. stop(): void;
  145082. /**
  145083. * Remove all active particles
  145084. */
  145085. reset(): void;
  145086. /**
  145087. * Returns the string "GPUParticleSystem"
  145088. * @returns a string containing the class name
  145089. */
  145090. getClassName(): string;
  145091. /**
  145092. * Gets the custom effect used to render the particles
  145093. * @param blendMode Blend mode for which the effect should be retrieved
  145094. * @returns The effect
  145095. */
  145096. getCustomEffect(blendMode?: number): Nullable<Effect>;
  145097. /**
  145098. * Sets the custom effect used to render the particles
  145099. * @param effect The effect to set
  145100. * @param blendMode Blend mode for which the effect should be set
  145101. */
  145102. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  145103. /** @hidden */
  145104. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  145105. /**
  145106. * Observable that will be called just before the particles are drawn
  145107. */
  145108. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  145109. /**
  145110. * Gets the name of the particle vertex shader
  145111. */
  145112. get vertexShaderName(): string;
  145113. private _colorGradientsTexture;
  145114. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  145115. /**
  145116. * Adds a new color gradient
  145117. * @param gradient defines the gradient to use (between 0 and 1)
  145118. * @param color1 defines the color to affect to the specified gradient
  145119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  145120. * @returns the current particle system
  145121. */
  145122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  145123. private _refreshColorGradient;
  145124. /** Force the system to rebuild all gradients that need to be resync */
  145125. forceRefreshGradients(): void;
  145126. /**
  145127. * Remove a specific color gradient
  145128. * @param gradient defines the gradient to remove
  145129. * @returns the current particle system
  145130. */
  145131. removeColorGradient(gradient: number): GPUParticleSystem;
  145132. private _angularSpeedGradientsTexture;
  145133. private _sizeGradientsTexture;
  145134. private _velocityGradientsTexture;
  145135. private _limitVelocityGradientsTexture;
  145136. private _dragGradientsTexture;
  145137. private _addFactorGradient;
  145138. /**
  145139. * Adds a new size gradient
  145140. * @param gradient defines the gradient to use (between 0 and 1)
  145141. * @param factor defines the size factor to affect to the specified gradient
  145142. * @returns the current particle system
  145143. */
  145144. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  145145. /**
  145146. * Remove a specific size gradient
  145147. * @param gradient defines the gradient to remove
  145148. * @returns the current particle system
  145149. */
  145150. removeSizeGradient(gradient: number): GPUParticleSystem;
  145151. private _refreshFactorGradient;
  145152. /**
  145153. * Adds a new angular speed gradient
  145154. * @param gradient defines the gradient to use (between 0 and 1)
  145155. * @param factor defines the angular speed to affect to the specified gradient
  145156. * @returns the current particle system
  145157. */
  145158. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  145159. /**
  145160. * Remove a specific angular speed gradient
  145161. * @param gradient defines the gradient to remove
  145162. * @returns the current particle system
  145163. */
  145164. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  145165. /**
  145166. * Adds a new velocity gradient
  145167. * @param gradient defines the gradient to use (between 0 and 1)
  145168. * @param factor defines the velocity to affect to the specified gradient
  145169. * @returns the current particle system
  145170. */
  145171. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145172. /**
  145173. * Remove a specific velocity gradient
  145174. * @param gradient defines the gradient to remove
  145175. * @returns the current particle system
  145176. */
  145177. removeVelocityGradient(gradient: number): GPUParticleSystem;
  145178. /**
  145179. * Adds a new limit velocity gradient
  145180. * @param gradient defines the gradient to use (between 0 and 1)
  145181. * @param factor defines the limit velocity value to affect to the specified gradient
  145182. * @returns the current particle system
  145183. */
  145184. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145185. /**
  145186. * Remove a specific limit velocity gradient
  145187. * @param gradient defines the gradient to remove
  145188. * @returns the current particle system
  145189. */
  145190. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  145191. /**
  145192. * Adds a new drag gradient
  145193. * @param gradient defines the gradient to use (between 0 and 1)
  145194. * @param factor defines the drag value to affect to the specified gradient
  145195. * @returns the current particle system
  145196. */
  145197. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  145198. /**
  145199. * Remove a specific drag gradient
  145200. * @param gradient defines the gradient to remove
  145201. * @returns the current particle system
  145202. */
  145203. removeDragGradient(gradient: number): GPUParticleSystem;
  145204. /**
  145205. * Not supported by GPUParticleSystem
  145206. * @param gradient defines the gradient to use (between 0 and 1)
  145207. * @param factor defines the emit rate value to affect to the specified gradient
  145208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145209. * @returns the current particle system
  145210. */
  145211. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145212. /**
  145213. * Not supported by GPUParticleSystem
  145214. * @param gradient defines the gradient to remove
  145215. * @returns the current particle system
  145216. */
  145217. removeEmitRateGradient(gradient: number): IParticleSystem;
  145218. /**
  145219. * Not supported by GPUParticleSystem
  145220. * @param gradient defines the gradient to use (between 0 and 1)
  145221. * @param factor defines the start size value to affect to the specified gradient
  145222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145223. * @returns the current particle system
  145224. */
  145225. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145226. /**
  145227. * Not supported by GPUParticleSystem
  145228. * @param gradient defines the gradient to remove
  145229. * @returns the current particle system
  145230. */
  145231. removeStartSizeGradient(gradient: number): IParticleSystem;
  145232. /**
  145233. * Not supported by GPUParticleSystem
  145234. * @param gradient defines the gradient to use (between 0 and 1)
  145235. * @param min defines the color remap minimal range
  145236. * @param max defines the color remap maximal range
  145237. * @returns the current particle system
  145238. */
  145239. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145240. /**
  145241. * Not supported by GPUParticleSystem
  145242. * @param gradient defines the gradient to remove
  145243. * @returns the current particle system
  145244. */
  145245. removeColorRemapGradient(): IParticleSystem;
  145246. /**
  145247. * Not supported by GPUParticleSystem
  145248. * @param gradient defines the gradient to use (between 0 and 1)
  145249. * @param min defines the alpha remap minimal range
  145250. * @param max defines the alpha remap maximal range
  145251. * @returns the current particle system
  145252. */
  145253. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145254. /**
  145255. * Not supported by GPUParticleSystem
  145256. * @param gradient defines the gradient to remove
  145257. * @returns the current particle system
  145258. */
  145259. removeAlphaRemapGradient(): IParticleSystem;
  145260. /**
  145261. * Not supported by GPUParticleSystem
  145262. * @param gradient defines the gradient to use (between 0 and 1)
  145263. * @param color defines the color to affect to the specified gradient
  145264. * @returns the current particle system
  145265. */
  145266. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  145267. /**
  145268. * Not supported by GPUParticleSystem
  145269. * @param gradient defines the gradient to remove
  145270. * @returns the current particle system
  145271. */
  145272. removeRampGradient(): IParticleSystem;
  145273. /**
  145274. * Not supported by GPUParticleSystem
  145275. * @returns the list of ramp gradients
  145276. */
  145277. getRampGradients(): Nullable<Array<Color3Gradient>>;
  145278. /**
  145279. * Not supported by GPUParticleSystem
  145280. * Gets or sets a boolean indicating that ramp gradients must be used
  145281. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  145282. */
  145283. get useRampGradients(): boolean;
  145284. set useRampGradients(value: boolean);
  145285. /**
  145286. * Not supported by GPUParticleSystem
  145287. * @param gradient defines the gradient to use (between 0 and 1)
  145288. * @param factor defines the life time factor to affect to the specified gradient
  145289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145290. * @returns the current particle system
  145291. */
  145292. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145293. /**
  145294. * Not supported by GPUParticleSystem
  145295. * @param gradient defines the gradient to remove
  145296. * @returns the current particle system
  145297. */
  145298. removeLifeTimeGradient(gradient: number): IParticleSystem;
  145299. /**
  145300. * Instantiates a GPU particle system.
  145301. * 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.
  145302. * @param name The name of the particle system
  145303. * @param options The options used to create the system
  145304. * @param scene The scene the particle system belongs to
  145305. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  145306. * @param customEffect a custom effect used to change the way particles are rendered by default
  145307. */
  145308. constructor(name: string, options: Partial<{
  145309. capacity: number;
  145310. randomTextureSize: number;
  145311. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  145312. protected _reset(): void;
  145313. private _createUpdateVAO;
  145314. private _createRenderVAO;
  145315. private _initialize;
  145316. /** @hidden */
  145317. _recreateUpdateEffect(): void;
  145318. private _getEffect;
  145319. /**
  145320. * Fill the defines array according to the current settings of the particle system
  145321. * @param defines Array to be updated
  145322. * @param blendMode blend mode to take into account when updating the array
  145323. */
  145324. fillDefines(defines: Array<string>, blendMode?: number): void;
  145325. /**
  145326. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  145327. * @param uniforms Uniforms array to fill
  145328. * @param attributes Attributes array to fill
  145329. * @param samplers Samplers array to fill
  145330. */
  145331. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  145332. /** @hidden */
  145333. _recreateRenderEffect(): Effect;
  145334. /**
  145335. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  145336. * @param preWarm defines if we are in the pre-warmimg phase
  145337. */
  145338. animate(preWarm?: boolean): void;
  145339. private _createFactorGradientTexture;
  145340. private _createSizeGradientTexture;
  145341. private _createAngularSpeedGradientTexture;
  145342. private _createVelocityGradientTexture;
  145343. private _createLimitVelocityGradientTexture;
  145344. private _createDragGradientTexture;
  145345. private _createColorGradientTexture;
  145346. /**
  145347. * Renders the particle system in its current state
  145348. * @param preWarm defines if the system should only update the particles but not render them
  145349. * @returns the current number of particles
  145350. */
  145351. render(preWarm?: boolean): number;
  145352. /**
  145353. * Rebuilds the particle system
  145354. */
  145355. rebuild(): void;
  145356. private _releaseBuffers;
  145357. private _releaseVAOs;
  145358. /**
  145359. * Disposes the particle system and free the associated resources
  145360. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145361. */
  145362. dispose(disposeTexture?: boolean): void;
  145363. /**
  145364. * Clones the particle system.
  145365. * @param name The name of the cloned object
  145366. * @param newEmitter The new emitter to use
  145367. * @returns the cloned particle system
  145368. */
  145369. clone(name: string, newEmitter: any): GPUParticleSystem;
  145370. /**
  145371. * Serializes the particle system to a JSON object
  145372. * @param serializeTexture defines if the texture must be serialized as well
  145373. * @returns the JSON object
  145374. */
  145375. serialize(serializeTexture?: boolean): any;
  145376. /**
  145377. * Parses a JSON object to create a GPU particle system.
  145378. * @param parsedParticleSystem The JSON object to parse
  145379. * @param scene The scene to create the particle system in
  145380. * @param rootUrl The root url to use to load external dependencies like texture
  145381. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145382. * @returns the parsed GPU particle system
  145383. */
  145384. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145385. }
  145386. }
  145387. declare module BABYLON {
  145388. /**
  145389. * Represents a set of particle systems working together to create a specific effect
  145390. */
  145391. export class ParticleSystemSet implements IDisposable {
  145392. /**
  145393. * Gets or sets base Assets URL
  145394. */
  145395. static BaseAssetsUrl: string;
  145396. private _emitterCreationOptions;
  145397. private _emitterNode;
  145398. /**
  145399. * Gets the particle system list
  145400. */
  145401. systems: IParticleSystem[];
  145402. /**
  145403. * Gets the emitter node used with this set
  145404. */
  145405. get emitterNode(): Nullable<TransformNode>;
  145406. /**
  145407. * Creates a new emitter mesh as a sphere
  145408. * @param options defines the options used to create the sphere
  145409. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145410. * @param scene defines the hosting scene
  145411. */
  145412. setEmitterAsSphere(options: {
  145413. diameter: number;
  145414. segments: number;
  145415. color: Color3;
  145416. }, renderingGroupId: number, scene: Scene): void;
  145417. /**
  145418. * Starts all particle systems of the set
  145419. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145420. */
  145421. start(emitter?: AbstractMesh): void;
  145422. /**
  145423. * Release all associated resources
  145424. */
  145425. dispose(): void;
  145426. /**
  145427. * Serialize the set into a JSON compatible object
  145428. * @param serializeTexture defines if the texture must be serialized as well
  145429. * @returns a JSON compatible representation of the set
  145430. */
  145431. serialize(serializeTexture?: boolean): any;
  145432. /**
  145433. * Parse a new ParticleSystemSet from a serialized source
  145434. * @param data defines a JSON compatible representation of the set
  145435. * @param scene defines the hosting scene
  145436. * @param gpu defines if we want GPU particles or CPU particles
  145437. * @returns a new ParticleSystemSet
  145438. */
  145439. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145440. }
  145441. }
  145442. declare module BABYLON {
  145443. /**
  145444. * This class is made for on one-liner static method to help creating particle system set.
  145445. */
  145446. export class ParticleHelper {
  145447. /**
  145448. * Gets or sets base Assets URL
  145449. */
  145450. static BaseAssetsUrl: string;
  145451. /** Define the Url to load snippets */
  145452. static SnippetUrl: string;
  145453. /**
  145454. * Create a default particle system that you can tweak
  145455. * @param emitter defines the emitter to use
  145456. * @param capacity defines the system capacity (default is 500 particles)
  145457. * @param scene defines the hosting scene
  145458. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145459. * @returns the new Particle system
  145460. */
  145461. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145462. /**
  145463. * This is the main static method (one-liner) of this helper to create different particle systems
  145464. * @param type This string represents the type to the particle system to create
  145465. * @param scene The scene where the particle system should live
  145466. * @param gpu If the system will use gpu
  145467. * @returns the ParticleSystemSet created
  145468. */
  145469. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145470. /**
  145471. * Static function used to export a particle system to a ParticleSystemSet variable.
  145472. * Please note that the emitter shape is not exported
  145473. * @param systems defines the particle systems to export
  145474. * @returns the created particle system set
  145475. */
  145476. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145477. /**
  145478. * Creates a particle system from a snippet saved in a remote file
  145479. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145480. * @param url defines the url to load from
  145481. * @param scene defines the hosting scene
  145482. * @param gpu If the system will use gpu
  145483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145484. * @returns a promise that will resolve to the new particle system
  145485. */
  145486. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145487. /**
  145488. * Creates a particle system from a snippet saved by the particle system editor
  145489. * @param snippetId defines the snippet to load
  145490. * @param scene defines the hosting scene
  145491. * @param gpu If the system will use gpu
  145492. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145493. * @returns a promise that will resolve to the new particle system
  145494. */
  145495. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145496. }
  145497. }
  145498. declare module BABYLON {
  145499. interface Engine {
  145500. /**
  145501. * Create an effect to use with particle systems.
  145502. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145503. * the particle system for which you want to create a custom effect in the last parameter
  145504. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145505. * @param uniformsNames defines a list of attribute names
  145506. * @param samplers defines an array of string used to represent textures
  145507. * @param defines defines the string containing the defines to use to compile the shaders
  145508. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145509. * @param onCompiled defines a function to call when the effect creation is successful
  145510. * @param onError defines a function to call when the effect creation has failed
  145511. * @param particleSystem the particle system you want to create the effect for
  145512. * @returns the new Effect
  145513. */
  145514. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145515. }
  145516. interface Mesh {
  145517. /**
  145518. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145519. * @returns an array of IParticleSystem
  145520. */
  145521. getEmittedParticleSystems(): IParticleSystem[];
  145522. /**
  145523. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145524. * @returns an array of IParticleSystem
  145525. */
  145526. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145527. }
  145528. }
  145529. declare module BABYLON {
  145530. /** Defines the 4 color options */
  145531. export enum PointColor {
  145532. /** color value */
  145533. Color = 2,
  145534. /** uv value */
  145535. UV = 1,
  145536. /** random value */
  145537. Random = 0,
  145538. /** stated value */
  145539. Stated = 3
  145540. }
  145541. /**
  145542. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145543. * 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.
  145544. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145545. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145546. *
  145547. * Full documentation here : TO BE ENTERED
  145548. */
  145549. export class PointsCloudSystem implements IDisposable {
  145550. /**
  145551. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145552. * Example : var p = SPS.particles[i];
  145553. */
  145554. particles: CloudPoint[];
  145555. /**
  145556. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145557. */
  145558. nbParticles: number;
  145559. /**
  145560. * This a counter for your own usage. It's not set by any SPS functions.
  145561. */
  145562. counter: number;
  145563. /**
  145564. * The PCS name. This name is also given to the underlying mesh.
  145565. */
  145566. name: string;
  145567. /**
  145568. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145569. */
  145570. mesh: Mesh;
  145571. /**
  145572. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145573. * Please read :
  145574. */
  145575. vars: any;
  145576. /**
  145577. * @hidden
  145578. */
  145579. _size: number;
  145580. private _scene;
  145581. private _promises;
  145582. private _positions;
  145583. private _indices;
  145584. private _normals;
  145585. private _colors;
  145586. private _uvs;
  145587. private _indices32;
  145588. private _positions32;
  145589. private _colors32;
  145590. private _uvs32;
  145591. private _updatable;
  145592. private _isVisibilityBoxLocked;
  145593. private _alwaysVisible;
  145594. private _groups;
  145595. private _groupCounter;
  145596. private _computeParticleColor;
  145597. private _computeParticleTexture;
  145598. private _computeParticleRotation;
  145599. private _computeBoundingBox;
  145600. private _isReady;
  145601. /**
  145602. * Creates a PCS (Points Cloud System) object
  145603. * @param name (String) is the PCS name, this will be the underlying mesh name
  145604. * @param pointSize (number) is the size for each point
  145605. * @param scene (Scene) is the scene in which the PCS is added
  145606. * @param options defines the options of the PCS e.g.
  145607. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145608. */
  145609. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145610. updatable?: boolean;
  145611. });
  145612. /**
  145613. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145614. * If no points were added to the PCS, the returned mesh is just a single point.
  145615. * @returns a promise for the created mesh
  145616. */
  145617. buildMeshAsync(): Promise<Mesh>;
  145618. /**
  145619. * @hidden
  145620. */
  145621. private _buildMesh;
  145622. private _addParticle;
  145623. private _randomUnitVector;
  145624. private _getColorIndicesForCoord;
  145625. private _setPointsColorOrUV;
  145626. private _colorFromTexture;
  145627. private _calculateDensity;
  145628. /**
  145629. * Adds points to the PCS in random positions within a unit sphere
  145630. * @param nb (positive integer) the number of particles to be created from this model
  145631. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145632. * @returns the number of groups in the system
  145633. */
  145634. addPoints(nb: number, pointFunction?: any): number;
  145635. /**
  145636. * Adds points to the PCS from the surface of the model shape
  145637. * @param mesh is any Mesh object that will be used as a surface model for the points
  145638. * @param nb (positive integer) the number of particles to be created from this model
  145639. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145640. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145641. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145642. * @returns the number of groups in the system
  145643. */
  145644. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145645. /**
  145646. * Adds points to the PCS inside the model shape
  145647. * @param mesh is any Mesh object that will be used as a surface model for the points
  145648. * @param nb (positive integer) the number of particles to be created from this model
  145649. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145650. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145651. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145652. * @returns the number of groups in the system
  145653. */
  145654. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145655. /**
  145656. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145657. * This method calls `updateParticle()` for each particle of the SPS.
  145658. * For an animated SPS, it is usually called within the render loop.
  145659. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145660. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145661. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145662. * @returns the PCS.
  145663. */
  145664. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145665. /**
  145666. * Disposes the PCS.
  145667. */
  145668. dispose(): void;
  145669. /**
  145670. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145671. * doc :
  145672. * @returns the PCS.
  145673. */
  145674. refreshVisibleSize(): PointsCloudSystem;
  145675. /**
  145676. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145677. * @param size the size (float) of the visibility box
  145678. * note : this doesn't lock the PCS mesh bounding box.
  145679. * doc :
  145680. */
  145681. setVisibilityBox(size: number): void;
  145682. /**
  145683. * Gets whether the PCS is always visible or not
  145684. * doc :
  145685. */
  145686. get isAlwaysVisible(): boolean;
  145687. /**
  145688. * Sets the PCS as always visible or not
  145689. * doc :
  145690. */
  145691. set isAlwaysVisible(val: boolean);
  145692. /**
  145693. * Tells to `setParticles()` to compute the particle rotations or not
  145694. * Default value : false. The PCS is faster when it's set to false
  145695. * Note : particle rotations are only applied to parent particles
  145696. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145697. */
  145698. set computeParticleRotation(val: boolean);
  145699. /**
  145700. * Tells to `setParticles()` to compute the particle colors or not.
  145701. * Default value : true. The PCS is faster when it's set to false.
  145702. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145703. */
  145704. set computeParticleColor(val: boolean);
  145705. set computeParticleTexture(val: boolean);
  145706. /**
  145707. * Gets if `setParticles()` computes the particle colors or not.
  145708. * Default value : false. The PCS is faster when it's set to false.
  145709. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145710. */
  145711. get computeParticleColor(): boolean;
  145712. /**
  145713. * Gets if `setParticles()` computes the particle textures or not.
  145714. * Default value : false. The PCS is faster when it's set to false.
  145715. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145716. */
  145717. get computeParticleTexture(): boolean;
  145718. /**
  145719. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145720. */
  145721. set computeBoundingBox(val: boolean);
  145722. /**
  145723. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145724. */
  145725. get computeBoundingBox(): boolean;
  145726. /**
  145727. * This function does nothing. It may be overwritten to set all the particle first values.
  145728. * The PCS doesn't call this function, you may have to call it by your own.
  145729. * doc :
  145730. */
  145731. initParticles(): void;
  145732. /**
  145733. * This function does nothing. It may be overwritten to recycle a particle
  145734. * The PCS doesn't call this function, you can to call it
  145735. * doc :
  145736. * @param particle The particle to recycle
  145737. * @returns the recycled particle
  145738. */
  145739. recycleParticle(particle: CloudPoint): CloudPoint;
  145740. /**
  145741. * Updates a particle : this function should be overwritten by the user.
  145742. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145743. * doc :
  145744. * @example : just set a particle position or velocity and recycle conditions
  145745. * @param particle The particle to update
  145746. * @returns the updated particle
  145747. */
  145748. updateParticle(particle: CloudPoint): CloudPoint;
  145749. /**
  145750. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145751. * This does nothing and may be overwritten by the user.
  145752. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145753. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145754. * @param update the boolean update value actually passed to setParticles()
  145755. */
  145756. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145757. /**
  145758. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145759. * This will be passed three parameters.
  145760. * This does nothing and may be overwritten by the user.
  145761. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145763. * @param update the boolean update value actually passed to setParticles()
  145764. */
  145765. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145766. }
  145767. }
  145768. declare module BABYLON {
  145769. /**
  145770. * Represents one particle of a points cloud system.
  145771. */
  145772. export class CloudPoint {
  145773. /**
  145774. * particle global index
  145775. */
  145776. idx: number;
  145777. /**
  145778. * The color of the particle
  145779. */
  145780. color: Nullable<Color4>;
  145781. /**
  145782. * The world space position of the particle.
  145783. */
  145784. position: Vector3;
  145785. /**
  145786. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145787. */
  145788. rotation: Vector3;
  145789. /**
  145790. * The world space rotation quaternion of the particle.
  145791. */
  145792. rotationQuaternion: Nullable<Quaternion>;
  145793. /**
  145794. * The uv of the particle.
  145795. */
  145796. uv: Nullable<Vector2>;
  145797. /**
  145798. * The current speed of the particle.
  145799. */
  145800. velocity: Vector3;
  145801. /**
  145802. * The pivot point in the particle local space.
  145803. */
  145804. pivot: Vector3;
  145805. /**
  145806. * Must the particle be translated from its pivot point in its local space ?
  145807. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145808. * Default : false
  145809. */
  145810. translateFromPivot: boolean;
  145811. /**
  145812. * Index of this particle in the global "positions" array (Internal use)
  145813. * @hidden
  145814. */
  145815. _pos: number;
  145816. /**
  145817. * @hidden Index of this particle in the global "indices" array (Internal use)
  145818. */
  145819. _ind: number;
  145820. /**
  145821. * Group this particle belongs to
  145822. */
  145823. _group: PointsGroup;
  145824. /**
  145825. * Group id of this particle
  145826. */
  145827. groupId: number;
  145828. /**
  145829. * Index of the particle in its group id (Internal use)
  145830. */
  145831. idxInGroup: number;
  145832. /**
  145833. * @hidden Particle BoundingInfo object (Internal use)
  145834. */
  145835. _boundingInfo: BoundingInfo;
  145836. /**
  145837. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145838. */
  145839. _pcs: PointsCloudSystem;
  145840. /**
  145841. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145842. */
  145843. _stillInvisible: boolean;
  145844. /**
  145845. * @hidden Last computed particle rotation matrix
  145846. */
  145847. _rotationMatrix: number[];
  145848. /**
  145849. * Parent particle Id, if any.
  145850. * Default null.
  145851. */
  145852. parentId: Nullable<number>;
  145853. /**
  145854. * @hidden Internal global position in the PCS.
  145855. */
  145856. _globalPosition: Vector3;
  145857. /**
  145858. * Creates a Point Cloud object.
  145859. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145860. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145861. * @param group (PointsGroup) is the group the particle belongs to
  145862. * @param groupId (integer) is the group identifier in the PCS.
  145863. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145864. * @param pcs defines the PCS it is associated to
  145865. */
  145866. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145867. /**
  145868. * get point size
  145869. */
  145870. get size(): Vector3;
  145871. /**
  145872. * Set point size
  145873. */
  145874. set size(scale: Vector3);
  145875. /**
  145876. * Legacy support, changed quaternion to rotationQuaternion
  145877. */
  145878. get quaternion(): Nullable<Quaternion>;
  145879. /**
  145880. * Legacy support, changed quaternion to rotationQuaternion
  145881. */
  145882. set quaternion(q: Nullable<Quaternion>);
  145883. /**
  145884. * Returns a boolean. True if the particle intersects a mesh, else false
  145885. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145886. * @param target is the object (point or mesh) what the intersection is computed against
  145887. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145888. * @returns true if it intersects
  145889. */
  145890. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145891. /**
  145892. * get the rotation matrix of the particle
  145893. * @hidden
  145894. */
  145895. getRotationMatrix(m: Matrix): void;
  145896. }
  145897. /**
  145898. * Represents a group of points in a points cloud system
  145899. * * PCS internal tool, don't use it manually.
  145900. */
  145901. export class PointsGroup {
  145902. /**
  145903. * The group id
  145904. * @hidden
  145905. */
  145906. groupID: number;
  145907. /**
  145908. * image data for group (internal use)
  145909. * @hidden
  145910. */
  145911. _groupImageData: Nullable<ArrayBufferView>;
  145912. /**
  145913. * Image Width (internal use)
  145914. * @hidden
  145915. */
  145916. _groupImgWidth: number;
  145917. /**
  145918. * Image Height (internal use)
  145919. * @hidden
  145920. */
  145921. _groupImgHeight: number;
  145922. /**
  145923. * Custom position function (internal use)
  145924. * @hidden
  145925. */
  145926. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145927. /**
  145928. * density per facet for surface points
  145929. * @hidden
  145930. */
  145931. _groupDensity: number[];
  145932. /**
  145933. * Only when points are colored by texture carries pointer to texture list array
  145934. * @hidden
  145935. */
  145936. _textureNb: number;
  145937. /**
  145938. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145939. * PCS internal tool, don't use it manually.
  145940. * @hidden
  145941. */
  145942. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145943. }
  145944. }
  145945. declare module BABYLON {
  145946. interface Scene {
  145947. /** @hidden (Backing field) */
  145948. _physicsEngine: Nullable<IPhysicsEngine>;
  145949. /** @hidden */
  145950. _physicsTimeAccumulator: number;
  145951. /**
  145952. * Gets the current physics engine
  145953. * @returns a IPhysicsEngine or null if none attached
  145954. */
  145955. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145956. /**
  145957. * Enables physics to the current scene
  145958. * @param gravity defines the scene's gravity for the physics engine
  145959. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145960. * @return a boolean indicating if the physics engine was initialized
  145961. */
  145962. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145963. /**
  145964. * Disables and disposes the physics engine associated with the scene
  145965. */
  145966. disablePhysicsEngine(): void;
  145967. /**
  145968. * Gets a boolean indicating if there is an active physics engine
  145969. * @returns a boolean indicating if there is an active physics engine
  145970. */
  145971. isPhysicsEnabled(): boolean;
  145972. /**
  145973. * Deletes a physics compound impostor
  145974. * @param compound defines the compound to delete
  145975. */
  145976. deleteCompoundImpostor(compound: any): void;
  145977. /**
  145978. * An event triggered when physic simulation is about to be run
  145979. */
  145980. onBeforePhysicsObservable: Observable<Scene>;
  145981. /**
  145982. * An event triggered when physic simulation has been done
  145983. */
  145984. onAfterPhysicsObservable: Observable<Scene>;
  145985. }
  145986. interface AbstractMesh {
  145987. /** @hidden */
  145988. _physicsImpostor: Nullable<PhysicsImpostor>;
  145989. /**
  145990. * Gets or sets impostor used for physic simulation
  145991. * @see https://doc.babylonjs.com/features/physics_engine
  145992. */
  145993. physicsImpostor: Nullable<PhysicsImpostor>;
  145994. /**
  145995. * Gets the current physics impostor
  145996. * @see https://doc.babylonjs.com/features/physics_engine
  145997. * @returns a physics impostor or null
  145998. */
  145999. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146000. /** Apply a physic impulse to the mesh
  146001. * @param force defines the force to apply
  146002. * @param contactPoint defines where to apply the force
  146003. * @returns the current mesh
  146004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146005. */
  146006. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146007. /**
  146008. * Creates a physic joint between two meshes
  146009. * @param otherMesh defines the other mesh to use
  146010. * @param pivot1 defines the pivot to use on this mesh
  146011. * @param pivot2 defines the pivot to use on the other mesh
  146012. * @param options defines additional options (can be plugin dependent)
  146013. * @returns the current mesh
  146014. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146015. */
  146016. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146017. /** @hidden */
  146018. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146019. }
  146020. /**
  146021. * Defines the physics engine scene component responsible to manage a physics engine
  146022. */
  146023. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146024. /**
  146025. * The component name helpful to identify the component in the list of scene components.
  146026. */
  146027. readonly name: string;
  146028. /**
  146029. * The scene the component belongs to.
  146030. */
  146031. scene: Scene;
  146032. /**
  146033. * Creates a new instance of the component for the given scene
  146034. * @param scene Defines the scene to register the component in
  146035. */
  146036. constructor(scene: Scene);
  146037. /**
  146038. * Registers the component in a given scene
  146039. */
  146040. register(): void;
  146041. /**
  146042. * Rebuilds the elements related to this component in case of
  146043. * context lost for instance.
  146044. */
  146045. rebuild(): void;
  146046. /**
  146047. * Disposes the component and the associated ressources
  146048. */
  146049. dispose(): void;
  146050. }
  146051. }
  146052. declare module BABYLON {
  146053. /**
  146054. * A helper for physics simulations
  146055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146056. */
  146057. export class PhysicsHelper {
  146058. private _scene;
  146059. private _physicsEngine;
  146060. /**
  146061. * Initializes the Physics helper
  146062. * @param scene Babylon.js scene
  146063. */
  146064. constructor(scene: Scene);
  146065. /**
  146066. * Applies a radial explosion impulse
  146067. * @param origin the origin of the explosion
  146068. * @param radiusOrEventOptions the radius or the options of radial explosion
  146069. * @param strength the explosion strength
  146070. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146071. * @returns A physics radial explosion event, or null
  146072. */
  146073. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146074. /**
  146075. * Applies a radial explosion force
  146076. * @param origin the origin of the explosion
  146077. * @param radiusOrEventOptions the radius or the options of radial explosion
  146078. * @param strength the explosion strength
  146079. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146080. * @returns A physics radial explosion event, or null
  146081. */
  146082. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146083. /**
  146084. * Creates a gravitational field
  146085. * @param origin the origin of the explosion
  146086. * @param radiusOrEventOptions the radius or the options of radial explosion
  146087. * @param strength the explosion strength
  146088. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146089. * @returns A physics gravitational field event, or null
  146090. */
  146091. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  146092. /**
  146093. * Creates a physics updraft event
  146094. * @param origin the origin of the updraft
  146095. * @param radiusOrEventOptions the radius or the options of the updraft
  146096. * @param strength the strength of the updraft
  146097. * @param height the height of the updraft
  146098. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  146099. * @returns A physics updraft event, or null
  146100. */
  146101. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  146102. /**
  146103. * Creates a physics vortex event
  146104. * @param origin the of the vortex
  146105. * @param radiusOrEventOptions the radius or the options of the vortex
  146106. * @param strength the strength of the vortex
  146107. * @param height the height of the vortex
  146108. * @returns a Physics vortex event, or null
  146109. * A physics vortex event or null
  146110. */
  146111. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  146112. }
  146113. /**
  146114. * Represents a physics radial explosion event
  146115. */
  146116. class PhysicsRadialExplosionEvent {
  146117. private _scene;
  146118. private _options;
  146119. private _sphere;
  146120. private _dataFetched;
  146121. /**
  146122. * Initializes a radial explosioin event
  146123. * @param _scene BabylonJS scene
  146124. * @param _options The options for the vortex event
  146125. */
  146126. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  146127. /**
  146128. * Returns the data related to the radial explosion event (sphere).
  146129. * @returns The radial explosion event data
  146130. */
  146131. getData(): PhysicsRadialExplosionEventData;
  146132. /**
  146133. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  146134. * @param impostor A physics imposter
  146135. * @param origin the origin of the explosion
  146136. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  146137. */
  146138. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  146139. /**
  146140. * Triggers affecterd impostors callbacks
  146141. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  146142. */
  146143. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  146144. /**
  146145. * Disposes the sphere.
  146146. * @param force Specifies if the sphere should be disposed by force
  146147. */
  146148. dispose(force?: boolean): void;
  146149. /*** Helpers ***/
  146150. private _prepareSphere;
  146151. private _intersectsWithSphere;
  146152. }
  146153. /**
  146154. * Represents a gravitational field event
  146155. */
  146156. class PhysicsGravitationalFieldEvent {
  146157. private _physicsHelper;
  146158. private _scene;
  146159. private _origin;
  146160. private _options;
  146161. private _tickCallback;
  146162. private _sphere;
  146163. private _dataFetched;
  146164. /**
  146165. * Initializes the physics gravitational field event
  146166. * @param _physicsHelper A physics helper
  146167. * @param _scene BabylonJS scene
  146168. * @param _origin The origin position of the gravitational field event
  146169. * @param _options The options for the vortex event
  146170. */
  146171. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  146172. /**
  146173. * Returns the data related to the gravitational field event (sphere).
  146174. * @returns A gravitational field event
  146175. */
  146176. getData(): PhysicsGravitationalFieldEventData;
  146177. /**
  146178. * Enables the gravitational field.
  146179. */
  146180. enable(): void;
  146181. /**
  146182. * Disables the gravitational field.
  146183. */
  146184. disable(): void;
  146185. /**
  146186. * Disposes the sphere.
  146187. * @param force The force to dispose from the gravitational field event
  146188. */
  146189. dispose(force?: boolean): void;
  146190. private _tick;
  146191. }
  146192. /**
  146193. * Represents a physics updraft event
  146194. */
  146195. class PhysicsUpdraftEvent {
  146196. private _scene;
  146197. private _origin;
  146198. private _options;
  146199. private _physicsEngine;
  146200. private _originTop;
  146201. private _originDirection;
  146202. private _tickCallback;
  146203. private _cylinder;
  146204. private _cylinderPosition;
  146205. private _dataFetched;
  146206. /**
  146207. * Initializes the physics updraft event
  146208. * @param _scene BabylonJS scene
  146209. * @param _origin The origin position of the updraft
  146210. * @param _options The options for the updraft event
  146211. */
  146212. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  146213. /**
  146214. * Returns the data related to the updraft event (cylinder).
  146215. * @returns A physics updraft event
  146216. */
  146217. getData(): PhysicsUpdraftEventData;
  146218. /**
  146219. * Enables the updraft.
  146220. */
  146221. enable(): void;
  146222. /**
  146223. * Disables the updraft.
  146224. */
  146225. disable(): void;
  146226. /**
  146227. * Disposes the cylinder.
  146228. * @param force Specifies if the updraft should be disposed by force
  146229. */
  146230. dispose(force?: boolean): void;
  146231. private getImpostorHitData;
  146232. private _tick;
  146233. /*** Helpers ***/
  146234. private _prepareCylinder;
  146235. private _intersectsWithCylinder;
  146236. }
  146237. /**
  146238. * Represents a physics vortex event
  146239. */
  146240. class PhysicsVortexEvent {
  146241. private _scene;
  146242. private _origin;
  146243. private _options;
  146244. private _physicsEngine;
  146245. private _originTop;
  146246. private _tickCallback;
  146247. private _cylinder;
  146248. private _cylinderPosition;
  146249. private _dataFetched;
  146250. /**
  146251. * Initializes the physics vortex event
  146252. * @param _scene The BabylonJS scene
  146253. * @param _origin The origin position of the vortex
  146254. * @param _options The options for the vortex event
  146255. */
  146256. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  146257. /**
  146258. * Returns the data related to the vortex event (cylinder).
  146259. * @returns The physics vortex event data
  146260. */
  146261. getData(): PhysicsVortexEventData;
  146262. /**
  146263. * Enables the vortex.
  146264. */
  146265. enable(): void;
  146266. /**
  146267. * Disables the cortex.
  146268. */
  146269. disable(): void;
  146270. /**
  146271. * Disposes the sphere.
  146272. * @param force
  146273. */
  146274. dispose(force?: boolean): void;
  146275. private getImpostorHitData;
  146276. private _tick;
  146277. /*** Helpers ***/
  146278. private _prepareCylinder;
  146279. private _intersectsWithCylinder;
  146280. }
  146281. /**
  146282. * Options fot the radial explosion event
  146283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146284. */
  146285. export class PhysicsRadialExplosionEventOptions {
  146286. /**
  146287. * The radius of the sphere for the radial explosion.
  146288. */
  146289. radius: number;
  146290. /**
  146291. * The strenth of the explosion.
  146292. */
  146293. strength: number;
  146294. /**
  146295. * The strenght of the force in correspondence to the distance of the affected object
  146296. */
  146297. falloff: PhysicsRadialImpulseFalloff;
  146298. /**
  146299. * Sphere options for the radial explosion.
  146300. */
  146301. sphere: {
  146302. segments: number;
  146303. diameter: number;
  146304. };
  146305. /**
  146306. * Sphere options for the radial explosion.
  146307. */
  146308. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  146309. }
  146310. /**
  146311. * Options fot the updraft event
  146312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146313. */
  146314. export class PhysicsUpdraftEventOptions {
  146315. /**
  146316. * The radius of the cylinder for the vortex
  146317. */
  146318. radius: number;
  146319. /**
  146320. * The strenth of the updraft.
  146321. */
  146322. strength: number;
  146323. /**
  146324. * The height of the cylinder for the updraft.
  146325. */
  146326. height: number;
  146327. /**
  146328. * The mode for the the updraft.
  146329. */
  146330. updraftMode: PhysicsUpdraftMode;
  146331. }
  146332. /**
  146333. * Options fot the vortex event
  146334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146335. */
  146336. export class PhysicsVortexEventOptions {
  146337. /**
  146338. * The radius of the cylinder for the vortex
  146339. */
  146340. radius: number;
  146341. /**
  146342. * The strenth of the vortex.
  146343. */
  146344. strength: number;
  146345. /**
  146346. * The height of the cylinder for the vortex.
  146347. */
  146348. height: number;
  146349. /**
  146350. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146351. */
  146352. centripetalForceThreshold: number;
  146353. /**
  146354. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146355. */
  146356. centripetalForceMultiplier: number;
  146357. /**
  146358. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146359. */
  146360. centrifugalForceMultiplier: number;
  146361. /**
  146362. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146363. */
  146364. updraftForceMultiplier: number;
  146365. }
  146366. /**
  146367. * The strenght of the force in correspondence to the distance of the affected object
  146368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146369. */
  146370. export enum PhysicsRadialImpulseFalloff {
  146371. /** Defines that impulse is constant in strength across it's whole radius */
  146372. Constant = 0,
  146373. /** Defines that impulse gets weaker if it's further from the origin */
  146374. Linear = 1
  146375. }
  146376. /**
  146377. * The strength of the force in correspondence to the distance of the affected object
  146378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146379. */
  146380. export enum PhysicsUpdraftMode {
  146381. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146382. Center = 0,
  146383. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146384. Perpendicular = 1
  146385. }
  146386. /**
  146387. * Interface for a physics hit data
  146388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146389. */
  146390. export interface PhysicsHitData {
  146391. /**
  146392. * The force applied at the contact point
  146393. */
  146394. force: Vector3;
  146395. /**
  146396. * The contact point
  146397. */
  146398. contactPoint: Vector3;
  146399. /**
  146400. * The distance from the origin to the contact point
  146401. */
  146402. distanceFromOrigin: number;
  146403. }
  146404. /**
  146405. * Interface for radial explosion event data
  146406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146407. */
  146408. export interface PhysicsRadialExplosionEventData {
  146409. /**
  146410. * A sphere used for the radial explosion event
  146411. */
  146412. sphere: Mesh;
  146413. }
  146414. /**
  146415. * Interface for gravitational field event data
  146416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146417. */
  146418. export interface PhysicsGravitationalFieldEventData {
  146419. /**
  146420. * A sphere mesh used for the gravitational field event
  146421. */
  146422. sphere: Mesh;
  146423. }
  146424. /**
  146425. * Interface for updraft event data
  146426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146427. */
  146428. export interface PhysicsUpdraftEventData {
  146429. /**
  146430. * A cylinder used for the updraft event
  146431. */
  146432. cylinder: Mesh;
  146433. }
  146434. /**
  146435. * Interface for vortex event data
  146436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146437. */
  146438. export interface PhysicsVortexEventData {
  146439. /**
  146440. * A cylinder used for the vortex event
  146441. */
  146442. cylinder: Mesh;
  146443. }
  146444. /**
  146445. * Interface for an affected physics impostor
  146446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146447. */
  146448. export interface PhysicsAffectedImpostorWithData {
  146449. /**
  146450. * The impostor affected by the effect
  146451. */
  146452. impostor: PhysicsImpostor;
  146453. /**
  146454. * The data about the hit/horce from the explosion
  146455. */
  146456. hitData: PhysicsHitData;
  146457. }
  146458. }
  146459. declare module BABYLON {
  146460. /** @hidden */
  146461. export var blackAndWhitePixelShader: {
  146462. name: string;
  146463. shader: string;
  146464. };
  146465. }
  146466. declare module BABYLON {
  146467. /**
  146468. * Post process used to render in black and white
  146469. */
  146470. export class BlackAndWhitePostProcess extends PostProcess {
  146471. /**
  146472. * Linear about to convert he result to black and white (default: 1)
  146473. */
  146474. degree: number;
  146475. /**
  146476. * Creates a black and white post process
  146477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146478. * @param name The name of the effect.
  146479. * @param options The required width/height ratio to downsize to before computing the render pass.
  146480. * @param camera The camera to apply the render pass to.
  146481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146482. * @param engine The engine which the post process will be applied. (default: current engine)
  146483. * @param reusable If the post process can be reused on the same frame. (default: false)
  146484. */
  146485. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146486. }
  146487. }
  146488. declare module BABYLON {
  146489. /**
  146490. * This represents a set of one or more post processes in Babylon.
  146491. * A post process can be used to apply a shader to a texture after it is rendered.
  146492. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146493. */
  146494. export class PostProcessRenderEffect {
  146495. private _postProcesses;
  146496. private _getPostProcesses;
  146497. private _singleInstance;
  146498. private _cameras;
  146499. private _indicesForCamera;
  146500. /**
  146501. * Name of the effect
  146502. * @hidden
  146503. */
  146504. _name: string;
  146505. /**
  146506. * Instantiates a post process render effect.
  146507. * A post process can be used to apply a shader to a texture after it is rendered.
  146508. * @param engine The engine the effect is tied to
  146509. * @param name The name of the effect
  146510. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146511. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146512. */
  146513. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146514. /**
  146515. * Checks if all the post processes in the effect are supported.
  146516. */
  146517. get isSupported(): boolean;
  146518. /**
  146519. * Updates the current state of the effect
  146520. * @hidden
  146521. */
  146522. _update(): void;
  146523. /**
  146524. * Attaches the effect on cameras
  146525. * @param cameras The camera to attach to.
  146526. * @hidden
  146527. */
  146528. _attachCameras(cameras: Camera): void;
  146529. /**
  146530. * Attaches the effect on cameras
  146531. * @param cameras The camera to attach to.
  146532. * @hidden
  146533. */
  146534. _attachCameras(cameras: Camera[]): void;
  146535. /**
  146536. * Detaches the effect on cameras
  146537. * @param cameras The camera to detatch from.
  146538. * @hidden
  146539. */
  146540. _detachCameras(cameras: Camera): void;
  146541. /**
  146542. * Detatches the effect on cameras
  146543. * @param cameras The camera to detatch from.
  146544. * @hidden
  146545. */
  146546. _detachCameras(cameras: Camera[]): void;
  146547. /**
  146548. * Enables the effect on given cameras
  146549. * @param cameras The camera to enable.
  146550. * @hidden
  146551. */
  146552. _enable(cameras: Camera): void;
  146553. /**
  146554. * Enables the effect on given cameras
  146555. * @param cameras The camera to enable.
  146556. * @hidden
  146557. */
  146558. _enable(cameras: Nullable<Camera[]>): void;
  146559. /**
  146560. * Disables the effect on the given cameras
  146561. * @param cameras The camera to disable.
  146562. * @hidden
  146563. */
  146564. _disable(cameras: Camera): void;
  146565. /**
  146566. * Disables the effect on the given cameras
  146567. * @param cameras The camera to disable.
  146568. * @hidden
  146569. */
  146570. _disable(cameras: Nullable<Camera[]>): void;
  146571. /**
  146572. * Gets a list of the post processes contained in the effect.
  146573. * @param camera The camera to get the post processes on.
  146574. * @returns The list of the post processes in the effect.
  146575. */
  146576. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146577. }
  146578. }
  146579. declare module BABYLON {
  146580. /** @hidden */
  146581. export var extractHighlightsPixelShader: {
  146582. name: string;
  146583. shader: string;
  146584. };
  146585. }
  146586. declare module BABYLON {
  146587. /**
  146588. * 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.
  146589. */
  146590. export class ExtractHighlightsPostProcess extends PostProcess {
  146591. /**
  146592. * The luminance threshold, pixels below this value will be set to black.
  146593. */
  146594. threshold: number;
  146595. /** @hidden */
  146596. _exposure: number;
  146597. /**
  146598. * Post process which has the input texture to be used when performing highlight extraction
  146599. * @hidden
  146600. */
  146601. _inputPostProcess: Nullable<PostProcess>;
  146602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146603. }
  146604. }
  146605. declare module BABYLON {
  146606. /** @hidden */
  146607. export var bloomMergePixelShader: {
  146608. name: string;
  146609. shader: string;
  146610. };
  146611. }
  146612. declare module BABYLON {
  146613. /**
  146614. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146615. */
  146616. export class BloomMergePostProcess extends PostProcess {
  146617. /** Weight of the bloom to be added to the original input. */
  146618. weight: number;
  146619. /**
  146620. * Creates a new instance of @see BloomMergePostProcess
  146621. * @param name The name of the effect.
  146622. * @param originalFromInput Post process which's input will be used for the merge.
  146623. * @param blurred Blurred highlights post process which's output will be used.
  146624. * @param weight Weight of the bloom to be added to the original input.
  146625. * @param options The required width/height ratio to downsize to before computing the render pass.
  146626. * @param camera The camera to apply the render pass to.
  146627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146628. * @param engine The engine which the post process will be applied. (default: current engine)
  146629. * @param reusable If the post process can be reused on the same frame. (default: false)
  146630. * @param textureType Type of textures used when performing the post process. (default: 0)
  146631. * @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)
  146632. */
  146633. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146634. /** Weight of the bloom to be added to the original input. */
  146635. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146636. }
  146637. }
  146638. declare module BABYLON {
  146639. /**
  146640. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146641. */
  146642. export class BloomEffect extends PostProcessRenderEffect {
  146643. private bloomScale;
  146644. /**
  146645. * @hidden Internal
  146646. */
  146647. _effects: Array<PostProcess>;
  146648. /**
  146649. * @hidden Internal
  146650. */
  146651. _downscale: ExtractHighlightsPostProcess;
  146652. private _blurX;
  146653. private _blurY;
  146654. private _merge;
  146655. /**
  146656. * The luminance threshold to find bright areas of the image to bloom.
  146657. */
  146658. get threshold(): number;
  146659. set threshold(value: number);
  146660. /**
  146661. * The strength of the bloom.
  146662. */
  146663. get weight(): number;
  146664. set weight(value: number);
  146665. /**
  146666. * Specifies the size of the bloom blur kernel, relative to the final output size
  146667. */
  146668. get kernel(): number;
  146669. set kernel(value: number);
  146670. /**
  146671. * Creates a new instance of @see BloomEffect
  146672. * @param scene The scene the effect belongs to.
  146673. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146674. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146675. * @param bloomWeight The the strength of bloom.
  146676. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146677. * @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)
  146678. */
  146679. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146680. /**
  146681. * Disposes each of the internal effects for a given camera.
  146682. * @param camera The camera to dispose the effect on.
  146683. */
  146684. disposeEffects(camera: Camera): void;
  146685. /**
  146686. * @hidden Internal
  146687. */
  146688. _updateEffects(): void;
  146689. /**
  146690. * Internal
  146691. * @returns if all the contained post processes are ready.
  146692. * @hidden
  146693. */
  146694. _isReady(): boolean;
  146695. }
  146696. }
  146697. declare module BABYLON {
  146698. /** @hidden */
  146699. export var chromaticAberrationPixelShader: {
  146700. name: string;
  146701. shader: string;
  146702. };
  146703. }
  146704. declare module BABYLON {
  146705. /**
  146706. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146707. */
  146708. export class ChromaticAberrationPostProcess extends PostProcess {
  146709. /**
  146710. * The amount of seperation of rgb channels (default: 30)
  146711. */
  146712. aberrationAmount: number;
  146713. /**
  146714. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146715. */
  146716. radialIntensity: number;
  146717. /**
  146718. * 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))
  146719. */
  146720. direction: Vector2;
  146721. /**
  146722. * 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))
  146723. */
  146724. centerPosition: Vector2;
  146725. /**
  146726. * Creates a new instance ChromaticAberrationPostProcess
  146727. * @param name The name of the effect.
  146728. * @param screenWidth The width of the screen to apply the effect on.
  146729. * @param screenHeight The height of the screen to apply the effect on.
  146730. * @param options The required width/height ratio to downsize to before computing the render pass.
  146731. * @param camera The camera to apply the render pass to.
  146732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146733. * @param engine The engine which the post process will be applied. (default: current engine)
  146734. * @param reusable If the post process can be reused on the same frame. (default: false)
  146735. * @param textureType Type of textures used when performing the post process. (default: 0)
  146736. * @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)
  146737. */
  146738. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146739. }
  146740. }
  146741. declare module BABYLON {
  146742. /** @hidden */
  146743. export var circleOfConfusionPixelShader: {
  146744. name: string;
  146745. shader: string;
  146746. };
  146747. }
  146748. declare module BABYLON {
  146749. /**
  146750. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146751. */
  146752. export class CircleOfConfusionPostProcess extends PostProcess {
  146753. /**
  146754. * 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.
  146755. */
  146756. lensSize: number;
  146757. /**
  146758. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146759. */
  146760. fStop: number;
  146761. /**
  146762. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146763. */
  146764. focusDistance: number;
  146765. /**
  146766. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146767. */
  146768. focalLength: number;
  146769. private _depthTexture;
  146770. /**
  146771. * Creates a new instance CircleOfConfusionPostProcess
  146772. * @param name The name of the effect.
  146773. * @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.
  146774. * @param options The required width/height ratio to downsize to before computing the render pass.
  146775. * @param camera The camera to apply the render pass to.
  146776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146777. * @param engine The engine which the post process will be applied. (default: current engine)
  146778. * @param reusable If the post process can be reused on the same frame. (default: false)
  146779. * @param textureType Type of textures used when performing the post process. (default: 0)
  146780. * @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)
  146781. */
  146782. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146783. /**
  146784. * 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.
  146785. */
  146786. set depthTexture(value: RenderTargetTexture);
  146787. }
  146788. }
  146789. declare module BABYLON {
  146790. /** @hidden */
  146791. export var colorCorrectionPixelShader: {
  146792. name: string;
  146793. shader: string;
  146794. };
  146795. }
  146796. declare module BABYLON {
  146797. /**
  146798. *
  146799. * This post-process allows the modification of rendered colors by using
  146800. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146801. *
  146802. * The object needs to be provided an url to a texture containing the color
  146803. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146804. * Use an image editing software to tweak the LUT to match your needs.
  146805. *
  146806. * For an example of a color LUT, see here:
  146807. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146808. * For explanations on color grading, see here:
  146809. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146810. *
  146811. */
  146812. export class ColorCorrectionPostProcess extends PostProcess {
  146813. private _colorTableTexture;
  146814. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146815. }
  146816. }
  146817. declare module BABYLON {
  146818. /** @hidden */
  146819. export var convolutionPixelShader: {
  146820. name: string;
  146821. shader: string;
  146822. };
  146823. }
  146824. declare module BABYLON {
  146825. /**
  146826. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146827. * input texture to perform effects such as edge detection or sharpening
  146828. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146829. */
  146830. export class ConvolutionPostProcess extends PostProcess {
  146831. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146832. kernel: number[];
  146833. /**
  146834. * Creates a new instance ConvolutionPostProcess
  146835. * @param name The name of the effect.
  146836. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146837. * @param options The required width/height ratio to downsize to before computing the render pass.
  146838. * @param camera The camera to apply the render pass to.
  146839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146840. * @param engine The engine which the post process will be applied. (default: current engine)
  146841. * @param reusable If the post process can be reused on the same frame. (default: false)
  146842. * @param textureType Type of textures used when performing the post process. (default: 0)
  146843. */
  146844. constructor(name: string,
  146845. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146846. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146847. /**
  146848. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146849. */
  146850. static EdgeDetect0Kernel: number[];
  146851. /**
  146852. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146853. */
  146854. static EdgeDetect1Kernel: number[];
  146855. /**
  146856. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146857. */
  146858. static EdgeDetect2Kernel: number[];
  146859. /**
  146860. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146861. */
  146862. static SharpenKernel: number[];
  146863. /**
  146864. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146865. */
  146866. static EmbossKernel: number[];
  146867. /**
  146868. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146869. */
  146870. static GaussianKernel: number[];
  146871. }
  146872. }
  146873. declare module BABYLON {
  146874. /**
  146875. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146876. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146877. * based on samples that have a large difference in distance than the center pixel.
  146878. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146879. */
  146880. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146881. direction: Vector2;
  146882. /**
  146883. * Creates a new instance CircleOfConfusionPostProcess
  146884. * @param name The name of the effect.
  146885. * @param scene The scene the effect belongs to.
  146886. * @param direction The direction the blur should be applied.
  146887. * @param kernel The size of the kernel used to blur.
  146888. * @param options The required width/height ratio to downsize to before computing the render pass.
  146889. * @param camera The camera to apply the render pass to.
  146890. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146891. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146893. * @param engine The engine which the post process will be applied. (default: current engine)
  146894. * @param reusable If the post process can be reused on the same frame. (default: false)
  146895. * @param textureType Type of textures used when performing the post process. (default: 0)
  146896. * @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)
  146897. */
  146898. 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);
  146899. }
  146900. }
  146901. declare module BABYLON {
  146902. /** @hidden */
  146903. export var depthOfFieldMergePixelShader: {
  146904. name: string;
  146905. shader: string;
  146906. };
  146907. }
  146908. declare module BABYLON {
  146909. /**
  146910. * Options to be set when merging outputs from the default pipeline.
  146911. */
  146912. export class DepthOfFieldMergePostProcessOptions {
  146913. /**
  146914. * The original image to merge on top of
  146915. */
  146916. originalFromInput: PostProcess;
  146917. /**
  146918. * Parameters to perform the merge of the depth of field effect
  146919. */
  146920. depthOfField?: {
  146921. circleOfConfusion: PostProcess;
  146922. blurSteps: Array<PostProcess>;
  146923. };
  146924. /**
  146925. * Parameters to perform the merge of bloom effect
  146926. */
  146927. bloom?: {
  146928. blurred: PostProcess;
  146929. weight: number;
  146930. };
  146931. }
  146932. /**
  146933. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146934. */
  146935. export class DepthOfFieldMergePostProcess extends PostProcess {
  146936. private blurSteps;
  146937. /**
  146938. * Creates a new instance of DepthOfFieldMergePostProcess
  146939. * @param name The name of the effect.
  146940. * @param originalFromInput Post process which's input will be used for the merge.
  146941. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146942. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146943. * @param options The required width/height ratio to downsize to before computing the render pass.
  146944. * @param camera The camera to apply the render pass to.
  146945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146946. * @param engine The engine which the post process will be applied. (default: current engine)
  146947. * @param reusable If the post process can be reused on the same frame. (default: false)
  146948. * @param textureType Type of textures used when performing the post process. (default: 0)
  146949. * @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)
  146950. */
  146951. 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);
  146952. /**
  146953. * Updates the effect with the current post process compile time values and recompiles the shader.
  146954. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146955. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146956. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146957. * @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
  146958. * @param onCompiled Called when the shader has been compiled.
  146959. * @param onError Called if there is an error when compiling a shader.
  146960. */
  146961. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146962. }
  146963. }
  146964. declare module BABYLON {
  146965. /**
  146966. * Specifies the level of max blur that should be applied when using the depth of field effect
  146967. */
  146968. export enum DepthOfFieldEffectBlurLevel {
  146969. /**
  146970. * Subtle blur
  146971. */
  146972. Low = 0,
  146973. /**
  146974. * Medium blur
  146975. */
  146976. Medium = 1,
  146977. /**
  146978. * Large blur
  146979. */
  146980. High = 2
  146981. }
  146982. /**
  146983. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146984. */
  146985. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146986. private _circleOfConfusion;
  146987. /**
  146988. * @hidden Internal, blurs from high to low
  146989. */
  146990. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146991. private _depthOfFieldBlurY;
  146992. private _dofMerge;
  146993. /**
  146994. * @hidden Internal post processes in depth of field effect
  146995. */
  146996. _effects: Array<PostProcess>;
  146997. /**
  146998. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146999. */
  147000. set focalLength(value: number);
  147001. get focalLength(): number;
  147002. /**
  147003. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147004. */
  147005. set fStop(value: number);
  147006. get fStop(): number;
  147007. /**
  147008. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147009. */
  147010. set focusDistance(value: number);
  147011. get focusDistance(): number;
  147012. /**
  147013. * 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.
  147014. */
  147015. set lensSize(value: number);
  147016. get lensSize(): number;
  147017. /**
  147018. * Creates a new instance DepthOfFieldEffect
  147019. * @param scene The scene the effect belongs to.
  147020. * @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.
  147021. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147022. * @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)
  147023. */
  147024. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147025. /**
  147026. * Get the current class name of the current effet
  147027. * @returns "DepthOfFieldEffect"
  147028. */
  147029. getClassName(): string;
  147030. /**
  147031. * 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.
  147032. */
  147033. set depthTexture(value: RenderTargetTexture);
  147034. /**
  147035. * Disposes each of the internal effects for a given camera.
  147036. * @param camera The camera to dispose the effect on.
  147037. */
  147038. disposeEffects(camera: Camera): void;
  147039. /**
  147040. * @hidden Internal
  147041. */
  147042. _updateEffects(): void;
  147043. /**
  147044. * Internal
  147045. * @returns if all the contained post processes are ready.
  147046. * @hidden
  147047. */
  147048. _isReady(): boolean;
  147049. }
  147050. }
  147051. declare module BABYLON {
  147052. /** @hidden */
  147053. export var displayPassPixelShader: {
  147054. name: string;
  147055. shader: string;
  147056. };
  147057. }
  147058. declare module BABYLON {
  147059. /**
  147060. * DisplayPassPostProcess which produces an output the same as it's input
  147061. */
  147062. export class DisplayPassPostProcess extends PostProcess {
  147063. /**
  147064. * Creates the DisplayPassPostProcess
  147065. * @param name The name of the effect.
  147066. * @param options The required width/height ratio to downsize to before computing the render pass.
  147067. * @param camera The camera to apply the render pass to.
  147068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147069. * @param engine The engine which the post process will be applied. (default: current engine)
  147070. * @param reusable If the post process can be reused on the same frame. (default: false)
  147071. */
  147072. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147073. }
  147074. }
  147075. declare module BABYLON {
  147076. /** @hidden */
  147077. export var filterPixelShader: {
  147078. name: string;
  147079. shader: string;
  147080. };
  147081. }
  147082. declare module BABYLON {
  147083. /**
  147084. * Applies a kernel filter to the image
  147085. */
  147086. export class FilterPostProcess extends PostProcess {
  147087. /** The matrix to be applied to the image */
  147088. kernelMatrix: Matrix;
  147089. /**
  147090. *
  147091. * @param name The name of the effect.
  147092. * @param kernelMatrix The matrix to be applied to the image
  147093. * @param options The required width/height ratio to downsize to before computing the render pass.
  147094. * @param camera The camera to apply the render pass to.
  147095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147096. * @param engine The engine which the post process will be applied. (default: current engine)
  147097. * @param reusable If the post process can be reused on the same frame. (default: false)
  147098. */
  147099. constructor(name: string,
  147100. /** The matrix to be applied to the image */
  147101. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147102. }
  147103. }
  147104. declare module BABYLON {
  147105. /** @hidden */
  147106. export var fxaaPixelShader: {
  147107. name: string;
  147108. shader: string;
  147109. };
  147110. }
  147111. declare module BABYLON {
  147112. /** @hidden */
  147113. export var fxaaVertexShader: {
  147114. name: string;
  147115. shader: string;
  147116. };
  147117. }
  147118. declare module BABYLON {
  147119. /**
  147120. * Fxaa post process
  147121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  147122. */
  147123. export class FxaaPostProcess extends PostProcess {
  147124. /** @hidden */
  147125. texelWidth: number;
  147126. /** @hidden */
  147127. texelHeight: number;
  147128. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147129. private _getDefines;
  147130. }
  147131. }
  147132. declare module BABYLON {
  147133. /** @hidden */
  147134. export var grainPixelShader: {
  147135. name: string;
  147136. shader: string;
  147137. };
  147138. }
  147139. declare module BABYLON {
  147140. /**
  147141. * The GrainPostProcess adds noise to the image at mid luminance levels
  147142. */
  147143. export class GrainPostProcess extends PostProcess {
  147144. /**
  147145. * The intensity of the grain added (default: 30)
  147146. */
  147147. intensity: number;
  147148. /**
  147149. * If the grain should be randomized on every frame
  147150. */
  147151. animated: boolean;
  147152. /**
  147153. * Creates a new instance of @see GrainPostProcess
  147154. * @param name The name of the effect.
  147155. * @param options The required width/height ratio to downsize to before computing the render pass.
  147156. * @param camera The camera to apply the render pass to.
  147157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147158. * @param engine The engine which the post process will be applied. (default: current engine)
  147159. * @param reusable If the post process can be reused on the same frame. (default: false)
  147160. * @param textureType Type of textures used when performing the post process. (default: 0)
  147161. * @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)
  147162. */
  147163. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147164. }
  147165. }
  147166. declare module BABYLON {
  147167. /** @hidden */
  147168. export var highlightsPixelShader: {
  147169. name: string;
  147170. shader: string;
  147171. };
  147172. }
  147173. declare module BABYLON {
  147174. /**
  147175. * Extracts highlights from the image
  147176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147177. */
  147178. export class HighlightsPostProcess extends PostProcess {
  147179. /**
  147180. * Extracts highlights from the image
  147181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147182. * @param name The name of the effect.
  147183. * @param options The required width/height ratio to downsize to before computing the render pass.
  147184. * @param camera The camera to apply the render pass to.
  147185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147186. * @param engine The engine which the post process will be applied. (default: current engine)
  147187. * @param reusable If the post process can be reused on the same frame. (default: false)
  147188. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  147189. */
  147190. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147191. }
  147192. }
  147193. declare module BABYLON {
  147194. /** @hidden */
  147195. export var mrtFragmentDeclaration: {
  147196. name: string;
  147197. shader: string;
  147198. };
  147199. }
  147200. declare module BABYLON {
  147201. /** @hidden */
  147202. export var geometryPixelShader: {
  147203. name: string;
  147204. shader: string;
  147205. };
  147206. }
  147207. declare module BABYLON {
  147208. /** @hidden */
  147209. export var geometryVertexShader: {
  147210. name: string;
  147211. shader: string;
  147212. };
  147213. }
  147214. declare module BABYLON {
  147215. /** @hidden */
  147216. interface ISavedTransformationMatrix {
  147217. world: Matrix;
  147218. viewProjection: Matrix;
  147219. }
  147220. /**
  147221. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  147222. */
  147223. export class GeometryBufferRenderer {
  147224. /**
  147225. * Constant used to retrieve the position texture index in the G-Buffer textures array
  147226. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  147227. */
  147228. static readonly POSITION_TEXTURE_TYPE: number;
  147229. /**
  147230. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  147231. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  147232. */
  147233. static readonly VELOCITY_TEXTURE_TYPE: number;
  147234. /**
  147235. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  147236. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  147237. */
  147238. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  147239. /**
  147240. * Dictionary used to store the previous transformation matrices of each rendered mesh
  147241. * in order to compute objects velocities when enableVelocity is set to "true"
  147242. * @hidden
  147243. */
  147244. _previousTransformationMatrices: {
  147245. [index: number]: ISavedTransformationMatrix;
  147246. };
  147247. /**
  147248. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  147249. * in order to compute objects velocities when enableVelocity is set to "true"
  147250. * @hidden
  147251. */
  147252. _previousBonesTransformationMatrices: {
  147253. [index: number]: Float32Array;
  147254. };
  147255. /**
  147256. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  147257. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  147258. */
  147259. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  147260. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  147261. renderTransparentMeshes: boolean;
  147262. private _scene;
  147263. private _multiRenderTarget;
  147264. private _ratio;
  147265. private _enablePosition;
  147266. private _enableVelocity;
  147267. private _enableReflectivity;
  147268. private _positionIndex;
  147269. private _velocityIndex;
  147270. private _reflectivityIndex;
  147271. protected _effect: Effect;
  147272. protected _cachedDefines: string;
  147273. /**
  147274. * Set the render list (meshes to be rendered) used in the G buffer.
  147275. */
  147276. set renderList(meshes: Mesh[]);
  147277. /**
  147278. * Gets wether or not G buffer are supported by the running hardware.
  147279. * This requires draw buffer supports
  147280. */
  147281. get isSupported(): boolean;
  147282. /**
  147283. * Returns the index of the given texture type in the G-Buffer textures array
  147284. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  147285. * @returns the index of the given texture type in the G-Buffer textures array
  147286. */
  147287. getTextureIndex(textureType: number): number;
  147288. /**
  147289. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  147290. */
  147291. get enablePosition(): boolean;
  147292. /**
  147293. * Sets whether or not objects positions are enabled for the G buffer.
  147294. */
  147295. set enablePosition(enable: boolean);
  147296. /**
  147297. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  147298. */
  147299. get enableVelocity(): boolean;
  147300. /**
  147301. * Sets wether or not objects velocities are enabled for the G buffer.
  147302. */
  147303. set enableVelocity(enable: boolean);
  147304. /**
  147305. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  147306. */
  147307. get enableReflectivity(): boolean;
  147308. /**
  147309. * Sets wether or not objects roughness are enabled for the G buffer.
  147310. */
  147311. set enableReflectivity(enable: boolean);
  147312. /**
  147313. * Gets the scene associated with the buffer.
  147314. */
  147315. get scene(): Scene;
  147316. /**
  147317. * Gets the ratio used by the buffer during its creation.
  147318. * How big is the buffer related to the main canvas.
  147319. */
  147320. get ratio(): number;
  147321. /** @hidden */
  147322. static _SceneComponentInitialization: (scene: Scene) => void;
  147323. /**
  147324. * Creates a new G Buffer for the scene
  147325. * @param scene The scene the buffer belongs to
  147326. * @param ratio How big is the buffer related to the main canvas.
  147327. */
  147328. constructor(scene: Scene, ratio?: number);
  147329. /**
  147330. * Checks wether everything is ready to render a submesh to the G buffer.
  147331. * @param subMesh the submesh to check readiness for
  147332. * @param useInstances is the mesh drawn using instance or not
  147333. * @returns true if ready otherwise false
  147334. */
  147335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147336. /**
  147337. * Gets the current underlying G Buffer.
  147338. * @returns the buffer
  147339. */
  147340. getGBuffer(): MultiRenderTarget;
  147341. /**
  147342. * Gets the number of samples used to render the buffer (anti aliasing).
  147343. */
  147344. get samples(): number;
  147345. /**
  147346. * Sets the number of samples used to render the buffer (anti aliasing).
  147347. */
  147348. set samples(value: number);
  147349. /**
  147350. * Disposes the renderer and frees up associated resources.
  147351. */
  147352. dispose(): void;
  147353. protected _createRenderTargets(): void;
  147354. private _copyBonesTransformationMatrices;
  147355. }
  147356. }
  147357. declare module BABYLON {
  147358. interface Scene {
  147359. /** @hidden (Backing field) */
  147360. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147361. /**
  147362. * Gets or Sets the current geometry buffer associated to the scene.
  147363. */
  147364. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147365. /**
  147366. * Enables a GeometryBufferRender and associates it with the scene
  147367. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147368. * @returns the GeometryBufferRenderer
  147369. */
  147370. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147371. /**
  147372. * Disables the GeometryBufferRender associated with the scene
  147373. */
  147374. disableGeometryBufferRenderer(): void;
  147375. }
  147376. /**
  147377. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147378. * in several rendering techniques.
  147379. */
  147380. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147381. /**
  147382. * The component name helpful to identify the component in the list of scene components.
  147383. */
  147384. readonly name: string;
  147385. /**
  147386. * The scene the component belongs to.
  147387. */
  147388. scene: Scene;
  147389. /**
  147390. * Creates a new instance of the component for the given scene
  147391. * @param scene Defines the scene to register the component in
  147392. */
  147393. constructor(scene: Scene);
  147394. /**
  147395. * Registers the component in a given scene
  147396. */
  147397. register(): void;
  147398. /**
  147399. * Rebuilds the elements related to this component in case of
  147400. * context lost for instance.
  147401. */
  147402. rebuild(): void;
  147403. /**
  147404. * Disposes the component and the associated ressources
  147405. */
  147406. dispose(): void;
  147407. private _gatherRenderTargets;
  147408. }
  147409. }
  147410. declare module BABYLON {
  147411. /** @hidden */
  147412. export var motionBlurPixelShader: {
  147413. name: string;
  147414. shader: string;
  147415. };
  147416. }
  147417. declare module BABYLON {
  147418. /**
  147419. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147420. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147421. * As an example, all you have to do is to create the post-process:
  147422. * var mb = new BABYLON.MotionBlurPostProcess(
  147423. * 'mb', // The name of the effect.
  147424. * scene, // The scene containing the objects to blur according to their velocity.
  147425. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147426. * camera // The camera to apply the render pass to.
  147427. * );
  147428. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147429. */
  147430. export class MotionBlurPostProcess extends PostProcess {
  147431. /**
  147432. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147433. */
  147434. motionStrength: number;
  147435. /**
  147436. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147437. */
  147438. get motionBlurSamples(): number;
  147439. /**
  147440. * Sets the number of iterations to be used for motion blur quality
  147441. */
  147442. set motionBlurSamples(samples: number);
  147443. private _motionBlurSamples;
  147444. private _geometryBufferRenderer;
  147445. /**
  147446. * Creates a new instance MotionBlurPostProcess
  147447. * @param name The name of the effect.
  147448. * @param scene The scene containing the objects to blur according to their velocity.
  147449. * @param options The required width/height ratio to downsize to before computing the render pass.
  147450. * @param camera The camera to apply the render pass to.
  147451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147452. * @param engine The engine which the post process will be applied. (default: current engine)
  147453. * @param reusable If the post process can be reused on the same frame. (default: false)
  147454. * @param textureType Type of textures used when performing the post process. (default: 0)
  147455. * @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)
  147456. */
  147457. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147458. /**
  147459. * Excludes the given skinned mesh from computing bones velocities.
  147460. * 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.
  147461. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147462. */
  147463. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147464. /**
  147465. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147466. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147467. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147468. */
  147469. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147470. /**
  147471. * Disposes the post process.
  147472. * @param camera The camera to dispose the post process on.
  147473. */
  147474. dispose(camera?: Camera): void;
  147475. }
  147476. }
  147477. declare module BABYLON {
  147478. /** @hidden */
  147479. export var refractionPixelShader: {
  147480. name: string;
  147481. shader: string;
  147482. };
  147483. }
  147484. declare module BABYLON {
  147485. /**
  147486. * Post process which applies a refractin texture
  147487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147488. */
  147489. export class RefractionPostProcess extends PostProcess {
  147490. /** the base color of the refraction (used to taint the rendering) */
  147491. color: Color3;
  147492. /** simulated refraction depth */
  147493. depth: number;
  147494. /** the coefficient of the base color (0 to remove base color tainting) */
  147495. colorLevel: number;
  147496. private _refTexture;
  147497. private _ownRefractionTexture;
  147498. /**
  147499. * Gets or sets the refraction texture
  147500. * Please note that you are responsible for disposing the texture if you set it manually
  147501. */
  147502. get refractionTexture(): Texture;
  147503. set refractionTexture(value: Texture);
  147504. /**
  147505. * Initializes the RefractionPostProcess
  147506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147507. * @param name The name of the effect.
  147508. * @param refractionTextureUrl Url of the refraction texture to use
  147509. * @param color the base color of the refraction (used to taint the rendering)
  147510. * @param depth simulated refraction depth
  147511. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147512. * @param camera The camera to apply the render pass to.
  147513. * @param options The required width/height ratio to downsize to before computing the render pass.
  147514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147515. * @param engine The engine which the post process will be applied. (default: current engine)
  147516. * @param reusable If the post process can be reused on the same frame. (default: false)
  147517. */
  147518. constructor(name: string, refractionTextureUrl: string,
  147519. /** the base color of the refraction (used to taint the rendering) */
  147520. color: Color3,
  147521. /** simulated refraction depth */
  147522. depth: number,
  147523. /** the coefficient of the base color (0 to remove base color tainting) */
  147524. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147525. /**
  147526. * Disposes of the post process
  147527. * @param camera Camera to dispose post process on
  147528. */
  147529. dispose(camera: Camera): void;
  147530. }
  147531. }
  147532. declare module BABYLON {
  147533. /** @hidden */
  147534. export var sharpenPixelShader: {
  147535. name: string;
  147536. shader: string;
  147537. };
  147538. }
  147539. declare module BABYLON {
  147540. /**
  147541. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147542. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147543. */
  147544. export class SharpenPostProcess extends PostProcess {
  147545. /**
  147546. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147547. */
  147548. colorAmount: number;
  147549. /**
  147550. * How much sharpness should be applied (default: 0.3)
  147551. */
  147552. edgeAmount: number;
  147553. /**
  147554. * Creates a new instance ConvolutionPostProcess
  147555. * @param name The name of the effect.
  147556. * @param options The required width/height ratio to downsize to before computing the render pass.
  147557. * @param camera The camera to apply the render pass to.
  147558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147559. * @param engine The engine which the post process will be applied. (default: current engine)
  147560. * @param reusable If the post process can be reused on the same frame. (default: false)
  147561. * @param textureType Type of textures used when performing the post process. (default: 0)
  147562. * @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)
  147563. */
  147564. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147565. }
  147566. }
  147567. declare module BABYLON {
  147568. /**
  147569. * PostProcessRenderPipeline
  147570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147571. */
  147572. export class PostProcessRenderPipeline {
  147573. private engine;
  147574. private _renderEffects;
  147575. private _renderEffectsForIsolatedPass;
  147576. /**
  147577. * List of inspectable custom properties (used by the Inspector)
  147578. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147579. */
  147580. inspectableCustomProperties: IInspectable[];
  147581. /**
  147582. * @hidden
  147583. */
  147584. protected _cameras: Camera[];
  147585. /** @hidden */
  147586. _name: string;
  147587. /**
  147588. * Gets pipeline name
  147589. */
  147590. get name(): string;
  147591. /** Gets the list of attached cameras */
  147592. get cameras(): Camera[];
  147593. /**
  147594. * Initializes a PostProcessRenderPipeline
  147595. * @param engine engine to add the pipeline to
  147596. * @param name name of the pipeline
  147597. */
  147598. constructor(engine: Engine, name: string);
  147599. /**
  147600. * Gets the class name
  147601. * @returns "PostProcessRenderPipeline"
  147602. */
  147603. getClassName(): string;
  147604. /**
  147605. * If all the render effects in the pipeline are supported
  147606. */
  147607. get isSupported(): boolean;
  147608. /**
  147609. * Adds an effect to the pipeline
  147610. * @param renderEffect the effect to add
  147611. */
  147612. addEffect(renderEffect: PostProcessRenderEffect): void;
  147613. /** @hidden */
  147614. _rebuild(): void;
  147615. /** @hidden */
  147616. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147617. /** @hidden */
  147618. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147619. /** @hidden */
  147620. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147621. /** @hidden */
  147622. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147623. /** @hidden */
  147624. _attachCameras(cameras: Camera, unique: boolean): void;
  147625. /** @hidden */
  147626. _attachCameras(cameras: Camera[], unique: boolean): void;
  147627. /** @hidden */
  147628. _detachCameras(cameras: Camera): void;
  147629. /** @hidden */
  147630. _detachCameras(cameras: Nullable<Camera[]>): void;
  147631. /** @hidden */
  147632. _update(): void;
  147633. /** @hidden */
  147634. _reset(): void;
  147635. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147636. /**
  147637. * Disposes of the pipeline
  147638. */
  147639. dispose(): void;
  147640. }
  147641. }
  147642. declare module BABYLON {
  147643. /**
  147644. * PostProcessRenderPipelineManager class
  147645. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147646. */
  147647. export class PostProcessRenderPipelineManager {
  147648. private _renderPipelines;
  147649. /**
  147650. * Initializes a PostProcessRenderPipelineManager
  147651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147652. */
  147653. constructor();
  147654. /**
  147655. * Gets the list of supported render pipelines
  147656. */
  147657. get supportedPipelines(): PostProcessRenderPipeline[];
  147658. /**
  147659. * Adds a pipeline to the manager
  147660. * @param renderPipeline The pipeline to add
  147661. */
  147662. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147663. /**
  147664. * Attaches a camera to the pipeline
  147665. * @param renderPipelineName The name of the pipeline to attach to
  147666. * @param cameras the camera to attach
  147667. * @param unique if the camera can be attached multiple times to the pipeline
  147668. */
  147669. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147670. /**
  147671. * Detaches a camera from the pipeline
  147672. * @param renderPipelineName The name of the pipeline to detach from
  147673. * @param cameras the camera to detach
  147674. */
  147675. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147676. /**
  147677. * Enables an effect by name on a pipeline
  147678. * @param renderPipelineName the name of the pipeline to enable the effect in
  147679. * @param renderEffectName the name of the effect to enable
  147680. * @param cameras the cameras that the effect should be enabled on
  147681. */
  147682. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147683. /**
  147684. * Disables an effect by name on a pipeline
  147685. * @param renderPipelineName the name of the pipeline to disable the effect in
  147686. * @param renderEffectName the name of the effect to disable
  147687. * @param cameras the cameras that the effect should be disabled on
  147688. */
  147689. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147690. /**
  147691. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147692. */
  147693. update(): void;
  147694. /** @hidden */
  147695. _rebuild(): void;
  147696. /**
  147697. * Disposes of the manager and pipelines
  147698. */
  147699. dispose(): void;
  147700. }
  147701. }
  147702. declare module BABYLON {
  147703. interface Scene {
  147704. /** @hidden (Backing field) */
  147705. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147706. /**
  147707. * Gets the postprocess render pipeline manager
  147708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147709. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147710. */
  147711. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147712. }
  147713. /**
  147714. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147715. */
  147716. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147717. /**
  147718. * The component name helpfull to identify the component in the list of scene components.
  147719. */
  147720. readonly name: string;
  147721. /**
  147722. * The scene the component belongs to.
  147723. */
  147724. scene: Scene;
  147725. /**
  147726. * Creates a new instance of the component for the given scene
  147727. * @param scene Defines the scene to register the component in
  147728. */
  147729. constructor(scene: Scene);
  147730. /**
  147731. * Registers the component in a given scene
  147732. */
  147733. register(): void;
  147734. /**
  147735. * Rebuilds the elements related to this component in case of
  147736. * context lost for instance.
  147737. */
  147738. rebuild(): void;
  147739. /**
  147740. * Disposes the component and the associated ressources
  147741. */
  147742. dispose(): void;
  147743. private _gatherRenderTargets;
  147744. }
  147745. }
  147746. declare module BABYLON {
  147747. /**
  147748. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147749. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147750. */
  147751. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147752. private _scene;
  147753. private _camerasToBeAttached;
  147754. /**
  147755. * ID of the sharpen post process,
  147756. */
  147757. private readonly SharpenPostProcessId;
  147758. /**
  147759. * @ignore
  147760. * ID of the image processing post process;
  147761. */
  147762. readonly ImageProcessingPostProcessId: string;
  147763. /**
  147764. * @ignore
  147765. * ID of the Fast Approximate Anti-Aliasing post process;
  147766. */
  147767. readonly FxaaPostProcessId: string;
  147768. /**
  147769. * ID of the chromatic aberration post process,
  147770. */
  147771. private readonly ChromaticAberrationPostProcessId;
  147772. /**
  147773. * ID of the grain post process
  147774. */
  147775. private readonly GrainPostProcessId;
  147776. /**
  147777. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147778. */
  147779. sharpen: SharpenPostProcess;
  147780. private _sharpenEffect;
  147781. private bloom;
  147782. /**
  147783. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147784. */
  147785. depthOfField: DepthOfFieldEffect;
  147786. /**
  147787. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147788. */
  147789. fxaa: FxaaPostProcess;
  147790. /**
  147791. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147792. */
  147793. imageProcessing: ImageProcessingPostProcess;
  147794. /**
  147795. * Chromatic aberration post process which will shift rgb colors in the image
  147796. */
  147797. chromaticAberration: ChromaticAberrationPostProcess;
  147798. private _chromaticAberrationEffect;
  147799. /**
  147800. * Grain post process which add noise to the image
  147801. */
  147802. grain: GrainPostProcess;
  147803. private _grainEffect;
  147804. /**
  147805. * Glow post process which adds a glow to emissive areas of the image
  147806. */
  147807. private _glowLayer;
  147808. /**
  147809. * Animations which can be used to tweak settings over a period of time
  147810. */
  147811. animations: Animation[];
  147812. private _imageProcessingConfigurationObserver;
  147813. private _sharpenEnabled;
  147814. private _bloomEnabled;
  147815. private _depthOfFieldEnabled;
  147816. private _depthOfFieldBlurLevel;
  147817. private _fxaaEnabled;
  147818. private _imageProcessingEnabled;
  147819. private _defaultPipelineTextureType;
  147820. private _bloomScale;
  147821. private _chromaticAberrationEnabled;
  147822. private _grainEnabled;
  147823. private _buildAllowed;
  147824. /**
  147825. * Gets active scene
  147826. */
  147827. get scene(): Scene;
  147828. /**
  147829. * Enable or disable the sharpen process from the pipeline
  147830. */
  147831. set sharpenEnabled(enabled: boolean);
  147832. get sharpenEnabled(): boolean;
  147833. private _resizeObserver;
  147834. private _hardwareScaleLevel;
  147835. private _bloomKernel;
  147836. /**
  147837. * Specifies the size of the bloom blur kernel, relative to the final output size
  147838. */
  147839. get bloomKernel(): number;
  147840. set bloomKernel(value: number);
  147841. /**
  147842. * Specifies the weight of the bloom in the final rendering
  147843. */
  147844. private _bloomWeight;
  147845. /**
  147846. * Specifies the luma threshold for the area that will be blurred by the bloom
  147847. */
  147848. private _bloomThreshold;
  147849. private _hdr;
  147850. /**
  147851. * The strength of the bloom.
  147852. */
  147853. set bloomWeight(value: number);
  147854. get bloomWeight(): number;
  147855. /**
  147856. * The strength of the bloom.
  147857. */
  147858. set bloomThreshold(value: number);
  147859. get bloomThreshold(): number;
  147860. /**
  147861. * The scale of the bloom, lower value will provide better performance.
  147862. */
  147863. set bloomScale(value: number);
  147864. get bloomScale(): number;
  147865. /**
  147866. * Enable or disable the bloom from the pipeline
  147867. */
  147868. set bloomEnabled(enabled: boolean);
  147869. get bloomEnabled(): boolean;
  147870. private _rebuildBloom;
  147871. /**
  147872. * If the depth of field is enabled.
  147873. */
  147874. get depthOfFieldEnabled(): boolean;
  147875. set depthOfFieldEnabled(enabled: boolean);
  147876. /**
  147877. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147878. */
  147879. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147880. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147881. /**
  147882. * If the anti aliasing is enabled.
  147883. */
  147884. set fxaaEnabled(enabled: boolean);
  147885. get fxaaEnabled(): boolean;
  147886. private _samples;
  147887. /**
  147888. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147889. */
  147890. set samples(sampleCount: number);
  147891. get samples(): number;
  147892. /**
  147893. * If image processing is enabled.
  147894. */
  147895. set imageProcessingEnabled(enabled: boolean);
  147896. get imageProcessingEnabled(): boolean;
  147897. /**
  147898. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147899. */
  147900. set glowLayerEnabled(enabled: boolean);
  147901. get glowLayerEnabled(): boolean;
  147902. /**
  147903. * Gets the glow layer (or null if not defined)
  147904. */
  147905. get glowLayer(): Nullable<GlowLayer>;
  147906. /**
  147907. * Enable or disable the chromaticAberration process from the pipeline
  147908. */
  147909. set chromaticAberrationEnabled(enabled: boolean);
  147910. get chromaticAberrationEnabled(): boolean;
  147911. /**
  147912. * Enable or disable the grain process from the pipeline
  147913. */
  147914. set grainEnabled(enabled: boolean);
  147915. get grainEnabled(): boolean;
  147916. /**
  147917. * @constructor
  147918. * @param name - The rendering pipeline name (default: "")
  147919. * @param hdr - If high dynamic range textures should be used (default: true)
  147920. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147921. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147922. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147923. */
  147924. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147925. /**
  147926. * Get the class name
  147927. * @returns "DefaultRenderingPipeline"
  147928. */
  147929. getClassName(): string;
  147930. /**
  147931. * Force the compilation of the entire pipeline.
  147932. */
  147933. prepare(): void;
  147934. private _hasCleared;
  147935. private _prevPostProcess;
  147936. private _prevPrevPostProcess;
  147937. private _setAutoClearAndTextureSharing;
  147938. private _depthOfFieldSceneObserver;
  147939. private _buildPipeline;
  147940. private _disposePostProcesses;
  147941. /**
  147942. * Adds a camera to the pipeline
  147943. * @param camera the camera to be added
  147944. */
  147945. addCamera(camera: Camera): void;
  147946. /**
  147947. * Removes a camera from the pipeline
  147948. * @param camera the camera to remove
  147949. */
  147950. removeCamera(camera: Camera): void;
  147951. /**
  147952. * Dispose of the pipeline and stop all post processes
  147953. */
  147954. dispose(): void;
  147955. /**
  147956. * Serialize the rendering pipeline (Used when exporting)
  147957. * @returns the serialized object
  147958. */
  147959. serialize(): any;
  147960. /**
  147961. * Parse the serialized pipeline
  147962. * @param source Source pipeline.
  147963. * @param scene The scene to load the pipeline to.
  147964. * @param rootUrl The URL of the serialized pipeline.
  147965. * @returns An instantiated pipeline from the serialized object.
  147966. */
  147967. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147968. }
  147969. }
  147970. declare module BABYLON {
  147971. /** @hidden */
  147972. export var lensHighlightsPixelShader: {
  147973. name: string;
  147974. shader: string;
  147975. };
  147976. }
  147977. declare module BABYLON {
  147978. /** @hidden */
  147979. export var depthOfFieldPixelShader: {
  147980. name: string;
  147981. shader: string;
  147982. };
  147983. }
  147984. declare module BABYLON {
  147985. /**
  147986. * BABYLON.JS Chromatic Aberration GLSL Shader
  147987. * Author: Olivier Guyot
  147988. * Separates very slightly R, G and B colors on the edges of the screen
  147989. * Inspired by Francois Tarlier & Martins Upitis
  147990. */
  147991. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147992. /**
  147993. * @ignore
  147994. * The chromatic aberration PostProcess id in the pipeline
  147995. */
  147996. LensChromaticAberrationEffect: string;
  147997. /**
  147998. * @ignore
  147999. * The highlights enhancing PostProcess id in the pipeline
  148000. */
  148001. HighlightsEnhancingEffect: string;
  148002. /**
  148003. * @ignore
  148004. * The depth-of-field PostProcess id in the pipeline
  148005. */
  148006. LensDepthOfFieldEffect: string;
  148007. private _scene;
  148008. private _depthTexture;
  148009. private _grainTexture;
  148010. private _chromaticAberrationPostProcess;
  148011. private _highlightsPostProcess;
  148012. private _depthOfFieldPostProcess;
  148013. private _edgeBlur;
  148014. private _grainAmount;
  148015. private _chromaticAberration;
  148016. private _distortion;
  148017. private _highlightsGain;
  148018. private _highlightsThreshold;
  148019. private _dofDistance;
  148020. private _dofAperture;
  148021. private _dofDarken;
  148022. private _dofPentagon;
  148023. private _blurNoise;
  148024. /**
  148025. * @constructor
  148026. *
  148027. * Effect parameters are as follow:
  148028. * {
  148029. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148030. * edge_blur: number; // from 0 to x (1 for realism)
  148031. * distortion: number; // from 0 to x (1 for realism)
  148032. * grain_amount: number; // from 0 to 1
  148033. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148034. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148035. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148036. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148037. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148038. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148039. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148040. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148041. * }
  148042. * Note: if an effect parameter is unset, effect is disabled
  148043. *
  148044. * @param name The rendering pipeline name
  148045. * @param parameters - An object containing all parameters (see above)
  148046. * @param scene The scene linked to this pipeline
  148047. * @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)
  148048. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148049. */
  148050. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148051. /**
  148052. * Get the class name
  148053. * @returns "LensRenderingPipeline"
  148054. */
  148055. getClassName(): string;
  148056. /**
  148057. * Gets associated scene
  148058. */
  148059. get scene(): Scene;
  148060. /**
  148061. * Gets or sets the edge blur
  148062. */
  148063. get edgeBlur(): number;
  148064. set edgeBlur(value: number);
  148065. /**
  148066. * Gets or sets the grain amount
  148067. */
  148068. get grainAmount(): number;
  148069. set grainAmount(value: number);
  148070. /**
  148071. * Gets or sets the chromatic aberration amount
  148072. */
  148073. get chromaticAberration(): number;
  148074. set chromaticAberration(value: number);
  148075. /**
  148076. * Gets or sets the depth of field aperture
  148077. */
  148078. get dofAperture(): number;
  148079. set dofAperture(value: number);
  148080. /**
  148081. * Gets or sets the edge distortion
  148082. */
  148083. get edgeDistortion(): number;
  148084. set edgeDistortion(value: number);
  148085. /**
  148086. * Gets or sets the depth of field distortion
  148087. */
  148088. get dofDistortion(): number;
  148089. set dofDistortion(value: number);
  148090. /**
  148091. * Gets or sets the darken out of focus amount
  148092. */
  148093. get darkenOutOfFocus(): number;
  148094. set darkenOutOfFocus(value: number);
  148095. /**
  148096. * Gets or sets a boolean indicating if blur noise is enabled
  148097. */
  148098. get blurNoise(): boolean;
  148099. set blurNoise(value: boolean);
  148100. /**
  148101. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  148102. */
  148103. get pentagonBokeh(): boolean;
  148104. set pentagonBokeh(value: boolean);
  148105. /**
  148106. * Gets or sets the highlight grain amount
  148107. */
  148108. get highlightsGain(): number;
  148109. set highlightsGain(value: number);
  148110. /**
  148111. * Gets or sets the highlight threshold
  148112. */
  148113. get highlightsThreshold(): number;
  148114. set highlightsThreshold(value: number);
  148115. /**
  148116. * Sets the amount of blur at the edges
  148117. * @param amount blur amount
  148118. */
  148119. setEdgeBlur(amount: number): void;
  148120. /**
  148121. * Sets edge blur to 0
  148122. */
  148123. disableEdgeBlur(): void;
  148124. /**
  148125. * Sets the amout of grain
  148126. * @param amount Amount of grain
  148127. */
  148128. setGrainAmount(amount: number): void;
  148129. /**
  148130. * Set grain amount to 0
  148131. */
  148132. disableGrain(): void;
  148133. /**
  148134. * Sets the chromatic aberration amount
  148135. * @param amount amount of chromatic aberration
  148136. */
  148137. setChromaticAberration(amount: number): void;
  148138. /**
  148139. * Sets chromatic aberration amount to 0
  148140. */
  148141. disableChromaticAberration(): void;
  148142. /**
  148143. * Sets the EdgeDistortion amount
  148144. * @param amount amount of EdgeDistortion
  148145. */
  148146. setEdgeDistortion(amount: number): void;
  148147. /**
  148148. * Sets edge distortion to 0
  148149. */
  148150. disableEdgeDistortion(): void;
  148151. /**
  148152. * Sets the FocusDistance amount
  148153. * @param amount amount of FocusDistance
  148154. */
  148155. setFocusDistance(amount: number): void;
  148156. /**
  148157. * Disables depth of field
  148158. */
  148159. disableDepthOfField(): void;
  148160. /**
  148161. * Sets the Aperture amount
  148162. * @param amount amount of Aperture
  148163. */
  148164. setAperture(amount: number): void;
  148165. /**
  148166. * Sets the DarkenOutOfFocus amount
  148167. * @param amount amount of DarkenOutOfFocus
  148168. */
  148169. setDarkenOutOfFocus(amount: number): void;
  148170. private _pentagonBokehIsEnabled;
  148171. /**
  148172. * Creates a pentagon bokeh effect
  148173. */
  148174. enablePentagonBokeh(): void;
  148175. /**
  148176. * Disables the pentagon bokeh effect
  148177. */
  148178. disablePentagonBokeh(): void;
  148179. /**
  148180. * Enables noise blur
  148181. */
  148182. enableNoiseBlur(): void;
  148183. /**
  148184. * Disables noise blur
  148185. */
  148186. disableNoiseBlur(): void;
  148187. /**
  148188. * Sets the HighlightsGain amount
  148189. * @param amount amount of HighlightsGain
  148190. */
  148191. setHighlightsGain(amount: number): void;
  148192. /**
  148193. * Sets the HighlightsThreshold amount
  148194. * @param amount amount of HighlightsThreshold
  148195. */
  148196. setHighlightsThreshold(amount: number): void;
  148197. /**
  148198. * Disables highlights
  148199. */
  148200. disableHighlights(): void;
  148201. /**
  148202. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  148203. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  148204. */
  148205. dispose(disableDepthRender?: boolean): void;
  148206. private _createChromaticAberrationPostProcess;
  148207. private _createHighlightsPostProcess;
  148208. private _createDepthOfFieldPostProcess;
  148209. private _createGrainTexture;
  148210. }
  148211. }
  148212. declare module BABYLON {
  148213. /** @hidden */
  148214. export var fibonacci: {
  148215. name: string;
  148216. shader: string;
  148217. };
  148218. }
  148219. declare module BABYLON {
  148220. /** @hidden */
  148221. export var diffusionProfile: {
  148222. name: string;
  148223. shader: string;
  148224. };
  148225. }
  148226. declare module BABYLON {
  148227. /** @hidden */
  148228. export var subSurfaceScatteringPixelShader: {
  148229. name: string;
  148230. shader: string;
  148231. };
  148232. }
  148233. declare module BABYLON {
  148234. /**
  148235. * Sub surface scattering post process
  148236. */
  148237. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148238. /** @hidden */
  148239. texelWidth: number;
  148240. /** @hidden */
  148241. texelHeight: number;
  148242. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148243. }
  148244. }
  148245. declare module BABYLON {
  148246. /**
  148247. * Interface for defining prepass effects in the prepass post-process pipeline
  148248. */
  148249. export interface PrePassEffectConfiguration {
  148250. /**
  148251. * Post process to attach for this effect
  148252. */
  148253. postProcess: PostProcess;
  148254. /**
  148255. * Is the effect enabled
  148256. */
  148257. enabled: boolean;
  148258. /**
  148259. * Disposes the effect configuration
  148260. */
  148261. dispose(): void;
  148262. /**
  148263. * Disposes the effect configuration
  148264. */
  148265. createPostProcess: () => PostProcess;
  148266. }
  148267. }
  148268. declare module BABYLON {
  148269. /**
  148270. * Contains all parameters needed for the prepass to perform
  148271. * screen space subsurface scattering
  148272. */
  148273. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  148274. private _ssDiffusionS;
  148275. private _ssFilterRadii;
  148276. private _ssDiffusionD;
  148277. /**
  148278. * Post process to attach for screen space subsurface scattering
  148279. */
  148280. postProcess: SubSurfaceScatteringPostProcess;
  148281. /**
  148282. * Diffusion profile color for subsurface scattering
  148283. */
  148284. get ssDiffusionS(): number[];
  148285. /**
  148286. * Diffusion profile max color channel value for subsurface scattering
  148287. */
  148288. get ssDiffusionD(): number[];
  148289. /**
  148290. * Diffusion profile filter radius for subsurface scattering
  148291. */
  148292. get ssFilterRadii(): number[];
  148293. /**
  148294. * Is subsurface enabled
  148295. */
  148296. enabled: boolean;
  148297. /**
  148298. * Diffusion profile colors for subsurface scattering
  148299. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  148300. * See ...
  148301. * Note that you can only store up to 5 of them
  148302. */
  148303. ssDiffusionProfileColors: Color3[];
  148304. /**
  148305. * Defines the ratio real world => scene units.
  148306. * Used for subsurface scattering
  148307. */
  148308. metersPerUnit: number;
  148309. private _scene;
  148310. /**
  148311. * Builds a subsurface configuration object
  148312. * @param scene The scene
  148313. */
  148314. constructor(scene: Scene);
  148315. /**
  148316. * Adds a new diffusion profile.
  148317. * Useful for more realistic subsurface scattering on diverse materials.
  148318. * @param color The color of the diffusion profile. Should be the average color of the material.
  148319. * @return The index of the diffusion profile for the material subsurface configuration
  148320. */
  148321. addDiffusionProfile(color: Color3): number;
  148322. /**
  148323. * Creates the sss post process
  148324. * @return The created post process
  148325. */
  148326. createPostProcess(): SubSurfaceScatteringPostProcess;
  148327. /**
  148328. * Deletes all diffusion profiles.
  148329. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  148330. */
  148331. clearAllDiffusionProfiles(): void;
  148332. /**
  148333. * Disposes this object
  148334. */
  148335. dispose(): void;
  148336. /**
  148337. * @hidden
  148338. * https://zero-radiance.github.io/post/sampling-diffusion/
  148339. *
  148340. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  148341. * ------------------------------------------------------------------------------------
  148342. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  148343. * PDF[r, phi, s] = r * R[r, phi, s]
  148344. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  148345. * ------------------------------------------------------------------------------------
  148346. * We importance sample the color channel with the widest scattering distance.
  148347. */
  148348. getDiffusionProfileParameters(color: Color3): number;
  148349. /**
  148350. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  148351. * 'u' is the random number (the value of the CDF): [0, 1).
  148352. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  148353. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  148354. */
  148355. private _sampleBurleyDiffusionProfile;
  148356. }
  148357. }
  148358. declare module BABYLON {
  148359. /**
  148360. * Renders a pre pass of the scene
  148361. * This means every mesh in the scene will be rendered to a render target texture
  148362. * And then this texture will be composited to the rendering canvas with post processes
  148363. * It is necessary for effects like subsurface scattering or deferred shading
  148364. */
  148365. export class PrePassRenderer {
  148366. /** @hidden */
  148367. static _SceneComponentInitialization: (scene: Scene) => void;
  148368. private _scene;
  148369. private _engine;
  148370. private _isDirty;
  148371. /**
  148372. * Number of textures in the multi render target texture where the scene is directly rendered
  148373. */
  148374. readonly mrtCount: number;
  148375. /**
  148376. * The render target where the scene is directly rendered
  148377. */
  148378. prePassRT: MultiRenderTarget;
  148379. private _mrtTypes;
  148380. private _multiRenderAttachments;
  148381. private _defaultAttachments;
  148382. private _clearAttachments;
  148383. private _postProcesses;
  148384. private readonly _clearColor;
  148385. /**
  148386. * Image processing post process for composition
  148387. */
  148388. imageProcessingPostProcess: ImageProcessingPostProcess;
  148389. /**
  148390. * Configuration for sub surface scattering post process
  148391. */
  148392. subSurfaceConfiguration: SubSurfaceConfiguration;
  148393. /**
  148394. * Should materials render their geometry on the MRT
  148395. */
  148396. materialsShouldRenderGeometry: boolean;
  148397. /**
  148398. * Should materials render the irradiance information on the MRT
  148399. */
  148400. materialsShouldRenderIrradiance: boolean;
  148401. private _enabled;
  148402. /**
  148403. * Indicates if the prepass is enabled
  148404. */
  148405. get enabled(): boolean;
  148406. /**
  148407. * How many samples are used for MSAA of the scene render target
  148408. */
  148409. get samples(): number;
  148410. set samples(n: number);
  148411. /**
  148412. * Instanciates a prepass renderer
  148413. * @param scene The scene
  148414. */
  148415. constructor(scene: Scene);
  148416. private _initializeAttachments;
  148417. private _createCompositionEffect;
  148418. /**
  148419. * Indicates if rendering a prepass is supported
  148420. */
  148421. get isSupported(): boolean;
  148422. /**
  148423. * Sets the proper output textures to draw in the engine.
  148424. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  148425. */
  148426. bindAttachmentsForEffect(effect: Effect): void;
  148427. /**
  148428. * @hidden
  148429. */
  148430. _beforeCameraDraw(): void;
  148431. /**
  148432. * @hidden
  148433. */
  148434. _afterCameraDraw(): void;
  148435. private _checkRTSize;
  148436. private _bindFrameBuffer;
  148437. /**
  148438. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  148439. */
  148440. clear(): void;
  148441. private _setState;
  148442. private _enable;
  148443. private _disable;
  148444. private _resetPostProcessChain;
  148445. private _bindPostProcessChain;
  148446. /**
  148447. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  148448. */
  148449. markAsDirty(): void;
  148450. private _update;
  148451. /**
  148452. * Disposes the prepass renderer.
  148453. */
  148454. dispose(): void;
  148455. }
  148456. }
  148457. declare module BABYLON {
  148458. /** @hidden */
  148459. export var ssao2PixelShader: {
  148460. name: string;
  148461. shader: string;
  148462. };
  148463. }
  148464. declare module BABYLON {
  148465. /** @hidden */
  148466. export var ssaoCombinePixelShader: {
  148467. name: string;
  148468. shader: string;
  148469. };
  148470. }
  148471. declare module BABYLON {
  148472. /**
  148473. * Render pipeline to produce ssao effect
  148474. */
  148475. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  148476. /**
  148477. * @ignore
  148478. * The PassPostProcess id in the pipeline that contains the original scene color
  148479. */
  148480. SSAOOriginalSceneColorEffect: string;
  148481. /**
  148482. * @ignore
  148483. * The SSAO PostProcess id in the pipeline
  148484. */
  148485. SSAORenderEffect: string;
  148486. /**
  148487. * @ignore
  148488. * The horizontal blur PostProcess id in the pipeline
  148489. */
  148490. SSAOBlurHRenderEffect: string;
  148491. /**
  148492. * @ignore
  148493. * The vertical blur PostProcess id in the pipeline
  148494. */
  148495. SSAOBlurVRenderEffect: string;
  148496. /**
  148497. * @ignore
  148498. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148499. */
  148500. SSAOCombineRenderEffect: string;
  148501. /**
  148502. * The output strength of the SSAO post-process. Default value is 1.0.
  148503. */
  148504. totalStrength: number;
  148505. /**
  148506. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  148507. */
  148508. maxZ: number;
  148509. /**
  148510. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  148511. */
  148512. minZAspect: number;
  148513. private _samples;
  148514. /**
  148515. * Number of samples used for the SSAO calculations. Default value is 8
  148516. */
  148517. set samples(n: number);
  148518. get samples(): number;
  148519. private _textureSamples;
  148520. /**
  148521. * Number of samples to use for antialiasing
  148522. */
  148523. set textureSamples(n: number);
  148524. get textureSamples(): number;
  148525. /**
  148526. * Force rendering the geometry through geometry buffer
  148527. */
  148528. private _forceGeometryBuffer;
  148529. /**
  148530. * Ratio object used for SSAO ratio and blur ratio
  148531. */
  148532. private _ratio;
  148533. /**
  148534. * Dynamically generated sphere sampler.
  148535. */
  148536. private _sampleSphere;
  148537. /**
  148538. * Blur filter offsets
  148539. */
  148540. private _samplerOffsets;
  148541. private _expensiveBlur;
  148542. /**
  148543. * If bilateral blur should be used
  148544. */
  148545. set expensiveBlur(b: boolean);
  148546. get expensiveBlur(): boolean;
  148547. /**
  148548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  148549. */
  148550. radius: number;
  148551. /**
  148552. * The base color of the SSAO post-process
  148553. * The final result is "base + ssao" between [0, 1]
  148554. */
  148555. base: number;
  148556. /**
  148557. * Support test.
  148558. */
  148559. static get IsSupported(): boolean;
  148560. private _scene;
  148561. private _randomTexture;
  148562. private _originalColorPostProcess;
  148563. private _ssaoPostProcess;
  148564. private _blurHPostProcess;
  148565. private _blurVPostProcess;
  148566. private _ssaoCombinePostProcess;
  148567. private _prePassRenderer;
  148568. /**
  148569. * Gets active scene
  148570. */
  148571. get scene(): Scene;
  148572. /**
  148573. * @constructor
  148574. * @param name The rendering pipeline name
  148575. * @param scene The scene linked to this pipeline
  148576. * @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 }
  148577. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148578. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  148579. */
  148580. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  148581. /**
  148582. * Get the class name
  148583. * @returns "SSAO2RenderingPipeline"
  148584. */
  148585. getClassName(): string;
  148586. /**
  148587. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148588. */
  148589. dispose(disableGeometryBufferRenderer?: boolean): void;
  148590. private _createBlurPostProcess;
  148591. /** @hidden */
  148592. _rebuild(): void;
  148593. private _bits;
  148594. private _radicalInverse_VdC;
  148595. private _hammersley;
  148596. private _hemisphereSample_uniform;
  148597. private _generateHemisphere;
  148598. private _getDefinesForSSAO;
  148599. private _createSSAOPostProcess;
  148600. private _createSSAOCombinePostProcess;
  148601. private _createRandomTexture;
  148602. /**
  148603. * Serialize the rendering pipeline (Used when exporting)
  148604. * @returns the serialized object
  148605. */
  148606. serialize(): any;
  148607. /**
  148608. * Parse the serialized pipeline
  148609. * @param source Source pipeline.
  148610. * @param scene The scene to load the pipeline to.
  148611. * @param rootUrl The URL of the serialized pipeline.
  148612. * @returns An instantiated pipeline from the serialized object.
  148613. */
  148614. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148615. }
  148616. }
  148617. declare module BABYLON {
  148618. /** @hidden */
  148619. export var ssaoPixelShader: {
  148620. name: string;
  148621. shader: string;
  148622. };
  148623. }
  148624. declare module BABYLON {
  148625. /**
  148626. * Render pipeline to produce ssao effect
  148627. */
  148628. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148629. /**
  148630. * @ignore
  148631. * The PassPostProcess id in the pipeline that contains the original scene color
  148632. */
  148633. SSAOOriginalSceneColorEffect: string;
  148634. /**
  148635. * @ignore
  148636. * The SSAO PostProcess id in the pipeline
  148637. */
  148638. SSAORenderEffect: string;
  148639. /**
  148640. * @ignore
  148641. * The horizontal blur PostProcess id in the pipeline
  148642. */
  148643. SSAOBlurHRenderEffect: string;
  148644. /**
  148645. * @ignore
  148646. * The vertical blur PostProcess id in the pipeline
  148647. */
  148648. SSAOBlurVRenderEffect: string;
  148649. /**
  148650. * @ignore
  148651. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148652. */
  148653. SSAOCombineRenderEffect: string;
  148654. /**
  148655. * The output strength of the SSAO post-process. Default value is 1.0.
  148656. */
  148657. totalStrength: number;
  148658. /**
  148659. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148660. */
  148661. radius: number;
  148662. /**
  148663. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148664. * Must not be equal to fallOff and superior to fallOff.
  148665. * Default value is 0.0075
  148666. */
  148667. area: number;
  148668. /**
  148669. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148670. * Must not be equal to area and inferior to area.
  148671. * Default value is 0.000001
  148672. */
  148673. fallOff: number;
  148674. /**
  148675. * The base color of the SSAO post-process
  148676. * The final result is "base + ssao" between [0, 1]
  148677. */
  148678. base: number;
  148679. private _scene;
  148680. private _depthTexture;
  148681. private _randomTexture;
  148682. private _originalColorPostProcess;
  148683. private _ssaoPostProcess;
  148684. private _blurHPostProcess;
  148685. private _blurVPostProcess;
  148686. private _ssaoCombinePostProcess;
  148687. private _firstUpdate;
  148688. /**
  148689. * Gets active scene
  148690. */
  148691. get scene(): Scene;
  148692. /**
  148693. * @constructor
  148694. * @param name - The rendering pipeline name
  148695. * @param scene - The scene linked to this pipeline
  148696. * @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 }
  148697. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148698. */
  148699. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148700. /**
  148701. * Get the class name
  148702. * @returns "SSAORenderingPipeline"
  148703. */
  148704. getClassName(): string;
  148705. /**
  148706. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148707. */
  148708. dispose(disableDepthRender?: boolean): void;
  148709. private _createBlurPostProcess;
  148710. /** @hidden */
  148711. _rebuild(): void;
  148712. private _createSSAOPostProcess;
  148713. private _createSSAOCombinePostProcess;
  148714. private _createRandomTexture;
  148715. }
  148716. }
  148717. declare module BABYLON {
  148718. /** @hidden */
  148719. export var screenSpaceReflectionPixelShader: {
  148720. name: string;
  148721. shader: string;
  148722. };
  148723. }
  148724. declare module BABYLON {
  148725. /**
  148726. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148727. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148728. */
  148729. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148730. /**
  148731. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148732. */
  148733. threshold: number;
  148734. /**
  148735. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148736. */
  148737. strength: number;
  148738. /**
  148739. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148740. */
  148741. reflectionSpecularFalloffExponent: number;
  148742. /**
  148743. * 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]
  148744. */
  148745. step: number;
  148746. /**
  148747. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148748. */
  148749. roughnessFactor: number;
  148750. private _geometryBufferRenderer;
  148751. private _enableSmoothReflections;
  148752. private _reflectionSamples;
  148753. private _smoothSteps;
  148754. /**
  148755. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148756. * @param name The name of the effect.
  148757. * @param scene The scene containing the objects to calculate reflections.
  148758. * @param options The required width/height ratio to downsize to before computing the render pass.
  148759. * @param camera The camera to apply the render pass to.
  148760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148761. * @param engine The engine which the post process will be applied. (default: current engine)
  148762. * @param reusable If the post process can be reused on the same frame. (default: false)
  148763. * @param textureType Type of textures used when performing the post process. (default: 0)
  148764. * @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)
  148765. */
  148766. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148767. /**
  148768. * Gets wether or not smoothing reflections is enabled.
  148769. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148770. */
  148771. get enableSmoothReflections(): boolean;
  148772. /**
  148773. * Sets wether or not smoothing reflections is enabled.
  148774. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148775. */
  148776. set enableSmoothReflections(enabled: boolean);
  148777. /**
  148778. * Gets the number of samples taken while computing reflections. More samples count is high,
  148779. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148780. */
  148781. get reflectionSamples(): number;
  148782. /**
  148783. * Sets the number of samples taken while computing reflections. More samples count is high,
  148784. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148785. */
  148786. set reflectionSamples(samples: number);
  148787. /**
  148788. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148789. * more the post-process will require GPU power and can generate a drop in FPS.
  148790. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148791. */
  148792. get smoothSteps(): number;
  148793. set smoothSteps(steps: number);
  148794. private _updateEffectDefines;
  148795. }
  148796. }
  148797. declare module BABYLON {
  148798. /** @hidden */
  148799. export var standardPixelShader: {
  148800. name: string;
  148801. shader: string;
  148802. };
  148803. }
  148804. declare module BABYLON {
  148805. /**
  148806. * Standard rendering pipeline
  148807. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148808. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148809. */
  148810. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148811. /**
  148812. * Public members
  148813. */
  148814. /**
  148815. * Post-process which contains the original scene color before the pipeline applies all the effects
  148816. */
  148817. originalPostProcess: Nullable<PostProcess>;
  148818. /**
  148819. * Post-process used to down scale an image x4
  148820. */
  148821. downSampleX4PostProcess: Nullable<PostProcess>;
  148822. /**
  148823. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148824. */
  148825. brightPassPostProcess: Nullable<PostProcess>;
  148826. /**
  148827. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148828. */
  148829. blurHPostProcesses: PostProcess[];
  148830. /**
  148831. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148832. */
  148833. blurVPostProcesses: PostProcess[];
  148834. /**
  148835. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148836. */
  148837. textureAdderPostProcess: Nullable<PostProcess>;
  148838. /**
  148839. * Post-process used to create volumetric lighting effect
  148840. */
  148841. volumetricLightPostProcess: Nullable<PostProcess>;
  148842. /**
  148843. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148844. */
  148845. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148846. /**
  148847. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148848. */
  148849. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148850. /**
  148851. * Post-process used to merge the volumetric light effect and the real scene color
  148852. */
  148853. volumetricLightMergePostProces: Nullable<PostProcess>;
  148854. /**
  148855. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148856. */
  148857. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148858. /**
  148859. * Base post-process used to calculate the average luminance of the final image for HDR
  148860. */
  148861. luminancePostProcess: Nullable<PostProcess>;
  148862. /**
  148863. * Post-processes used to create down sample post-processes in order to get
  148864. * the average luminance of the final image for HDR
  148865. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148866. */
  148867. luminanceDownSamplePostProcesses: PostProcess[];
  148868. /**
  148869. * Post-process used to create a HDR effect (light adaptation)
  148870. */
  148871. hdrPostProcess: Nullable<PostProcess>;
  148872. /**
  148873. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148874. */
  148875. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148876. /**
  148877. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148878. */
  148879. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148880. /**
  148881. * Post-process used to merge the final HDR post-process and the real scene color
  148882. */
  148883. hdrFinalPostProcess: Nullable<PostProcess>;
  148884. /**
  148885. * Post-process used to create a lens flare effect
  148886. */
  148887. lensFlarePostProcess: Nullable<PostProcess>;
  148888. /**
  148889. * Post-process that merges the result of the lens flare post-process and the real scene color
  148890. */
  148891. lensFlareComposePostProcess: Nullable<PostProcess>;
  148892. /**
  148893. * Post-process used to create a motion blur effect
  148894. */
  148895. motionBlurPostProcess: Nullable<PostProcess>;
  148896. /**
  148897. * Post-process used to create a depth of field effect
  148898. */
  148899. depthOfFieldPostProcess: Nullable<PostProcess>;
  148900. /**
  148901. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148902. */
  148903. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148904. /**
  148905. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148906. */
  148907. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148908. /**
  148909. * Represents the brightness threshold in order to configure the illuminated surfaces
  148910. */
  148911. brightThreshold: number;
  148912. /**
  148913. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148914. */
  148915. blurWidth: number;
  148916. /**
  148917. * Sets if the blur for highlighted surfaces must be only horizontal
  148918. */
  148919. horizontalBlur: boolean;
  148920. /**
  148921. * Gets the overall exposure used by the pipeline
  148922. */
  148923. get exposure(): number;
  148924. /**
  148925. * Sets the overall exposure used by the pipeline
  148926. */
  148927. set exposure(value: number);
  148928. /**
  148929. * Texture used typically to simulate "dirty" on camera lens
  148930. */
  148931. lensTexture: Nullable<Texture>;
  148932. /**
  148933. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148934. */
  148935. volumetricLightCoefficient: number;
  148936. /**
  148937. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148938. */
  148939. volumetricLightPower: number;
  148940. /**
  148941. * Used the set the blur intensity to smooth the volumetric lights
  148942. */
  148943. volumetricLightBlurScale: number;
  148944. /**
  148945. * Light (spot or directional) used to generate the volumetric lights rays
  148946. * The source light must have a shadow generate so the pipeline can get its
  148947. * depth map
  148948. */
  148949. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148950. /**
  148951. * For eye adaptation, represents the minimum luminance the eye can see
  148952. */
  148953. hdrMinimumLuminance: number;
  148954. /**
  148955. * For eye adaptation, represents the decrease luminance speed
  148956. */
  148957. hdrDecreaseRate: number;
  148958. /**
  148959. * For eye adaptation, represents the increase luminance speed
  148960. */
  148961. hdrIncreaseRate: number;
  148962. /**
  148963. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148964. */
  148965. get hdrAutoExposure(): boolean;
  148966. /**
  148967. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148968. */
  148969. set hdrAutoExposure(value: boolean);
  148970. /**
  148971. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148972. */
  148973. lensColorTexture: Nullable<Texture>;
  148974. /**
  148975. * The overall strengh for the lens flare effect
  148976. */
  148977. lensFlareStrength: number;
  148978. /**
  148979. * Dispersion coefficient for lens flare ghosts
  148980. */
  148981. lensFlareGhostDispersal: number;
  148982. /**
  148983. * Main lens flare halo width
  148984. */
  148985. lensFlareHaloWidth: number;
  148986. /**
  148987. * Based on the lens distortion effect, defines how much the lens flare result
  148988. * is distorted
  148989. */
  148990. lensFlareDistortionStrength: number;
  148991. /**
  148992. * Configures the blur intensity used for for lens flare (halo)
  148993. */
  148994. lensFlareBlurWidth: number;
  148995. /**
  148996. * Lens star texture must be used to simulate rays on the flares and is available
  148997. * in the documentation
  148998. */
  148999. lensStarTexture: Nullable<Texture>;
  149000. /**
  149001. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149002. * flare effect by taking account of the dirt texture
  149003. */
  149004. lensFlareDirtTexture: Nullable<Texture>;
  149005. /**
  149006. * Represents the focal length for the depth of field effect
  149007. */
  149008. depthOfFieldDistance: number;
  149009. /**
  149010. * Represents the blur intensity for the blurred part of the depth of field effect
  149011. */
  149012. depthOfFieldBlurWidth: number;
  149013. /**
  149014. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149015. */
  149016. get motionStrength(): number;
  149017. /**
  149018. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149019. */
  149020. set motionStrength(strength: number);
  149021. /**
  149022. * Gets wether or not the motion blur post-process is object based or screen based.
  149023. */
  149024. get objectBasedMotionBlur(): boolean;
  149025. /**
  149026. * Sets wether or not the motion blur post-process should be object based or screen based
  149027. */
  149028. set objectBasedMotionBlur(value: boolean);
  149029. /**
  149030. * List of animations for the pipeline (IAnimatable implementation)
  149031. */
  149032. animations: Animation[];
  149033. /**
  149034. * Private members
  149035. */
  149036. private _scene;
  149037. private _currentDepthOfFieldSource;
  149038. private _basePostProcess;
  149039. private _fixedExposure;
  149040. private _currentExposure;
  149041. private _hdrAutoExposure;
  149042. private _hdrCurrentLuminance;
  149043. private _motionStrength;
  149044. private _isObjectBasedMotionBlur;
  149045. private _floatTextureType;
  149046. private _camerasToBeAttached;
  149047. private _ratio;
  149048. private _bloomEnabled;
  149049. private _depthOfFieldEnabled;
  149050. private _vlsEnabled;
  149051. private _lensFlareEnabled;
  149052. private _hdrEnabled;
  149053. private _motionBlurEnabled;
  149054. private _fxaaEnabled;
  149055. private _screenSpaceReflectionsEnabled;
  149056. private _motionBlurSamples;
  149057. private _volumetricLightStepsCount;
  149058. private _samples;
  149059. /**
  149060. * @ignore
  149061. * Specifies if the bloom pipeline is enabled
  149062. */
  149063. get BloomEnabled(): boolean;
  149064. set BloomEnabled(enabled: boolean);
  149065. /**
  149066. * @ignore
  149067. * Specifies if the depth of field pipeline is enabed
  149068. */
  149069. get DepthOfFieldEnabled(): boolean;
  149070. set DepthOfFieldEnabled(enabled: boolean);
  149071. /**
  149072. * @ignore
  149073. * Specifies if the lens flare pipeline is enabed
  149074. */
  149075. get LensFlareEnabled(): boolean;
  149076. set LensFlareEnabled(enabled: boolean);
  149077. /**
  149078. * @ignore
  149079. * Specifies if the HDR pipeline is enabled
  149080. */
  149081. get HDREnabled(): boolean;
  149082. set HDREnabled(enabled: boolean);
  149083. /**
  149084. * @ignore
  149085. * Specifies if the volumetric lights scattering effect is enabled
  149086. */
  149087. get VLSEnabled(): boolean;
  149088. set VLSEnabled(enabled: boolean);
  149089. /**
  149090. * @ignore
  149091. * Specifies if the motion blur effect is enabled
  149092. */
  149093. get MotionBlurEnabled(): boolean;
  149094. set MotionBlurEnabled(enabled: boolean);
  149095. /**
  149096. * Specifies if anti-aliasing is enabled
  149097. */
  149098. get fxaaEnabled(): boolean;
  149099. set fxaaEnabled(enabled: boolean);
  149100. /**
  149101. * Specifies if screen space reflections are enabled.
  149102. */
  149103. get screenSpaceReflectionsEnabled(): boolean;
  149104. set screenSpaceReflectionsEnabled(enabled: boolean);
  149105. /**
  149106. * Specifies the number of steps used to calculate the volumetric lights
  149107. * Typically in interval [50, 200]
  149108. */
  149109. get volumetricLightStepsCount(): number;
  149110. set volumetricLightStepsCount(count: number);
  149111. /**
  149112. * Specifies the number of samples used for the motion blur effect
  149113. * Typically in interval [16, 64]
  149114. */
  149115. get motionBlurSamples(): number;
  149116. set motionBlurSamples(samples: number);
  149117. /**
  149118. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149119. */
  149120. get samples(): number;
  149121. set samples(sampleCount: number);
  149122. /**
  149123. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149124. * @constructor
  149125. * @param name The rendering pipeline name
  149126. * @param scene The scene linked to this pipeline
  149127. * @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)
  149128. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149130. */
  149131. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149132. private _buildPipeline;
  149133. private _createDownSampleX4PostProcess;
  149134. private _createBrightPassPostProcess;
  149135. private _createBlurPostProcesses;
  149136. private _createTextureAdderPostProcess;
  149137. private _createVolumetricLightPostProcess;
  149138. private _createLuminancePostProcesses;
  149139. private _createHdrPostProcess;
  149140. private _createLensFlarePostProcess;
  149141. private _createDepthOfFieldPostProcess;
  149142. private _createMotionBlurPostProcess;
  149143. private _getDepthTexture;
  149144. private _disposePostProcesses;
  149145. /**
  149146. * Dispose of the pipeline and stop all post processes
  149147. */
  149148. dispose(): void;
  149149. /**
  149150. * Serialize the rendering pipeline (Used when exporting)
  149151. * @returns the serialized object
  149152. */
  149153. serialize(): any;
  149154. /**
  149155. * Parse the serialized pipeline
  149156. * @param source Source pipeline.
  149157. * @param scene The scene to load the pipeline to.
  149158. * @param rootUrl The URL of the serialized pipeline.
  149159. * @returns An instantiated pipeline from the serialized object.
  149160. */
  149161. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149162. /**
  149163. * Luminance steps
  149164. */
  149165. static LuminanceSteps: number;
  149166. }
  149167. }
  149168. declare module BABYLON {
  149169. /** @hidden */
  149170. export var stereoscopicInterlacePixelShader: {
  149171. name: string;
  149172. shader: string;
  149173. };
  149174. }
  149175. declare module BABYLON {
  149176. /**
  149177. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149178. */
  149179. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149180. private _stepSize;
  149181. private _passedProcess;
  149182. /**
  149183. * Initializes a StereoscopicInterlacePostProcessI
  149184. * @param name The name of the effect.
  149185. * @param rigCameras The rig cameras to be appled to the post process
  149186. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149187. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149189. * @param engine The engine which the post process will be applied. (default: current engine)
  149190. * @param reusable If the post process can be reused on the same frame. (default: false)
  149191. */
  149192. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149193. }
  149194. /**
  149195. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149196. */
  149197. export class StereoscopicInterlacePostProcess extends PostProcess {
  149198. private _stepSize;
  149199. private _passedProcess;
  149200. /**
  149201. * Initializes a StereoscopicInterlacePostProcess
  149202. * @param name The name of the effect.
  149203. * @param rigCameras The rig cameras to be appled to the post process
  149204. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149206. * @param engine The engine which the post process will be applied. (default: current engine)
  149207. * @param reusable If the post process can be reused on the same frame. (default: false)
  149208. */
  149209. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149210. }
  149211. }
  149212. declare module BABYLON {
  149213. /** @hidden */
  149214. export var tonemapPixelShader: {
  149215. name: string;
  149216. shader: string;
  149217. };
  149218. }
  149219. declare module BABYLON {
  149220. /** Defines operator used for tonemapping */
  149221. export enum TonemappingOperator {
  149222. /** Hable */
  149223. Hable = 0,
  149224. /** Reinhard */
  149225. Reinhard = 1,
  149226. /** HejiDawson */
  149227. HejiDawson = 2,
  149228. /** Photographic */
  149229. Photographic = 3
  149230. }
  149231. /**
  149232. * Defines a post process to apply tone mapping
  149233. */
  149234. export class TonemapPostProcess extends PostProcess {
  149235. private _operator;
  149236. /** Defines the required exposure adjustement */
  149237. exposureAdjustment: number;
  149238. /**
  149239. * Creates a new TonemapPostProcess
  149240. * @param name defines the name of the postprocess
  149241. * @param _operator defines the operator to use
  149242. * @param exposureAdjustment defines the required exposure adjustement
  149243. * @param camera defines the camera to use (can be null)
  149244. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149245. * @param engine defines the hosting engine (can be ignore if camera is set)
  149246. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149247. */
  149248. constructor(name: string, _operator: TonemappingOperator,
  149249. /** Defines the required exposure adjustement */
  149250. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149251. }
  149252. }
  149253. declare module BABYLON {
  149254. /** @hidden */
  149255. export var volumetricLightScatteringPixelShader: {
  149256. name: string;
  149257. shader: string;
  149258. };
  149259. }
  149260. declare module BABYLON {
  149261. /** @hidden */
  149262. export var volumetricLightScatteringPassVertexShader: {
  149263. name: string;
  149264. shader: string;
  149265. };
  149266. }
  149267. declare module BABYLON {
  149268. /** @hidden */
  149269. export var volumetricLightScatteringPassPixelShader: {
  149270. name: string;
  149271. shader: string;
  149272. };
  149273. }
  149274. declare module BABYLON {
  149275. /**
  149276. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149277. */
  149278. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149279. private _volumetricLightScatteringPass;
  149280. private _volumetricLightScatteringRTT;
  149281. private _viewPort;
  149282. private _screenCoordinates;
  149283. private _cachedDefines;
  149284. /**
  149285. * If not undefined, the mesh position is computed from the attached node position
  149286. */
  149287. attachedNode: {
  149288. position: Vector3;
  149289. };
  149290. /**
  149291. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149292. */
  149293. customMeshPosition: Vector3;
  149294. /**
  149295. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149296. */
  149297. useCustomMeshPosition: boolean;
  149298. /**
  149299. * If the post-process should inverse the light scattering direction
  149300. */
  149301. invert: boolean;
  149302. /**
  149303. * The internal mesh used by the post-process
  149304. */
  149305. mesh: Mesh;
  149306. /**
  149307. * @hidden
  149308. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149309. */
  149310. get useDiffuseColor(): boolean;
  149311. set useDiffuseColor(useDiffuseColor: boolean);
  149312. /**
  149313. * Array containing the excluded meshes not rendered in the internal pass
  149314. */
  149315. excludedMeshes: AbstractMesh[];
  149316. /**
  149317. * Controls the overall intensity of the post-process
  149318. */
  149319. exposure: number;
  149320. /**
  149321. * Dissipates each sample's contribution in range [0, 1]
  149322. */
  149323. decay: number;
  149324. /**
  149325. * Controls the overall intensity of each sample
  149326. */
  149327. weight: number;
  149328. /**
  149329. * Controls the density of each sample
  149330. */
  149331. density: number;
  149332. /**
  149333. * @constructor
  149334. * @param name The post-process name
  149335. * @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)
  149336. * @param camera The camera that the post-process will be attached to
  149337. * @param mesh The mesh used to create the light scattering
  149338. * @param samples The post-process quality, default 100
  149339. * @param samplingModeThe post-process filtering mode
  149340. * @param engine The babylon engine
  149341. * @param reusable If the post-process is reusable
  149342. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  149343. */
  149344. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  149345. /**
  149346. * Returns the string "VolumetricLightScatteringPostProcess"
  149347. * @returns "VolumetricLightScatteringPostProcess"
  149348. */
  149349. getClassName(): string;
  149350. private _isReady;
  149351. /**
  149352. * Sets the new light position for light scattering effect
  149353. * @param position The new custom light position
  149354. */
  149355. setCustomMeshPosition(position: Vector3): void;
  149356. /**
  149357. * Returns the light position for light scattering effect
  149358. * @return Vector3 The custom light position
  149359. */
  149360. getCustomMeshPosition(): Vector3;
  149361. /**
  149362. * Disposes the internal assets and detaches the post-process from the camera
  149363. */
  149364. dispose(camera: Camera): void;
  149365. /**
  149366. * Returns the render target texture used by the post-process
  149367. * @return the render target texture used by the post-process
  149368. */
  149369. getPass(): RenderTargetTexture;
  149370. private _meshExcluded;
  149371. private _createPass;
  149372. private _updateMeshScreenCoordinates;
  149373. /**
  149374. * Creates a default mesh for the Volumeric Light Scattering post-process
  149375. * @param name The mesh name
  149376. * @param scene The scene where to create the mesh
  149377. * @return the default mesh
  149378. */
  149379. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  149380. }
  149381. }
  149382. declare module BABYLON {
  149383. interface Scene {
  149384. /** @hidden (Backing field) */
  149385. _boundingBoxRenderer: BoundingBoxRenderer;
  149386. /** @hidden (Backing field) */
  149387. _forceShowBoundingBoxes: boolean;
  149388. /**
  149389. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  149390. */
  149391. forceShowBoundingBoxes: boolean;
  149392. /**
  149393. * Gets the bounding box renderer associated with the scene
  149394. * @returns a BoundingBoxRenderer
  149395. */
  149396. getBoundingBoxRenderer(): BoundingBoxRenderer;
  149397. }
  149398. interface AbstractMesh {
  149399. /** @hidden (Backing field) */
  149400. _showBoundingBox: boolean;
  149401. /**
  149402. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  149403. */
  149404. showBoundingBox: boolean;
  149405. }
  149406. /**
  149407. * Component responsible of rendering the bounding box of the meshes in a scene.
  149408. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  149409. */
  149410. export class BoundingBoxRenderer implements ISceneComponent {
  149411. /**
  149412. * The component name helpfull to identify the component in the list of scene components.
  149413. */
  149414. readonly name: string;
  149415. /**
  149416. * The scene the component belongs to.
  149417. */
  149418. scene: Scene;
  149419. /**
  149420. * Color of the bounding box lines placed in front of an object
  149421. */
  149422. frontColor: Color3;
  149423. /**
  149424. * Color of the bounding box lines placed behind an object
  149425. */
  149426. backColor: Color3;
  149427. /**
  149428. * Defines if the renderer should show the back lines or not
  149429. */
  149430. showBackLines: boolean;
  149431. /**
  149432. * Observable raised before rendering a bounding box
  149433. */
  149434. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  149435. /**
  149436. * Observable raised after rendering a bounding box
  149437. */
  149438. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  149439. /**
  149440. * @hidden
  149441. */
  149442. renderList: SmartArray<BoundingBox>;
  149443. private _colorShader;
  149444. private _vertexBuffers;
  149445. private _indexBuffer;
  149446. private _fillIndexBuffer;
  149447. private _fillIndexData;
  149448. /**
  149449. * Instantiates a new bounding box renderer in a scene.
  149450. * @param scene the scene the renderer renders in
  149451. */
  149452. constructor(scene: Scene);
  149453. /**
  149454. * Registers the component in a given scene
  149455. */
  149456. register(): void;
  149457. private _evaluateSubMesh;
  149458. private _activeMesh;
  149459. private _prepareRessources;
  149460. private _createIndexBuffer;
  149461. /**
  149462. * Rebuilds the elements related to this component in case of
  149463. * context lost for instance.
  149464. */
  149465. rebuild(): void;
  149466. /**
  149467. * @hidden
  149468. */
  149469. reset(): void;
  149470. /**
  149471. * Render the bounding boxes of a specific rendering group
  149472. * @param renderingGroupId defines the rendering group to render
  149473. */
  149474. render(renderingGroupId: number): void;
  149475. /**
  149476. * In case of occlusion queries, we can render the occlusion bounding box through this method
  149477. * @param mesh Define the mesh to render the occlusion bounding box for
  149478. */
  149479. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  149480. /**
  149481. * Dispose and release the resources attached to this renderer.
  149482. */
  149483. dispose(): void;
  149484. }
  149485. }
  149486. declare module BABYLON {
  149487. interface Scene {
  149488. /** @hidden (Backing field) */
  149489. _depthRenderer: {
  149490. [id: string]: DepthRenderer;
  149491. };
  149492. /**
  149493. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  149494. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  149495. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  149496. * @returns the created depth renderer
  149497. */
  149498. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  149499. /**
  149500. * Disables a depth renderer for a given camera
  149501. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  149502. */
  149503. disableDepthRenderer(camera?: Nullable<Camera>): void;
  149504. }
  149505. /**
  149506. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  149507. * in several rendering techniques.
  149508. */
  149509. export class DepthRendererSceneComponent implements ISceneComponent {
  149510. /**
  149511. * The component name helpfull to identify the component in the list of scene components.
  149512. */
  149513. readonly name: string;
  149514. /**
  149515. * The scene the component belongs to.
  149516. */
  149517. scene: Scene;
  149518. /**
  149519. * Creates a new instance of the component for the given scene
  149520. * @param scene Defines the scene to register the component in
  149521. */
  149522. constructor(scene: Scene);
  149523. /**
  149524. * Registers the component in a given scene
  149525. */
  149526. register(): void;
  149527. /**
  149528. * Rebuilds the elements related to this component in case of
  149529. * context lost for instance.
  149530. */
  149531. rebuild(): void;
  149532. /**
  149533. * Disposes the component and the associated ressources
  149534. */
  149535. dispose(): void;
  149536. private _gatherRenderTargets;
  149537. private _gatherActiveCameraRenderTargets;
  149538. }
  149539. }
  149540. declare module BABYLON {
  149541. interface AbstractScene {
  149542. /** @hidden (Backing field) */
  149543. _prePassRenderer: Nullable<PrePassRenderer>;
  149544. /**
  149545. * Gets or Sets the current prepass renderer associated to the scene.
  149546. */
  149547. prePassRenderer: Nullable<PrePassRenderer>;
  149548. /**
  149549. * Enables the prepass and associates it with the scene
  149550. * @returns the PrePassRenderer
  149551. */
  149552. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149553. /**
  149554. * Disables the prepass associated with the scene
  149555. */
  149556. disablePrePassRenderer(): void;
  149557. }
  149558. /**
  149559. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149560. * in several rendering techniques.
  149561. */
  149562. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149563. /**
  149564. * The component name helpful to identify the component in the list of scene components.
  149565. */
  149566. readonly name: string;
  149567. /**
  149568. * The scene the component belongs to.
  149569. */
  149570. scene: Scene;
  149571. /**
  149572. * Creates a new instance of the component for the given scene
  149573. * @param scene Defines the scene to register the component in
  149574. */
  149575. constructor(scene: Scene);
  149576. /**
  149577. * Registers the component in a given scene
  149578. */
  149579. register(): void;
  149580. private _beforeCameraDraw;
  149581. private _afterCameraDraw;
  149582. private _beforeClearStage;
  149583. /**
  149584. * Serializes the component data to the specified json object
  149585. * @param serializationObject The object to serialize to
  149586. */
  149587. serialize(serializationObject: any): void;
  149588. /**
  149589. * Adds all the elements from the container to the scene
  149590. * @param container the container holding the elements
  149591. */
  149592. addFromContainer(container: AbstractScene): void;
  149593. /**
  149594. * Removes all the elements in the container from the scene
  149595. * @param container contains the elements to remove
  149596. * @param dispose if the removed element should be disposed (default: false)
  149597. */
  149598. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149599. /**
  149600. * Rebuilds the elements related to this component in case of
  149601. * context lost for instance.
  149602. */
  149603. rebuild(): void;
  149604. /**
  149605. * Disposes the component and the associated ressources
  149606. */
  149607. dispose(): void;
  149608. }
  149609. }
  149610. declare module BABYLON {
  149611. /** @hidden */
  149612. export var outlinePixelShader: {
  149613. name: string;
  149614. shader: string;
  149615. };
  149616. }
  149617. declare module BABYLON {
  149618. /** @hidden */
  149619. export var outlineVertexShader: {
  149620. name: string;
  149621. shader: string;
  149622. };
  149623. }
  149624. declare module BABYLON {
  149625. interface Scene {
  149626. /** @hidden */
  149627. _outlineRenderer: OutlineRenderer;
  149628. /**
  149629. * Gets the outline renderer associated with the scene
  149630. * @returns a OutlineRenderer
  149631. */
  149632. getOutlineRenderer(): OutlineRenderer;
  149633. }
  149634. interface AbstractMesh {
  149635. /** @hidden (Backing field) */
  149636. _renderOutline: boolean;
  149637. /**
  149638. * Gets or sets a boolean indicating if the outline must be rendered as well
  149639. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149640. */
  149641. renderOutline: boolean;
  149642. /** @hidden (Backing field) */
  149643. _renderOverlay: boolean;
  149644. /**
  149645. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149646. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149647. */
  149648. renderOverlay: boolean;
  149649. }
  149650. /**
  149651. * This class is responsible to draw bothe outline/overlay of meshes.
  149652. * It should not be used directly but through the available method on mesh.
  149653. */
  149654. export class OutlineRenderer implements ISceneComponent {
  149655. /**
  149656. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149657. */
  149658. private static _StencilReference;
  149659. /**
  149660. * The name of the component. Each component must have a unique name.
  149661. */
  149662. name: string;
  149663. /**
  149664. * The scene the component belongs to.
  149665. */
  149666. scene: Scene;
  149667. /**
  149668. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149669. */
  149670. zOffset: number;
  149671. private _engine;
  149672. private _effect;
  149673. private _cachedDefines;
  149674. private _savedDepthWrite;
  149675. /**
  149676. * Instantiates a new outline renderer. (There could be only one per scene).
  149677. * @param scene Defines the scene it belongs to
  149678. */
  149679. constructor(scene: Scene);
  149680. /**
  149681. * Register the component to one instance of a scene.
  149682. */
  149683. register(): void;
  149684. /**
  149685. * Rebuilds the elements related to this component in case of
  149686. * context lost for instance.
  149687. */
  149688. rebuild(): void;
  149689. /**
  149690. * Disposes the component and the associated ressources.
  149691. */
  149692. dispose(): void;
  149693. /**
  149694. * Renders the outline in the canvas.
  149695. * @param subMesh Defines the sumesh to render
  149696. * @param batch Defines the batch of meshes in case of instances
  149697. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149698. */
  149699. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149700. /**
  149701. * Returns whether or not the outline renderer is ready for a given submesh.
  149702. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149703. * @param subMesh Defines the submesh to check readyness for
  149704. * @param useInstances Defines wheter wee are trying to render instances or not
  149705. * @returns true if ready otherwise false
  149706. */
  149707. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149708. private _beforeRenderingMesh;
  149709. private _afterRenderingMesh;
  149710. }
  149711. }
  149712. declare module BABYLON {
  149713. /**
  149714. * Defines the basic options interface of a Sprite Frame Source Size.
  149715. */
  149716. export interface ISpriteJSONSpriteSourceSize {
  149717. /**
  149718. * number of the original width of the Frame
  149719. */
  149720. w: number;
  149721. /**
  149722. * number of the original height of the Frame
  149723. */
  149724. h: number;
  149725. }
  149726. /**
  149727. * Defines the basic options interface of a Sprite Frame Data.
  149728. */
  149729. export interface ISpriteJSONSpriteFrameData {
  149730. /**
  149731. * number of the x offset of the Frame
  149732. */
  149733. x: number;
  149734. /**
  149735. * number of the y offset of the Frame
  149736. */
  149737. y: number;
  149738. /**
  149739. * number of the width of the Frame
  149740. */
  149741. w: number;
  149742. /**
  149743. * number of the height of the Frame
  149744. */
  149745. h: number;
  149746. }
  149747. /**
  149748. * Defines the basic options interface of a JSON Sprite.
  149749. */
  149750. export interface ISpriteJSONSprite {
  149751. /**
  149752. * string name of the Frame
  149753. */
  149754. filename: string;
  149755. /**
  149756. * ISpriteJSONSpriteFrame basic object of the frame data
  149757. */
  149758. frame: ISpriteJSONSpriteFrameData;
  149759. /**
  149760. * boolean to flag is the frame was rotated.
  149761. */
  149762. rotated: boolean;
  149763. /**
  149764. * boolean to flag is the frame was trimmed.
  149765. */
  149766. trimmed: boolean;
  149767. /**
  149768. * ISpriteJSONSpriteFrame basic object of the source data
  149769. */
  149770. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149771. /**
  149772. * ISpriteJSONSpriteFrame basic object of the source data
  149773. */
  149774. sourceSize: ISpriteJSONSpriteSourceSize;
  149775. }
  149776. /**
  149777. * Defines the basic options interface of a JSON atlas.
  149778. */
  149779. export interface ISpriteJSONAtlas {
  149780. /**
  149781. * Array of objects that contain the frame data.
  149782. */
  149783. frames: Array<ISpriteJSONSprite>;
  149784. /**
  149785. * object basic object containing the sprite meta data.
  149786. */
  149787. meta?: object;
  149788. }
  149789. }
  149790. declare module BABYLON {
  149791. /** @hidden */
  149792. export var spriteMapPixelShader: {
  149793. name: string;
  149794. shader: string;
  149795. };
  149796. }
  149797. declare module BABYLON {
  149798. /** @hidden */
  149799. export var spriteMapVertexShader: {
  149800. name: string;
  149801. shader: string;
  149802. };
  149803. }
  149804. declare module BABYLON {
  149805. /**
  149806. * Defines the basic options interface of a SpriteMap
  149807. */
  149808. export interface ISpriteMapOptions {
  149809. /**
  149810. * Vector2 of the number of cells in the grid.
  149811. */
  149812. stageSize?: Vector2;
  149813. /**
  149814. * Vector2 of the size of the output plane in World Units.
  149815. */
  149816. outputSize?: Vector2;
  149817. /**
  149818. * Vector3 of the position of the output plane in World Units.
  149819. */
  149820. outputPosition?: Vector3;
  149821. /**
  149822. * Vector3 of the rotation of the output plane.
  149823. */
  149824. outputRotation?: Vector3;
  149825. /**
  149826. * number of layers that the system will reserve in resources.
  149827. */
  149828. layerCount?: number;
  149829. /**
  149830. * number of max animation frames a single cell will reserve in resources.
  149831. */
  149832. maxAnimationFrames?: number;
  149833. /**
  149834. * number cell index of the base tile when the system compiles.
  149835. */
  149836. baseTile?: number;
  149837. /**
  149838. * boolean flip the sprite after its been repositioned by the framing data.
  149839. */
  149840. flipU?: boolean;
  149841. /**
  149842. * Vector3 scalar of the global RGB values of the SpriteMap.
  149843. */
  149844. colorMultiply?: Vector3;
  149845. }
  149846. /**
  149847. * Defines the IDisposable interface in order to be cleanable from resources.
  149848. */
  149849. export interface ISpriteMap extends IDisposable {
  149850. /**
  149851. * String name of the SpriteMap.
  149852. */
  149853. name: string;
  149854. /**
  149855. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149856. */
  149857. atlasJSON: ISpriteJSONAtlas;
  149858. /**
  149859. * Texture of the SpriteMap.
  149860. */
  149861. spriteSheet: Texture;
  149862. /**
  149863. * The parameters to initialize the SpriteMap with.
  149864. */
  149865. options: ISpriteMapOptions;
  149866. }
  149867. /**
  149868. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149869. */
  149870. export class SpriteMap implements ISpriteMap {
  149871. /** The Name of the spriteMap */
  149872. name: string;
  149873. /** The JSON file with the frame and meta data */
  149874. atlasJSON: ISpriteJSONAtlas;
  149875. /** The systems Sprite Sheet Texture */
  149876. spriteSheet: Texture;
  149877. /** Arguments passed with the Constructor */
  149878. options: ISpriteMapOptions;
  149879. /** Public Sprite Storage array, parsed from atlasJSON */
  149880. sprites: Array<ISpriteJSONSprite>;
  149881. /** Returns the Number of Sprites in the System */
  149882. get spriteCount(): number;
  149883. /** Returns the Position of Output Plane*/
  149884. get position(): Vector3;
  149885. /** Returns the Position of Output Plane*/
  149886. set position(v: Vector3);
  149887. /** Returns the Rotation of Output Plane*/
  149888. get rotation(): Vector3;
  149889. /** Returns the Rotation of Output Plane*/
  149890. set rotation(v: Vector3);
  149891. /** Sets the AnimationMap*/
  149892. get animationMap(): RawTexture;
  149893. /** Sets the AnimationMap*/
  149894. set animationMap(v: RawTexture);
  149895. /** Scene that the SpriteMap was created in */
  149896. private _scene;
  149897. /** Texture Buffer of Float32 that holds tile frame data*/
  149898. private _frameMap;
  149899. /** Texture Buffers of Float32 that holds tileMap data*/
  149900. private _tileMaps;
  149901. /** Texture Buffer of Float32 that holds Animation Data*/
  149902. private _animationMap;
  149903. /** Custom ShaderMaterial Central to the System*/
  149904. private _material;
  149905. /** Custom ShaderMaterial Central to the System*/
  149906. private _output;
  149907. /** Systems Time Ticker*/
  149908. private _time;
  149909. /**
  149910. * Creates a new SpriteMap
  149911. * @param name defines the SpriteMaps Name
  149912. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149913. * @param spriteSheet is the Texture that the Sprites are on.
  149914. * @param options a basic deployment configuration
  149915. * @param scene The Scene that the map is deployed on
  149916. */
  149917. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149918. /**
  149919. * Returns tileID location
  149920. * @returns Vector2 the cell position ID
  149921. */
  149922. getTileID(): Vector2;
  149923. /**
  149924. * Gets the UV location of the mouse over the SpriteMap.
  149925. * @returns Vector2 the UV position of the mouse interaction
  149926. */
  149927. getMousePosition(): Vector2;
  149928. /**
  149929. * Creates the "frame" texture Buffer
  149930. * -------------------------------------
  149931. * Structure of frames
  149932. * "filename": "Falling-Water-2.png",
  149933. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149934. * "rotated": true,
  149935. * "trimmed": true,
  149936. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149937. * "sourceSize": {"w":32,"h":32}
  149938. * @returns RawTexture of the frameMap
  149939. */
  149940. private _createFrameBuffer;
  149941. /**
  149942. * Creates the tileMap texture Buffer
  149943. * @param buffer normally and array of numbers, or a false to generate from scratch
  149944. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149945. * @returns RawTexture of the tileMap
  149946. */
  149947. private _createTileBuffer;
  149948. /**
  149949. * Modifies the data of the tileMaps
  149950. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149951. * @param pos is the iVector2 Coordinates of the Tile
  149952. * @param tile The SpriteIndex of the new Tile
  149953. */
  149954. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149955. /**
  149956. * Creates the animationMap texture Buffer
  149957. * @param buffer normally and array of numbers, or a false to generate from scratch
  149958. * @returns RawTexture of the animationMap
  149959. */
  149960. private _createTileAnimationBuffer;
  149961. /**
  149962. * Modifies the data of the animationMap
  149963. * @param cellID is the Index of the Sprite
  149964. * @param _frame is the target Animation frame
  149965. * @param toCell is the Target Index of the next frame of the animation
  149966. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149967. * @param speed is a global scalar of the time variable on the map.
  149968. */
  149969. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149970. /**
  149971. * Exports the .tilemaps file
  149972. */
  149973. saveTileMaps(): void;
  149974. /**
  149975. * Imports the .tilemaps file
  149976. * @param url of the .tilemaps file
  149977. */
  149978. loadTileMaps(url: string): void;
  149979. /**
  149980. * Release associated resources
  149981. */
  149982. dispose(): void;
  149983. }
  149984. }
  149985. declare module BABYLON {
  149986. /**
  149987. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149988. * @see https://doc.babylonjs.com/babylon101/sprites
  149989. */
  149990. export class SpritePackedManager extends SpriteManager {
  149991. /** defines the packed manager's name */
  149992. name: string;
  149993. /**
  149994. * Creates a new sprite manager from a packed sprite sheet
  149995. * @param name defines the manager's name
  149996. * @param imgUrl defines the sprite sheet url
  149997. * @param capacity defines the maximum allowed number of sprites
  149998. * @param scene defines the hosting scene
  149999. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150000. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150001. * @param samplingMode defines the smapling mode to use with spritesheet
  150002. * @param fromPacked set to true; do not alter
  150003. */
  150004. constructor(
  150005. /** defines the packed manager's name */
  150006. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150007. }
  150008. }
  150009. declare module BABYLON {
  150010. /**
  150011. * Defines the list of states available for a task inside a AssetsManager
  150012. */
  150013. export enum AssetTaskState {
  150014. /**
  150015. * Initialization
  150016. */
  150017. INIT = 0,
  150018. /**
  150019. * Running
  150020. */
  150021. RUNNING = 1,
  150022. /**
  150023. * Done
  150024. */
  150025. DONE = 2,
  150026. /**
  150027. * Error
  150028. */
  150029. ERROR = 3
  150030. }
  150031. /**
  150032. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150033. */
  150034. export abstract class AbstractAssetTask {
  150035. /**
  150036. * Task name
  150037. */ name: string;
  150038. /**
  150039. * Callback called when the task is successful
  150040. */
  150041. onSuccess: (task: any) => void;
  150042. /**
  150043. * Callback called when the task is not successful
  150044. */
  150045. onError: (task: any, message?: string, exception?: any) => void;
  150046. /**
  150047. * Creates a new AssetsManager
  150048. * @param name defines the name of the task
  150049. */
  150050. constructor(
  150051. /**
  150052. * Task name
  150053. */ name: string);
  150054. private _isCompleted;
  150055. private _taskState;
  150056. private _errorObject;
  150057. /**
  150058. * Get if the task is completed
  150059. */
  150060. get isCompleted(): boolean;
  150061. /**
  150062. * Gets the current state of the task
  150063. */
  150064. get taskState(): AssetTaskState;
  150065. /**
  150066. * Gets the current error object (if task is in error)
  150067. */
  150068. get errorObject(): {
  150069. message?: string;
  150070. exception?: any;
  150071. };
  150072. /**
  150073. * Internal only
  150074. * @hidden
  150075. */
  150076. _setErrorObject(message?: string, exception?: any): void;
  150077. /**
  150078. * Execute the current task
  150079. * @param scene defines the scene where you want your assets to be loaded
  150080. * @param onSuccess is a callback called when the task is successfully executed
  150081. * @param onError is a callback called if an error occurs
  150082. */
  150083. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150084. /**
  150085. * Execute the current task
  150086. * @param scene defines the scene where you want your assets to be loaded
  150087. * @param onSuccess is a callback called when the task is successfully executed
  150088. * @param onError is a callback called if an error occurs
  150089. */
  150090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150091. /**
  150092. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150093. * This can be used with failed tasks that have the reason for failure fixed.
  150094. */
  150095. reset(): void;
  150096. private onErrorCallback;
  150097. private onDoneCallback;
  150098. }
  150099. /**
  150100. * Define the interface used by progress events raised during assets loading
  150101. */
  150102. export interface IAssetsProgressEvent {
  150103. /**
  150104. * Defines the number of remaining tasks to process
  150105. */
  150106. remainingCount: number;
  150107. /**
  150108. * Defines the total number of tasks
  150109. */
  150110. totalCount: number;
  150111. /**
  150112. * Defines the task that was just processed
  150113. */
  150114. task: AbstractAssetTask;
  150115. }
  150116. /**
  150117. * Class used to share progress information about assets loading
  150118. */
  150119. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150120. /**
  150121. * Defines the number of remaining tasks to process
  150122. */
  150123. remainingCount: number;
  150124. /**
  150125. * Defines the total number of tasks
  150126. */
  150127. totalCount: number;
  150128. /**
  150129. * Defines the task that was just processed
  150130. */
  150131. task: AbstractAssetTask;
  150132. /**
  150133. * Creates a AssetsProgressEvent
  150134. * @param remainingCount defines the number of remaining tasks to process
  150135. * @param totalCount defines the total number of tasks
  150136. * @param task defines the task that was just processed
  150137. */
  150138. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150139. }
  150140. /**
  150141. * Define a task used by AssetsManager to load meshes
  150142. */
  150143. export class MeshAssetTask extends AbstractAssetTask {
  150144. /**
  150145. * Defines the name of the task
  150146. */
  150147. name: string;
  150148. /**
  150149. * Defines the list of mesh's names you want to load
  150150. */
  150151. meshesNames: any;
  150152. /**
  150153. * Defines the root url to use as a base to load your meshes and associated resources
  150154. */
  150155. rootUrl: string;
  150156. /**
  150157. * Defines the filename or File of the scene to load from
  150158. */
  150159. sceneFilename: string | File;
  150160. /**
  150161. * Gets the list of loaded meshes
  150162. */
  150163. loadedMeshes: Array<AbstractMesh>;
  150164. /**
  150165. * Gets the list of loaded particle systems
  150166. */
  150167. loadedParticleSystems: Array<IParticleSystem>;
  150168. /**
  150169. * Gets the list of loaded skeletons
  150170. */
  150171. loadedSkeletons: Array<Skeleton>;
  150172. /**
  150173. * Gets the list of loaded animation groups
  150174. */
  150175. loadedAnimationGroups: Array<AnimationGroup>;
  150176. /**
  150177. * Callback called when the task is successful
  150178. */
  150179. onSuccess: (task: MeshAssetTask) => void;
  150180. /**
  150181. * Callback called when the task is successful
  150182. */
  150183. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150184. /**
  150185. * Creates a new MeshAssetTask
  150186. * @param name defines the name of the task
  150187. * @param meshesNames defines the list of mesh's names you want to load
  150188. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150189. * @param sceneFilename defines the filename or File of the scene to load from
  150190. */
  150191. constructor(
  150192. /**
  150193. * Defines the name of the task
  150194. */
  150195. name: string,
  150196. /**
  150197. * Defines the list of mesh's names you want to load
  150198. */
  150199. meshesNames: any,
  150200. /**
  150201. * Defines the root url to use as a base to load your meshes and associated resources
  150202. */
  150203. rootUrl: string,
  150204. /**
  150205. * Defines the filename or File of the scene to load from
  150206. */
  150207. sceneFilename: string | File);
  150208. /**
  150209. * Execute the current task
  150210. * @param scene defines the scene where you want your assets to be loaded
  150211. * @param onSuccess is a callback called when the task is successfully executed
  150212. * @param onError is a callback called if an error occurs
  150213. */
  150214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150215. }
  150216. /**
  150217. * Define a task used by AssetsManager to load text content
  150218. */
  150219. export class TextFileAssetTask extends AbstractAssetTask {
  150220. /**
  150221. * Defines the name of the task
  150222. */
  150223. name: string;
  150224. /**
  150225. * Defines the location of the file to load
  150226. */
  150227. url: string;
  150228. /**
  150229. * Gets the loaded text string
  150230. */
  150231. text: string;
  150232. /**
  150233. * Callback called when the task is successful
  150234. */
  150235. onSuccess: (task: TextFileAssetTask) => void;
  150236. /**
  150237. * Callback called when the task is successful
  150238. */
  150239. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  150240. /**
  150241. * Creates a new TextFileAssetTask object
  150242. * @param name defines the name of the task
  150243. * @param url defines the location of the file to load
  150244. */
  150245. constructor(
  150246. /**
  150247. * Defines the name of the task
  150248. */
  150249. name: string,
  150250. /**
  150251. * Defines the location of the file to load
  150252. */
  150253. url: string);
  150254. /**
  150255. * Execute the current task
  150256. * @param scene defines the scene where you want your assets to be loaded
  150257. * @param onSuccess is a callback called when the task is successfully executed
  150258. * @param onError is a callback called if an error occurs
  150259. */
  150260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150261. }
  150262. /**
  150263. * Define a task used by AssetsManager to load binary data
  150264. */
  150265. export class BinaryFileAssetTask extends AbstractAssetTask {
  150266. /**
  150267. * Defines the name of the task
  150268. */
  150269. name: string;
  150270. /**
  150271. * Defines the location of the file to load
  150272. */
  150273. url: string;
  150274. /**
  150275. * Gets the lodaded data (as an array buffer)
  150276. */
  150277. data: ArrayBuffer;
  150278. /**
  150279. * Callback called when the task is successful
  150280. */
  150281. onSuccess: (task: BinaryFileAssetTask) => void;
  150282. /**
  150283. * Callback called when the task is successful
  150284. */
  150285. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  150286. /**
  150287. * Creates a new BinaryFileAssetTask object
  150288. * @param name defines the name of the new task
  150289. * @param url defines the location of the file to load
  150290. */
  150291. constructor(
  150292. /**
  150293. * Defines the name of the task
  150294. */
  150295. name: string,
  150296. /**
  150297. * Defines the location of the file to load
  150298. */
  150299. url: string);
  150300. /**
  150301. * Execute the current task
  150302. * @param scene defines the scene where you want your assets to be loaded
  150303. * @param onSuccess is a callback called when the task is successfully executed
  150304. * @param onError is a callback called if an error occurs
  150305. */
  150306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150307. }
  150308. /**
  150309. * Define a task used by AssetsManager to load images
  150310. */
  150311. export class ImageAssetTask extends AbstractAssetTask {
  150312. /**
  150313. * Defines the name of the task
  150314. */
  150315. name: string;
  150316. /**
  150317. * Defines the location of the image to load
  150318. */
  150319. url: string;
  150320. /**
  150321. * Gets the loaded images
  150322. */
  150323. image: HTMLImageElement;
  150324. /**
  150325. * Callback called when the task is successful
  150326. */
  150327. onSuccess: (task: ImageAssetTask) => void;
  150328. /**
  150329. * Callback called when the task is successful
  150330. */
  150331. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  150332. /**
  150333. * Creates a new ImageAssetTask
  150334. * @param name defines the name of the task
  150335. * @param url defines the location of the image to load
  150336. */
  150337. constructor(
  150338. /**
  150339. * Defines the name of the task
  150340. */
  150341. name: string,
  150342. /**
  150343. * Defines the location of the image to load
  150344. */
  150345. url: string);
  150346. /**
  150347. * Execute the current task
  150348. * @param scene defines the scene where you want your assets to be loaded
  150349. * @param onSuccess is a callback called when the task is successfully executed
  150350. * @param onError is a callback called if an error occurs
  150351. */
  150352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150353. }
  150354. /**
  150355. * Defines the interface used by texture loading tasks
  150356. */
  150357. export interface ITextureAssetTask<TEX extends BaseTexture> {
  150358. /**
  150359. * Gets the loaded texture
  150360. */
  150361. texture: TEX;
  150362. }
  150363. /**
  150364. * Define a task used by AssetsManager to load 2D textures
  150365. */
  150366. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  150367. /**
  150368. * Defines the name of the task
  150369. */
  150370. name: string;
  150371. /**
  150372. * Defines the location of the file to load
  150373. */
  150374. url: string;
  150375. /**
  150376. * Defines if mipmap should not be generated (default is false)
  150377. */
  150378. noMipmap?: boolean | undefined;
  150379. /**
  150380. * Defines if texture must be inverted on Y axis (default is true)
  150381. */
  150382. invertY: boolean;
  150383. /**
  150384. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150385. */
  150386. samplingMode: number;
  150387. /**
  150388. * Gets the loaded texture
  150389. */
  150390. texture: Texture;
  150391. /**
  150392. * Callback called when the task is successful
  150393. */
  150394. onSuccess: (task: TextureAssetTask) => void;
  150395. /**
  150396. * Callback called when the task is successful
  150397. */
  150398. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150399. /**
  150400. * Creates a new TextureAssetTask object
  150401. * @param name defines the name of the task
  150402. * @param url defines the location of the file to load
  150403. * @param noMipmap defines if mipmap should not be generated (default is false)
  150404. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150405. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150406. */
  150407. constructor(
  150408. /**
  150409. * Defines the name of the task
  150410. */
  150411. name: string,
  150412. /**
  150413. * Defines the location of the file to load
  150414. */
  150415. url: string,
  150416. /**
  150417. * Defines if mipmap should not be generated (default is false)
  150418. */
  150419. noMipmap?: boolean | undefined,
  150420. /**
  150421. * Defines if texture must be inverted on Y axis (default is true)
  150422. */
  150423. invertY?: boolean,
  150424. /**
  150425. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150426. */
  150427. samplingMode?: number);
  150428. /**
  150429. * Execute the current task
  150430. * @param scene defines the scene where you want your assets to be loaded
  150431. * @param onSuccess is a callback called when the task is successfully executed
  150432. * @param onError is a callback called if an error occurs
  150433. */
  150434. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150435. }
  150436. /**
  150437. * Define a task used by AssetsManager to load cube textures
  150438. */
  150439. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150440. /**
  150441. * Defines the name of the task
  150442. */
  150443. name: string;
  150444. /**
  150445. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150446. */
  150447. url: string;
  150448. /**
  150449. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150450. */
  150451. extensions?: string[] | undefined;
  150452. /**
  150453. * Defines if mipmaps should not be generated (default is false)
  150454. */
  150455. noMipmap?: boolean | undefined;
  150456. /**
  150457. * Defines the explicit list of files (undefined by default)
  150458. */
  150459. files?: string[] | undefined;
  150460. /**
  150461. * Gets the loaded texture
  150462. */
  150463. texture: CubeTexture;
  150464. /**
  150465. * Callback called when the task is successful
  150466. */
  150467. onSuccess: (task: CubeTextureAssetTask) => void;
  150468. /**
  150469. * Callback called when the task is successful
  150470. */
  150471. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150472. /**
  150473. * Creates a new CubeTextureAssetTask
  150474. * @param name defines the name of the task
  150475. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150476. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150477. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150478. * @param files defines the explicit list of files (undefined by default)
  150479. */
  150480. constructor(
  150481. /**
  150482. * Defines the name of the task
  150483. */
  150484. name: string,
  150485. /**
  150486. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150487. */
  150488. url: string,
  150489. /**
  150490. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150491. */
  150492. extensions?: string[] | undefined,
  150493. /**
  150494. * Defines if mipmaps should not be generated (default is false)
  150495. */
  150496. noMipmap?: boolean | undefined,
  150497. /**
  150498. * Defines the explicit list of files (undefined by default)
  150499. */
  150500. files?: string[] | undefined);
  150501. /**
  150502. * Execute the current task
  150503. * @param scene defines the scene where you want your assets to be loaded
  150504. * @param onSuccess is a callback called when the task is successfully executed
  150505. * @param onError is a callback called if an error occurs
  150506. */
  150507. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150508. }
  150509. /**
  150510. * Define a task used by AssetsManager to load HDR cube textures
  150511. */
  150512. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150513. /**
  150514. * Defines the name of the task
  150515. */
  150516. name: string;
  150517. /**
  150518. * Defines the location of the file to load
  150519. */
  150520. url: string;
  150521. /**
  150522. * Defines the desired size (the more it increases the longer the generation will be)
  150523. */
  150524. size: number;
  150525. /**
  150526. * Defines if mipmaps should not be generated (default is false)
  150527. */
  150528. noMipmap: boolean;
  150529. /**
  150530. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150531. */
  150532. generateHarmonics: boolean;
  150533. /**
  150534. * 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)
  150535. */
  150536. gammaSpace: boolean;
  150537. /**
  150538. * Internal Use Only
  150539. */
  150540. reserved: boolean;
  150541. /**
  150542. * Gets the loaded texture
  150543. */
  150544. texture: HDRCubeTexture;
  150545. /**
  150546. * Callback called when the task is successful
  150547. */
  150548. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150549. /**
  150550. * Callback called when the task is successful
  150551. */
  150552. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150553. /**
  150554. * Creates a new HDRCubeTextureAssetTask object
  150555. * @param name defines the name of the task
  150556. * @param url defines the location of the file to load
  150557. * @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.
  150558. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150559. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150560. * @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)
  150561. * @param reserved Internal use only
  150562. */
  150563. constructor(
  150564. /**
  150565. * Defines the name of the task
  150566. */
  150567. name: string,
  150568. /**
  150569. * Defines the location of the file to load
  150570. */
  150571. url: string,
  150572. /**
  150573. * Defines the desired size (the more it increases the longer the generation will be)
  150574. */
  150575. size: number,
  150576. /**
  150577. * Defines if mipmaps should not be generated (default is false)
  150578. */
  150579. noMipmap?: boolean,
  150580. /**
  150581. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150582. */
  150583. generateHarmonics?: boolean,
  150584. /**
  150585. * 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)
  150586. */
  150587. gammaSpace?: boolean,
  150588. /**
  150589. * Internal Use Only
  150590. */
  150591. reserved?: boolean);
  150592. /**
  150593. * Execute the current task
  150594. * @param scene defines the scene where you want your assets to be loaded
  150595. * @param onSuccess is a callback called when the task is successfully executed
  150596. * @param onError is a callback called if an error occurs
  150597. */
  150598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150599. }
  150600. /**
  150601. * Define a task used by AssetsManager to load Equirectangular cube textures
  150602. */
  150603. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150604. /**
  150605. * Defines the name of the task
  150606. */
  150607. name: string;
  150608. /**
  150609. * Defines the location of the file to load
  150610. */
  150611. url: string;
  150612. /**
  150613. * Defines the desired size (the more it increases the longer the generation will be)
  150614. */
  150615. size: number;
  150616. /**
  150617. * Defines if mipmaps should not be generated (default is false)
  150618. */
  150619. noMipmap: boolean;
  150620. /**
  150621. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150622. * but the standard material would require them in Gamma space) (default is true)
  150623. */
  150624. gammaSpace: boolean;
  150625. /**
  150626. * Gets the loaded texture
  150627. */
  150628. texture: EquiRectangularCubeTexture;
  150629. /**
  150630. * Callback called when the task is successful
  150631. */
  150632. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150633. /**
  150634. * Callback called when the task is successful
  150635. */
  150636. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150637. /**
  150638. * Creates a new EquiRectangularCubeTextureAssetTask object
  150639. * @param name defines the name of the task
  150640. * @param url defines the location of the file to load
  150641. * @param size defines the desired size (the more it increases the longer the generation will be)
  150642. * If the size is omitted this implies you are using a preprocessed cubemap.
  150643. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150644. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150645. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150646. * (default is true)
  150647. */
  150648. constructor(
  150649. /**
  150650. * Defines the name of the task
  150651. */
  150652. name: string,
  150653. /**
  150654. * Defines the location of the file to load
  150655. */
  150656. url: string,
  150657. /**
  150658. * Defines the desired size (the more it increases the longer the generation will be)
  150659. */
  150660. size: number,
  150661. /**
  150662. * Defines if mipmaps should not be generated (default is false)
  150663. */
  150664. noMipmap?: boolean,
  150665. /**
  150666. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150667. * but the standard material would require them in Gamma space) (default is true)
  150668. */
  150669. gammaSpace?: boolean);
  150670. /**
  150671. * Execute the current task
  150672. * @param scene defines the scene where you want your assets to be loaded
  150673. * @param onSuccess is a callback called when the task is successfully executed
  150674. * @param onError is a callback called if an error occurs
  150675. */
  150676. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150677. }
  150678. /**
  150679. * This class can be used to easily import assets into a scene
  150680. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150681. */
  150682. export class AssetsManager {
  150683. private _scene;
  150684. private _isLoading;
  150685. protected _tasks: AbstractAssetTask[];
  150686. protected _waitingTasksCount: number;
  150687. protected _totalTasksCount: number;
  150688. /**
  150689. * Callback called when all tasks are processed
  150690. */
  150691. onFinish: (tasks: AbstractAssetTask[]) => void;
  150692. /**
  150693. * Callback called when a task is successful
  150694. */
  150695. onTaskSuccess: (task: AbstractAssetTask) => void;
  150696. /**
  150697. * Callback called when a task had an error
  150698. */
  150699. onTaskError: (task: AbstractAssetTask) => void;
  150700. /**
  150701. * Callback called when a task is done (whatever the result is)
  150702. */
  150703. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150704. /**
  150705. * Observable called when all tasks are processed
  150706. */
  150707. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150708. /**
  150709. * Observable called when a task had an error
  150710. */
  150711. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150712. /**
  150713. * Observable called when all tasks were executed
  150714. */
  150715. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150716. /**
  150717. * Observable called when a task is done (whatever the result is)
  150718. */
  150719. onProgressObservable: Observable<IAssetsProgressEvent>;
  150720. /**
  150721. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150722. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150723. */
  150724. useDefaultLoadingScreen: boolean;
  150725. /**
  150726. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150727. * when all assets have been downloaded.
  150728. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150729. */
  150730. autoHideLoadingUI: boolean;
  150731. /**
  150732. * Creates a new AssetsManager
  150733. * @param scene defines the scene to work on
  150734. */
  150735. constructor(scene: Scene);
  150736. /**
  150737. * Add a MeshAssetTask to the list of active tasks
  150738. * @param taskName defines the name of the new task
  150739. * @param meshesNames defines the name of meshes to load
  150740. * @param rootUrl defines the root url to use to locate files
  150741. * @param sceneFilename defines the filename of the scene file
  150742. * @returns a new MeshAssetTask object
  150743. */
  150744. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150745. /**
  150746. * Add a TextFileAssetTask to the list of active tasks
  150747. * @param taskName defines the name of the new task
  150748. * @param url defines the url of the file to load
  150749. * @returns a new TextFileAssetTask object
  150750. */
  150751. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150752. /**
  150753. * Add a BinaryFileAssetTask to the list of active tasks
  150754. * @param taskName defines the name of the new task
  150755. * @param url defines the url of the file to load
  150756. * @returns a new BinaryFileAssetTask object
  150757. */
  150758. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150759. /**
  150760. * Add a ImageAssetTask to the list of active tasks
  150761. * @param taskName defines the name of the new task
  150762. * @param url defines the url of the file to load
  150763. * @returns a new ImageAssetTask object
  150764. */
  150765. addImageTask(taskName: string, url: string): ImageAssetTask;
  150766. /**
  150767. * Add a TextureAssetTask to the list of active tasks
  150768. * @param taskName defines the name of the new task
  150769. * @param url defines the url of the file to load
  150770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150771. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150772. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150773. * @returns a new TextureAssetTask object
  150774. */
  150775. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150776. /**
  150777. * Add a CubeTextureAssetTask to the list of active tasks
  150778. * @param taskName defines the name of the new task
  150779. * @param url defines the url of the file to load
  150780. * @param extensions defines the extension to use to load the cube map (can be null)
  150781. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150782. * @param files defines the list of files to load (can be null)
  150783. * @returns a new CubeTextureAssetTask object
  150784. */
  150785. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150786. /**
  150787. *
  150788. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150789. * @param taskName defines the name of the new task
  150790. * @param url defines the url of the file to load
  150791. * @param size defines the size you want for the cubemap (can be null)
  150792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150793. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150794. * @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)
  150795. * @param reserved Internal use only
  150796. * @returns a new HDRCubeTextureAssetTask object
  150797. */
  150798. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150799. /**
  150800. *
  150801. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150802. * @param taskName defines the name of the new task
  150803. * @param url defines the url of the file to load
  150804. * @param size defines the size you want for the cubemap (can be null)
  150805. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150806. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150807. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150808. * @returns a new EquiRectangularCubeTextureAssetTask object
  150809. */
  150810. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150811. /**
  150812. * Remove a task from the assets manager.
  150813. * @param task the task to remove
  150814. */
  150815. removeTask(task: AbstractAssetTask): void;
  150816. private _decreaseWaitingTasksCount;
  150817. private _runTask;
  150818. /**
  150819. * Reset the AssetsManager and remove all tasks
  150820. * @return the current instance of the AssetsManager
  150821. */
  150822. reset(): AssetsManager;
  150823. /**
  150824. * Start the loading process
  150825. * @return the current instance of the AssetsManager
  150826. */
  150827. load(): AssetsManager;
  150828. /**
  150829. * Start the loading process as an async operation
  150830. * @return a promise returning the list of failed tasks
  150831. */
  150832. loadAsync(): Promise<void>;
  150833. }
  150834. }
  150835. declare module BABYLON {
  150836. /**
  150837. * Wrapper class for promise with external resolve and reject.
  150838. */
  150839. export class Deferred<T> {
  150840. /**
  150841. * The promise associated with this deferred object.
  150842. */
  150843. readonly promise: Promise<T>;
  150844. private _resolve;
  150845. private _reject;
  150846. /**
  150847. * The resolve method of the promise associated with this deferred object.
  150848. */
  150849. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150850. /**
  150851. * The reject method of the promise associated with this deferred object.
  150852. */
  150853. get reject(): (reason?: any) => void;
  150854. /**
  150855. * Constructor for this deferred object.
  150856. */
  150857. constructor();
  150858. }
  150859. }
  150860. declare module BABYLON {
  150861. /**
  150862. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150863. */
  150864. export class MeshExploder {
  150865. private _centerMesh;
  150866. private _meshes;
  150867. private _meshesOrigins;
  150868. private _toCenterVectors;
  150869. private _scaledDirection;
  150870. private _newPosition;
  150871. private _centerPosition;
  150872. /**
  150873. * Explodes meshes from a center mesh.
  150874. * @param meshes The meshes to explode.
  150875. * @param centerMesh The mesh to be center of explosion.
  150876. */
  150877. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150878. private _setCenterMesh;
  150879. /**
  150880. * Get class name
  150881. * @returns "MeshExploder"
  150882. */
  150883. getClassName(): string;
  150884. /**
  150885. * "Exploded meshes"
  150886. * @returns Array of meshes with the centerMesh at index 0.
  150887. */
  150888. getMeshes(): Array<Mesh>;
  150889. /**
  150890. * Explodes meshes giving a specific direction
  150891. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150892. */
  150893. explode(direction?: number): void;
  150894. }
  150895. }
  150896. declare module BABYLON {
  150897. /**
  150898. * Class used to help managing file picking and drag'n'drop
  150899. */
  150900. export class FilesInput {
  150901. /**
  150902. * List of files ready to be loaded
  150903. */
  150904. static get FilesToLoad(): {
  150905. [key: string]: File;
  150906. };
  150907. /**
  150908. * Callback called when a file is processed
  150909. */
  150910. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150911. private _engine;
  150912. private _currentScene;
  150913. private _sceneLoadedCallback;
  150914. private _progressCallback;
  150915. private _additionalRenderLoopLogicCallback;
  150916. private _textureLoadingCallback;
  150917. private _startingProcessingFilesCallback;
  150918. private _onReloadCallback;
  150919. private _errorCallback;
  150920. private _elementToMonitor;
  150921. private _sceneFileToLoad;
  150922. private _filesToLoad;
  150923. /**
  150924. * Creates a new FilesInput
  150925. * @param engine defines the rendering engine
  150926. * @param scene defines the hosting scene
  150927. * @param sceneLoadedCallback callback called when scene is loaded
  150928. * @param progressCallback callback called to track progress
  150929. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150930. * @param textureLoadingCallback callback called when a texture is loading
  150931. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150932. * @param onReloadCallback callback called when a reload is requested
  150933. * @param errorCallback callback call if an error occurs
  150934. */
  150935. 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>);
  150936. private _dragEnterHandler;
  150937. private _dragOverHandler;
  150938. private _dropHandler;
  150939. /**
  150940. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150941. * @param elementToMonitor defines the DOM element to track
  150942. */
  150943. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150944. /** Gets the current list of files to load */
  150945. get filesToLoad(): File[];
  150946. /**
  150947. * Release all associated resources
  150948. */
  150949. dispose(): void;
  150950. private renderFunction;
  150951. private drag;
  150952. private drop;
  150953. private _traverseFolder;
  150954. private _processFiles;
  150955. /**
  150956. * Load files from a drop event
  150957. * @param event defines the drop event to use as source
  150958. */
  150959. loadFiles(event: any): void;
  150960. private _processReload;
  150961. /**
  150962. * Reload the current scene from the loaded files
  150963. */
  150964. reload(): void;
  150965. }
  150966. }
  150967. declare module BABYLON {
  150968. /**
  150969. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150970. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150971. */
  150972. export class SceneOptimization {
  150973. /**
  150974. * Defines the priority of this optimization (0 by default which means first in the list)
  150975. */
  150976. priority: number;
  150977. /**
  150978. * Gets a string describing the action executed by the current optimization
  150979. * @returns description string
  150980. */
  150981. getDescription(): string;
  150982. /**
  150983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150984. * @param scene defines the current scene where to apply this optimization
  150985. * @param optimizer defines the current optimizer
  150986. * @returns true if everything that can be done was applied
  150987. */
  150988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150989. /**
  150990. * Creates the SceneOptimization object
  150991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150992. * @param desc defines the description associated with the optimization
  150993. */
  150994. constructor(
  150995. /**
  150996. * Defines the priority of this optimization (0 by default which means first in the list)
  150997. */
  150998. priority?: number);
  150999. }
  151000. /**
  151001. * Defines an optimization used to reduce the size of render target textures
  151002. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151003. */
  151004. export class TextureOptimization extends SceneOptimization {
  151005. /**
  151006. * Defines the priority of this optimization (0 by default which means first in the list)
  151007. */
  151008. priority: number;
  151009. /**
  151010. * 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
  151011. */
  151012. maximumSize: number;
  151013. /**
  151014. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151015. */
  151016. step: number;
  151017. /**
  151018. * Gets a string describing the action executed by the current optimization
  151019. * @returns description string
  151020. */
  151021. getDescription(): string;
  151022. /**
  151023. * Creates the TextureOptimization object
  151024. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151025. * @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
  151026. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151027. */
  151028. constructor(
  151029. /**
  151030. * Defines the priority of this optimization (0 by default which means first in the list)
  151031. */
  151032. priority?: number,
  151033. /**
  151034. * 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
  151035. */
  151036. maximumSize?: number,
  151037. /**
  151038. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151039. */
  151040. step?: number);
  151041. /**
  151042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151043. * @param scene defines the current scene where to apply this optimization
  151044. * @param optimizer defines the current optimizer
  151045. * @returns true if everything that can be done was applied
  151046. */
  151047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151048. }
  151049. /**
  151050. * Defines an optimization used to increase or decrease the rendering resolution
  151051. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151052. */
  151053. export class HardwareScalingOptimization extends SceneOptimization {
  151054. /**
  151055. * Defines the priority of this optimization (0 by default which means first in the list)
  151056. */
  151057. priority: number;
  151058. /**
  151059. * Defines the maximum scale to use (2 by default)
  151060. */
  151061. maximumScale: number;
  151062. /**
  151063. * Defines the step to use between two passes (0.5 by default)
  151064. */
  151065. step: number;
  151066. private _currentScale;
  151067. private _directionOffset;
  151068. /**
  151069. * Gets a string describing the action executed by the current optimization
  151070. * @return description string
  151071. */
  151072. getDescription(): string;
  151073. /**
  151074. * Creates the HardwareScalingOptimization object
  151075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151076. * @param maximumScale defines the maximum scale to use (2 by default)
  151077. * @param step defines the step to use between two passes (0.5 by default)
  151078. */
  151079. constructor(
  151080. /**
  151081. * Defines the priority of this optimization (0 by default which means first in the list)
  151082. */
  151083. priority?: number,
  151084. /**
  151085. * Defines the maximum scale to use (2 by default)
  151086. */
  151087. maximumScale?: number,
  151088. /**
  151089. * Defines the step to use between two passes (0.5 by default)
  151090. */
  151091. step?: number);
  151092. /**
  151093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151094. * @param scene defines the current scene where to apply this optimization
  151095. * @param optimizer defines the current optimizer
  151096. * @returns true if everything that can be done was applied
  151097. */
  151098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151099. }
  151100. /**
  151101. * Defines an optimization used to remove shadows
  151102. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151103. */
  151104. export class ShadowsOptimization extends SceneOptimization {
  151105. /**
  151106. * Gets a string describing the action executed by the current optimization
  151107. * @return description string
  151108. */
  151109. getDescription(): string;
  151110. /**
  151111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151112. * @param scene defines the current scene where to apply this optimization
  151113. * @param optimizer defines the current optimizer
  151114. * @returns true if everything that can be done was applied
  151115. */
  151116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151117. }
  151118. /**
  151119. * Defines an optimization used to turn post-processes off
  151120. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151121. */
  151122. export class PostProcessesOptimization extends SceneOptimization {
  151123. /**
  151124. * Gets a string describing the action executed by the current optimization
  151125. * @return description string
  151126. */
  151127. getDescription(): string;
  151128. /**
  151129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151130. * @param scene defines the current scene where to apply this optimization
  151131. * @param optimizer defines the current optimizer
  151132. * @returns true if everything that can be done was applied
  151133. */
  151134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151135. }
  151136. /**
  151137. * Defines an optimization used to turn lens flares off
  151138. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151139. */
  151140. export class LensFlaresOptimization extends SceneOptimization {
  151141. /**
  151142. * Gets a string describing the action executed by the current optimization
  151143. * @return description string
  151144. */
  151145. getDescription(): string;
  151146. /**
  151147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151148. * @param scene defines the current scene where to apply this optimization
  151149. * @param optimizer defines the current optimizer
  151150. * @returns true if everything that can be done was applied
  151151. */
  151152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151153. }
  151154. /**
  151155. * Defines an optimization based on user defined callback.
  151156. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151157. */
  151158. export class CustomOptimization extends SceneOptimization {
  151159. /**
  151160. * Callback called to apply the custom optimization.
  151161. */
  151162. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151163. /**
  151164. * Callback called to get custom description
  151165. */
  151166. onGetDescription: () => string;
  151167. /**
  151168. * Gets a string describing the action executed by the current optimization
  151169. * @returns description string
  151170. */
  151171. getDescription(): string;
  151172. /**
  151173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151174. * @param scene defines the current scene where to apply this optimization
  151175. * @param optimizer defines the current optimizer
  151176. * @returns true if everything that can be done was applied
  151177. */
  151178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151179. }
  151180. /**
  151181. * Defines an optimization used to turn particles off
  151182. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151183. */
  151184. export class ParticlesOptimization extends SceneOptimization {
  151185. /**
  151186. * Gets a string describing the action executed by the current optimization
  151187. * @return description string
  151188. */
  151189. getDescription(): string;
  151190. /**
  151191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151192. * @param scene defines the current scene where to apply this optimization
  151193. * @param optimizer defines the current optimizer
  151194. * @returns true if everything that can be done was applied
  151195. */
  151196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151197. }
  151198. /**
  151199. * Defines an optimization used to turn render targets off
  151200. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151201. */
  151202. export class RenderTargetsOptimization extends SceneOptimization {
  151203. /**
  151204. * Gets a string describing the action executed by the current optimization
  151205. * @return description string
  151206. */
  151207. getDescription(): string;
  151208. /**
  151209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151210. * @param scene defines the current scene where to apply this optimization
  151211. * @param optimizer defines the current optimizer
  151212. * @returns true if everything that can be done was applied
  151213. */
  151214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151215. }
  151216. /**
  151217. * Defines an optimization used to merge meshes with compatible materials
  151218. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151219. */
  151220. export class MergeMeshesOptimization extends SceneOptimization {
  151221. private static _UpdateSelectionTree;
  151222. /**
  151223. * Gets or sets a boolean which defines if optimization octree has to be updated
  151224. */
  151225. static get UpdateSelectionTree(): boolean;
  151226. /**
  151227. * Gets or sets a boolean which defines if optimization octree has to be updated
  151228. */
  151229. static set UpdateSelectionTree(value: boolean);
  151230. /**
  151231. * Gets a string describing the action executed by the current optimization
  151232. * @return description string
  151233. */
  151234. getDescription(): string;
  151235. private _canBeMerged;
  151236. /**
  151237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151238. * @param scene defines the current scene where to apply this optimization
  151239. * @param optimizer defines the current optimizer
  151240. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  151241. * @returns true if everything that can be done was applied
  151242. */
  151243. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  151244. }
  151245. /**
  151246. * Defines a list of options used by SceneOptimizer
  151247. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151248. */
  151249. export class SceneOptimizerOptions {
  151250. /**
  151251. * Defines the target frame rate to reach (60 by default)
  151252. */
  151253. targetFrameRate: number;
  151254. /**
  151255. * Defines the interval between two checkes (2000ms by default)
  151256. */
  151257. trackerDuration: number;
  151258. /**
  151259. * Gets the list of optimizations to apply
  151260. */
  151261. optimizations: SceneOptimization[];
  151262. /**
  151263. * Creates a new list of options used by SceneOptimizer
  151264. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  151265. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  151266. */
  151267. constructor(
  151268. /**
  151269. * Defines the target frame rate to reach (60 by default)
  151270. */
  151271. targetFrameRate?: number,
  151272. /**
  151273. * Defines the interval between two checkes (2000ms by default)
  151274. */
  151275. trackerDuration?: number);
  151276. /**
  151277. * Add a new optimization
  151278. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  151279. * @returns the current SceneOptimizerOptions
  151280. */
  151281. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  151282. /**
  151283. * Add a new custom optimization
  151284. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  151285. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  151286. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151287. * @returns the current SceneOptimizerOptions
  151288. */
  151289. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  151290. /**
  151291. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  151292. * @param targetFrameRate defines the target frame rate (60 by default)
  151293. * @returns a SceneOptimizerOptions object
  151294. */
  151295. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151296. /**
  151297. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  151298. * @param targetFrameRate defines the target frame rate (60 by default)
  151299. * @returns a SceneOptimizerOptions object
  151300. */
  151301. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151302. /**
  151303. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  151304. * @param targetFrameRate defines the target frame rate (60 by default)
  151305. * @returns a SceneOptimizerOptions object
  151306. */
  151307. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151308. }
  151309. /**
  151310. * Class used to run optimizations in order to reach a target frame rate
  151311. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151312. */
  151313. export class SceneOptimizer implements IDisposable {
  151314. private _isRunning;
  151315. private _options;
  151316. private _scene;
  151317. private _currentPriorityLevel;
  151318. private _targetFrameRate;
  151319. private _trackerDuration;
  151320. private _currentFrameRate;
  151321. private _sceneDisposeObserver;
  151322. private _improvementMode;
  151323. /**
  151324. * Defines an observable called when the optimizer reaches the target frame rate
  151325. */
  151326. onSuccessObservable: Observable<SceneOptimizer>;
  151327. /**
  151328. * Defines an observable called when the optimizer enables an optimization
  151329. */
  151330. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  151331. /**
  151332. * Defines an observable called when the optimizer is not able to reach the target frame rate
  151333. */
  151334. onFailureObservable: Observable<SceneOptimizer>;
  151335. /**
  151336. * Gets a boolean indicating if the optimizer is in improvement mode
  151337. */
  151338. get isInImprovementMode(): boolean;
  151339. /**
  151340. * Gets the current priority level (0 at start)
  151341. */
  151342. get currentPriorityLevel(): number;
  151343. /**
  151344. * Gets the current frame rate checked by the SceneOptimizer
  151345. */
  151346. get currentFrameRate(): number;
  151347. /**
  151348. * Gets or sets the current target frame rate (60 by default)
  151349. */
  151350. get targetFrameRate(): number;
  151351. /**
  151352. * Gets or sets the current target frame rate (60 by default)
  151353. */
  151354. set targetFrameRate(value: number);
  151355. /**
  151356. * Gets or sets the current interval between two checks (every 2000ms by default)
  151357. */
  151358. get trackerDuration(): number;
  151359. /**
  151360. * Gets or sets the current interval between two checks (every 2000ms by default)
  151361. */
  151362. set trackerDuration(value: number);
  151363. /**
  151364. * Gets the list of active optimizations
  151365. */
  151366. get optimizations(): SceneOptimization[];
  151367. /**
  151368. * Creates a new SceneOptimizer
  151369. * @param scene defines the scene to work on
  151370. * @param options defines the options to use with the SceneOptimizer
  151371. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  151372. * @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)
  151373. */
  151374. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  151375. /**
  151376. * Stops the current optimizer
  151377. */
  151378. stop(): void;
  151379. /**
  151380. * Reset the optimizer to initial step (current priority level = 0)
  151381. */
  151382. reset(): void;
  151383. /**
  151384. * Start the optimizer. By default it will try to reach a specific framerate
  151385. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  151386. */
  151387. start(): void;
  151388. private _checkCurrentState;
  151389. /**
  151390. * Release all resources
  151391. */
  151392. dispose(): void;
  151393. /**
  151394. * Helper function to create a SceneOptimizer with one single line of code
  151395. * @param scene defines the scene to work on
  151396. * @param options defines the options to use with the SceneOptimizer
  151397. * @param onSuccess defines a callback to call on success
  151398. * @param onFailure defines a callback to call on failure
  151399. * @returns the new SceneOptimizer object
  151400. */
  151401. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151402. }
  151403. }
  151404. declare module BABYLON {
  151405. /**
  151406. * Class used to serialize a scene into a string
  151407. */
  151408. export class SceneSerializer {
  151409. /**
  151410. * Clear cache used by a previous serialization
  151411. */
  151412. static ClearCache(): void;
  151413. /**
  151414. * Serialize a scene into a JSON compatible object
  151415. * @param scene defines the scene to serialize
  151416. * @returns a JSON compatible object
  151417. */
  151418. static Serialize(scene: Scene): any;
  151419. /**
  151420. * Serialize a mesh into a JSON compatible object
  151421. * @param toSerialize defines the mesh to serialize
  151422. * @param withParents defines if parents must be serialized as well
  151423. * @param withChildren defines if children must be serialized as well
  151424. * @returns a JSON compatible object
  151425. */
  151426. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151427. }
  151428. }
  151429. declare module BABYLON {
  151430. /**
  151431. * Class used to host texture specific utilities
  151432. */
  151433. export class TextureTools {
  151434. /**
  151435. * Uses the GPU to create a copy texture rescaled at a given size
  151436. * @param texture Texture to copy from
  151437. * @param width defines the desired width
  151438. * @param height defines the desired height
  151439. * @param useBilinearMode defines if bilinear mode has to be used
  151440. * @return the generated texture
  151441. */
  151442. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151443. }
  151444. }
  151445. declare module BABYLON {
  151446. /**
  151447. * This represents the different options available for the video capture.
  151448. */
  151449. export interface VideoRecorderOptions {
  151450. /** Defines the mime type of the video. */
  151451. mimeType: string;
  151452. /** Defines the FPS the video should be recorded at. */
  151453. fps: number;
  151454. /** Defines the chunk size for the recording data. */
  151455. recordChunckSize: number;
  151456. /** The audio tracks to attach to the recording. */
  151457. audioTracks?: MediaStreamTrack[];
  151458. }
  151459. /**
  151460. * This can help with recording videos from BabylonJS.
  151461. * This is based on the available WebRTC functionalities of the browser.
  151462. *
  151463. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151464. */
  151465. export class VideoRecorder {
  151466. private static readonly _defaultOptions;
  151467. /**
  151468. * Returns whether or not the VideoRecorder is available in your browser.
  151469. * @param engine Defines the Babylon Engine.
  151470. * @returns true if supported otherwise false.
  151471. */
  151472. static IsSupported(engine: Engine): boolean;
  151473. private readonly _options;
  151474. private _canvas;
  151475. private _mediaRecorder;
  151476. private _recordedChunks;
  151477. private _fileName;
  151478. private _resolve;
  151479. private _reject;
  151480. /**
  151481. * True when a recording is already in progress.
  151482. */
  151483. get isRecording(): boolean;
  151484. /**
  151485. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151486. * @param engine Defines the BabylonJS Engine you wish to record.
  151487. * @param options Defines options that can be used to customize the capture.
  151488. */
  151489. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151490. /**
  151491. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151492. */
  151493. stopRecording(): void;
  151494. /**
  151495. * Starts recording the canvas for a max duration specified in parameters.
  151496. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151497. * If null no automatic download will start and you can rely on the promise to get the data back.
  151498. * @param maxDuration Defines the maximum recording time in seconds.
  151499. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151500. * @return A promise callback at the end of the recording with the video data in Blob.
  151501. */
  151502. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151503. /**
  151504. * Releases internal resources used during the recording.
  151505. */
  151506. dispose(): void;
  151507. private _handleDataAvailable;
  151508. private _handleError;
  151509. private _handleStop;
  151510. }
  151511. }
  151512. declare module BABYLON {
  151513. /**
  151514. * Class containing a set of static utilities functions for screenshots
  151515. */
  151516. export class ScreenshotTools {
  151517. /**
  151518. * Captures a screenshot of the current rendering
  151519. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151520. * @param engine defines the rendering engine
  151521. * @param camera defines the source camera
  151522. * @param size This parameter can be set to a single number or to an object with the
  151523. * following (optional) properties: precision, width, height. If a single number is passed,
  151524. * it will be used for both width and height. If an object is passed, the screenshot size
  151525. * will be derived from the parameters. The precision property is a multiplier allowing
  151526. * rendering at a higher or lower resolution
  151527. * @param successCallback defines the callback receives a single parameter which contains the
  151528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151529. * src parameter of an <img> to display it
  151530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151531. * Check your browser for supported MIME types
  151532. */
  151533. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151534. /**
  151535. * Captures a screenshot of the current rendering
  151536. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151537. * @param engine defines the rendering engine
  151538. * @param camera defines the source camera
  151539. * @param size This parameter can be set to a single number or to an object with the
  151540. * following (optional) properties: precision, width, height. If a single number is passed,
  151541. * it will be used for both width and height. If an object is passed, the screenshot size
  151542. * will be derived from the parameters. The precision property is a multiplier allowing
  151543. * rendering at a higher or lower resolution
  151544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151545. * Check your browser for supported MIME types
  151546. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151547. * to the src parameter of an <img> to display it
  151548. */
  151549. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151550. /**
  151551. * Generates an image screenshot from the specified camera.
  151552. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151553. * @param engine The engine to use for rendering
  151554. * @param camera The camera to use for rendering
  151555. * @param size This parameter can be set to a single number or to an object with the
  151556. * following (optional) properties: precision, width, height. If a single number is passed,
  151557. * it will be used for both width and height. If an object is passed, the screenshot size
  151558. * will be derived from the parameters. The precision property is a multiplier allowing
  151559. * rendering at a higher or lower resolution
  151560. * @param successCallback The callback receives a single parameter which contains the
  151561. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151562. * src parameter of an <img> to display it
  151563. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151564. * Check your browser for supported MIME types
  151565. * @param samples Texture samples (default: 1)
  151566. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151567. * @param fileName A name for for the downloaded file.
  151568. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151569. */
  151570. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151571. /**
  151572. * Generates an image screenshot from the specified camera.
  151573. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151574. * @param engine The engine to use for rendering
  151575. * @param camera The camera to use for rendering
  151576. * @param size This parameter can be set to a single number or to an object with the
  151577. * following (optional) properties: precision, width, height. If a single number is passed,
  151578. * it will be used for both width and height. If an object is passed, the screenshot size
  151579. * will be derived from the parameters. The precision property is a multiplier allowing
  151580. * rendering at a higher or lower resolution
  151581. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151582. * Check your browser for supported MIME types
  151583. * @param samples Texture samples (default: 1)
  151584. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151585. * @param fileName A name for for the downloaded file.
  151586. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151587. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151588. * to the src parameter of an <img> to display it
  151589. */
  151590. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151591. /**
  151592. * Gets height and width for screenshot size
  151593. * @private
  151594. */
  151595. private static _getScreenshotSize;
  151596. }
  151597. }
  151598. declare module BABYLON {
  151599. /**
  151600. * Interface for a data buffer
  151601. */
  151602. export interface IDataBuffer {
  151603. /**
  151604. * Reads bytes from the data buffer.
  151605. * @param byteOffset The byte offset to read
  151606. * @param byteLength The byte length to read
  151607. * @returns A promise that resolves when the bytes are read
  151608. */
  151609. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151610. /**
  151611. * The byte length of the buffer.
  151612. */
  151613. readonly byteLength: number;
  151614. }
  151615. /**
  151616. * Utility class for reading from a data buffer
  151617. */
  151618. export class DataReader {
  151619. /**
  151620. * The data buffer associated with this data reader.
  151621. */
  151622. readonly buffer: IDataBuffer;
  151623. /**
  151624. * The current byte offset from the beginning of the data buffer.
  151625. */
  151626. byteOffset: number;
  151627. private _dataView;
  151628. private _dataByteOffset;
  151629. /**
  151630. * Constructor
  151631. * @param buffer The buffer to read
  151632. */
  151633. constructor(buffer: IDataBuffer);
  151634. /**
  151635. * Loads the given byte length.
  151636. * @param byteLength The byte length to load
  151637. * @returns A promise that resolves when the load is complete
  151638. */
  151639. loadAsync(byteLength: number): Promise<void>;
  151640. /**
  151641. * Read a unsigned 32-bit integer from the currently loaded data range.
  151642. * @returns The 32-bit integer read
  151643. */
  151644. readUint32(): number;
  151645. /**
  151646. * Read a byte array from the currently loaded data range.
  151647. * @param byteLength The byte length to read
  151648. * @returns The byte array read
  151649. */
  151650. readUint8Array(byteLength: number): Uint8Array;
  151651. /**
  151652. * Read a string from the currently loaded data range.
  151653. * @param byteLength The byte length to read
  151654. * @returns The string read
  151655. */
  151656. readString(byteLength: number): string;
  151657. /**
  151658. * Skips the given byte length the currently loaded data range.
  151659. * @param byteLength The byte length to skip
  151660. */
  151661. skipBytes(byteLength: number): void;
  151662. }
  151663. }
  151664. declare module BABYLON {
  151665. /**
  151666. * Class for storing data to local storage if available or in-memory storage otherwise
  151667. */
  151668. export class DataStorage {
  151669. private static _Storage;
  151670. private static _GetStorage;
  151671. /**
  151672. * Reads a string from the data storage
  151673. * @param key The key to read
  151674. * @param defaultValue The value if the key doesn't exist
  151675. * @returns The string value
  151676. */
  151677. static ReadString(key: string, defaultValue: string): string;
  151678. /**
  151679. * Writes a string to the data storage
  151680. * @param key The key to write
  151681. * @param value The value to write
  151682. */
  151683. static WriteString(key: string, value: string): void;
  151684. /**
  151685. * Reads a boolean from the data storage
  151686. * @param key The key to read
  151687. * @param defaultValue The value if the key doesn't exist
  151688. * @returns The boolean value
  151689. */
  151690. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151691. /**
  151692. * Writes a boolean to the data storage
  151693. * @param key The key to write
  151694. * @param value The value to write
  151695. */
  151696. static WriteBoolean(key: string, value: boolean): void;
  151697. /**
  151698. * Reads a number from the data storage
  151699. * @param key The key to read
  151700. * @param defaultValue The value if the key doesn't exist
  151701. * @returns The number value
  151702. */
  151703. static ReadNumber(key: string, defaultValue: number): number;
  151704. /**
  151705. * Writes a number to the data storage
  151706. * @param key The key to write
  151707. * @param value The value to write
  151708. */
  151709. static WriteNumber(key: string, value: number): void;
  151710. }
  151711. }
  151712. declare module BABYLON {
  151713. /**
  151714. * An interface for all Hit test features
  151715. */
  151716. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151717. /**
  151718. * Triggered when new babylon (transformed) hit test results are available
  151719. */
  151720. onHitTestResultObservable: Observable<T[]>;
  151721. }
  151722. /**
  151723. * Options used for hit testing
  151724. */
  151725. export interface IWebXRLegacyHitTestOptions {
  151726. /**
  151727. * Only test when user interacted with the scene. Default - hit test every frame
  151728. */
  151729. testOnPointerDownOnly?: boolean;
  151730. /**
  151731. * The node to use to transform the local results to world coordinates
  151732. */
  151733. worldParentNode?: TransformNode;
  151734. }
  151735. /**
  151736. * Interface defining the babylon result of raycasting/hit-test
  151737. */
  151738. export interface IWebXRLegacyHitResult {
  151739. /**
  151740. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151741. */
  151742. transformationMatrix: Matrix;
  151743. /**
  151744. * The native hit test result
  151745. */
  151746. xrHitResult: XRHitResult | XRHitTestResult;
  151747. }
  151748. /**
  151749. * The currently-working hit-test module.
  151750. * Hit test (or Ray-casting) is used to interact with the real world.
  151751. * For further information read here - https://github.com/immersive-web/hit-test
  151752. */
  151753. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151754. /**
  151755. * options to use when constructing this feature
  151756. */
  151757. readonly options: IWebXRLegacyHitTestOptions;
  151758. private _direction;
  151759. private _mat;
  151760. private _onSelectEnabled;
  151761. private _origin;
  151762. /**
  151763. * The module's name
  151764. */
  151765. static readonly Name: string;
  151766. /**
  151767. * The (Babylon) version of this module.
  151768. * This is an integer representing the implementation version.
  151769. * This number does not correspond to the WebXR specs version
  151770. */
  151771. static readonly Version: number;
  151772. /**
  151773. * Populated with the last native XR Hit Results
  151774. */
  151775. lastNativeXRHitResults: XRHitResult[];
  151776. /**
  151777. * Triggered when new babylon (transformed) hit test results are available
  151778. */
  151779. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151780. /**
  151781. * Creates a new instance of the (legacy version) hit test feature
  151782. * @param _xrSessionManager an instance of WebXRSessionManager
  151783. * @param options options to use when constructing this feature
  151784. */
  151785. constructor(_xrSessionManager: WebXRSessionManager,
  151786. /**
  151787. * options to use when constructing this feature
  151788. */
  151789. options?: IWebXRLegacyHitTestOptions);
  151790. /**
  151791. * execute a hit test with an XR Ray
  151792. *
  151793. * @param xrSession a native xrSession that will execute this hit test
  151794. * @param xrRay the ray (position and direction) to use for ray-casting
  151795. * @param referenceSpace native XR reference space to use for the hit-test
  151796. * @param filter filter function that will filter the results
  151797. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151798. */
  151799. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151800. /**
  151801. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151802. * @param event the (select) event to use to select with
  151803. * @param referenceSpace the reference space to use for this hit test
  151804. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151805. */
  151806. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151807. /**
  151808. * attach this feature
  151809. * Will usually be called by the features manager
  151810. *
  151811. * @returns true if successful.
  151812. */
  151813. attach(): boolean;
  151814. /**
  151815. * detach this feature.
  151816. * Will usually be called by the features manager
  151817. *
  151818. * @returns true if successful.
  151819. */
  151820. detach(): boolean;
  151821. /**
  151822. * Dispose this feature and all of the resources attached
  151823. */
  151824. dispose(): void;
  151825. protected _onXRFrame(frame: XRFrame): void;
  151826. private _onHitTestResults;
  151827. private _onSelect;
  151828. }
  151829. }
  151830. declare module BABYLON {
  151831. /**
  151832. * Options used for hit testing (version 2)
  151833. */
  151834. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151835. /**
  151836. * Do not create a permanent hit test. Will usually be used when only
  151837. * transient inputs are needed.
  151838. */
  151839. disablePermanentHitTest?: boolean;
  151840. /**
  151841. * Enable transient (for example touch-based) hit test inspections
  151842. */
  151843. enableTransientHitTest?: boolean;
  151844. /**
  151845. * Offset ray for the permanent hit test
  151846. */
  151847. offsetRay?: Vector3;
  151848. /**
  151849. * Offset ray for the transient hit test
  151850. */
  151851. transientOffsetRay?: Vector3;
  151852. /**
  151853. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151854. */
  151855. useReferenceSpace?: boolean;
  151856. }
  151857. /**
  151858. * Interface defining the babylon result of hit-test
  151859. */
  151860. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151861. /**
  151862. * The input source that generated this hit test (if transient)
  151863. */
  151864. inputSource?: XRInputSource;
  151865. /**
  151866. * Is this a transient hit test
  151867. */
  151868. isTransient?: boolean;
  151869. /**
  151870. * Position of the hit test result
  151871. */
  151872. position: Vector3;
  151873. /**
  151874. * Rotation of the hit test result
  151875. */
  151876. rotationQuaternion: Quaternion;
  151877. /**
  151878. * The native hit test result
  151879. */
  151880. xrHitResult: XRHitTestResult;
  151881. }
  151882. /**
  151883. * The currently-working hit-test module.
  151884. * Hit test (or Ray-casting) is used to interact with the real world.
  151885. * For further information read here - https://github.com/immersive-web/hit-test
  151886. *
  151887. * Tested on chrome (mobile) 80.
  151888. */
  151889. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151890. /**
  151891. * options to use when constructing this feature
  151892. */
  151893. readonly options: IWebXRHitTestOptions;
  151894. private _tmpMat;
  151895. private _tmpPos;
  151896. private _tmpQuat;
  151897. private _transientXrHitTestSource;
  151898. private _xrHitTestSource;
  151899. private initHitTestSource;
  151900. /**
  151901. * The module's name
  151902. */
  151903. static readonly Name: string;
  151904. /**
  151905. * The (Babylon) version of this module.
  151906. * This is an integer representing the implementation version.
  151907. * This number does not correspond to the WebXR specs version
  151908. */
  151909. static readonly Version: number;
  151910. /**
  151911. * When set to true, each hit test will have its own position/rotation objects
  151912. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151913. * the developers will clone them or copy them as they see fit.
  151914. */
  151915. autoCloneTransformation: boolean;
  151916. /**
  151917. * Triggered when new babylon (transformed) hit test results are available
  151918. */
  151919. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151920. /**
  151921. * Use this to temporarily pause hit test checks.
  151922. */
  151923. paused: boolean;
  151924. /**
  151925. * Creates a new instance of the hit test feature
  151926. * @param _xrSessionManager an instance of WebXRSessionManager
  151927. * @param options options to use when constructing this feature
  151928. */
  151929. constructor(_xrSessionManager: WebXRSessionManager,
  151930. /**
  151931. * options to use when constructing this feature
  151932. */
  151933. options?: IWebXRHitTestOptions);
  151934. /**
  151935. * attach this feature
  151936. * Will usually be called by the features manager
  151937. *
  151938. * @returns true if successful.
  151939. */
  151940. attach(): boolean;
  151941. /**
  151942. * detach this feature.
  151943. * Will usually be called by the features manager
  151944. *
  151945. * @returns true if successful.
  151946. */
  151947. detach(): boolean;
  151948. /**
  151949. * Dispose this feature and all of the resources attached
  151950. */
  151951. dispose(): void;
  151952. protected _onXRFrame(frame: XRFrame): void;
  151953. private _processWebXRHitTestResult;
  151954. }
  151955. }
  151956. declare module BABYLON {
  151957. /**
  151958. * Configuration options of the anchor system
  151959. */
  151960. export interface IWebXRAnchorSystemOptions {
  151961. /**
  151962. * a node that will be used to convert local to world coordinates
  151963. */
  151964. worldParentNode?: TransformNode;
  151965. /**
  151966. * If set to true a reference of the created anchors will be kept until the next session starts
  151967. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151968. */
  151969. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151970. }
  151971. /**
  151972. * A babylon container for an XR Anchor
  151973. */
  151974. export interface IWebXRAnchor {
  151975. /**
  151976. * A babylon-assigned ID for this anchor
  151977. */
  151978. id: number;
  151979. /**
  151980. * Transformation matrix to apply to an object attached to this anchor
  151981. */
  151982. transformationMatrix: Matrix;
  151983. /**
  151984. * The native anchor object
  151985. */
  151986. xrAnchor: XRAnchor;
  151987. /**
  151988. * if defined, this object will be constantly updated by the anchor's position and rotation
  151989. */
  151990. attachedNode?: TransformNode;
  151991. }
  151992. /**
  151993. * An implementation of the anchor system for WebXR.
  151994. * For further information see https://github.com/immersive-web/anchors/
  151995. */
  151996. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151997. private _options;
  151998. private _lastFrameDetected;
  151999. private _trackedAnchors;
  152000. private _referenceSpaceForFrameAnchors;
  152001. private _futureAnchors;
  152002. /**
  152003. * The module's name
  152004. */
  152005. static readonly Name: string;
  152006. /**
  152007. * The (Babylon) version of this module.
  152008. * This is an integer representing the implementation version.
  152009. * This number does not correspond to the WebXR specs version
  152010. */
  152011. static readonly Version: number;
  152012. /**
  152013. * Observers registered here will be executed when a new anchor was added to the session
  152014. */
  152015. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152016. /**
  152017. * Observers registered here will be executed when an anchor was removed from the session
  152018. */
  152019. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152020. /**
  152021. * Observers registered here will be executed when an existing anchor updates
  152022. * This can execute N times every frame
  152023. */
  152024. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152025. /**
  152026. * Set the reference space to use for anchor creation, when not using a hit test.
  152027. * Will default to the session's reference space if not defined
  152028. */
  152029. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152030. /**
  152031. * constructs a new anchor system
  152032. * @param _xrSessionManager an instance of WebXRSessionManager
  152033. * @param _options configuration object for this feature
  152034. */
  152035. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152036. private _tmpVector;
  152037. private _tmpQuaternion;
  152038. private _populateTmpTransformation;
  152039. /**
  152040. * Create a new anchor point using a hit test result at a specific point in the scene
  152041. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152042. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152043. *
  152044. * @param hitTestResult The hit test result to use for this anchor creation
  152045. * @param position an optional position offset for this anchor
  152046. * @param rotationQuaternion an optional rotation offset for this anchor
  152047. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152048. */
  152049. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152050. /**
  152051. * Add a new anchor at a specific position and rotation
  152052. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152053. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152054. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152055. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152056. *
  152057. * @param position the position in which to add an anchor
  152058. * @param rotationQuaternion an optional rotation for the anchor transformation
  152059. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152060. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152061. */
  152062. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152063. /**
  152064. * detach this feature.
  152065. * Will usually be called by the features manager
  152066. *
  152067. * @returns true if successful.
  152068. */
  152069. detach(): boolean;
  152070. /**
  152071. * Dispose this feature and all of the resources attached
  152072. */
  152073. dispose(): void;
  152074. protected _onXRFrame(frame: XRFrame): void;
  152075. /**
  152076. * avoiding using Array.find for global support.
  152077. * @param xrAnchor the plane to find in the array
  152078. */
  152079. private _findIndexInAnchorArray;
  152080. private _updateAnchorWithXRFrame;
  152081. private _createAnchorAtTransformation;
  152082. }
  152083. }
  152084. declare module BABYLON {
  152085. /**
  152086. * Options used in the plane detector module
  152087. */
  152088. export interface IWebXRPlaneDetectorOptions {
  152089. /**
  152090. * The node to use to transform the local results to world coordinates
  152091. */
  152092. worldParentNode?: TransformNode;
  152093. /**
  152094. * If set to true a reference of the created planes will be kept until the next session starts
  152095. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152096. */
  152097. doNotRemovePlanesOnSessionEnded?: boolean;
  152098. }
  152099. /**
  152100. * A babylon interface for a WebXR plane.
  152101. * A Plane is actually a polygon, built from N points in space
  152102. *
  152103. * Supported in chrome 79, not supported in canary 81 ATM
  152104. */
  152105. export interface IWebXRPlane {
  152106. /**
  152107. * a babylon-assigned ID for this polygon
  152108. */
  152109. id: number;
  152110. /**
  152111. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152112. */
  152113. polygonDefinition: Array<Vector3>;
  152114. /**
  152115. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152116. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152117. */
  152118. transformationMatrix: Matrix;
  152119. /**
  152120. * the native xr-plane object
  152121. */
  152122. xrPlane: XRPlane;
  152123. }
  152124. /**
  152125. * The plane detector is used to detect planes in the real world when in AR
  152126. * For more information see https://github.com/immersive-web/real-world-geometry/
  152127. */
  152128. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152129. private _options;
  152130. private _detectedPlanes;
  152131. private _enabled;
  152132. private _lastFrameDetected;
  152133. /**
  152134. * The module's name
  152135. */
  152136. static readonly Name: string;
  152137. /**
  152138. * The (Babylon) version of this module.
  152139. * This is an integer representing the implementation version.
  152140. * This number does not correspond to the WebXR specs version
  152141. */
  152142. static readonly Version: number;
  152143. /**
  152144. * Observers registered here will be executed when a new plane was added to the session
  152145. */
  152146. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152147. /**
  152148. * Observers registered here will be executed when a plane is no longer detected in the session
  152149. */
  152150. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152151. /**
  152152. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152153. * This can execute N times every frame
  152154. */
  152155. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152156. /**
  152157. * construct a new Plane Detector
  152158. * @param _xrSessionManager an instance of xr Session manager
  152159. * @param _options configuration to use when constructing this feature
  152160. */
  152161. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  152162. /**
  152163. * detach this feature.
  152164. * Will usually be called by the features manager
  152165. *
  152166. * @returns true if successful.
  152167. */
  152168. detach(): boolean;
  152169. /**
  152170. * Dispose this feature and all of the resources attached
  152171. */
  152172. dispose(): void;
  152173. protected _onXRFrame(frame: XRFrame): void;
  152174. private _init;
  152175. private _updatePlaneWithXRPlane;
  152176. /**
  152177. * avoiding using Array.find for global support.
  152178. * @param xrPlane the plane to find in the array
  152179. */
  152180. private findIndexInPlaneArray;
  152181. }
  152182. }
  152183. declare module BABYLON {
  152184. /**
  152185. * Options interface for the background remover plugin
  152186. */
  152187. export interface IWebXRBackgroundRemoverOptions {
  152188. /**
  152189. * Further background meshes to disable when entering AR
  152190. */
  152191. backgroundMeshes?: AbstractMesh[];
  152192. /**
  152193. * flags to configure the removal of the environment helper.
  152194. * If not set, the entire background will be removed. If set, flags should be set as well.
  152195. */
  152196. environmentHelperRemovalFlags?: {
  152197. /**
  152198. * Should the skybox be removed (default false)
  152199. */
  152200. skyBox?: boolean;
  152201. /**
  152202. * Should the ground be removed (default false)
  152203. */
  152204. ground?: boolean;
  152205. };
  152206. /**
  152207. * don't disable the environment helper
  152208. */
  152209. ignoreEnvironmentHelper?: boolean;
  152210. }
  152211. /**
  152212. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  152213. */
  152214. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  152215. /**
  152216. * read-only options to be used in this module
  152217. */
  152218. readonly options: IWebXRBackgroundRemoverOptions;
  152219. /**
  152220. * The module's name
  152221. */
  152222. static readonly Name: string;
  152223. /**
  152224. * The (Babylon) version of this module.
  152225. * This is an integer representing the implementation version.
  152226. * This number does not correspond to the WebXR specs version
  152227. */
  152228. static readonly Version: number;
  152229. /**
  152230. * registered observers will be triggered when the background state changes
  152231. */
  152232. onBackgroundStateChangedObservable: Observable<boolean>;
  152233. /**
  152234. * constructs a new background remover module
  152235. * @param _xrSessionManager the session manager for this module
  152236. * @param options read-only options to be used in this module
  152237. */
  152238. constructor(_xrSessionManager: WebXRSessionManager,
  152239. /**
  152240. * read-only options to be used in this module
  152241. */
  152242. options?: IWebXRBackgroundRemoverOptions);
  152243. /**
  152244. * attach this feature
  152245. * Will usually be called by the features manager
  152246. *
  152247. * @returns true if successful.
  152248. */
  152249. attach(): boolean;
  152250. /**
  152251. * detach this feature.
  152252. * Will usually be called by the features manager
  152253. *
  152254. * @returns true if successful.
  152255. */
  152256. detach(): boolean;
  152257. /**
  152258. * Dispose this feature and all of the resources attached
  152259. */
  152260. dispose(): void;
  152261. protected _onXRFrame(_xrFrame: XRFrame): void;
  152262. private _setBackgroundState;
  152263. }
  152264. }
  152265. declare module BABYLON {
  152266. /**
  152267. * Options for the controller physics feature
  152268. */
  152269. export class IWebXRControllerPhysicsOptions {
  152270. /**
  152271. * Should the headset get its own impostor
  152272. */
  152273. enableHeadsetImpostor?: boolean;
  152274. /**
  152275. * Optional parameters for the headset impostor
  152276. */
  152277. headsetImpostorParams?: {
  152278. /**
  152279. * The type of impostor to create. Default is sphere
  152280. */
  152281. impostorType: number;
  152282. /**
  152283. * the size of the impostor. Defaults to 10cm
  152284. */
  152285. impostorSize?: number | {
  152286. width: number;
  152287. height: number;
  152288. depth: number;
  152289. };
  152290. /**
  152291. * Friction definitions
  152292. */
  152293. friction?: number;
  152294. /**
  152295. * Restitution
  152296. */
  152297. restitution?: number;
  152298. };
  152299. /**
  152300. * The physics properties of the future impostors
  152301. */
  152302. physicsProperties?: {
  152303. /**
  152304. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  152305. * Note that this requires a physics engine that supports mesh impostors!
  152306. */
  152307. useControllerMesh?: boolean;
  152308. /**
  152309. * The type of impostor to create. Default is sphere
  152310. */
  152311. impostorType?: number;
  152312. /**
  152313. * the size of the impostor. Defaults to 10cm
  152314. */
  152315. impostorSize?: number | {
  152316. width: number;
  152317. height: number;
  152318. depth: number;
  152319. };
  152320. /**
  152321. * Friction definitions
  152322. */
  152323. friction?: number;
  152324. /**
  152325. * Restitution
  152326. */
  152327. restitution?: number;
  152328. };
  152329. /**
  152330. * the xr input to use with this pointer selection
  152331. */
  152332. xrInput: WebXRInput;
  152333. }
  152334. /**
  152335. * Add physics impostor to your webxr controllers,
  152336. * including naive calculation of their linear and angular velocity
  152337. */
  152338. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  152339. private readonly _options;
  152340. private _attachController;
  152341. private _controllers;
  152342. private _debugMode;
  152343. private _delta;
  152344. private _headsetImpostor?;
  152345. private _headsetMesh?;
  152346. private _lastTimestamp;
  152347. private _tmpQuaternion;
  152348. private _tmpVector;
  152349. /**
  152350. * The module's name
  152351. */
  152352. static readonly Name: string;
  152353. /**
  152354. * The (Babylon) version of this module.
  152355. * This is an integer representing the implementation version.
  152356. * This number does not correspond to the webxr specs version
  152357. */
  152358. static readonly Version: number;
  152359. /**
  152360. * Construct a new Controller Physics Feature
  152361. * @param _xrSessionManager the corresponding xr session manager
  152362. * @param _options options to create this feature with
  152363. */
  152364. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  152365. /**
  152366. * @hidden
  152367. * enable debugging - will show console outputs and the impostor mesh
  152368. */
  152369. _enablePhysicsDebug(): void;
  152370. /**
  152371. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  152372. * @param xrController the controller to add
  152373. */
  152374. addController(xrController: WebXRInputSource): void;
  152375. /**
  152376. * attach this feature
  152377. * Will usually be called by the features manager
  152378. *
  152379. * @returns true if successful.
  152380. */
  152381. attach(): boolean;
  152382. /**
  152383. * detach this feature.
  152384. * Will usually be called by the features manager
  152385. *
  152386. * @returns true if successful.
  152387. */
  152388. detach(): boolean;
  152389. /**
  152390. * Get the headset impostor, if enabled
  152391. * @returns the impostor
  152392. */
  152393. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152394. /**
  152395. * Get the physics impostor of a specific controller.
  152396. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152397. * @param controller the controller or the controller id of which to get the impostor
  152398. * @returns the impostor or null
  152399. */
  152400. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152401. /**
  152402. * Update the physics properties provided in the constructor
  152403. * @param newProperties the new properties object
  152404. */
  152405. setPhysicsProperties(newProperties: {
  152406. impostorType?: number;
  152407. impostorSize?: number | {
  152408. width: number;
  152409. height: number;
  152410. depth: number;
  152411. };
  152412. friction?: number;
  152413. restitution?: number;
  152414. }): void;
  152415. protected _onXRFrame(_xrFrame: any): void;
  152416. private _detachController;
  152417. }
  152418. }
  152419. declare module BABYLON {
  152420. /**
  152421. * The motion controller class for all microsoft mixed reality controllers
  152422. */
  152423. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152424. protected readonly _mapping: {
  152425. defaultButton: {
  152426. valueNodeName: string;
  152427. unpressedNodeName: string;
  152428. pressedNodeName: string;
  152429. };
  152430. defaultAxis: {
  152431. valueNodeName: string;
  152432. minNodeName: string;
  152433. maxNodeName: string;
  152434. };
  152435. buttons: {
  152436. "xr-standard-trigger": {
  152437. rootNodeName: string;
  152438. componentProperty: string;
  152439. states: string[];
  152440. };
  152441. "xr-standard-squeeze": {
  152442. rootNodeName: string;
  152443. componentProperty: string;
  152444. states: string[];
  152445. };
  152446. "xr-standard-touchpad": {
  152447. rootNodeName: string;
  152448. labelAnchorNodeName: string;
  152449. touchPointNodeName: string;
  152450. };
  152451. "xr-standard-thumbstick": {
  152452. rootNodeName: string;
  152453. componentProperty: string;
  152454. states: string[];
  152455. };
  152456. };
  152457. axes: {
  152458. "xr-standard-touchpad": {
  152459. "x-axis": {
  152460. rootNodeName: string;
  152461. };
  152462. "y-axis": {
  152463. rootNodeName: string;
  152464. };
  152465. };
  152466. "xr-standard-thumbstick": {
  152467. "x-axis": {
  152468. rootNodeName: string;
  152469. };
  152470. "y-axis": {
  152471. rootNodeName: string;
  152472. };
  152473. };
  152474. };
  152475. };
  152476. /**
  152477. * The base url used to load the left and right controller models
  152478. */
  152479. static MODEL_BASE_URL: string;
  152480. /**
  152481. * The name of the left controller model file
  152482. */
  152483. static MODEL_LEFT_FILENAME: string;
  152484. /**
  152485. * The name of the right controller model file
  152486. */
  152487. static MODEL_RIGHT_FILENAME: string;
  152488. profileId: string;
  152489. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152490. protected _getFilenameAndPath(): {
  152491. filename: string;
  152492. path: string;
  152493. };
  152494. protected _getModelLoadingConstraints(): boolean;
  152495. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152496. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152497. protected _updateModel(): void;
  152498. }
  152499. }
  152500. declare module BABYLON {
  152501. /**
  152502. * The motion controller class for oculus touch (quest, rift).
  152503. * This class supports legacy mapping as well the standard xr mapping
  152504. */
  152505. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152506. private _forceLegacyControllers;
  152507. private _modelRootNode;
  152508. /**
  152509. * The base url used to load the left and right controller models
  152510. */
  152511. static MODEL_BASE_URL: string;
  152512. /**
  152513. * The name of the left controller model file
  152514. */
  152515. static MODEL_LEFT_FILENAME: string;
  152516. /**
  152517. * The name of the right controller model file
  152518. */
  152519. static MODEL_RIGHT_FILENAME: string;
  152520. /**
  152521. * Base Url for the Quest controller model.
  152522. */
  152523. static QUEST_MODEL_BASE_URL: string;
  152524. profileId: string;
  152525. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152526. protected _getFilenameAndPath(): {
  152527. filename: string;
  152528. path: string;
  152529. };
  152530. protected _getModelLoadingConstraints(): boolean;
  152531. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152532. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152533. protected _updateModel(): void;
  152534. /**
  152535. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152536. * between the touch and touch 2.
  152537. */
  152538. private _isQuest;
  152539. }
  152540. }
  152541. declare module BABYLON {
  152542. /**
  152543. * The motion controller class for the standard HTC-Vive controllers
  152544. */
  152545. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152546. private _modelRootNode;
  152547. /**
  152548. * The base url used to load the left and right controller models
  152549. */
  152550. static MODEL_BASE_URL: string;
  152551. /**
  152552. * File name for the controller model.
  152553. */
  152554. static MODEL_FILENAME: string;
  152555. profileId: string;
  152556. /**
  152557. * Create a new Vive motion controller object
  152558. * @param scene the scene to use to create this controller
  152559. * @param gamepadObject the corresponding gamepad object
  152560. * @param handedness the handedness of the controller
  152561. */
  152562. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152563. protected _getFilenameAndPath(): {
  152564. filename: string;
  152565. path: string;
  152566. };
  152567. protected _getModelLoadingConstraints(): boolean;
  152568. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152569. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152570. protected _updateModel(): void;
  152571. }
  152572. }
  152573. declare module BABYLON {
  152574. /**
  152575. * A cursor which tracks a point on a path
  152576. */
  152577. export class PathCursor {
  152578. private path;
  152579. /**
  152580. * Stores path cursor callbacks for when an onchange event is triggered
  152581. */
  152582. private _onchange;
  152583. /**
  152584. * The value of the path cursor
  152585. */
  152586. value: number;
  152587. /**
  152588. * The animation array of the path cursor
  152589. */
  152590. animations: Animation[];
  152591. /**
  152592. * Initializes the path cursor
  152593. * @param path The path to track
  152594. */
  152595. constructor(path: Path2);
  152596. /**
  152597. * Gets the cursor point on the path
  152598. * @returns A point on the path cursor at the cursor location
  152599. */
  152600. getPoint(): Vector3;
  152601. /**
  152602. * Moves the cursor ahead by the step amount
  152603. * @param step The amount to move the cursor forward
  152604. * @returns This path cursor
  152605. */
  152606. moveAhead(step?: number): PathCursor;
  152607. /**
  152608. * Moves the cursor behind by the step amount
  152609. * @param step The amount to move the cursor back
  152610. * @returns This path cursor
  152611. */
  152612. moveBack(step?: number): PathCursor;
  152613. /**
  152614. * Moves the cursor by the step amount
  152615. * If the step amount is greater than one, an exception is thrown
  152616. * @param step The amount to move the cursor
  152617. * @returns This path cursor
  152618. */
  152619. move(step: number): PathCursor;
  152620. /**
  152621. * Ensures that the value is limited between zero and one
  152622. * @returns This path cursor
  152623. */
  152624. private ensureLimits;
  152625. /**
  152626. * Runs onchange callbacks on change (used by the animation engine)
  152627. * @returns This path cursor
  152628. */
  152629. private raiseOnChange;
  152630. /**
  152631. * Executes a function on change
  152632. * @param f A path cursor onchange callback
  152633. * @returns This path cursor
  152634. */
  152635. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152636. }
  152637. }
  152638. declare module BABYLON {
  152639. /** @hidden */
  152640. export var blurPixelShader: {
  152641. name: string;
  152642. shader: string;
  152643. };
  152644. }
  152645. declare module BABYLON {
  152646. /** @hidden */
  152647. export var pointCloudVertexDeclaration: {
  152648. name: string;
  152649. shader: string;
  152650. };
  152651. }
  152652. // Mixins
  152653. interface Window {
  152654. mozIndexedDB: IDBFactory;
  152655. webkitIndexedDB: IDBFactory;
  152656. msIndexedDB: IDBFactory;
  152657. webkitURL: typeof URL;
  152658. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152659. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152660. WebGLRenderingContext: WebGLRenderingContext;
  152661. MSGesture: MSGesture;
  152662. CANNON: any;
  152663. AudioContext: AudioContext;
  152664. webkitAudioContext: AudioContext;
  152665. PointerEvent: any;
  152666. Math: Math;
  152667. Uint8Array: Uint8ArrayConstructor;
  152668. Float32Array: Float32ArrayConstructor;
  152669. mozURL: typeof URL;
  152670. msURL: typeof URL;
  152671. VRFrameData: any; // WebVR, from specs 1.1
  152672. DracoDecoderModule: any;
  152673. setImmediate(handler: (...args: any[]) => void): number;
  152674. }
  152675. interface HTMLCanvasElement {
  152676. requestPointerLock(): void;
  152677. msRequestPointerLock?(): void;
  152678. mozRequestPointerLock?(): void;
  152679. webkitRequestPointerLock?(): void;
  152680. /** Track wether a record is in progress */
  152681. isRecording: boolean;
  152682. /** Capture Stream method defined by some browsers */
  152683. captureStream(fps?: number): MediaStream;
  152684. }
  152685. interface CanvasRenderingContext2D {
  152686. msImageSmoothingEnabled: boolean;
  152687. }
  152688. interface MouseEvent {
  152689. mozMovementX: number;
  152690. mozMovementY: number;
  152691. webkitMovementX: number;
  152692. webkitMovementY: number;
  152693. msMovementX: number;
  152694. msMovementY: number;
  152695. }
  152696. interface Navigator {
  152697. mozGetVRDevices: (any: any) => any;
  152698. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152699. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152700. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152701. webkitGetGamepads(): Gamepad[];
  152702. msGetGamepads(): Gamepad[];
  152703. webkitGamepads(): Gamepad[];
  152704. }
  152705. interface HTMLVideoElement {
  152706. mozSrcObject: any;
  152707. }
  152708. interface Math {
  152709. fround(x: number): number;
  152710. imul(a: number, b: number): number;
  152711. }
  152712. interface WebGLRenderingContext {
  152713. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152714. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152715. vertexAttribDivisor(index: number, divisor: number): void;
  152716. createVertexArray(): any;
  152717. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152718. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152719. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152720. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152721. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152722. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152723. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152724. // Queries
  152725. createQuery(): WebGLQuery;
  152726. deleteQuery(query: WebGLQuery): void;
  152727. beginQuery(target: number, query: WebGLQuery): void;
  152728. endQuery(target: number): void;
  152729. getQueryParameter(query: WebGLQuery, pname: number): any;
  152730. getQuery(target: number, pname: number): any;
  152731. MAX_SAMPLES: number;
  152732. RGBA8: number;
  152733. READ_FRAMEBUFFER: number;
  152734. DRAW_FRAMEBUFFER: number;
  152735. UNIFORM_BUFFER: number;
  152736. HALF_FLOAT_OES: number;
  152737. RGBA16F: number;
  152738. RGBA32F: number;
  152739. R32F: number;
  152740. RG32F: number;
  152741. RGB32F: number;
  152742. R16F: number;
  152743. RG16F: number;
  152744. RGB16F: number;
  152745. RED: number;
  152746. RG: number;
  152747. R8: number;
  152748. RG8: number;
  152749. UNSIGNED_INT_24_8: number;
  152750. DEPTH24_STENCIL8: number;
  152751. MIN: number;
  152752. MAX: number;
  152753. /* Multiple Render Targets */
  152754. drawBuffers(buffers: number[]): void;
  152755. readBuffer(src: number): void;
  152756. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152757. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152758. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152759. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152760. // Occlusion Query
  152761. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152762. ANY_SAMPLES_PASSED: number;
  152763. QUERY_RESULT_AVAILABLE: number;
  152764. QUERY_RESULT: number;
  152765. }
  152766. interface WebGLProgram {
  152767. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152768. }
  152769. interface EXT_disjoint_timer_query {
  152770. QUERY_COUNTER_BITS_EXT: number;
  152771. TIME_ELAPSED_EXT: number;
  152772. TIMESTAMP_EXT: number;
  152773. GPU_DISJOINT_EXT: number;
  152774. QUERY_RESULT_EXT: number;
  152775. QUERY_RESULT_AVAILABLE_EXT: number;
  152776. queryCounterEXT(query: WebGLQuery, target: number): void;
  152777. createQueryEXT(): WebGLQuery;
  152778. beginQueryEXT(target: number, query: WebGLQuery): void;
  152779. endQueryEXT(target: number): void;
  152780. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152781. deleteQueryEXT(query: WebGLQuery): void;
  152782. }
  152783. interface WebGLUniformLocation {
  152784. _currentState: any;
  152785. }
  152786. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152787. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152788. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152789. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152790. interface WebGLRenderingContext {
  152791. readonly RASTERIZER_DISCARD: number;
  152792. readonly DEPTH_COMPONENT24: number;
  152793. readonly TEXTURE_3D: number;
  152794. readonly TEXTURE_2D_ARRAY: number;
  152795. readonly TEXTURE_COMPARE_FUNC: number;
  152796. readonly TEXTURE_COMPARE_MODE: number;
  152797. readonly COMPARE_REF_TO_TEXTURE: number;
  152798. readonly TEXTURE_WRAP_R: number;
  152799. readonly HALF_FLOAT: number;
  152800. readonly RGB8: number;
  152801. readonly RED_INTEGER: number;
  152802. readonly RG_INTEGER: number;
  152803. readonly RGB_INTEGER: number;
  152804. readonly RGBA_INTEGER: number;
  152805. readonly R8_SNORM: number;
  152806. readonly RG8_SNORM: number;
  152807. readonly RGB8_SNORM: number;
  152808. readonly RGBA8_SNORM: number;
  152809. readonly R8I: number;
  152810. readonly RG8I: number;
  152811. readonly RGB8I: number;
  152812. readonly RGBA8I: number;
  152813. readonly R8UI: number;
  152814. readonly RG8UI: number;
  152815. readonly RGB8UI: number;
  152816. readonly RGBA8UI: number;
  152817. readonly R16I: number;
  152818. readonly RG16I: number;
  152819. readonly RGB16I: number;
  152820. readonly RGBA16I: number;
  152821. readonly R16UI: number;
  152822. readonly RG16UI: number;
  152823. readonly RGB16UI: number;
  152824. readonly RGBA16UI: number;
  152825. readonly R32I: number;
  152826. readonly RG32I: number;
  152827. readonly RGB32I: number;
  152828. readonly RGBA32I: number;
  152829. readonly R32UI: number;
  152830. readonly RG32UI: number;
  152831. readonly RGB32UI: number;
  152832. readonly RGBA32UI: number;
  152833. readonly RGB10_A2UI: number;
  152834. readonly R11F_G11F_B10F: number;
  152835. readonly RGB9_E5: number;
  152836. readonly RGB10_A2: number;
  152837. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152838. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152839. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152840. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152841. readonly DEPTH_COMPONENT32F: number;
  152842. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152843. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152844. 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;
  152845. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152846. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152847. readonly TRANSFORM_FEEDBACK: number;
  152848. readonly INTERLEAVED_ATTRIBS: number;
  152849. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152850. createTransformFeedback(): WebGLTransformFeedback;
  152851. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152852. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152853. beginTransformFeedback(primitiveMode: number): void;
  152854. endTransformFeedback(): void;
  152855. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152856. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152857. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152858. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152859. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152860. }
  152861. interface ImageBitmap {
  152862. readonly width: number;
  152863. readonly height: number;
  152864. close(): void;
  152865. }
  152866. interface WebGLQuery extends WebGLObject {
  152867. }
  152868. declare var WebGLQuery: {
  152869. prototype: WebGLQuery;
  152870. new(): WebGLQuery;
  152871. };
  152872. interface WebGLSampler extends WebGLObject {
  152873. }
  152874. declare var WebGLSampler: {
  152875. prototype: WebGLSampler;
  152876. new(): WebGLSampler;
  152877. };
  152878. interface WebGLSync extends WebGLObject {
  152879. }
  152880. declare var WebGLSync: {
  152881. prototype: WebGLSync;
  152882. new(): WebGLSync;
  152883. };
  152884. interface WebGLTransformFeedback extends WebGLObject {
  152885. }
  152886. declare var WebGLTransformFeedback: {
  152887. prototype: WebGLTransformFeedback;
  152888. new(): WebGLTransformFeedback;
  152889. };
  152890. interface WebGLVertexArrayObject extends WebGLObject {
  152891. }
  152892. declare var WebGLVertexArrayObject: {
  152893. prototype: WebGLVertexArrayObject;
  152894. new(): WebGLVertexArrayObject;
  152895. };
  152896. // Type definitions for WebVR API
  152897. // Project: https://w3c.github.io/webvr/
  152898. // Definitions by: six a <https://github.com/lostfictions>
  152899. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152900. interface VRDisplay extends EventTarget {
  152901. /**
  152902. * Dictionary of capabilities describing the VRDisplay.
  152903. */
  152904. readonly capabilities: VRDisplayCapabilities;
  152905. /**
  152906. * z-depth defining the far plane of the eye view frustum
  152907. * enables mapping of values in the render target depth
  152908. * attachment to scene coordinates. Initially set to 10000.0.
  152909. */
  152910. depthFar: number;
  152911. /**
  152912. * z-depth defining the near plane of the eye view frustum
  152913. * enables mapping of values in the render target depth
  152914. * attachment to scene coordinates. Initially set to 0.01.
  152915. */
  152916. depthNear: number;
  152917. /**
  152918. * An identifier for this distinct VRDisplay. Used as an
  152919. * association point in the Gamepad API.
  152920. */
  152921. readonly displayId: number;
  152922. /**
  152923. * A display name, a user-readable name identifying it.
  152924. */
  152925. readonly displayName: string;
  152926. readonly isConnected: boolean;
  152927. readonly isPresenting: boolean;
  152928. /**
  152929. * If this VRDisplay supports room-scale experiences, the optional
  152930. * stage attribute contains details on the room-scale parameters.
  152931. */
  152932. readonly stageParameters: VRStageParameters | null;
  152933. /**
  152934. * Passing the value returned by `requestAnimationFrame` to
  152935. * `cancelAnimationFrame` will unregister the callback.
  152936. * @param handle Define the hanle of the request to cancel
  152937. */
  152938. cancelAnimationFrame(handle: number): void;
  152939. /**
  152940. * Stops presenting to the VRDisplay.
  152941. * @returns a promise to know when it stopped
  152942. */
  152943. exitPresent(): Promise<void>;
  152944. /**
  152945. * Return the current VREyeParameters for the given eye.
  152946. * @param whichEye Define the eye we want the parameter for
  152947. * @returns the eye parameters
  152948. */
  152949. getEyeParameters(whichEye: string): VREyeParameters;
  152950. /**
  152951. * Populates the passed VRFrameData with the information required to render
  152952. * the current frame.
  152953. * @param frameData Define the data structure to populate
  152954. * @returns true if ok otherwise false
  152955. */
  152956. getFrameData(frameData: VRFrameData): boolean;
  152957. /**
  152958. * Get the layers currently being presented.
  152959. * @returns the list of VR layers
  152960. */
  152961. getLayers(): VRLayer[];
  152962. /**
  152963. * Return a VRPose containing the future predicted pose of the VRDisplay
  152964. * when the current frame will be presented. The value returned will not
  152965. * change until JavaScript has returned control to the browser.
  152966. *
  152967. * The VRPose will contain the position, orientation, velocity,
  152968. * and acceleration of each of these properties.
  152969. * @returns the pose object
  152970. */
  152971. getPose(): VRPose;
  152972. /**
  152973. * Return the current instantaneous pose of the VRDisplay, with no
  152974. * prediction applied.
  152975. * @returns the current instantaneous pose
  152976. */
  152977. getImmediatePose(): VRPose;
  152978. /**
  152979. * The callback passed to `requestAnimationFrame` will be called
  152980. * any time a new frame should be rendered. When the VRDisplay is
  152981. * presenting the callback will be called at the native refresh
  152982. * rate of the HMD. When not presenting this function acts
  152983. * identically to how window.requestAnimationFrame acts. Content should
  152984. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152985. * asynchronously from other displays and at differing refresh rates.
  152986. * @param callback Define the eaction to run next frame
  152987. * @returns the request handle it
  152988. */
  152989. requestAnimationFrame(callback: FrameRequestCallback): number;
  152990. /**
  152991. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152992. * Repeat calls while already presenting will update the VRLayers being displayed.
  152993. * @param layers Define the list of layer to present
  152994. * @returns a promise to know when the request has been fulfilled
  152995. */
  152996. requestPresent(layers: VRLayer[]): Promise<void>;
  152997. /**
  152998. * Reset the pose for this display, treating its current position and
  152999. * orientation as the "origin/zero" values. VRPose.position,
  153000. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153001. * updated when calling resetPose(). This should be called in only
  153002. * sitting-space experiences.
  153003. */
  153004. resetPose(): void;
  153005. /**
  153006. * The VRLayer provided to the VRDisplay will be captured and presented
  153007. * in the HMD. Calling this function has the same effect on the source
  153008. * canvas as any other operation that uses its source image, and canvases
  153009. * created without preserveDrawingBuffer set to true will be cleared.
  153010. * @param pose Define the pose to submit
  153011. */
  153012. submitFrame(pose?: VRPose): void;
  153013. }
  153014. declare var VRDisplay: {
  153015. prototype: VRDisplay;
  153016. new(): VRDisplay;
  153017. };
  153018. interface VRLayer {
  153019. leftBounds?: number[] | Float32Array | null;
  153020. rightBounds?: number[] | Float32Array | null;
  153021. source?: HTMLCanvasElement | null;
  153022. }
  153023. interface VRDisplayCapabilities {
  153024. readonly canPresent: boolean;
  153025. readonly hasExternalDisplay: boolean;
  153026. readonly hasOrientation: boolean;
  153027. readonly hasPosition: boolean;
  153028. readonly maxLayers: number;
  153029. }
  153030. interface VREyeParameters {
  153031. /** @deprecated */
  153032. readonly fieldOfView: VRFieldOfView;
  153033. readonly offset: Float32Array;
  153034. readonly renderHeight: number;
  153035. readonly renderWidth: number;
  153036. }
  153037. interface VRFieldOfView {
  153038. readonly downDegrees: number;
  153039. readonly leftDegrees: number;
  153040. readonly rightDegrees: number;
  153041. readonly upDegrees: number;
  153042. }
  153043. interface VRFrameData {
  153044. readonly leftProjectionMatrix: Float32Array;
  153045. readonly leftViewMatrix: Float32Array;
  153046. readonly pose: VRPose;
  153047. readonly rightProjectionMatrix: Float32Array;
  153048. readonly rightViewMatrix: Float32Array;
  153049. readonly timestamp: number;
  153050. }
  153051. interface VRPose {
  153052. readonly angularAcceleration: Float32Array | null;
  153053. readonly angularVelocity: Float32Array | null;
  153054. readonly linearAcceleration: Float32Array | null;
  153055. readonly linearVelocity: Float32Array | null;
  153056. readonly orientation: Float32Array | null;
  153057. readonly position: Float32Array | null;
  153058. readonly timestamp: number;
  153059. }
  153060. interface VRStageParameters {
  153061. sittingToStandingTransform?: Float32Array;
  153062. sizeX?: number;
  153063. sizeY?: number;
  153064. }
  153065. interface Navigator {
  153066. getVRDisplays(): Promise<VRDisplay[]>;
  153067. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153068. }
  153069. interface Window {
  153070. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153071. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153072. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153073. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153074. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153075. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153076. }
  153077. interface Gamepad {
  153078. readonly displayId: number;
  153079. }
  153080. type XRSessionMode =
  153081. | "inline"
  153082. | "immersive-vr"
  153083. | "immersive-ar";
  153084. type XRReferenceSpaceType =
  153085. | "viewer"
  153086. | "local"
  153087. | "local-floor"
  153088. | "bounded-floor"
  153089. | "unbounded";
  153090. type XREnvironmentBlendMode =
  153091. | "opaque"
  153092. | "additive"
  153093. | "alpha-blend";
  153094. type XRVisibilityState =
  153095. | "visible"
  153096. | "visible-blurred"
  153097. | "hidden";
  153098. type XRHandedness =
  153099. | "none"
  153100. | "left"
  153101. | "right";
  153102. type XRTargetRayMode =
  153103. | "gaze"
  153104. | "tracked-pointer"
  153105. | "screen";
  153106. type XREye =
  153107. | "none"
  153108. | "left"
  153109. | "right";
  153110. type XREventType =
  153111. | "devicechange"
  153112. | "visibilitychange"
  153113. | "end"
  153114. | "inputsourceschange"
  153115. | "select"
  153116. | "selectstart"
  153117. | "selectend"
  153118. | "squeeze"
  153119. | "squeezestart"
  153120. | "squeezeend"
  153121. | "reset";
  153122. interface XRSpace extends EventTarget {
  153123. }
  153124. interface XRRenderState {
  153125. depthNear?: number;
  153126. depthFar?: number;
  153127. inlineVerticalFieldOfView?: number;
  153128. baseLayer?: XRWebGLLayer;
  153129. }
  153130. interface XRInputSource {
  153131. handedness: XRHandedness;
  153132. targetRayMode: XRTargetRayMode;
  153133. targetRaySpace: XRSpace;
  153134. gripSpace: XRSpace | undefined;
  153135. gamepad: Gamepad | undefined;
  153136. profiles: Array<string>;
  153137. }
  153138. interface XRSessionInit {
  153139. optionalFeatures?: string[];
  153140. requiredFeatures?: string[];
  153141. }
  153142. interface XRSession {
  153143. addEventListener: Function;
  153144. removeEventListener: Function;
  153145. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153146. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153147. requestAnimationFrame: Function;
  153148. end(): Promise<void>;
  153149. renderState: XRRenderState;
  153150. inputSources: Array<XRInputSource>;
  153151. // hit test
  153152. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153153. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153154. // legacy AR hit test
  153155. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153156. // legacy plane detection
  153157. updateWorldTrackingState(options: {
  153158. planeDetectionState?: { enabled: boolean; }
  153159. }): void;
  153160. }
  153161. interface XRReferenceSpace extends XRSpace {
  153162. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  153163. onreset: any;
  153164. }
  153165. type XRPlaneSet = Set<XRPlane>;
  153166. type XRAnchorSet = Set<XRAnchor>;
  153167. interface XRFrame {
  153168. session: XRSession;
  153169. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  153170. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  153171. // AR
  153172. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  153173. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  153174. // Anchors
  153175. trackedAnchors?: XRAnchorSet;
  153176. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  153177. // Planes
  153178. worldInformation: {
  153179. detectedPlanes?: XRPlaneSet;
  153180. };
  153181. }
  153182. interface XRViewerPose extends XRPose {
  153183. views: Array<XRView>;
  153184. }
  153185. interface XRPose {
  153186. transform: XRRigidTransform;
  153187. emulatedPosition: boolean;
  153188. }
  153189. interface XRWebGLLayerOptions {
  153190. antialias?: boolean;
  153191. depth?: boolean;
  153192. stencil?: boolean;
  153193. alpha?: boolean;
  153194. multiview?: boolean;
  153195. framebufferScaleFactor?: number;
  153196. }
  153197. declare var XRWebGLLayer: {
  153198. prototype: XRWebGLLayer;
  153199. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  153200. };
  153201. interface XRWebGLLayer {
  153202. framebuffer: WebGLFramebuffer;
  153203. framebufferWidth: number;
  153204. framebufferHeight: number;
  153205. getViewport: Function;
  153206. }
  153207. declare class XRRigidTransform {
  153208. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  153209. position: DOMPointReadOnly;
  153210. orientation: DOMPointReadOnly;
  153211. matrix: Float32Array;
  153212. inverse: XRRigidTransform;
  153213. }
  153214. interface XRView {
  153215. eye: XREye;
  153216. projectionMatrix: Float32Array;
  153217. transform: XRRigidTransform;
  153218. }
  153219. interface XRInputSourceChangeEvent {
  153220. session: XRSession;
  153221. removed: Array<XRInputSource>;
  153222. added: Array<XRInputSource>;
  153223. }
  153224. interface XRInputSourceEvent extends Event {
  153225. readonly frame: XRFrame;
  153226. readonly inputSource: XRInputSource;
  153227. }
  153228. // Experimental(er) features
  153229. declare class XRRay {
  153230. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  153231. origin: DOMPointReadOnly;
  153232. direction: DOMPointReadOnly;
  153233. matrix: Float32Array;
  153234. }
  153235. declare enum XRHitTestTrackableType {
  153236. "point",
  153237. "plane"
  153238. }
  153239. interface XRHitResult {
  153240. hitMatrix: Float32Array;
  153241. }
  153242. interface XRTransientInputHitTestResult {
  153243. readonly inputSource: XRInputSource;
  153244. readonly results: Array<XRHitTestResult>;
  153245. }
  153246. interface XRHitTestResult {
  153247. getPose(baseSpace: XRSpace): XRPose | undefined;
  153248. // When anchor system is enabled
  153249. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  153250. }
  153251. interface XRHitTestSource {
  153252. cancel(): void;
  153253. }
  153254. interface XRTransientInputHitTestSource {
  153255. cancel(): void;
  153256. }
  153257. interface XRHitTestOptionsInit {
  153258. space: XRSpace;
  153259. entityTypes?: Array<XRHitTestTrackableType>;
  153260. offsetRay?: XRRay;
  153261. }
  153262. interface XRTransientInputHitTestOptionsInit {
  153263. profile: string;
  153264. entityTypes?: Array<XRHitTestTrackableType>;
  153265. offsetRay?: XRRay;
  153266. }
  153267. interface XRAnchor {
  153268. anchorSpace: XRSpace;
  153269. delete(): void;
  153270. }
  153271. interface XRPlane {
  153272. orientation: "Horizontal" | "Vertical";
  153273. planeSpace: XRSpace;
  153274. polygon: Array<DOMPointReadOnly>;
  153275. lastChangedTime: number;
  153276. }